[Cherry-pick] Create a GraphicsLayerUpdater class that will do periodic layer flushes...
authorprabha.p@samsung.com <prabha.p@samsung.com>
Tue, 18 Jun 2013 08:09:44 +0000 (17:09 +0900)
committerHurnjoo Lee <hurnjoo.lee@samsung.com>
Wed, 2 Oct 2013 07:56:20 +0000 (16:56 +0900)
[Title] Create a GraphicsLayerUpdater class that will do periodic layer flushes for layer trees containing tile caches
[Issue#] P130604-5534
[Problem] Delay in painting when the transition happens
[Cause]
[Solution] Cherry-pick
[Cherry-Picker] Prabhavathi Perumal <prabha.p@samsung.com>

Create a GraphicsLayerUpdater class that will do periodic layer flushes for layer trees containing tile caches

https://bugs.webkit.org/show_bug.cgi?id=99518

Reviewed by Dean Jackson.

When using tile caches in place of tiled layers, we need to recompute their
visible area periodically while animations and scrolling are happening.
Make a new class, GraphicsLayerUpdater, to handle this updating.
Internally, it uses DisplayRefreshMonitor to generate the periodic updates.

GraphicsLayer clients are notified that layers need periodic updates. Clients
are free to make use of GraphicsLayerUpdater to handle this updating, as
RenderLayerCompositor does.

Also do some minor refactoring of methods in RenderLayerCompositor that
get to Page.

* CMakeLists.txt: Add GraphicsLayerUpdater.cpp to the build.
* GNUmakefile.list.am: Ditto.
* PlatformBlackBerry.cmake: Ditto.
* Target.pri: Ditto.
* WebCore.gypi: Ditto.
* WebCore.vcproj/WebCore.vcproj: Ditto.
* WebCore.xcodeproj/project.pbxproj: Ditto.
* dom/Document.cpp:
(WebCore::Document::windowScreenDidChange): Tell the compositor that the screen
changed, so it can tell the GraphicsLayerUpdater if it has one.
* platform/graphics/GraphicsLayerClient.h:
(WebCore::GraphicsLayerClient::notifyFlushBeforeDisplayRefresh): Method called
for layers that need periodic updates, like tile cache layers.
* platform/graphics/GraphicsLayerUpdater.cpp: Added. Uses DisplayRefreshMonitorManager
to flush layers before the next refresh.
(WebCore::GraphicsLayerUpdater::GraphicsLayerUpdater):
(WebCore::GraphicsLayerUpdater::~GraphicsLayerUpdater):
(WebCore::GraphicsLayerUpdater::scheduleUpdate):
(WebCore::GraphicsLayerUpdater::screenDidChange):
(WebCore::GraphicsLayerUpdater::displayRefreshFired):
* platform/graphics/GraphicsLayerUpdater.h: Added.
(GraphicsLayerUpdaterClient): Clients need to implement flushLayers().
(WebCore::GraphicsLayerUpdaterClient::~GraphicsLayerUpdaterClient):
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::recursiveCommitChanges): For tile cache layers,
tell the client that this layer should be updated soon to update the visible rect.
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::notifyFlushBeforeDisplayRefresh): Pass this message
on to the compositor.
* rendering/RenderLayerBacking.h:
(RenderLayerBacking): Implement notifyFlushBeforeDisplayRefresh.
Add OVERRIDE to all the client overrides.
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::cacheAcceleratedCompositingFlags): Use helper to get to Page.
(WebCore::RenderLayerCompositor::scheduleLayerFlush): Ditto.
(WebCore::RenderLayerCompositor::flushPendingLayerChanges): Soon we're going to be asking
about the current state of animations inside the flush (for visible rect computation), so we
need a AnimationUpdateBlock to make sure all the animation times are in sync.
(WebCore::RenderLayerCompositor::notifyFlushBeforeDisplayRefresh): Make a GraphicsLayerUpdater
if necessary, and tell it to update soon.
(WebCore::RenderLayerCompositor::flushLayers): The GraphicsLayerUpdater client method.
Just does a flush. For now, considers this Frame as the flush root, which will need fixing for iframes.
(WebCore::RenderLayerCompositor::shouldPropagateCompositingToEnclosingFrame): Use helper to get to Page.
(WebCore::RenderLayerCompositor::deviceScaleFactor): Ditto.
(WebCore::RenderLayerCompositor::pageScaleFactor): Ditto.
(WebCore::RenderLayerCompositor::destroyRootLayer): Ditto.
(WebCore::RenderLayerCompositor::windowScreenDidChange): Tell the updater if we have one.
(WebCore::RenderLayerCompositor::scrollingCoordinator): Use helper to get to Page.
(WebCore::RenderLayerCompositor::graphicsLayerFactory): Use helper to get to Page.
(WebCore::RenderLayerCompositor::page): The helper.
* rendering/RenderLayerCompositor.h:
(RenderLayerCompositor): Add OVERRIDE to all the client overrides.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@131680 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Conflicts:

Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/rendering/RenderLayerBacking.h
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebCore/rendering/RenderLayerCompositor.h

Change-Id: I20fc4acdb2eb8ced842d039ef79251af617b4088

14 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/GNUmakefile.list.am
Source/WebCore/PlatformBlackBerry.cmake
Source/WebCore/Target.pri
Source/WebCore/WebCore.gypi
Source/WebCore/dom/Document.cpp
Source/WebCore/platform/graphics/GraphicsLayerClient.h
Source/WebCore/platform/graphics/GraphicsLayerUpdater.cpp [new file with mode: 0644]
Source/WebCore/platform/graphics/GraphicsLayerUpdater.h [new file with mode: 0644]
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
Source/WebCore/rendering/RenderLayerBacking.cpp
Source/WebCore/rendering/RenderLayerBacking.h
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebCore/rendering/RenderLayerCompositor.h

index 0b18962..d93f3b7 100755 (executable)
@@ -1822,6 +1822,7 @@ LIST(APPEND WebCore_SOURCES
     platform/graphics/GraphicsContext.cpp
     platform/graphics/GraphicsLayer.cpp
     platform/graphics/GraphicsLayerAnimation.cpp
+    platform/graphics/GraphicsLayerUpdater.cpp
     platform/graphics/GraphicsLayerTransform.cpp
     platform/graphics/GraphicsTypes.cpp
     platform/graphics/Image.cpp
index 9fab13b..74d98c9 100644 (file)
@@ -3537,6 +3537,9 @@ webcore_sources += \
        Source/WebCore/platform/graphics/GraphicsLayer.h \
        Source/WebCore/platform/graphics/GraphicsLayer.cpp \
        Source/WebCore/platform/graphics/GraphicsLayerClient.h \
+       Source/WebCore/platform/graphics/GraphicsLayerFactory.h \
+       Source/WebCore/platform/graphics/GraphicsLayerUpdater.h \
+       Source/WebCore/platform/graphics/GraphicsLayerUpdater.cpp \
        Source/WebCore/platform/graphics/GraphicsTypes.cpp \
        Source/WebCore/platform/graphics/GraphicsTypes.h \
        Source/WebCore/platform/graphics/GraphicsTypes3D.h \
index 9b4a11b..fd46207 100644 (file)
@@ -267,6 +267,7 @@ ENDIF ()
 IF (WTF_USE_ACCELERATED_COMPOSITING)
     LIST(APPEND WebCore_SOURCES
         ${WEBCORE_DIR}/platform/graphics/GraphicsLayer.cpp
+        ${WEBCORE_DIR}/platform/graphics/GraphicsLayerUpdater.cpp
         ${WEBCORE_DIR}/platform/graphics/blackberry/CanvasLayerWebKitThread.cpp
         ${WEBCORE_DIR}/platform/graphics/blackberry/GraphicsLayerBlackBerry.cpp
         ${WEBCORE_DIR}/platform/graphics/blackberry/LayerAnimation.cpp
index c3a8e71..02a4473 100644 (file)
@@ -962,6 +962,7 @@ SOURCES += \
     platform/graphics/GraphicsContext.cpp \
     platform/graphics/GraphicsLayer.cpp \
     platform/graphics/GraphicsLayerAnimation.cpp \
+    platform/graphics/GraphicsLayerUpdater.cpp \
     platform/graphics/GraphicsLayerTransform.cpp \
     platform/graphics/GraphicsTypes.cpp \
     platform/graphics/Image.cpp \
index ff4f7d3..dbae19d 100644 (file)
             'platform/graphics/GraphicsLayer.cpp',
             'platform/graphics/GraphicsLayerAnimation.cpp',
             'platform/graphics/GraphicsLayerAnimation.h',
+            'platform/graphics/GraphicsLayerUpdater.cpp',
+            'platform/graphics/GraphicsLayerUpdater.h',
             'platform/graphics/GraphicsLayerTransform.cpp',
             'platform/graphics/GraphicsLayerTransform.h',
             'platform/graphics/GraphicsTypes.cpp',
index f4e6bfa..706b514 100755 (executable)
 #include "ProcessingInstruction.h"
 #include "RegisteredEventListener.h"
 #include "RenderArena.h"
+#include "RenderLayerCompositor.h"
 #include "RenderNamedFlowThread.h"
 #include "RenderTextControl.h"
 #include "RenderView.h"
@@ -5355,14 +5356,18 @@ void Document::resumeScriptedAnimationControllerCallbacks()
 
 void Document::windowScreenDidChange(PlatformDisplayID displayID)
 {
+    UNUSED_PARAM(displayID);
+
 #if ENABLE(REQUEST_ANIMATION_FRAME)
     if (m_scriptedAnimationController)
         m_scriptedAnimationController->windowScreenDidChange(displayID);
-#else
-    UNUSED_PARAM(displayID);
 #endif
-}
 
+#if USE(ACCELERATED_COMPOSITING)
+    if (renderView()->usesCompositing())
+        renderView()->compositor()->windowScreenDidChange(displayID);
+#endif
+}
 
 String Document::displayStringModifiedByEncoding(const String& str) const
 {
index 6848cf4..dd1efaa 100644 (file)
@@ -90,6 +90,9 @@ public:
     // to appear on the screen.
     virtual void notifySyncRequired(const GraphicsLayer*) = 0;
     
+    // Notification that this layer requires a flush before the next display refresh.
+    virtual void notifyFlushBeforeDisplayRefresh(const GraphicsLayer*) { }
+
     virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const IntRect& inClip) = 0;
     virtual void didCommitChangesForLayer(const GraphicsLayer*) const { }
 
diff --git a/Source/WebCore/platform/graphics/GraphicsLayerUpdater.cpp b/Source/WebCore/platform/graphics/GraphicsLayerUpdater.cpp
new file mode 100644 (file)
index 0000000..f2e5c74
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if USE(ACCELERATED_COMPOSITING)
+
+#include "GraphicsLayerUpdater.h"
+
+#include "GraphicsLayer.h"
+
+namespace WebCore {
+
+GraphicsLayerUpdater::GraphicsLayerUpdater(GraphicsLayerUpdaterClient* client, PlatformDisplayID displayID)
+    : m_client(client)
+    , m_scheduled(false)
+{
+#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
+    DisplayRefreshMonitorManager::sharedManager()->registerClient(this);
+    DisplayRefreshMonitorManager::sharedManager()->windowScreenDidChange(displayID, this);
+    DisplayRefreshMonitorManager::sharedManager()->scheduleAnimation(this);
+#endif
+}
+
+GraphicsLayerUpdater::~GraphicsLayerUpdater()
+{
+    // ~DisplayRefreshMonitorClient unregisters us as a client.
+}
+
+void GraphicsLayerUpdater::scheduleUpdate()
+{
+    if (m_scheduled)
+        return;
+
+#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
+    DisplayRefreshMonitorManager::sharedManager()->scheduleAnimation(this);
+#endif
+    m_scheduled = true;
+}
+
+void GraphicsLayerUpdater::screenDidChange(PlatformDisplayID displayID)
+{
+#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
+    DisplayRefreshMonitorManager::sharedManager()->windowScreenDidChange(displayID, this);
+#endif
+}
+
+void GraphicsLayerUpdater::displayRefreshFired(double timestamp)
+{
+    UNUSED_PARAM(timestamp);
+    m_scheduled = false;
+
+    if (m_client)
+        m_client->flushLayers(this);
+}
+
+} // namespace WebCore
+
+#endif // USE(ACCELERATED_COMPOSITING)
diff --git a/Source/WebCore/platform/graphics/GraphicsLayerUpdater.h b/Source/WebCore/platform/graphics/GraphicsLayerUpdater.h
new file mode 100644 (file)
index 0000000..bb1700f
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef GraphicsLayerUpdater_h
+#define GraphicsLayerUpdater_h
+
+#if USE(ACCELERATED_COMPOSITING)
+
+#include "DisplayRefreshMonitor.h"
+#include "PlatformScreen.h"
+
+namespace WebCore {
+
+class GraphicsLayerUpdater;
+
+class GraphicsLayerUpdaterClient {
+public:
+    virtual ~GraphicsLayerUpdaterClient() { }
+    virtual void flushLayers(GraphicsLayerUpdater*) = 0;
+};
+
+class GraphicsLayerUpdater
+#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
+    : public DisplayRefreshMonitorClient
+#endif
+{
+public:
+    GraphicsLayerUpdater(GraphicsLayerUpdaterClient*, PlatformDisplayID);
+    ~GraphicsLayerUpdater();
+
+    void scheduleUpdate();
+    void screenDidChange(PlatformDisplayID);
+
+private:
+    virtual void displayRefreshFired(double timestamp);
+
+    GraphicsLayerUpdaterClient* m_client;
+    bool m_scheduled;
+};
+
+} // namespace WebCore
+
+#endif // USE(ACCELERATED_COMPOSITING)
+
+#endif // GraphicsLayerUpdater_h
index db4de7f..7b9ca83 100644 (file)
@@ -989,6 +989,9 @@ void GraphicsLayerCA::recursiveCommitChanges(const TransformState& state, float
 
     commitLayerChangesAfterSublayers();
 
+    if (client() && m_layer->layerType() == PlatformCALayer::LayerTypeTileCacheLayer)
+        client()->notifyFlushBeforeDisplayRefresh(this);
+
     if (hadChanges && client())
         client()->didCommitChangesForLayer(this);
 }
index d1f3255..ce8d58c 100644 (file)
@@ -1760,6 +1760,11 @@ void RenderLayerBacking::notifySyncRequired(const GraphicsLayer*)
         compositor()->scheduleLayerFlush();
 }
 
+void RenderLayerBacking::notifyFlushBeforeDisplayRefresh(const GraphicsLayer* layer)
+{
+    compositor()->notifyFlushBeforeDisplayRefresh(layer);
+}
+
 // This is used for the 'freeze' API, for testing only.
 void RenderLayerBacking::suspendAnimations(double time)
 {
index a2d1ed5..36ddc58 100644 (file)
@@ -133,20 +133,23 @@ public:
     void updateAfterWidgetResize();
 
     // GraphicsLayerClient interface
-    virtual bool shouldUseTileCache(const GraphicsLayer*) const;
+
     virtual bool usingTileCache(const GraphicsLayer*) const { return m_usingTiledCacheLayer; }
-    virtual void notifyAnimationStarted(const GraphicsLayer*, double startTime);
     virtual void notifySyncRequired(const GraphicsLayer*);
+    virtual bool shouldUseTileCache(const GraphicsLayer*) const OVERRIDE;
+    virtual void notifyAnimationStarted(const GraphicsLayer*, double startTime) OVERRIDE;
+    virtual void notifyFlushBeforeDisplayRefresh(const GraphicsLayer*) OVERRIDE;
+
 
-    virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const IntRect& clip);
+    virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const IntRect& clip) OVERRIDE;
 
-    virtual float deviceScaleFactor() const;
-    virtual float pageScaleFactor() const;
-    virtual void didCommitChangesForLayer(const GraphicsLayer*) const;
-    virtual bool getCurrentTransform(const GraphicsLayer*, TransformationMatrix&) const;
+    virtual float deviceScaleFactor() const OVERRIDE;
+    virtual float pageScaleFactor() const OVERRIDE;
+    virtual void didCommitChangesForLayer(const GraphicsLayer*) const OVERRIDE;
+    virtual bool getCurrentTransform(const GraphicsLayer*, TransformationMatrix&) const OVERRIDE;
 
-    virtual bool showDebugBorders(const GraphicsLayer*) const;
-    virtual bool showRepaintCounter(const GraphicsLayer*) const;
+    virtual bool showDebugBorders(const GraphicsLayer*) const OVERRIDE;
+    virtual bool showRepaintCounter(const GraphicsLayer*) const OVERRIDE;
 
 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
     virtual void platformLayerChanged(GraphicsLayer*, PlatformLayer* oldPlatformLayer, PlatformLayer* newPlatformLayer);
index 6baeafa..a773b9f 100644 (file)
@@ -232,9 +232,7 @@ void RenderLayerCompositor::cacheAcceleratedCompositingFlags()
         // We allow the chrome to override the settings, in case the page is rendered
         // on a chrome that doesn't allow accelerated compositing.
         if (hasAcceleratedCompositing) {
-            Frame* frame = m_renderView->frameView()->frame();
-            Page* page = frame ? frame->page() : 0;
-            if (page) {
+            if (Page* page = this->page()) {
                 ChromeClient* chromeClient = page->chrome()->client();
                 m_compositingTriggers = chromeClient->allowedCompositingTriggers();
                 hasAcceleratedCompositing = m_compositingTriggers;
@@ -274,12 +272,8 @@ void RenderLayerCompositor::setCompositingLayersNeedRebuild(bool needRebuild)
 
 void RenderLayerCompositor::scheduleLayerFlush()
 {
-    Frame* frame = m_renderView->frameView()->frame();
-    Page* page = frame ? frame->page() : 0;
-    if (!page)
-        return;
-
-    page->chrome()->client()->scheduleCompositingLayerSync();
+    if (Page* page = this->page())
+        page->chrome()->client()->scheduleCompositingLayerSync();
 }
 
 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
@@ -303,6 +297,8 @@ void RenderLayerCompositor::flushPendingLayerChanges(bool isFlushRoot)
     if (!isFlushRoot && rootLayerAttachment() == RootLayerAttachedViaEnclosingFrame)
         return;
     
+    AnimationUpdateBlock animationUpdateBlock(m_renderView->frameView()->frame()->animation());
+
     ASSERT(!m_flushingLayers);
     m_flushingLayers = true;
 
@@ -326,6 +322,24 @@ void RenderLayerCompositor::didFlushChangesForLayer(RenderLayer*)
 {
 }
 
+void RenderLayerCompositor::notifyFlushBeforeDisplayRefresh(const GraphicsLayer*)
+{
+    if (!m_layerUpdater) {
+        PlatformDisplayID displayID = 0;
+        if (Page* page = this->page())
+            displayID = page->displayID();
+
+        m_layerUpdater = adoptPtr(new GraphicsLayerUpdater(this, displayID));
+    }
+
+    m_layerUpdater->scheduleUpdate();
+}
+
+void RenderLayerCompositor::flushLayers(GraphicsLayerUpdater*)
+{
+    flushPendingLayerChanges(true); // FIXME: deal with iframes
+}
+
 RenderLayerCompositor* RenderLayerCompositor::enclosingCompositorFlushingLayers() const
 {
     if (!m_renderView->frameView())
@@ -1460,8 +1474,7 @@ bool RenderLayerCompositor::shouldPropagateCompositingToEnclosingFrame() const
 
     // On Mac, only propagate compositing if the frame is overlapped in the parent
     // document, or the parent is already compositing, or the main frame is scaled.
-    Frame* frame = m_renderView->frameView()->frame();
-    Page* page = frame ? frame->page() : 0;
+    Page* page = this->page();
     if (page && page->pageScaleFactor() != 1)
         return true;
     
@@ -2012,24 +2025,14 @@ bool RenderLayerCompositor::showRepaintCounter(const GraphicsLayer* layer) const
 
 float RenderLayerCompositor::deviceScaleFactor() const
 {
-    Frame* frame = m_renderView->frameView()->frame();
-    if (!frame)
-        return 1;
-    Page* page = frame->page();
-    if (!page)
-        return 1;
-    return page->deviceScaleFactor();
+    Page* page = this->page();
+    return page ? page->deviceScaleFactor() : 1;
 }
 
 float RenderLayerCompositor::pageScaleFactor() const
 {
-    Frame* frame = m_renderView->frameView()->frame();
-    if (!frame)
-        return 1;
-    Page* page = frame->page();
-    if (!page)
-        return 1;
-    return page->pageScaleFactor();
+    Page* page = this->page();
+    return page ? page->pageScaleFactor() : 1;
 }
 
 void RenderLayerCompositor::didCommitChangesForLayer(const GraphicsLayer*) const
@@ -2325,6 +2328,8 @@ void RenderLayerCompositor::destroyRootLayer()
     }
     ASSERT(!m_scrollLayer);
     m_rootContentLayer = nullptr;
+
+    m_layerUpdater = nullptr;
 }
 
 void RenderLayerCompositor::attachRootLayer(RootLayerAttachment attachment)
@@ -2487,12 +2492,16 @@ void RenderLayerCompositor::deviceOrPageScaleFactorChanged()
         rootLayer->noteDeviceOrPageScaleFactorChangedIncludingDescendants();
 }
 
+void RenderLayerCompositor::windowScreenDidChange(PlatformDisplayID displayID)
+{
+    if (m_layerUpdater)
+        m_layerUpdater->screenDidChange(displayID);
+}
+
 ScrollingCoordinator* RenderLayerCompositor::scrollingCoordinator() const
 {
-    if (Frame* frame = m_renderView->frameView()->frame()) {
-        if (Page* page = frame->page())
-            return page->scrollingCoordinator();
-    }
+    if (Page* page = this->page())
+        return page->scrollingCoordinator();
 
     return 0;
 }
@@ -2559,6 +2568,13 @@ void RenderLayerCompositor::scrollingLayerRemoved(RenderLayer* layer, GraphicsLa
         chromeClient->removeScrollingLayer(layer->renderer()->node(), scrollingLayer, contentsLayer);
 }
 #endif
+Page* RenderLayerCompositor::page() const
+{
+    if (Frame* frame = m_renderView->frameView()->frame())
+        return frame->page();
+
+    return 0;
+}
 
 } // namespace WebCore
 
index 41e1c97..44090bc 100644 (file)
 #define RenderLayerCompositor_h
 
 #include "ChromeClient.h"
+#include "Frame.h"
+#include "GraphicsLayerUpdater.h"
 #include "RenderLayer.h"
 #include "RenderLayerBacking.h"
 
 namespace WebCore {
 
 class GraphicsLayer;
+class GraphicsLayerUpdater;
 class RenderEmbeddedObject;
 class RenderPart;
 class ScrollingCoordinator;
@@ -54,7 +57,8 @@ enum CompositingUpdateType {
 // 
 // There is one RenderLayerCompositor per RenderView.
 
-class RenderLayerCompositor : public GraphicsLayerClient {
+class RenderLayerCompositor : public GraphicsLayerClient, public GraphicsLayerUpdaterClient {
+    WTF_MAKE_FAST_ALLOCATED;
 public:
     RenderLayerCompositor(RenderView*);
     ~RenderLayerCompositor();
@@ -199,15 +203,18 @@ public:
     bool compositorShowDebugBorders() const { return m_showDebugBorders; }
     bool compositorShowRepaintCounter() const { return m_showRepaintCounter; }
 
-    virtual float deviceScaleFactor() const;
-    virtual float pageScaleFactor() const;
-    virtual void didCommitChangesForLayer(const GraphicsLayer*) const;
+    virtual float deviceScaleFactor() const OVERRIDE;
+    virtual float pageScaleFactor() const OVERRIDE;
+    virtual void didCommitChangesForLayer(const GraphicsLayer*) const OVERRIDE;
+    virtual void notifyFlushBeforeDisplayRefresh(const GraphicsLayer*) OVERRIDE;
     
     bool keepLayersPixelAligned() const;
     bool acceleratedDrawingEnabled() const { return m_acceleratedDrawingEnabled; }
 
     void deviceOrPageScaleFactorChanged();
 
+    void windowScreenDidChange(PlatformDisplayID);
+
     GraphicsLayer* layerForHorizontalScrollbar() const { return m_layerForHorizontalScrollbar.get(); }
     GraphicsLayer* layerForVerticalScrollbar() const { return m_layerForVerticalScrollbar.get(); }
     GraphicsLayer* layerForScrollCorner() const { return m_layerForScrollCorner.get(); }
@@ -229,16 +236,21 @@ private:
     class OverlapMap;
 
     // GraphicsLayerClient Implementation
-    virtual void notifyAnimationStarted(const GraphicsLayer*, double) { }
     virtual void notifySyncRequired(const GraphicsLayer*) { scheduleLayerFlush(); }
-    virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const IntRect&);
-
-    virtual bool showDebugBorders(const GraphicsLayer*) const;
-    virtual bool showRepaintCounter(const GraphicsLayer*) const;
 
 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
     virtual void platformLayerChanged(GraphicsLayer*, PlatformLayer* /* oldPlatformLayer */, PlatformLayer* /* newPlatformLayer */) { }
 #endif
+    // GraphicsLayerClient implementation
+    virtual void notifyAnimationStarted(const GraphicsLayer*, double) OVERRIDE { }
+    virtual void notifyFlushRequired(const GraphicsLayer*) OVERRIDE { scheduleLayerFlush(); }
+    virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const IntRect&) OVERRIDE;
+
+    virtual bool showDebugBorders(const GraphicsLayer*) const OVERRIDE;
+    virtual bool showRepaintCounter(const GraphicsLayer*) const OVERRIDE;
+
+    // GraphicsLayerUpdaterClient implementation
+    virtual void flushLayers(GraphicsLayerUpdater*) OVERRIDE;
     
     // Whether the given RL needs a compositing layer.
     bool needsToBeComposited(const RenderLayer*) const;
@@ -292,6 +304,8 @@ private:
 
     bool isFlushingLayers() const { return m_flushingLayers; }
 
+    Page* page() const;
+
     ScrollingCoordinator* scrollingCoordinator() const;
 
     // Whether a running transition or animation enforces the need for a compositing layer.
@@ -376,6 +390,8 @@ private:
     OwnPtr<GraphicsLayer> m_contentShadowLayer;
 #endif
 
+    OwnPtr<GraphicsLayerUpdater> m_layerUpdater; // Updates tiled layer visible area periodically while animations are running.
+
 #if !LOG_DISABLED
     int m_rootLayerUpdateCount;
     int m_obligateCompositedLayerCount; // count of layer that have to be composited.