Chromium Code Reviews
DescriptionImageBuffer-less SVG masking and clipping.
This CL refactors the SVG clipping and masking logic using Skia saveLayer()
operations instead of explicitly allocated ImageBuffers.
The masking process involves two layers:
* a mask layer, where the mask shapes are drawn and which is composited into
the backdrop layer using regular SrcOver transfer mode.
* a content layer, where the content to-be-masked is drawn and which is
composited into the mask layer using SrcIn transfer mode.
The sequence of operations:
- saveLayer(SrcOver)
- draw mask shapes
- saveLayer(SrcIn)
- draw content
- restoreLayer(SrcIn) (content gets masked by the mask layer content)
- restoreLayer(SrcOver) (the now-masked content is blended into the backdrop)
For luminance masks, a custom Skia transfer mode wrapper (SkLumaMaskXfermode)
is used instead of regular SrcIn.
If needed, mask color space conversion is handled using an SkTableColorFilter.
As far as the number of allocated off-screen buffers goes, the two approaches
are equivalent: 2 SK layers vs. 1 SK layer + 1 ImageBuffer previously. But the
new implementation has several advantages:
* off-screen buffer allocation is now handled by Skia at rasterization time,
when the true resolution is known - this fixes various problems related to
impl-side painting on HiDPI devices (due to mask rasterization at record
time).
* masks are drawn directly into the target canvas, using the coordinate
system already in place - this avoids pixel snapping artifacts due to
integral ImageBuffer sizing.
* reduced memory utilization - we are no longer holding SVG mask/clip bitmaps
indefinitely in Blink.
* color space conversion and luminance calculation are handled more
efficiently using native Skia constructs instead of additional ImageBuffer
data copies/traversals.
* general code cleanup - GraphicsContext no longer needs to track an
imgbuffer clip as part of its state, and several related utility methods
can be removed.
One possible downside: we are losing the ability to cache mask ImageBuffers in
Blink, which may have a negative performance impact under certain conditions
(static mask reused frequently due to constantly re-painting a dynamic target).
There are plans to add caching capabilities in Skia to compensate for this.
23 pixel tests require rebaselining due to minor blending/rounding
differences.
R=pdr@chromium.org,schenney@chromium.org,dschulze@chromium.org,senorblanco@chromium.org
Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=156928
Patch Set 1 #Patch Set 2 : Self review. #Patch Set 3 : Removed Linux rebaselines. #
Total comments: 26
Patch Set 4 : Updated per review comments. #
Total comments: 3
Patch Set 5 : Rebased + minor cleanup. #Patch Set 6 : Re-uploading set 5 (last upload crashed) #Patch Set 7 : Fix the Win build. #Messages
Total messages: 15 (0 generated)
|