Re: [css-houdini-drafts] [css-paint-api] API spec should support accelerated rendering via declarative context such as servo webrender

I don't believe that any imperative api could match WebRender's native
 speed, because the whole point is that there is a limited list of 
things that can be drawn with CSS (leaving SVG aside). As there is a 
limited list of items to draw:

- Hand-optimizing the shaders and batching the draw calls is feasible
- The code is simple and fast
- Detecting the simpler cases is easy, making things even faster

The existing WebRender release is quite fast, and there is a work in 
progress version that does even more extensive optimizations based on 
the display list.

Thus, my suggestion is start with generating a simple display list 
format, like 
[here](https://github.com/servo/webrender_traits/blob/8b7c42d12dc7b07df109b5a3ae90201e8417ad33/src/display_item.rs#L88-L96),
 but with WebGl, border, and box-shadow removed, leaving:

- Rectangle (x1,y1,x2,y2,color)
- Image (bitmap or filename)
- Gradient (Rectangle, start, stop, stops)
- Text (Rectangle, font, text, color)

These should be able to be easily accelerated by just about any 
engine. I would release this first, and relegate anything else to a 
later extension. (As an aside, I find levels are confusing - either do
 versions, or name the extensions something distinct).

Regardless, I see two approaches to extending the capabilities:

- Render to a bitmap (possibly on the gpu) with WebGL or canvas, 
possibly using multiple threads
- Allow creating display item types with pre-bound shaders, and 
specifying the parameters per display item

The first api is nicer for CPU-based renderers, but is absolutely 
terrible for GPU based renderers. The second api is far better for GPU
 renderers as it allows rendering all display items of a given type at
 once in a single GPU batch. Alas, it will still not be able to 
replace the more specific display item types as it misses 
optimizations based on using combined/specialized shaders. For 
example, text on a flat color may be implemented differently compared 
with text being blended on top of a box shadow. Still, it's the least 
terrible option I can see here.

-- 
GitHub Notification of comment by samlh
Please view or discuss this issue at 
https://github.com/w3c/css-houdini-drafts/issues/207#issuecomment-225330921
 using your GitHub account

Received on Saturday, 11 June 2016 02:05:53 UTC