Closed
Bug 1239040
Opened 9 years ago
Closed 9 years ago
Implement PushLayer/PopLayer for DrawTargetSkia
Categories
(Core :: Graphics, defect)
Core
Graphics
Tracking
()
RESOLVED
FIXED
mozilla46
Tracking | Status | |
---|---|---|
firefox46 | --- | fixed |
People
(Reporter: lsalzman, Assigned: lsalzman)
References
Details
Attachments
(6 files, 5 obsolete files)
859 bytes,
patch
|
jrmuizel
:
review+
|
Details | Diff | Splinter Review |
11.81 KB,
patch
|
jrmuizel
:
review+
|
Details | Diff | Splinter Review |
8.38 KB,
patch
|
jrmuizel
:
review+
|
Details | Diff | Splinter Review |
7.44 KB,
patch
|
bas.schouten
:
review+
|
Details | Diff | Splinter Review |
5.76 KB,
patch
|
jrmuizel
:
review+
|
Details | Diff | Splinter Review |
12.31 KB,
patch
|
jrmuizel
:
review+
|
Details | Diff | Splinter Review |
No description provided.
Assignee | ||
Comment 1•9 years ago
|
||
We need to use SkCanvas::getTopDevice() to access the topmost layer in the canvas for copying the background and masking. Skia considers this legacy so we need to explicitly enable it.
Attachment #8707027 -
Flags: review?(jmuizelaar)
Assignee | ||
Comment 2•9 years ago
|
||
The old TempBitmap setup was cumbersome and only really appropriate if used within a single function. However, we need bitmaps to last beyond the scope of PushLayer until they finally get used in PopLayer.
So instead this uses the existing release function override mechanism in SkPixelRef - we're already paying for it, so may as well use it. It allows the underlying source surface to be released when the pixelref's refcount zeroes out, which works better for our purposes here. It also cleans up the code a lot.
Attachment #8707031 -
Flags: review?(jmuizelaar)
Assignee | ||
Comment 3•9 years ago
|
||
These are some drive-by cleanups of Mask and MaskSurface that I did as I was investigating Skia for PushLayer.
We don't really need to be creating local matrix shaders for each pattern, since all shaders allow the specifying of one on creation.
SkRectCoveringWholeSurface() is just unnecessary because drawPaint already does it.
Using SkLayerRasterizer doesn't make much sense if we already know we're dealing with a source surface. So instead we can just use extractAlpha on the bitmap when it's not the correct mask format, and otherwise sense all MaskSurface requests through the same path. It will still incur a copy in the non-A8 case, but will reduce some allocations and branches taken for path rendering that we don't actually need there.
Attachment #8707037 -
Flags: review?(jmuizelaar)
Assignee | ||
Comment 4•9 years ago
|
||
Patch does what it says on the tin.
Some trickery is required to deal with masks, since Skia does not have any simple support for that within saveLayer. So instead we're forced to steal a reference to the layer device before we restore the background. While restoring, we make sure the layer is not implicitly blended back by forcing the opacity to 0 temporarily. Finally, we draw the layer device to the background with our custom mask.
In the non-masked case this boils down to just simple usage of SkCanvas::saveLayer and SkCanvas::restore without the above trickery.
Attachment #8707042 -
Flags: review?(bas)
Assignee | ||
Comment 5•9 years ago
|
||
Small fix for setting the background copying xfer mode.
Attachment #8707042 -
Attachment is obsolete: true
Attachment #8707042 -
Flags: review?(bas)
Attachment #8707301 -
Flags: review?(bas)
Assignee | ||
Comment 6•9 years ago
|
||
This mainly fixes CopySurface to avoid accessing properties of the bottom layer so that it is safe to use inside PushLayer.
There are some other drive-by cleanups in this patch for clearing and drawSprite removal.
Attachment #8707302 -
Flags: review?(jmuizelaar)
Assignee | ||
Comment 7•9 years ago
|
||
The widget gtk code was trying to use LockBits (and also BorrowedXlibDrawable) inside PushLayer when rendering native widgets under certain circumstances. This never worked and has basically been broken since Bas' implemented PushLayer.
This fixes it to do saner things in both Skia and Cairo.
Attachment #8707304 -
Flags: review?(jmuizelaar)
Assignee | ||
Comment 8•9 years ago
|
||
Separated out the DrawTargetCairo bits so they can be fixed in the relevant bug report 1239106. This patch now only deals with DrawTargetSkia.
Attachment #8707304 -
Attachment is obsolete: true
Attachment #8707304 -
Flags: review?(jmuizelaar)
Attachment #8707305 -
Flags: review?(jmuizelaar)
Assignee | ||
Comment 9•9 years ago
|
||
Okay, one more re-roll of this... Upon further consideration it just made more sense to let LockBits to optionally report an origin for the data, without disturbing any existing use-cases (since they don't request it). BorrowedXlibDrawable is also similarly easily modified.
This way we don't have any performance regressions vs. the non-native-pushlayer paths when rendering widgets and keep them rendering through the same backend bits in widget/gtk.
Attachment #8707305 -
Attachment is obsolete: true
Attachment #8707305 -
Flags: review?(jmuizelaar)
Attachment #8707332 -
Flags: review?(jmuizelaar)
Assignee | ||
Comment 10•9 years ago
|
||
Revert the drawSprite -> drawBitmap conversion as that will cause a performance regression until we use Skia m49+.
Attachment #8707302 -
Attachment is obsolete: true
Attachment #8707302 -
Flags: review?(jmuizelaar)
Attachment #8707623 -
Flags: review?(jmuizelaar)
Updated•9 years ago
|
Attachment #8707027 -
Flags: review?(jmuizelaar) → review+
Comment 11•9 years ago
|
||
Comment on attachment 8707031 [details] [diff] [review]
part 2 - cleanup of DrawTargetSkia GetBitmapForSurface to use installPixels
Review of attachment 8707031 [details] [diff] [review]:
-----------------------------------------------------------------
Nice.
Attachment #8707031 -
Flags: review?(jmuizelaar) → review+
Updated•9 years ago
|
Attachment #8707037 -
Flags: review?(jmuizelaar) → review+
Updated•9 years ago
|
Attachment #8707623 -
Flags: review?(jmuizelaar) → review+
Assignee | ||
Comment 12•9 years ago
|
||
This adds in support for LockBits under PushLayer in DrawTargetCairo rather than failing.
Attachment #8707332 -
Attachment is obsolete: true
Attachment #8707332 -
Flags: review?(jmuizelaar)
Attachment #8707907 -
Flags: review?(jmuizelaar)
Comment 13•9 years ago
|
||
Comment on attachment 8707301 [details] [diff] [review]
part 4 - implement PushLayer for DrawTargetSkia
Review of attachment 8707301 [details] [diff] [review]:
-----------------------------------------------------------------
::: gfx/2d/DrawTargetSkia.cpp
@@ +1069,5 @@
> + SkShader* shader = SkShader::CreateBitmapShader(layerBitmap,
> + SkShader::kClamp_TileMode,
> + SkShader::kClamp_TileMode,
> + &layerMat);
> + SkSafeUnref(paint.setShader(shader));
nit: Wow this is an ugly pattern.
Attachment #8707301 -
Flags: review?(bas) → review+
Comment 14•9 years ago
|
||
Comment on attachment 8707907 [details] [diff] [review]
part 6 - fix DrawTargetCairo/DrawTargetSkia LockBits and BorrowedXlibDrawable to work inside PushLayer
Review of attachment 8707907 [details] [diff] [review]:
-----------------------------------------------------------------
Other than the aOrigin default parameter business this looks fine.
::: gfx/2d/2D.h
@@ +746,5 @@
> * Release takes the original data pointer for safety.
> */
> virtual bool LockBits(uint8_t** aData, IntSize* aSize,
> + int32_t* aStride, SurfaceFormat* aFormat,
> + IntPoint* aOrigin = nullptr) { return false; }
I'd rather not have aOrigin have a default parameter. I don't think there are many cases where you want to ignore the result.
Attachment #8707907 -
Flags: review?(jmuizelaar) → review-
Comment 15•9 years ago
|
||
Comment on attachment 8707907 [details] [diff] [review]
part 6 - fix DrawTargetCairo/DrawTargetSkia LockBits and BorrowedXlibDrawable to work inside PushLayer
Review of attachment 8707907 [details] [diff] [review]:
-----------------------------------------------------------------
::: gfx/2d/2D.h
@@ +746,5 @@
> * Release takes the original data pointer for safety.
> */
> virtual bool LockBits(uint8_t** aData, IntSize* aSize,
> + int32_t* aStride, SurfaceFormat* aFormat,
> + IntPoint* aOrigin = nullptr) { return false; }
I wonder if just to make sure we're not having other unexpected behavior we want to specify the bounds the caller can draw to so they can optionally check if they're sufficient to do what they want.
Comment 16•9 years ago
|
||
Comment on attachment 8707907 [details] [diff] [review]
part 6 - fix DrawTargetCairo/DrawTargetSkia LockBits and BorrowedXlibDrawable to work inside PushLayer
Review of attachment 8707907 [details] [diff] [review]:
-----------------------------------------------------------------
I changed my mind about the default parameter business.
::: gfx/2d/2D.h
@@ +746,5 @@
> * Release takes the original data pointer for safety.
> */
> virtual bool LockBits(uint8_t** aData, IntSize* aSize,
> + int32_t* aStride, SurfaceFormat* aFormat,
> + IntPoint* aOrigin = nullptr) { return false; }
I'd rather not have aOrigin have a default parameter. I don't think there are many cases where you want to ignore the result.
Attachment #8707907 -
Flags: review- → review+
Assignee | ||
Comment 17•9 years ago
|
||
Keywords: checkin-needed
Comment 18•9 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/c4b9f8f265db
https://hg.mozilla.org/integration/mozilla-inbound/rev/f52b5d9ac763
https://hg.mozilla.org/integration/mozilla-inbound/rev/0798566a8d00
https://hg.mozilla.org/integration/mozilla-inbound/rev/a32088113b26
https://hg.mozilla.org/integration/mozilla-inbound/rev/9bcdab1d4fda
https://hg.mozilla.org/integration/mozilla-inbound/rev/606793e62820
Keywords: checkin-needed
Comment 19•9 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/c4b9f8f265db
https://hg.mozilla.org/mozilla-central/rev/f52b5d9ac763
https://hg.mozilla.org/mozilla-central/rev/0798566a8d00
https://hg.mozilla.org/mozilla-central/rev/a32088113b26
https://hg.mozilla.org/mozilla-central/rev/9bcdab1d4fda
https://hg.mozilla.org/mozilla-central/rev/606793e62820
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
status-firefox46:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla46
You need to log in
before you can comment on or make changes to this bug.
Description
•