Hello paint-dev,
I came up with this idea when I tried to write a simplistic renderer
to replay 3D transform display items in layerization mode (for testing
& sanity check). Why can't we paint everything in device coordinate?
Is it something we have thought about in the past but didn't do?
Anyway I think it is a good timing to bring discussion up again
because many of the engineering constraints have changed:
1. With S.P. we no longer have the GraphicsLayer/cc::Layer abstraction
that mandates the compositor to create a rectangular backing in local
coordinate (Not completely true. We still have raster scale. Why not
raster matrix?).
2. With Ganesh, Skia may actually be fast for non-trivial transforms.
There are a few advantages painting in device coordinate:
1. 3D contents don't need to be re-sampled (texture mapping), result
in better render quality.
2. Less memory usage because 3D contents won't need layers, whether
permanent or temporary.
3. Easier to handle unbounded surfaces.
I made a few example to demonstrate the limitation of rendering in
local coordinates:
http://jsbin.com/nokeju/1/
All three examples are similar, with an inner layer that has a X-W
skew, flattened, then do an opposite X-W skew on the outer layer. With
CSS properties applied on the outer layer to enforce render surfaces.
On top: Chrome gave up because the outer layer is forced to create a
render surface by opacity:0.99, but the projection of the inner layer
on the outer layer is unbounded on the left side.
Middle: Use overflow:hidden to enforce render surface, thus the
surface is no longer unbounded. Rendered result is correct, but with
terrible quality because the inner layer is re-sampled twice.
On bottom: Quality is good because no intermediate render surface is
created, but near plane clipping is incorrect. The layer should be
clipped at x>=50 because of the intermediate flattening.
Here are a few reasons why we can't do it today that I can think of:
1. Perspective support in Skia is experimental. Here is one bug I
reported today which would be a deal breaker:
https://code.google.com/p/skia/issues/detail?id=3681
I had a quick chat with some Skia folks. If I understand correctly, it
will be a low-priority bug for Skia because none of the major client
is using perspective, but if Chrome decides to use Skia for 3D
rendering, the priority can change. (And I will be happy to contribute
too.)
2. It is unclear how anti-alias should work. FSAA probably not an
option for Chrome.
3. We probably still need layers in local coordinate for animation.
I'm not suggesting to tie this to any phase of S.P. launch, but it
could be a stepping stone for layerization algorithm. Again I came up
with this idea because I want to be able to test the 3D transform
display items generated by Blink, which can't be done without a
layerization algorithm in place. However layerization algorithm too
will be difficult to test without see real data generated by Blink. I
think having a simplistic 3D display list renderer without
layerization would be a good approach to break the engineering chicken
& egg problem. Also it provides a benchmark reference for us to try
and fine tune different layerization triggers. WDYT?