Bug 94663 - [chromium] Refactor CCLayerTreeHostCommon: always propagate clipRect down, without boolean flags
Summary: [chromium] Refactor CCLayerTreeHostCommon: always propagate clipRect down, wi...
Status: RESOLVED WONTFIX
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Shawn Singh
URL:
Keywords:
Depends on: 94542
Blocks: 94541
  Show dependency treegraph
 
Reported: 2012-08-21 18:31 PDT by Shawn Singh
Modified: 2012-10-08 16:13 PDT (History)
6 users (show)

See Also:


Attachments
Patch (14.04 KB, patch)
2012-08-21 18:48 PDT, Shawn Singh
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Shawn Singh 2012-08-21 18:31:52 PDT
This is actually part 1 of https://bugs.webkit.org/show_bug.cgi?id=94541, I realized it would be a good idea to split it into a separate patch so that any problems down the road may be easier to diagnose.

This patch removes the boolean flags that controlled wether clipRects are actually "active" for a layer or not.  Instead, now the clipRect is always active.

There was one kink where, now that clipRects are passed across renderSurfaces, they may not be valid on the main thread if the transform was animating.  I believe it's correct and equivalent to the existing code to prevent the clipRect from affecting drawableContentRects and surface clipRects when !transformToScreenIsKnown(), so I opted for that.
Comment 1 Shawn Singh 2012-08-21 18:48:51 PDT
Created attachment 159841 [details]
Patch

tested on osx unit and layout tests, no obvious regressions. Also tested on the apple iphone page which has been a good practical example of multiple renderSurfaces with clipping and animations all combined; the page works fine with this patch.
Comment 2 Dana Jansens 2012-08-22 07:46:10 PDT
Comment on attachment 159841 [details]
Patch

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

As long as things aren't removed from the RSLL when they wouldn't have been before, I think you're good. The values within layers are supposed to represent a given point in time in the animation, not the full span of possibilities. So I dont think you don't need to loosen drawableContentRect or anything, if that's what you mean.

> Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp:685
> +        if (!layer->replicaLayer() && transformToScreenIsKnown(layer) && !clippedContentRect.isEmpty()) {

Why transformToScreen? It's only using drawTransform() inside.
Comment 3 Shawn Singh 2012-08-22 09:24:51 PDT
(In reply to comment #2)
> (From update of attachment 159841 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=159841&action=review
> 
> As long as things aren't removed from the RSLL when they wouldn't have been before, I think you're good. The values within layers are supposed to represent a given point in time in the animation, not the full span of possibilities. So I dont think you don't need to loosen drawableContentRect or anything, if that's what you mean.
> 
> > Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp:685
> > +        if (!layer->replicaLayer() && transformToScreenIsKnown(layer) && !clippedContentRect.isEmpty()) {
> 
> Why transformToScreen? It's only using drawTransform() inside.

Because the clipRect is now passed down across renderSurfaces, and we shouldn't be using it when any of the hierarchy of transforms is unknown.

Without this, it actually does fail your own test case, "verifyClipRectCullsSurfaceWithoutVisibleContent".  This is what I wanted to ask you about offline, but after thinking over it more, I think this patch is doing the right thing.

Note, there were 2 places where we have to replace subtreeShouldBeSkipped with transformToScreenIsKnown(...)  I'm pretty sure those have to be screen space checks for the same reason.
Comment 4 Adrienne Walker 2012-08-22 10:21:44 PDT
Comment on attachment 159841 [details]
Patch

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

> Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp:579
> +        // so that it is described with repsect to the current target surface. Note that this transformation may cause

typo

> Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp:581
> +        clipRectForSubtree = enclosingIntRect(CCMathUtil::projectClippedRect(renderSurface->drawTransform().inverse(), FloatRect(clipRectFromAncestor)));

I have a lot of mixed feelings about this patch and this line is the source of most of them.  If you project clip rects down, then it will cut down on the ability to reuse render surfaces.  If they are ever-so-slightly off-screen then they will change size and need to be entirely redrawn.

I also don't see how this change allows you to handle visibleContentRect calculations any more easily.  Previously with a boolean, you could either use the clip rect or just set the visible state to the entire content bounds.  Now without a boolean, you can just use the clip rect.

> Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp:380
> -    parentSublayerMatrix.scale3d(10, 10, 3.3);
> +    parentSublayerMatrix.scale3d(0.3, 0.3, 1);

0.3f
Comment 5 Adrienne Walker 2012-08-22 10:22:59 PDT
Comment on attachment 159841 [details]
Patch

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

>> Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp:380
>> +    parentSublayerMatrix.scale3d(0.3, 0.3, 1);
> 
> 0.3f

Er, scratch that, this takes a double.  Too many literla float conversion warnings on Windows has clouded my brain.
Comment 6 Shawn Singh 2012-08-22 11:57:40 PDT
(In reply to comment #4)
> (From update of attachment 159841 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=159841&action=review
> 
> > Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp:579
> > +        // so that it is described with repsect to the current target surface. Note that this transformation may cause
> 
> typo
> 
> > Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp:581
> > +        clipRectForSubtree = enclosingIntRect(CCMathUtil::projectClippedRect(renderSurface->drawTransform().inverse(), FloatRect(clipRectFromAncestor)));
> 
> I have a lot of mixed feelings about this patch and this line is the source of most of them.  If you project clip rects down, then it will cut down on the ability to reuse render surfaces.  If they are ever-so-slightly off-screen then they will change size and need to be entirely redrawn.
> 
> I also don't see how this change allows you to handle visibleContentRect calculations any more easily.  Previously with a boolean, you could either use the clip rect or just set the visible state to the entire content bounds.  Now without a boolean, you can just use the clip rect.
> 
> > Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp:380
> > -    parentSublayerMatrix.scale3d(10, 10, 3.3);
> > +    parentSublayerMatrix.scale3d(0.3, 0.3, 1);
> 
> 0.3f


(1) You're right, we should not affect surface clipRects.   It's also worth noting that in one of my previous refactors, I forced the root layer to clip to viewport.  This means that renderSurfaces that draw to the root will also be uncachable when they animate and get clipped.  I'll fix it very soon.

(2) However, we still do need to inverse-project clipRects.   I think I figured out how to do this cleanly without forcing us to propagate clipRects down.  The downside is that it further relies on surface->clipRect().isEmpty() - but it's definitely less evil than what I was trying to do in this patch =)

So this patch is probably WONTFIX, I'll mark it that way when I'm certain.   Thanks for the voice of reason Enne =)
Comment 7 Shawn Singh 2012-08-22 16:09:11 PDT
I have a working patch now for merging visibleLayerRect that doesn't require this factor.
Comment 8 Eric Seidel (no email) 2012-10-08 16:13:32 PDT
Comment on attachment 159841 [details]
Patch

Cleared review? from attachment 159841 [details] so that this bug does not appear in http://webkit.org/pending-review.  If you would like this patch reviewed, please attach it to a new bug (or re-open this bug before marking it for review again).