Description
(brain dump only - needs more detail added)
At the moment we have various hacks in the WR code and shaders to handle the fact that mix-blend-mode must be isolated from other stacking contexts. I think we can modify how we implement mix-blend-mode in a way that removes these hacks and also is an optimization - removing the need for framebuffer readback in most cases.
When we encounter a mix-blend-mode during flattening, we should move the parent stacking context to be a child of the mix-blend-mode picture node. Then, no readback is needed - the parent stacking context will be drawn to an off-screen surface in the correct pass.
A couple of caveats:
- We still need to do the readback if the parent stacking context is the root (framebuffer). This is rare, and in future we can also track if the root only has a simple background color and avoid the readback in this case too.
- To get correct blending, we need to ensure that the render task created for the mix-blend-mode is the maximum of the size of the backdrop and child stacking context.
This should allow for a much faster implementation of mix-blend-mode in the majority of cases, by skipping framebuffer readback. It also makes it easier to optimize some of the common cases, where the backdrop is a solid color (either by detecting this, or caching the solid color picture in the texture cache).
Activity
kvark commentedon Jun 26, 2018
Sounds reasonable. For the first caveat, can't we introduce an "artificial" full-screen picture just so the readback path is not needed (at the cost of an extra blit/copy)?
gw3583 commentedon Jun 26, 2018
Yup, that should work.
Gankra commentedon Jun 26, 2018
vague reminder to not introduce a side-channel attack with content-based optimizations on mix-blend-modes/filters.