Bug 77646 - [chromium] Plumb animation started notifications from CCLayerTreeHost to GraphicsLayerChromium
Summary: [chromium] Plumb animation started notifications from CCLayerTreeHost to Grap...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: vollick
URL:
Keywords:
Depends on:
Blocks: 76468 77662
  Show dependency treegraph
 
Reported: 2012-02-02 09:01 PST by vollick
Modified: 2012-02-28 11:46 PST (History)
4 users (show)

See Also:


Attachments
Patch (10.38 KB, patch)
2012-02-02 09:39 PST, vollick
no flags Details | Formatted Diff | Diff
Patch (33.98 KB, patch)
2012-02-08 13:44 PST, vollick
no flags Details | Formatted Diff | Diff
Patch (13.76 KB, patch)
2012-02-10 15:32 PST, vollick
no flags Details | Formatted Diff | Diff
Patch (33.53 KB, patch)
2012-02-24 14:28 PST, vollick
no flags Details | Formatted Diff | Diff
Patch (32.70 KB, patch)
2012-02-24 14:33 PST, vollick
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description vollick 2012-02-02 09:01:23 PST
We must notify the GraphicsLayer's client when we've started an animation on this layer. We need to get the animation started results (which are plumbed to CCLayerTreeHost) to their respective GraphicsLayerChromiums so that this notification can take place.
Comment 1 vollick 2012-02-02 09:39:15 PST
Created attachment 125148 [details]
Patch
Comment 2 Nat Duca 2012-02-02 14:02:38 PST
Comment on attachment 125148 [details]
Patch

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

Looks good but we need to go to an AnimationDelegate model rather than a generic LayerChromiumClient.

> Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp:78
> +    m_layer->setClient(this);

People would like us to use an animation delegate model.

E.g. CCLayerChromium::setAnimationDelegate(this)

Where CCLayerChromiumAnimationDelegate has our notifyAnimationStarted method.

We should only set the delegate when we have an animation. Though, we don't have to clear the delegate when stop having an animation --- just make sure you clear it during destruction. :)
Comment 3 vollick 2012-02-08 13:44:00 PST
Created attachment 126145 [details]
Patch
Comment 4 Nat Duca 2012-02-09 21:28:46 PST
Comment on attachment 126145 [details]
Patch

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

> Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp:79
>  

I'd like this to only be set when you add an animation. Once set, it can be left on forever. Essentially, remove this line, then on the *Animation methods, put a call like setLayerAnimationDelegateIfNeeded() before using the layer. That should set the delegate, if its not already set.

> Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp:88
> +        m_layer->clearLayerAnimationDelegate();

Why clear and not just setAnimationDelegate(0)?

> Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp:94
> +        m_layer->clearLayerAnimationDelegate();

what's this? And why is it conditional on m_transformLayer?

> Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp:378
> +    return primaryLayer()->addAnimation(values, boxSize, animation, animationName, timeOffset);

is primaryLayer always going to have an animation delegate pointing at us?  What if primaryLayer is a transform layer?

Again, i'd prefer we did a setLayerDelegate(primaryLayer()) call here to prevent this mess.

> Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.h:46
> +class GraphicsLayerChromium : public GraphicsLayer,

Check webkit style, is this normative?

> Source/WebCore/platform/graphics/chromium/LayerChromium.h:223
> +    void clearLayerAnimationDelegate() { m_layerAnimationDelegate = 0; }

Not sure this makes sense when you have a setter above.

> Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp:270
> +    setAnimationResultsRecursive(results.get(), m_rootLayer.get());

if you use a const reference to the CCAnimationResults, then you can just do *results here. I definitely prefer being const-correct in this case --- we're not mutating the results.

> Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp:606
> +{

Is there any way to normalize between the name "setAnimationResults" and "nofityAnimations"? It'd be cool if it was CCLTH::notifyLayersOfAnimationResults(CCAnimationResults*) or something. Please dont use that name, it kinda sucks. But hopefully you get my point.

> Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp:232
>  

Looks like you did a bugfix in the animationcontrollerimpl. You should have a test for the controller that catches this mistake, if possible... if not, nbd. But its a good corner case you uncovered.

Do you have tests for the layer delegate being called correctly? Smells like a test for the CCLayerTreeHostTest file
Comment 5 vollick 2012-02-10 15:32:09 PST
Created attachment 126595 [details]
Patch
Comment 6 James Robinson 2012-02-17 23:35:51 PST
Comment on attachment 126595 [details]
Patch

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

> Source/WebCore/platform/graphics/chromium/LayerChromium.cpp:2
> + * Copyright (C) 2012 Google Inc. All rights reserved.

don't change copyright header dates when modifying the file, just leave them alone

> Source/WebCore/platform/graphics/chromium/LayerChromium.h:227
> +    friend class CCLayerTreeHost;

It would be much, much better to have notifyAnimationStarted() be public than to friend CCLayerTreeHost
Comment 7 vollick 2012-02-24 14:28:38 PST
Created attachment 128809 [details]
Patch
Comment 8 vollick 2012-02-24 14:33:08 PST
Created attachment 128811 [details]
Patch
Comment 9 vollick 2012-02-24 14:36:51 PST
Noteworthy changes:
 - There are now two types of animation event
   1) Started (webkit needs this notification)
   2) Finished (GraphicsLayerChromium needs this to update its animation id map)

 - I now test that these events get sent in response to an animation being started and finished (CCLayerTreeHostTest.cpp)

(In reply to comment #6)
> (From update of attachment 126595 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=126595&action=review
> 
> > Source/WebCore/platform/graphics/chromium/LayerChromium.cpp:2
> > + * Copyright (C) 2012 Google Inc. All rights reserved.
> 
> don't change copyright header dates when modifying the file, just leave them alone
> 
Done.
> > Source/WebCore/platform/graphics/chromium/LayerChromium.h:227
> > +    friend class CCLayerTreeHost;
> 
> It would be much, much better to have notifyAnimationStarted() be public than to friend CCLayerTreeHost
Done.
Comment 10 James Robinson 2012-02-24 14:59:24 PST
Comment on attachment 128811 [details]
Patch

I think there's an issue with startTime here - on the impl side we're using the monotonicallyIncreasingTime() clock, but GraphicsLayerClient is expecting the currentTime() timebase.  I think we need a re-normalization pass on the time values somewhere (probably GraphicsLayerChromium) in case the timebases are different for the two time sources.  As we discussed offline I think it's fine to file a bug on that issue separately and take care of it before we turn this on by default since it'll be pretty isolated from the rest of this patch, which looks great.

R=me!
Comment 11 WebKit Review Bot 2012-02-24 18:19:55 PST
Comment on attachment 128811 [details]
Patch

Clearing flags on attachment: 128811

Committed r108880: <http://trac.webkit.org/changeset/108880>
Comment 12 WebKit Review Bot 2012-02-24 18:20:01 PST
All reviewed patches have been landed.  Closing bug.