Today the OGL pipeline only "accelerates" antialiased rendering (via the OGLMaskFill
primitive) in the following cases:
- AlphaComposite.SrcOver
- AlphaComposite.Src, extra alpha == 1.0, source paint is opaque
The reason we can't support any arbitrary AlphaComposite mode is because of the
way the MaskFill operation is defined:
dst = ((src <MODE> dst) * maskA) + (dst * (1 - maskA))
This can be simplified as follows for the above modes, which can then be easily
accelerated via OpenGL using its built-in blending functions:
dst = (src * maskA) <SrcOver> dst
Implementing most of the other AlphaComposite rules would require performing the
compositing step in a shader, which can be tricky given that the framebuffer contents
are not accessible from a fragment shader. This bug report proposes to make changes
to OGLMaskFill and OGLPaints so that it becomes possible to accelerate these other
AlphaComposite modes when fragment shaders are available in hardware. This
approach should be much faster than the software-based loops that we fall back on
today in these cases, because it won't be necessary to suffer the cost of reading
back from VRAM into system memory to perform the compositing operation. In addition,
these changes will pave the way for accelerating the extended compositing modes
that are proposed in 5094232.