Source/WebCore/ChangeLog

112012-01-04 James Robinson <jamesr@chromium.org>
22
 3 [chromium] Route all animate calls through CCLayerTreeHost in composited mode to simplify rate limiting logic
 4 https://bugs.webkit.org/show_bug.cgi?id=75577
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 This internalizes the animation rate limiting logic to CCLayerTreeHost and removes the setters/getters for the
 9 m_animating flag. This requires that all animation updates have to go through CCLayerTreeHost to get the right
 10 rate limiting behavior, regardless of which proxy is being used.
 11
 12 * platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
 13 (WebCore::CCLayerTreeHost::updateAnimations):
 14 (WebCore::CCLayerTreeHost::layout):
 15 (WebCore::CCLayerTreeHost::startRateLimiter):
 16 * platform/graphics/chromium/cc/CCLayerTreeHost.h:
 17 * platform/graphics/chromium/cc/CCThreadProxy.cpp:
 18 (WebCore::CCThreadProxy::beginFrameAndCommit):
 19
 202012-01-04 James Robinson <jamesr@chromium.org>
 21
322 [chromium] Remove chromium compositor support for unused zoomAnimatorTransform
423 https://bugs.webkit.org/show_bug.cgi?id=75585
524

Source/WebKit/chromium/ChangeLog

112012-01-04 James Robinson <jamesr@chromium.org>
22
 3 [chromium] Route all animate calls through CCLayerTreeHost in composited mode to simplify rate limiting logic
 4 https://bugs.webkit.org/show_bug.cgi?id=75577
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Routes WebWidget-initiated animate() calls through the CCLayerTreeHost in composited mode. CCLayerTreeHost's
 9 rate limiting logic needs to be aware of when requestAnimationFrame callbacks are run. In threaded mode, the
 10 animate calls are driven from CCThreadProxy and so the CCLayerTreeHost can set whatever state it needs. This
 11 makes the single-threaded mode where the animate calls are driven through the WebWidget interface outside of the
 12 CCProxy's control.
 13
 14 This is a small step towards inverting the scheduling control from the WebWidget to the compositor.
 15
 16 * src/WebViewImpl.cpp:
 17 (WebKit::WebViewImpl::animate):
 18 (WebKit::WebViewImpl::updateAnimations):
 19 * src/WebViewImpl.h:
 20
 212012-01-04 James Robinson <jamesr@chromium.org>
 22
323 [chromium] Remove chromium compositor support for unused zoomAnimatorTransform
424 https://bugs.webkit.org/show_bug.cgi?id=75585
525

Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp

@@void CCLayerTreeHost::deleteContentsTexturesOnImplThread(TextureAllocator* alloc
118118 m_contentsTextureManager->evictAndDeleteAllTextures(allocator);
119119}
120120
121 void CCLayerTreeHost::animateAndLayout(double frameBeginTime)
 121void CCLayerTreeHost::updateAnimations(double frameBeginTime)
122122{
123123 m_animating = true;
124  m_client->animateAndLayout(frameBeginTime);
 124 m_client->updateAnimations(frameBeginTime);
125125 m_animating = false;
126126}
127127
 128void CCLayerTreeHost::layout()
 129{
 130 m_client->layout();
 131}
 132
128133void CCLayerTreeHost::beginCommitOnImplThread(CCLayerTreeHostImpl* hostImpl)
129134{
130135 ASSERT(CCProxy::isImplThread());

@@void CCLayerTreeHost::applyScrollAndScale(const CCScrollAndScaleSet& info)
500505
501506void CCLayerTreeHost::startRateLimiter(GraphicsContext3D* context)
502507{
503  if (animating())
 508 if (m_animating)
504509 return;
505510 ASSERT(context);
506511 RateLimiterMap::iterator it = m_rateLimiters.find(context);

Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h

@@class TextureManager;
5353
5454class CCLayerTreeHostClient {
5555public:
56  virtual void animateAndLayout(double frameBeginTime) = 0;
 56 virtual void updateAnimations(double frameBeginTime) = 0;
 57 virtual void layout() = 0;
5758 virtual void applyScrollAndScale(const IntSize& scrollDelta, float pageScale) = 0;
5859 virtual PassRefPtr<GraphicsContext3D> createLayerTreeHostContext3D() = 0;
5960 virtual void didRecreateGraphicsContext(bool success) = 0;

@@public:
121122 static bool anyLayerTreeHostInstanceExists();
122123
123124 // CCLayerTreeHost interface to CCProxy.
124  void animateAndLayout(double frameBeginTime);
 125 void updateAnimations(double frameBeginTime);
 126 void layout();
125127 void beginCommitOnImplThread(CCLayerTreeHostImpl*);
126128 void finishCommitOnImplThread(CCLayerTreeHostImpl*);
127129 void commitComplete();

@@public:
133135 void didCompleteSwapBuffers() { m_client->didCompleteSwapBuffers(); }
134136 void deleteContentsTexturesOnImplThread(TextureAllocator*);
135137
136  // CCLayerTreeHost interface to WebView.
137  bool animating() const { return m_animating; }
138  void setAnimating(bool animating) { m_animating = animating; } // Can be removed when non-threaded scheduling moves inside.
139 
140138 CCLayerTreeHostClient* client() { return m_client; }
141139
142140 int compositorIdentifier() const { return m_compositorIdentifier; }

Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp

@@void CCThreadProxy::beginFrameAndCommit(int sequenceNumber, double frameBeginTim
363363 // Re-do the commit flow so that we don't send the scrollInfo on the BFAC message.
364364 m_layerTreeHost->applyScrollAndScale(*scrollInfo);
365365
366  // FIXME: recreate the context if it was requested by the impl thread
367  {
368  TRACE_EVENT("CCLayerTreeHost::animateAndLayout", this, 0);
369  m_layerTreeHost->animateAndLayout(frameBeginTime);
370  }
 366 // FIXME: recreate the context if it was requested by the impl thread.
 367 m_layerTreeHost->updateAnimations(frameBeginTime);
 368 m_layerTreeHost->layout();
371369
372370 ASSERT(m_lastExecutedBeginFrameAndCommitSequenceNumber == sequenceNumber);
373371
374  // Clear the commit flag after animateAndLayout here --- objects that only
 372 // Clear the commit flag after updating animations and layout here --- objects that only
375373 // layout when painted will trigger another setNeedsCommit inside
376374 // updateLayers.
377375 m_commitRequested = false;

Source/WebKit/chromium/public/platform/WebLayerTreeViewClient.h

@@class WebThread;
3333
3434class WebLayerTreeViewClient {
3535public:
36  // Updates animation and layout. This is called before the compositing pass
37  // so that layers can be updated at the given frame time.
38  virtual void animateAndLayout(double frameBeginTime) = 0;
 36 // Updates animation and layout. These are called before the compositing
 37 // pass so that layers can be updated at the given frame time.
 38 virtual void updateAnimations(double frameBeginTime) = 0;
 39 virtual void layout() = 0;
3940
4041 // Applies a scroll delta to the root layer, which is bundled with a page
4142 // scale factor that may apply a CSS transform on the whole document (used

Source/WebKit/chromium/src/WebLayerTreeViewImpl.cpp

@@WebLayerTreeViewImpl::~WebLayerTreeViewImpl()
6060{
6161}
6262
63 void WebLayerTreeViewImpl::animateAndLayout(double frameBeginTime)
 63void WebLayerTreeViewImpl::updateAnimations(double frameBeginTime)
6464{
6565 if (m_client)
66  m_client->animateAndLayout(frameBeginTime);
 66 m_client->updateAnimations(frameBeginTime);
 67}
 68
 69void WebLayerTreeViewImpl::layout()
 70{
 71 if (m_client)
 72 m_client->layout();
6773}
6874
6975void WebLayerTreeViewImpl::applyScrollAndScale(const WebCore::IntSize& scrollDelta, float pageScale)

Source/WebKit/chromium/src/WebLayerTreeViewImpl.h

@@public:
4141private:
4242 WebLayerTreeViewImpl(WebLayerTreeViewClient*, const WebLayerTreeView::Settings&);
4343 virtual ~WebLayerTreeViewImpl();
44  virtual void animateAndLayout(double frameBeginTime);
 44 virtual void updateAnimations(double frameBeginTime);
 45 virtual void layout();
4546 virtual void applyScrollAndScale(const WebCore::IntSize& scrollDelta, float pageScale);
4647 virtual PassRefPtr<WebCore::GraphicsContext3D> createLayerTreeHostContext3D();
4748 virtual void didRecreateGraphicsContext(bool success);

Source/WebKit/chromium/src/WebViewImpl.cpp

@@void WebViewImpl::didExitFullScreen()
11281128void WebViewImpl::animate(double frameBeginTime)
11291129{
11301130#if ENABLE(REQUEST_ANIMATION_FRAME)
1131  TRACE_EVENT("WebViewImpl::animate", this, 0);
11321131 // FIXME: remove this zero-check once render_widget has been modified to
11331132 // pass in a frameBeginTime.
11341133 if (!frameBeginTime)
11351134 frameBeginTime = currentTime();
1136  WebFrameImpl* webframe = mainFrameImpl();
1137  if (webframe) {
1138  FrameView* view = webframe->frameView();
1139  if (view) {
1140  if (!CCProxy::hasImplThread() && m_layerTreeHost)
1141  m_layerTreeHost->setAnimating(true);
11421135
1143  view->serviceScriptedAnimations(convertSecondsToDOMTimeStamp(frameBeginTime));
 1136#if USE(ACCELERATED_COMPOSITING)
 1137 // In composited mode, we always go through the compositor so it can apply
 1138 // appropriate flow-control mechanisms.
 1139 if (isAcceleratedCompositingActive())
 1140 m_layerTreeHost->updateAnimations(frameBeginTime);
 1141 else
 1142#endif
 1143 updateAnimations(frameBeginTime);
 1144#endif
 1145}
11441146
1145  if (!CCProxy::hasImplThread() && m_layerTreeHost)
1146  m_layerTreeHost->setAnimating(false);
1147  }
1148  }
 1147void WebViewImpl::updateAnimations(double frameBeginTime)
 1148{
 1149#if ENABLE(REQUEST_ANIMATION_FRAME)
 1150 TRACE_EVENT("WebViewImpl::updateAnimations", this, 0);
 1151
 1152 WebFrameImpl* webframe = mainFrameImpl();
 1153 if (!webframe)
 1154 return;
 1155 FrameView* view = webframe->frameView();
 1156 if (!view)
 1157 return;
 1158 view->serviceScriptedAnimations(convertSecondsToDOMTimeStamp(frameBeginTime));
11491159#endif
11501160}
11511161

@@PassRefPtr<GraphicsContext3D> WebViewImpl::createLayerTreeHostContext3D()
29802990 return context;
29812991}
29822992
2983 void WebViewImpl::animateAndLayout(double frameBeginTime)
2984 {
2985  animate(frameBeginTime);
2986  layout();
2987 }
2988 
29892993void WebViewImpl::applyScrollAndScale(const IntSize& scrollDelta, float pageScaleDelta)
29902994{
29912995 if (!mainFrameImpl() || !mainFrameImpl()->frameView())

Source/WebKit/chromium/src/WebViewImpl.h

@@public:
109109 virtual void willExitFullScreen();
110110 virtual void didExitFullScreen();
111111 virtual void animate(double frameBeginTime);
 112 // This also implements WebCore::CCLayerTreeHostClient::layout()
112113 virtual void layout();
113114 virtual void paint(WebCanvas*, const WebRect&);
114115 virtual void themeChanged();

@@public:
236237 virtual void removePageOverlay(WebPageOverlay*);
237238
238239 // CCLayerTreeHostClient
239  virtual void animateAndLayout(double frameBeginTime);
 240 virtual void updateAnimations(double frameBeginTime);
240241 virtual void applyScrollAndScale(const WebCore::IntSize&, float);
241242 virtual PassRefPtr<WebCore::GraphicsContext3D> createLayerTreeHostContext3D();
242243 virtual void didCommitAndDrawFrame();

Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp

@@public:
5959 virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl*) { }
6060 virtual void drawLayersOnCCThread(CCLayerTreeHostImpl*) { }
6161 virtual void applyScrollAndScale(const IntSize&, float) { }
62  virtual void animateAndLayout(double frameBeginTime) { }
 62 virtual void updateAnimations(double frameBeginTime) { }
 63 virtual void layout() { }
6364};
6465
6566// Adapts CCLayerTreeHostImpl for test. Runs real code, then invokes test hooks.

@@public:
137138 return adoptPtr(new MockLayerTreeHostClient(testHooks));
138139 }
139140
140  virtual void animateAndLayout(double frameBeginTime)
 141 virtual void updateAnimations(double frameBeginTime)
141142 {
142  m_testHooks->animateAndLayout(frameBeginTime);
 143 m_testHooks->updateAnimations(frameBeginTime);
 144 }
 145
 146 virtual void layout()
 147 {
 148 m_testHooks->layout();
143149 }
144150
145151 virtual void applyScrollAndScale(const IntSize& scrollDelta, float scale)

@@public:
696702 postSetNeedsAnimateToMainThread();
697703 }
698704
699  virtual void animateAndLayout(double)
 705 virtual void updateAnimations(double)
700706 {
701707 if (!m_numAnimates) {
702708 m_layerTreeHost->setNeedsAnimate();

@@public:
736742 postSetNeedsCommitToMainThread();
737743 }
738744
739  virtual void animateAndLayout(double frameBeginTime)
 745 virtual void layout()
740746 {
741747 LayerChromium* root = m_layerTreeHost->rootLayer();
742748 if (!m_layerTreeHost->frameNumber())

Source/WebKit/chromium/tests/LayerChromiumTest.cpp

@@namespace {
5252
5353class FakeCCLayerTreeHostClient : public CCLayerTreeHostClient {
5454public:
55  virtual void animateAndLayout(double frameBeginTime) { }
 55 virtual void updateAnimations(double frameBeginTime) { }
 56 virtual void layout() { }
5657 virtual void applyScrollAndScale(const IntSize& scrollDelta, float pageScale) { }
5758 virtual PassRefPtr<GraphicsContext3D> createLayerTreeHostContext3D() { return 0; }
5859 virtual void didRecreateGraphicsContext(bool success) { }

Source/WebKit/chromium/tests/WebLayerTest.cpp

@@class MockWebLayerTreeViewClient : public WebLayerTreeViewClient {
5252public:
5353 MOCK_METHOD0(scheduleComposite, void());
5454
55  virtual void animateAndLayout(double frameBeginTime) { }
 55 virtual void updateAnimations(double frameBeginTime) { }
 56 virtual void layout() { }
5657 virtual void applyScrollAndScale(const WebSize& scrollDelta, float scaleFactor) { }
5758 virtual WebGraphicsContext3D* createContext3D() { return CompositorFakeWebGraphicsContext3D::create(WebGraphicsContext3D::Attributes()).leakPtr(); }
5859 virtual void didRebindGraphicsContext(bool success) { }