Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upNeed API to set a composition operator that's not "over" #1416
Comments
tiling: derive Default for CompositeOps. I was poking at #1416, and found this while at it. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/1499) <!-- Reviewable:end -->
tiling: derive Default for CompositeOps. I was poking at #1416, and found this while at it. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/1499) <!-- Reviewable:end -->
|
@glennw There's one aspect of this that may be worth thinking about as part of #1774: For optimal performance with operator source, the concept of "opaqueness" may need to be split into two dimensions. If you draw something with operator source, the old values of the destination pixels get completely ignored and replaced. So you'll want to cull any primitives underneath anything that's drawn with operator source, because anything that was drawn underneath has no impact on the final rendering anyway. However, after drawing the operator source item, the affected pixels may be transparent, and for example any text that is drawn directly on top will not be able to use subpixel AA. The same applies to operator clear. So there's a difference between "opaque in the sense that items underneath can be culled", and "opaque in the sense that items on top will draw to opaque pixels". Just something to be aware of. |
I'm having trouble understanding this part. Why would a primitive care about what's drawn on top of it? |
|
The primitive itself does not care about what is drawn on top of it. But the rendering system as a whole does. In general, some decisions about a given item depend on the type of items underneath it, and some depend on the type of items on top of it. More specifically, if the question is "Do I have to render item $X?", the answer is "Not if there's an opaque element with operator OVER on top of it, or if there's any element with operator SOURCE on top of it." And if the question is "Can I use subpixel AA for the text item $Y?", then the answer is "Not if there's an operator SOURCE item underneath it that's not opaque (unless there is another opaque element in between).". |
|
I have a naive implementation of this. It adds a It seems to be working well; I now have working vibrancy and rounded bottom corners. The text on top of vibrancy doesn't render the way it should, but that's expected. |
|
I do agree that we probably want a simpler API for this, since it's such a niche use case in WR. How about a post-processing API which can apply a list of screen-aligned rectangles with a mask + composition operator? |
|
For the rectangle-clearing use case, the order with respect to the other display items is important. For example, at the moment, our browser chrome on macOS has elements in this order:
So the rectangle needs to be cleared after 2 but before 4. |
|
Ah, makes sense. I wonder if a specific primitive type might make sense then? |
|
Sounds good to me. For the other use case (rounding the window corners), maybe the API should be just that: Give WebRender an API that lets you specify a BorderRadius struct for the root frame buffer, and then WebRender itself can decide how to apply that root clip. It may still decide to use the destination-in blend mode with four small rounded images to do that. |
|
Yep, that sounds good. |
Webrender currently supports MixBlendModes, but all the modes in this list don't affect the destination alpha. In Gecko we also need the modes Clear and Destination Out. Ideally we'd have all the porter duff modes so that we can support the whole list of Moz2D CompositionOp values.
We have two cases where we need this, and both of them are about native appearance on Mac.