Bug 82564 - [chromium] Remove SkCanvas::LayerIter use from OpaqueRegionSkia
Summary: [chromium] Remove SkCanvas::LayerIter use from OpaqueRegionSkia
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Dana Jansens
URL:
Keywords:
: 81723 (view as bug list)
Depends on:
Blocks: 84275
  Show dependency treegraph
 
Reported: 2012-03-28 19:56 PDT by Dana Jansens
Modified: 2012-04-18 17:25 PDT (History)
8 users (show)

See Also:


Attachments
Patch (23.41 KB, patch)
2012-03-28 20:19 PDT, Dana Jansens
no flags Details | Formatted Diff | Diff
Patch (23.60 KB, patch)
2012-03-29 15:05 PDT, Dana Jansens
no flags Details | Formatted Diff | Diff
Patch (23.56 KB, patch)
2012-03-29 19:25 PDT, Dana Jansens
no flags Details | Formatted Diff | Diff
Patch (28.34 KB, patch)
2012-03-30 15:12 PDT, Dana Jansens
no flags Details | Formatted Diff | Diff
Patch (28.41 KB, patch)
2012-04-02 17:22 PDT, Dana Jansens
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dana Jansens 2012-03-28 19:56:19 PDT
[chromium] Remove SkCanvas::LayerIter use from OpaqueRegionSkia
Comment 1 Dana Jansens 2012-03-28 20:04:51 PDT
This is required for per-tile-painting in the renderer.
Comment 2 Dana Jansens 2012-03-28 20:17:03 PDT
I attempted to do this a few times before I found the LayerIter and felt like we got very solid with it. But I'm sorry to say that it doesn't work with SkPictureRecord, and it is going to  leave the SkCanvas public API so we can't rely on it. 

But I think I'm in a spot where I can do a better job of this now. :)

We have to change any code that does saveLayer() on the canvas underlying the GraphicsContext, to instead do it through the platformContext. And PlatformContextSkia implements imageClipping through the saveLayer()/restore(), so we need to track what it is doing explicitly as well.
Comment 3 Dana Jansens 2012-03-28 20:19:12 PDT
Created attachment 134485 [details]
Patch
Comment 4 Dana Jansens 2012-03-28 20:20:34 PDT
*** Bug 81723 has been marked as a duplicate of this bug. ***
Comment 5 Stephen White 2012-03-29 14:42:29 PDT
Comment on attachment 134485 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=134485&action=review

> Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp:284
>          &layerPaint,
>          static_cast<SkCanvas::SaveFlags>(SkCanvas::kHasAlphaLayer_SaveFlag |
>                                           SkCanvas::kFullColorLayer_SaveFlag));
> +    platformContext()->didSaveLayer(layerPaint);

Couldn't this call platformContext()->saveLayer() (and skip the "did" here)?

> Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp:292
> +    platformContext()->didRestoreLayer();
>      platformContext()->canvas()->restore();

Same here:  couldn't this call platformContext()->restore()?
Comment 6 Dana Jansens 2012-03-29 14:44:22 PDT
Comment on attachment 134485 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=134485&action=review

>> Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp:284
>> +    platformContext()->didSaveLayer(layerPaint);
> 
> Couldn't this call platformContext()->saveLayer() (and skip the "did" here)?

yes! i added that later.. good idea, will do.
Comment 7 Dana Jansens 2012-03-29 15:05:53 PDT
Created attachment 134676 [details]
Patch
Comment 8 Dana Jansens 2012-03-29 19:25:05 PDT
Created attachment 134712 [details]
Patch

While it is not in practice now null, the SkPaint* for saveLayer() could be null, so fixing this patch to work correctly in the face of that.

FYI I'm working on a followup to use SKDrawLoopers more intelligently instead of just bailing. I say this cuz it's going to mess up the stack in this patch, but it's a similar idea so fair to do this first I think.
Comment 9 Stephen White 2012-03-30 08:35:00 PDT
Comment on attachment 134712 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=134712&action=review

> Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp:107
> +    SkRect m_previousImageBufferClipRect;
> +    SkRect m_totalImageBufferClipRect;
> +    SkRect m_previousImageBufferOpaqueRect;
> +    SkRect m_totalImageBufferOpaqueRect;

Since this seems to be specific to the opaque region tracker, perhaps it should be moved there?
Comment 10 Dana Jansens 2012-03-30 15:12:44 PDT
Created attachment 134897 [details]
Patch
Comment 11 Dana Jansens 2012-03-30 15:22:31 PDT
- Added the bounds to the PlatformContextSkia::saveLayer() method.
- Save the SkPaints in the stack in OpaqueRegionSkia.
- Moved the data for the image clip/mask into the OpaqueRegionSkia stack.
- Fixed the logic around preservesOpaque and added a unit test to verify it.
Comment 12 Stephen White 2012-04-02 17:08:03 PDT
Comment on attachment 134897 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=134897&action=review

> Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp:234
> +    m_opaqueRegion.pushCanvasLayer(paint);

Shouldn't this be guarded by if (m_trackOpaqueRegion)?

> Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp:242
> +    m_opaqueRegion.pushCanvasLayer(paint);

Same as above.

> Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp:248
> +    m_opaqueRegion.popCanvasLayer();

Same as above.

> Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp:277
> +    SkRect opaqueRect = bitmap->isOpaque() ? m_state->m_clip : SkRect::MakeEmpty();
> +    m_opaqueRegion.setImageMask(opaqueRect);

Same as above.
Comment 13 Dana Jansens 2012-04-02 17:22:08 PDT
Created attachment 135239 [details]
Patch

done x4 !
Comment 14 Stephen White 2012-04-02 17:23:33 PDT
Comment on attachment 135239 [details]
Patch

OK.  r=me
Comment 15 WebKit Review Bot 2012-04-02 20:31:41 PDT
Comment on attachment 135239 [details]
Patch

Clearing flags on attachment: 135239

Committed r112980: <http://trac.webkit.org/changeset/112980>
Comment 16 WebKit Review Bot 2012-04-02 20:31:46 PDT
All reviewed patches have been landed.  Closing bug.