Title: [137968] trunk/Source
Revision
137968
Author
[email protected]
Date
2012-12-17 18:38:10 -0800 (Mon, 17 Dec 2012)

Log Message

Coordinated Graphics: Refactor TiledBackingStore code in CoordinatedGraphicsLayer.
https://bugs.webkit.org/show_bug.cgi?id=103959

Patch by Huang Dongsung <[email protected]> on 2012-12-17
Reviewed by Kenneth Rohde Christiansen.

Source/WebCore:

TiledBackingStore::setCommitTileUpdatesOnIdleEventLoop() is used when class
methods cannot be called asynchronously by client. Updates of tiles are
committed as soon as all the events in event queue have been processed.
After this patch Frame sets m_commitTileUpdatesOnIdleEventLoop to true.

In addition, remove TiledBackingStoreClient::tiledBackingStoreUpdatesAllowed()
which was introduced for Coordinated Graphics.

Refactoring covered by existing tests.

* page/Frame.cpp:
(WebCore::Frame::setTiledBackingStoreEnabled):
* platform/graphics/TiledBackingStore.cpp:
(WebCore::TiledBackingStore::TiledBackingStore):
(WebCore::TiledBackingStore::setTrajectoryVector):
  Separate setting a trajectory vector from coverWithTilesIfNeeded().
(WebCore::TiledBackingStore::coverWithTilesIfNeeded):
(WebCore::TiledBackingStore::updateTileBuffers):
(WebCore::TiledBackingStore::createTiles):
(WebCore::TiledBackingStore::isTileBufferUpdatesSuspended):
(WebCore::TiledBackingStore::startTileBufferUpdateTimer):
(WebCore::TiledBackingStore::tileBufferUpdateTimerFired):
(WebCore::TiledBackingStore::startBackingStoreUpdateTimer):
(WebCore::TiledBackingStore::backingStoreUpdateTimerFired):
* platform/graphics/TiledBackingStore.h:
(TiledBackingStore):
(WebCore::TiledBackingStore::setCommitTileUpdatesOnIdleEventLoop):
* platform/graphics/TiledBackingStoreClient.h:
(WebCore::TiledBackingStoreClient::tiledBackingStoreHasPendingTileCreation):
    If TiledBackingStore does not create all tiles, TiledBackingStore
    notifies a client of needing to create tiles more, when
    m_commitTileUpdatesOnIdleEventLoop is false.

Source/WebKit2:

Currently, CoordinatedGraphicsLayer has complex code related to TiledBackingStore.
It has two problem.
1. CoordinatedGraphicsLayer hacks TiledBackingStore to prevent
TiledBackingStore from asynchronously sending UpdateTile message to UI
Process.
2. CreateTile and RemoveTile message can be sent to UI Process at any time.

This patch makes CoordinatedGraphicsLayer use TiledBackingStore more explicitly.
It means only during flushing layer states, CoordinatedGraphicsLayer
calls methods of TiledBackingStore, which indirectly call createTile(),
updateTile() and removeTile().

* WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp:
(WebCore::CoordinatedGraphicsLayer::CoordinatedGraphicsLayer):
(WebCore::CoordinatedGraphicsLayer::setVisibleContentRectTrajectoryVector):
(WebCore::CoordinatedGraphicsLayer::setContentsScale):
(WebCore::CoordinatedGraphicsLayer::adjustContentsScale):
(WebCore::CoordinatedGraphicsLayer::tiledBackingStoreHasPendingTileCreation):
(WebCore::CoordinatedGraphicsLayer::beginContentUpdate):
(WebCore::CoordinatedGraphicsLayer::createTile):
(WebCore::CoordinatedGraphicsLayer::updateTile):
(WebCore::CoordinatedGraphicsLayer::removeTile):
(WebCore::CoordinatedGraphicsLayer::updateContentBuffers):
(WebCore::CoordinatedGraphicsLayer::purgeBackingStores):
(WebCore::CoordinatedGraphicsLayer::setNeedsVisibleRectAdjustment):
(WebCore::CoordinatedGraphicsLayer::computeTransformedVisibleRect):
* WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.h:
(CoordinatedGraphicsLayerClient):
(CoordinatedGraphicsLayer):
* WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp:
(WebKit::CoordinatedLayerTreeHost::notifyFlushRequired):
(WebKit::CoordinatedLayerTreeHost::createGraphicsLayer):
(WebKit::CoordinatedLayerTreeHost::setVisibleContentsRect):
* WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (137967 => 137968)


--- trunk/Source/WebCore/ChangeLog	2012-12-18 02:22:51 UTC (rev 137967)
+++ trunk/Source/WebCore/ChangeLog	2012-12-18 02:38:10 UTC (rev 137968)
@@ -1,3 +1,43 @@
+2012-12-17  Huang Dongsung  <[email protected]>
+
+        Coordinated Graphics: Refactor TiledBackingStore code in CoordinatedGraphicsLayer.
+        https://bugs.webkit.org/show_bug.cgi?id=103959
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        TiledBackingStore::setCommitTileUpdatesOnIdleEventLoop() is used when class
+        methods cannot be called asynchronously by client. Updates of tiles are
+        committed as soon as all the events in event queue have been processed.
+        After this patch Frame sets m_commitTileUpdatesOnIdleEventLoop to true.
+
+        In addition, remove TiledBackingStoreClient::tiledBackingStoreUpdatesAllowed()
+        which was introduced for Coordinated Graphics.
+
+        Refactoring covered by existing tests.
+
+        * page/Frame.cpp:
+        (WebCore::Frame::setTiledBackingStoreEnabled):
+        * platform/graphics/TiledBackingStore.cpp:
+        (WebCore::TiledBackingStore::TiledBackingStore):
+        (WebCore::TiledBackingStore::setTrajectoryVector):
+          Separate setting a trajectory vector from coverWithTilesIfNeeded().
+        (WebCore::TiledBackingStore::coverWithTilesIfNeeded):
+        (WebCore::TiledBackingStore::updateTileBuffers):
+        (WebCore::TiledBackingStore::createTiles):
+        (WebCore::TiledBackingStore::isTileBufferUpdatesSuspended):
+        (WebCore::TiledBackingStore::startTileBufferUpdateTimer):
+        (WebCore::TiledBackingStore::tileBufferUpdateTimerFired):
+        (WebCore::TiledBackingStore::startBackingStoreUpdateTimer):
+        (WebCore::TiledBackingStore::backingStoreUpdateTimerFired):
+        * platform/graphics/TiledBackingStore.h:
+        (TiledBackingStore):
+        (WebCore::TiledBackingStore::setCommitTileUpdatesOnIdleEventLoop):
+        * platform/graphics/TiledBackingStoreClient.h:
+        (WebCore::TiledBackingStoreClient::tiledBackingStoreHasPendingTileCreation):
+            If TiledBackingStore does not create all tiles, TiledBackingStore
+            notifies a client of needing to create tiles more, when
+            m_commitTileUpdatesOnIdleEventLoop is false.
+
 2012-12-17  Dean Jackson  <[email protected]>
 
         Track menu should be sorted

Modified: trunk/Source/WebCore/page/Frame.cpp (137967 => 137968)


--- trunk/Source/WebCore/page/Frame.cpp	2012-12-18 02:22:51 UTC (rev 137967)
+++ trunk/Source/WebCore/page/Frame.cpp	2012-12-18 02:38:10 UTC (rev 137968)
@@ -818,6 +818,7 @@
     if (m_tiledBackingStore)
         return;
     m_tiledBackingStore = adoptPtr(new TiledBackingStore(this));
+    m_tiledBackingStore->setCommitTileUpdatesOnIdleEventLoop(true);
     if (m_view)
         m_view->setPaintsEntireContents(true);
 }

Modified: trunk/Source/WebCore/platform/graphics/TiledBackingStore.cpp (137967 => 137968)


--- trunk/Source/WebCore/platform/graphics/TiledBackingStore.cpp	2012-12-18 02:22:51 UTC (rev 137967)
+++ trunk/Source/WebCore/platform/graphics/TiledBackingStore.cpp	2012-12-18 02:38:10 UTC (rev 137968)
@@ -41,12 +41,13 @@
     , m_tileBufferUpdateTimer(this, &TiledBackingStore::tileBufferUpdateTimerFired)
     , m_backingStoreUpdateTimer(this, &TiledBackingStore::backingStoreUpdateTimerFired)
     , m_tileSize(defaultTileDimension, defaultTileDimension)
-    , m_tileCreationDelay(0.01)
     , m_coverAreaMultiplier(2.0f)
     , m_contentsScale(1.f)
     , m_pendingScale(0)
+    , m_commitTileUpdatesOnIdleEventLoop(false)
     , m_contentsFrozen(false)
     , m_supportsAlpha(false)
+    , m_pendingTileCreation(false)
 {
 }
 
@@ -61,26 +62,20 @@
     startBackingStoreUpdateTimer();
 }
 
-void TiledBackingStore::setTileCreationDelay(double delay)
+void TiledBackingStore::setTrajectoryVector(const FloatPoint& trajectoryVector)
 {
-    m_tileCreationDelay = delay;
+    m_pendingTrajectoryVector = trajectoryVector;
+    m_pendingTrajectoryVector.normalize();
 }
 
-void TiledBackingStore::coverWithTilesIfNeeded(const FloatPoint& trajectoryVector)
+void TiledBackingStore::coverWithTilesIfNeeded()
 {
     IntRect visibleRect = this->visibleRect();
     IntRect rect = mapFromContents(m_client->tiledBackingStoreContentsRect());
 
-    FloatPoint normalizedVector = trajectoryVector;
-    normalizedVector.normalize();
-
-    if (m_trajectoryVector == normalizedVector && m_visibleRect == visibleRect && m_rect == rect)
-        return;
-
-    m_trajectoryVector = normalizedVector;
-    m_visibleRect = visibleRect;
-
-    createTiles();
+    bool didChange = m_trajectoryVector != m_pendingTrajectoryVector || m_visibleRect != visibleRect || m_rect != rect;
+    if (didChange || m_pendingTileCreation)
+        createTiles();
 }
 
 void TiledBackingStore::invalidate(const IntRect& contentsDirtyRect)
@@ -108,7 +103,7 @@
 
 void TiledBackingStore::updateTileBuffers()
 {
-    if (!m_client->tiledBackingStoreUpdatesAllowed() || m_contentsFrozen)
+    if (m_contentsFrozen)
         return;
 
     m_client->tiledBackingStorePaintBegin();
@@ -245,6 +240,8 @@
     // Update our backing store geometry.
     const IntRect previousRect = m_rect;
     m_rect = mapFromContents(m_client->tiledBackingStoreContentsRect());
+    m_trajectoryVector = m_pendingTrajectoryVector;
+    m_visibleRect = visibleRect();
 
     if (m_rect.isEmpty()) {
         setCoverRect(IntRect());
@@ -273,12 +270,9 @@
      * We must create or keep the tiles in the HERE region.
      */
 
-    const IntRect visibleRect = this->visibleRect();
-    m_visibleRect = visibleRect;
-
     IntRect coverRect;
     IntRect keepRect;
-    computeCoverAndKeepRect(visibleRect, coverRect, keepRect);
+    computeCoverAndKeepRect(m_visibleRect, coverRect, keepRect);
 
     setCoverRect(coverRect);
     setKeepRect(keepRect);
@@ -309,7 +303,7 @@
             if (tileAt(currentCoordinate))
                 continue;
             ++requiredTileCount;
-            double distance = tileDistance(visibleRect, currentCoordinate);
+            double distance = tileDistance(m_visibleRect, currentCoordinate);
             if (distance > shortestDistance)
                 continue;
             if (distance < shortestDistance) {
@@ -333,8 +327,16 @@
         updateTileBuffers();
 
     // Re-call createTiles on a timer to cover the visible area with the newest shortest distance.
-    if (requiredTileCount)
-        m_backingStoreUpdateTimer.startOneShot(m_tileCreationDelay);
+    m_pendingTileCreation = requiredTileCount;
+    if (m_pendingTileCreation) {
+        if (!m_commitTileUpdatesOnIdleEventLoop) {
+            m_client->tiledBackingStoreHasPendingTileCreation();
+            return;
+        }
+
+        static const double tileCreationDelay = 0.01;
+        startBackingStoreUpdateTimer(tileCreationDelay);
+    }
 }
 
 void TiledBackingStore::adjustForContentsRect(IntRect& rect) const
@@ -423,7 +425,7 @@
 
 bool TiledBackingStore::isTileBufferUpdatesSuspended() const
 {
-    return m_contentsFrozen || !m_client->tiledBackingStoreUpdatesAllowed();
+    return m_contentsFrozen;
 }
 
 bool TiledBackingStore::resizeEdgeTiles()
@@ -526,6 +528,9 @@
 
 void TiledBackingStore::startTileBufferUpdateTimer()
 {
+    if (!m_commitTileUpdatesOnIdleEventLoop)
+        return;
+
     if (m_tileBufferUpdateTimer.isActive() || isTileBufferUpdatesSuspended())
         return;
     m_tileBufferUpdateTimer.startOneShot(0);
@@ -533,18 +538,23 @@
 
 void TiledBackingStore::tileBufferUpdateTimerFired(Timer<TiledBackingStore>*)
 {
+    ASSERT(m_commitTileUpdatesOnIdleEventLoop);
     updateTileBuffers();
 }
 
-void TiledBackingStore::startBackingStoreUpdateTimer()
+void TiledBackingStore::startBackingStoreUpdateTimer(double interval)
 {
+    if (!m_commitTileUpdatesOnIdleEventLoop)
+        return;
+
     if (m_backingStoreUpdateTimer.isActive() || isBackingStoreUpdatesSuspended())
         return;
-    m_backingStoreUpdateTimer.startOneShot(0);
+    m_backingStoreUpdateTimer.startOneShot(interval);
 }
 
 void TiledBackingStore::backingStoreUpdateTimerFired(Timer<TiledBackingStore>*)
 {
+    ASSERT(m_commitTileUpdatesOnIdleEventLoop);
     createTiles();
 }
 

Modified: trunk/Source/WebCore/platform/graphics/TiledBackingStore.h (137967 => 137968)


--- trunk/Source/WebCore/platform/graphics/TiledBackingStore.h	2012-12-18 02:22:51 UTC (rev 137967)
+++ trunk/Source/WebCore/platform/graphics/TiledBackingStore.h	2012-12-18 02:38:10 UTC (rev 137968)
@@ -46,8 +46,13 @@
 
     TiledBackingStoreClient* client() { return m_client; }
 
-    void coverWithTilesIfNeeded(const FloatPoint& panningTrajectoryVector = FloatPoint());
+    // Used when class methods cannot be called asynchronously by client.
+    // Updates of tiles are committed as soon as all the events in event queue have been processed.
+    void setCommitTileUpdatesOnIdleEventLoop(bool enable) { m_commitTileUpdatesOnIdleEventLoop = enable; }
 
+    void setTrajectoryVector(const FloatPoint&);
+    void coverWithTilesIfNeeded();
+
     float contentsScale() { return m_contentsScale; }
     void setContentsScale(float);
 
@@ -62,9 +67,6 @@
     IntSize tileSize() { return m_tileSize; }
     void setTileSize(const IntSize&);
 
-    double tileCreationDelay() const { return m_tileCreationDelay; }
-    void setTileCreationDelay(double delay);
-
     IntRect mapToContents(const IntRect&) const;
     IntRect mapFromContents(const IntRect&) const;
 
@@ -81,7 +83,7 @@
 
 private:
     void startTileBufferUpdateTimer();
-    void startBackingStoreUpdateTimer();
+    void startBackingStoreUpdateTimer(double = 0);
 
     void tileBufferUpdateTimerFired(Timer<TiledBackingStore>*);
     void backingStoreUpdateTimerFired(Timer<TiledBackingStore>*);
@@ -120,10 +122,10 @@
     Timer<TiledBackingStore> m_backingStoreUpdateTimer;
 
     IntSize m_tileSize;
-    double m_tileCreationDelay;
     float m_coverAreaMultiplier;
 
     FloatPoint m_trajectoryVector;
+    FloatPoint m_pendingTrajectoryVector;
     IntRect m_visibleRect;
 
     IntRect m_coverRect;
@@ -133,8 +135,10 @@
     float m_contentsScale;
     float m_pendingScale;
 
+    bool m_commitTileUpdatesOnIdleEventLoop;
     bool m_contentsFrozen;
     bool m_supportsAlpha;
+    bool m_pendingTileCreation;
 
     friend class Tile;
 };

Modified: trunk/Source/WebCore/platform/graphics/TiledBackingStoreClient.h (137967 => 137968)


--- trunk/Source/WebCore/platform/graphics/TiledBackingStoreClient.h	2012-12-18 02:22:51 UTC (rev 137967)
+++ trunk/Source/WebCore/platform/graphics/TiledBackingStoreClient.h	2012-12-18 02:38:10 UTC (rev 137968)
@@ -33,7 +33,7 @@
     virtual void tiledBackingStorePaintBegin() = 0;
     virtual void tiledBackingStorePaint(GraphicsContext*, const IntRect&) = 0;
     virtual void tiledBackingStorePaintEnd(const Vector<IntRect>& paintedArea) = 0;
-    virtual bool tiledBackingStoreUpdatesAllowed() const { return true; }
+    virtual void tiledBackingStoreHasPendingTileCreation() { }
     virtual IntRect tiledBackingStoreContentsRect() = 0;
     virtual IntRect tiledBackingStoreVisibleRect() = 0;
     virtual Color tiledBackingStoreBackgroundColor() const = 0;

Modified: trunk/Source/WebKit2/ChangeLog (137967 => 137968)


--- trunk/Source/WebKit2/ChangeLog	2012-12-18 02:22:51 UTC (rev 137967)
+++ trunk/Source/WebKit2/ChangeLog	2012-12-18 02:38:10 UTC (rev 137968)
@@ -1,3 +1,45 @@
+2012-12-17  Huang Dongsung  <[email protected]>
+
+        Coordinated Graphics: Refactor TiledBackingStore code in CoordinatedGraphicsLayer.
+        https://bugs.webkit.org/show_bug.cgi?id=103959
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Currently, CoordinatedGraphicsLayer has complex code related to TiledBackingStore.
+        It has two problem.
+        1. CoordinatedGraphicsLayer hacks TiledBackingStore to prevent
+        TiledBackingStore from asynchronously sending UpdateTile message to UI
+        Process.
+        2. CreateTile and RemoveTile message can be sent to UI Process at any time.
+
+        This patch makes CoordinatedGraphicsLayer use TiledBackingStore more explicitly.
+        It means only during flushing layer states, CoordinatedGraphicsLayer
+        calls methods of TiledBackingStore, which indirectly call createTile(),
+        updateTile() and removeTile().
+
+        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp:
+        (WebCore::CoordinatedGraphicsLayer::CoordinatedGraphicsLayer):
+        (WebCore::CoordinatedGraphicsLayer::setVisibleContentRectTrajectoryVector):
+        (WebCore::CoordinatedGraphicsLayer::setContentsScale):
+        (WebCore::CoordinatedGraphicsLayer::adjustContentsScale):
+        (WebCore::CoordinatedGraphicsLayer::tiledBackingStoreHasPendingTileCreation):
+        (WebCore::CoordinatedGraphicsLayer::beginContentUpdate):
+        (WebCore::CoordinatedGraphicsLayer::createTile):
+        (WebCore::CoordinatedGraphicsLayer::updateTile):
+        (WebCore::CoordinatedGraphicsLayer::removeTile):
+        (WebCore::CoordinatedGraphicsLayer::updateContentBuffers):
+        (WebCore::CoordinatedGraphicsLayer::purgeBackingStores):
+        (WebCore::CoordinatedGraphicsLayer::setNeedsVisibleRectAdjustment):
+        (WebCore::CoordinatedGraphicsLayer::computeTransformedVisibleRect):
+        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.h:
+        (CoordinatedGraphicsLayerClient):
+        (CoordinatedGraphicsLayer):
+        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp:
+        (WebKit::CoordinatedLayerTreeHost::notifyFlushRequired):
+        (WebKit::CoordinatedLayerTreeHost::createGraphicsLayer):
+        (WebKit::CoordinatedLayerTreeHost::setVisibleContentsRect):
+        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h:
+
 2012-12-17  Brady Eidson  <[email protected]>
 
         Can't visit sites with untrusted certs with the NetworkProcess.

Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp (137967 => 137968)


--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp	2012-12-18 02:22:51 UTC (rev 137967)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp	2012-12-18 02:38:10 UTC (rev 137968)
@@ -38,6 +38,9 @@
 #include "WebPage.h"
 #include <wtf/CurrentTime.h>
 #include <wtf/HashMap.h>
+#ifndef NDEBUG
+#include <wtf/TemporaryChange.h>
+#endif
 #include <wtf/text/CString.h>
 
 using namespace WebKit;
@@ -103,7 +106,9 @@
 
 CoordinatedGraphicsLayer::CoordinatedGraphicsLayer(GraphicsLayerClient* client)
     : GraphicsLayer(client)
-    , m_inUpdateMode(false)
+#ifndef NDEBUG
+    , m_isPurging(false)
+#endif
     , m_shouldUpdateVisibleRect(true)
     , m_shouldSyncLayerState(true)
     , m_shouldSyncChildren(true)
@@ -114,6 +119,8 @@
     , m_canvasNeedsDisplay(false)
     , m_canvasNeedsCreate(false)
     , m_canvasNeedsDestroy(false)
+    , m_pendingContentsScaleAdjustment(false)
+    , m_pendingVisibleRectAdjustment(false)
     , m_coordinator(0)
     , m_contentsScale(1)
     , m_compositedNativeImagePtr(0)
@@ -637,14 +644,18 @@
 
 void CoordinatedGraphicsLayer::setVisibleContentRectTrajectoryVector(const FloatPoint& trajectoryVector)
 {
-    if (m_mainBackingStore)
-        m_mainBackingStore->coverWithTilesIfNeeded(trajectoryVector);
+    if (!m_mainBackingStore)
+        return;
+
+    m_mainBackingStore->setTrajectoryVector(trajectoryVector);
+    setNeedsVisibleRectAdjustment();
 }
 
 void CoordinatedGraphicsLayer::setContentsScale(float scale)
 {
     m_contentsScale = scale;
-    adjustContentsScale();
+    if (shouldHaveBackingStore())
+        m_pendingContentsScaleAdjustment = true;
 }
 
 float CoordinatedGraphicsLayer::effectiveContentsScale()
@@ -654,9 +665,7 @@
 
 void CoordinatedGraphicsLayer::adjustContentsScale()
 {
-    if (!shouldHaveBackingStore())
-        return;
-
+    ASSERT(shouldHaveBackingStore());
     if (!m_mainBackingStore || m_mainBackingStore->contentsScale() == effectiveContentsScale())
         return;
 
@@ -688,11 +697,11 @@
 {
 }
 
-bool CoordinatedGraphicsLayer::tiledBackingStoreUpdatesAllowed() const
+void CoordinatedGraphicsLayer::tiledBackingStoreHasPendingTileCreation()
 {
-    if (!m_inUpdateMode)
-        return false;
-    return m_coordinator->layerTreeTileUpdatesAllowed();
+    setNeedsVisibleRectAdjustment();
+    if (client())
+        client()->notifyFlushRequired(this);
 }
 
 IntRect CoordinatedGraphicsLayer::tiledBackingStoreContentsRect()
@@ -736,24 +745,28 @@
 PassOwnPtr<GraphicsContext> CoordinatedGraphicsLayer::beginContentUpdate(const IntSize& size, uint32_t& atlas, IntPoint& offset)
 {
     ASSERT(m_coordinator);
+    ASSERT(m_coordinator->isFlushingLayerChanges());
     return m_coordinator->beginContentUpdate(size, contentsOpaque() ? CoordinatedSurface::NoFlags : CoordinatedSurface::SupportsAlpha, atlas, offset);
 }
 
 void CoordinatedGraphicsLayer::createTile(uint32_t tileID, const SurfaceUpdateInfo& updateInfo, const WebCore::IntRect& tileRect)
 {
     ASSERT(m_coordinator);
+    ASSERT(m_coordinator->isFlushingLayerChanges());
     m_coordinator->createTile(id(), tileID, updateInfo, tileRect);
 }
 
 void CoordinatedGraphicsLayer::updateTile(uint32_t tileID, const SurfaceUpdateInfo& updateInfo, const IntRect& tileRect)
 {
     ASSERT(m_coordinator);
+    ASSERT(m_coordinator->isFlushingLayerChanges());
     m_coordinator->updateTile(id(), tileID, updateInfo, tileRect);
 }
 
 void CoordinatedGraphicsLayer::removeTile(uint32_t tileID)
 {
     ASSERT(m_coordinator);
+    ASSERT(m_coordinator->isFlushingLayerChanges() || m_isPurging);
     m_coordinator->removeTile(id(), tileID);
 }
 
@@ -765,13 +778,22 @@
         return;
     }
 
-    m_inUpdateMode = true;
+    if (m_pendingContentsScaleAdjustment) {
+        adjustContentsScale();
+        m_pendingContentsScaleAdjustment = false;
+    }
+
     // This is the only place we (re)create the main tiled backing store, once we
     // have a remote client and we are ready to send our data to the UI process.
     if (!m_mainBackingStore)
         createBackingStore();
+
+    if (m_pendingVisibleRectAdjustment) {
+        m_pendingVisibleRectAdjustment = false;
+        m_mainBackingStore->coverWithTilesIfNeeded();
+    }
+
     m_mainBackingStore->updateTileBuffers();
-    m_inUpdateMode = false;
 
     // The previous backing store is kept around to avoid flickering between
     // removing the existing tiles and painting the new ones. The first time
@@ -782,6 +804,9 @@
 
 void CoordinatedGraphicsLayer::purgeBackingStores()
 {
+#ifndef NDEBUG
+    TemporaryChange<bool> updateModeProtector(m_isPurging, true);
+#endif
     m_mainBackingStore.clear();
     m_previousBackingStore.clear();
 
@@ -795,10 +820,10 @@
     m_coordinator = coordinator;
 }
 
-void CoordinatedGraphicsLayer::adjustVisibleRect()
+void CoordinatedGraphicsLayer::setNeedsVisibleRectAdjustment()
 {
-    if (m_mainBackingStore)
-        m_mainBackingStore->coverWithTilesIfNeeded();
+    if (shouldHaveBackingStore())
+        m_pendingVisibleRectAdjustment = true;
 }
 
 bool CoordinatedGraphicsLayer::hasPendingVisibleChanges()
@@ -899,8 +924,7 @@
     m_cachedInverseTransform = m_layerTransform.combined().inverse();
 
     // The combined transform will be used in tiledBackingStoreVisibleRect.
-    adjustVisibleRect();
-    adjustContentsScale();
+    setNeedsVisibleRectAdjustment();
 }
 
 static PassOwnPtr<GraphicsLayer> createCoordinatedGraphicsLayer(GraphicsLayerClient* client)

Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.h (137967 => 137968)


--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.h	2012-12-18 02:22:51 UTC (rev 137967)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.h	2012-12-18 02:38:10 UTC (rev 137968)
@@ -59,7 +59,6 @@
     virtual void removeTile(CoordinatedLayerID, uint32_t tileID) = 0;
 
     virtual WebCore::FloatRect visibleContentsRect() const = 0;
-    virtual bool layerTreeTileUpdatesAllowed() const = 0;
     virtual PassRefPtr<CoordinatedImageBacking> createImageBackingIfNeeded(WebCore::Image*) = 0;
     virtual void syncLayerState(CoordinatedLayerID, const CoordinatedLayerInfo&) = 0;
     virtual void syncLayerChildren(CoordinatedLayerID, const Vector<CoordinatedLayerID>&) = 0;
@@ -151,7 +150,7 @@
     virtual void tiledBackingStorePaintBegin() OVERRIDE;
     virtual void tiledBackingStorePaint(GraphicsContext*, const IntRect&) OVERRIDE;
     virtual void tiledBackingStorePaintEnd(const Vector<IntRect>& paintedArea) OVERRIDE;
-    virtual bool tiledBackingStoreUpdatesAllowed() const OVERRIDE;
+    virtual void tiledBackingStoreHasPendingTileCreation() OVERRIDE;
     virtual IntRect tiledBackingStoreContentsRect() OVERRIDE;
     virtual IntRect tiledBackingStoreVisibleRect() OVERRIDE;
     virtual Color tiledBackingStoreBackgroundColor() const OVERRIDE;
@@ -164,7 +163,7 @@
 
     void setCoordinator(WebKit::CoordinatedGraphicsLayerClient*);
 
-    void adjustVisibleRect();
+    void setNeedsVisibleRectAdjustment();
     void purgeBackingStores();
     bool hasPendingVisibleChanges();
 
@@ -219,7 +218,9 @@
     FloatPoint m_adjustedPosition;
     FloatPoint3D m_adjustedAnchorPoint;
 
-    bool m_inUpdateMode : 1;
+#ifndef NDEBUG
+    bool m_isPurging;
+#endif
     bool m_shouldUpdateVisibleRect: 1;
     bool m_shouldSyncLayerState: 1;
     bool m_shouldSyncChildren: 1;
@@ -230,6 +231,8 @@
     bool m_canvasNeedsDisplay : 1;
     bool m_canvasNeedsCreate : 1;
     bool m_canvasNeedsDestroy : 1;
+    bool m_pendingContentsScaleAdjustment : 1;
+    bool m_pendingVisibleRectAdjustment : 1;
 
     WebKit::CoordinatedGraphicsLayerClient* m_coordinator;
     OwnPtr<TiledBackingStore> m_mainBackingStore;

Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp (137967 => 137968)


--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp	2012-12-18 02:22:51 UTC (rev 137967)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp	2012-12-18 02:38:10 UTC (rev 137968)
@@ -614,6 +614,7 @@
 
 void CoordinatedLayerTreeHost::notifyFlushRequired(const WebCore::GraphicsLayer*)
 {
+    scheduleLayerFlush();
 }
 
 void CoordinatedLayerTreeHost::paintContents(const WebCore::GraphicsLayer* graphicsLayer, WebCore::GraphicsContext& graphicsContext, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& clipRect)
@@ -637,7 +638,7 @@
     layer->setCoordinator(this);
     m_registeredLayers.add(layer);
     layer->setContentsScale(m_contentsScale);
-    layer->adjustVisibleRect();
+    layer->setNeedsVisibleRectAdjustment();
     return adoptPtr(layer);
 }
 
@@ -719,7 +720,7 @@
             if (contentsScaleDidChange)
                 (*it)->setContentsScale(scale);
             if (contentsRectDidChange)
-                (*it)->adjustVisibleRect();
+                (*it)->setNeedsVisibleRectAdjustment();
         }
     }
 
@@ -759,11 +760,6 @@
         m_updateAtlases[i]->didSwapBuffers();
 }
 
-bool CoordinatedLayerTreeHost::layerTreeTileUpdatesAllowed() const
-{
-    return !m_isSuspended && !m_waitingForUIProcess;
-}
-
 void CoordinatedLayerTreeHost::purgeBackingStores()
 {
     TemporaryChange<bool> purgingToggle(m_isPurging, true);

Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h (137967 => 137968)


--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h	2012-12-18 02:22:51 UTC (rev 137967)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h	2012-12-18 02:38:10 UTC (rev 137968)
@@ -86,7 +86,6 @@
     virtual WebCore::FloatRect visibleContentsRect() const;
     virtual void renderNextFrame();
     virtual void purgeBackingStores();
-    virtual bool layerTreeTileUpdatesAllowed() const;
     virtual void setVisibleContentsRect(const WebCore::FloatRect&, float scale, const WebCore::FloatPoint&);
     virtual void didReceiveCoordinatedLayerTreeHostMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&);
     virtual WebCore::GraphicsLayerFactory* graphicsLayerFactory() OVERRIDE;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to