[CoordinatedGraphics] Remove unnecessary two virtual methods from TiledBackingStoreClient
authorryuan.choi@navercorp.com <ryuan.choi@navercorp.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 30 Aug 2015 23:29:50 +0000 (23:29 +0000)
committerryuan.choi@navercorp.com <ryuan.choi@navercorp.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 30 Aug 2015 23:29:50 +0000 (23:29 +0000)
https://bugs.webkit.org/show_bug.cgi?id=147137

Reviewed by Gyuyoung Kim.

tiledBackingStoreContentsRect() and tiledBackingStoreVisibleRect() are not
necessary because CoordinatedGraphicsLayer can pass them directly if needed.
This patch removes them in order to simplify code flow between TiledBackingStore
and CoordinatedGraphicsLayer.

* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
(WebCore::CoordinatedGraphicsLayer::imageBackingVisible):
(WebCore::CoordinatedGraphicsLayer::adjustContentsScale):
(WebCore::clampToContentsRectIfRectIsInfinite):
(WebCore::CoordinatedGraphicsLayer::transformedVisibleRect):
(WebCore::CoordinatedGraphicsLayer::updateContentBuffers):
(WebCore::CoordinatedGraphicsLayer::tiledBackingStoreContentsRect): Deleted.
(WebCore::CoordinatedGraphicsLayer::tiledBackingStoreVisibleRect): Deleted.
* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
* platform/graphics/texmap/coordinated/TiledBackingStore.cpp:
(WebCore::TiledBackingStore::createTilesIfNeeded):
(WebCore::TiledBackingStore::coverageRatio):
(WebCore::TiledBackingStore::visibleAreaIsCovered):
Used TiledBackingStore's m_visibleRect and m_rect, cached and scaled values for
visibleRect, contentsRect.
(WebCore::TiledBackingStore::createTiles):
(WebCore::TiledBackingStore::removeAllNonVisibleTiles):
(WebCore::TiledBackingStore::coverWithTilesIfNeeded): Renamed to createTilesIfNeeded.
(WebCore::TiledBackingStore::visibleRect): Deleted. nobody used.
* platform/graphics/texmap/coordinated/TiledBackingStore.h:
* platform/graphics/texmap/coordinated/TiledBackingStoreClient.h:
(WebCore::TiledBackingStoreClient::tiledBackingStoreHasPendingTileCreation):
Removed default implementation.

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h
Source/WebCore/platform/graphics/texmap/coordinated/TiledBackingStore.cpp
Source/WebCore/platform/graphics/texmap/coordinated/TiledBackingStore.h
Source/WebCore/platform/graphics/texmap/coordinated/TiledBackingStoreClient.h

index 898f4bc..b44a180 100644 (file)
@@ -1,3 +1,39 @@
+2015-08-30  Ryuan Choi  <ryuan.choi@navercorp.com>
+
+        [CoordinatedGraphics] Remove unnecessary two virtual methods from TiledBackingStoreClient
+        https://bugs.webkit.org/show_bug.cgi?id=147137
+
+        Reviewed by Gyuyoung Kim.
+
+        tiledBackingStoreContentsRect() and tiledBackingStoreVisibleRect() are not
+        necessary because CoordinatedGraphicsLayer can pass them directly if needed.
+        This patch removes them in order to simplify code flow between TiledBackingStore
+        and CoordinatedGraphicsLayer.
+
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
+        (WebCore::CoordinatedGraphicsLayer::imageBackingVisible):
+        (WebCore::CoordinatedGraphicsLayer::adjustContentsScale):
+        (WebCore::clampToContentsRectIfRectIsInfinite):
+        (WebCore::CoordinatedGraphicsLayer::transformedVisibleRect):
+        (WebCore::CoordinatedGraphicsLayer::updateContentBuffers):
+        (WebCore::CoordinatedGraphicsLayer::tiledBackingStoreContentsRect): Deleted.
+        (WebCore::CoordinatedGraphicsLayer::tiledBackingStoreVisibleRect): Deleted.
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
+        * platform/graphics/texmap/coordinated/TiledBackingStore.cpp:
+        (WebCore::TiledBackingStore::createTilesIfNeeded):
+        (WebCore::TiledBackingStore::coverageRatio):
+        (WebCore::TiledBackingStore::visibleAreaIsCovered):
+        Used TiledBackingStore's m_visibleRect and m_rect, cached and scaled values for
+        visibleRect, contentsRect.
+        (WebCore::TiledBackingStore::createTiles):
+        (WebCore::TiledBackingStore::removeAllNonVisibleTiles):
+        (WebCore::TiledBackingStore::coverWithTilesIfNeeded): Renamed to createTilesIfNeeded.
+        (WebCore::TiledBackingStore::visibleRect): Deleted. nobody used.
+        * platform/graphics/texmap/coordinated/TiledBackingStore.h:
+        * platform/graphics/texmap/coordinated/TiledBackingStoreClient.h:
+        (WebCore::TiledBackingStoreClient::tiledBackingStoreHasPendingTileCreation):
+        Removed default implementation.
+
 2015-08-29  Jessie Berlin  <berlin@apple.com>
 
         El Capitan build fix.
index d37483d..dec8a0e 100644 (file)
@@ -798,7 +798,7 @@ void CoordinatedGraphicsLayer::resetLayerState()
 bool CoordinatedGraphicsLayer::imageBackingVisible()
 {
     ASSERT(m_coordinatedImageBacking);
-    return tiledBackingStoreVisibleRect().intersects(IntRect(contentsRect()));
+    return transformedVisibleRect().intersects(IntRect(contentsRect()));
 }
 
 void CoordinatedGraphicsLayer::releaseImageBackingIfNeeded()
@@ -860,7 +860,7 @@ void CoordinatedGraphicsLayer::adjustContentsScale()
     m_previousBackingStore = WTF::move(m_mainBackingStore);
 
     // No reason to save the previous backing store for non-visible areas.
-    m_previousBackingStore->removeAllNonVisibleTiles();
+    m_previousBackingStore->removeAllNonVisibleTiles(transformedVisibleRect(), IntRect(0, 0, size().width(), size().height()));
 }
 
 void CoordinatedGraphicsLayer::createBackingStore()
@@ -891,25 +891,20 @@ void CoordinatedGraphicsLayer::tiledBackingStoreHasPendingTileCreation()
     notifyFlushRequired();
 }
 
-IntRect CoordinatedGraphicsLayer::tiledBackingStoreContentsRect()
-{
-    return IntRect(0, 0, size().width(), size().height());
-}
-
-static void clampToContentsRectIfRectIsInfinite(FloatRect& rect, const IntRect& contentsRect)
+static void clampToContentsRectIfRectIsInfinite(FloatRect& rect, const FloatSize& contentsSize)
 {
     if (rect.width() >= LayoutUnit::nearlyMax() || rect.width() <= LayoutUnit::nearlyMin()) {
-        rect.setX(contentsRect.x());
-        rect.setWidth(contentsRect.width());
+        rect.setX(0);
+        rect.setWidth(contentsSize.width());
     }
 
     if (rect.height() >= LayoutUnit::nearlyMax() || rect.height() <= LayoutUnit::nearlyMin()) {
-        rect.setY(contentsRect.y());
-        rect.setHeight(contentsRect.height());
+        rect.setY(0);
+        rect.setHeight(contentsSize.height());
     }
 }
 
-IntRect CoordinatedGraphicsLayer::tiledBackingStoreVisibleRect()
+IntRect CoordinatedGraphicsLayer::transformedVisibleRect()
 {
     // Non-invertible layers are not visible.
     if (!m_layerTransform.combined().isInvertible())
@@ -920,7 +915,7 @@ IntRect CoordinatedGraphicsLayer::tiledBackingStoreVisibleRect()
     // so it might spread further than the real visible area (and then even more amplified by the cover rect multiplier).
     ASSERT(m_cachedInverseTransform == m_layerTransform.combined().inverse());
     FloatRect rect = m_cachedInverseTransform.clampedBoundsOfProjectedQuad(FloatQuad(m_coordinator->visibleContentsRect()));
-    clampToContentsRectIfRectIsInfinite(rect, tiledBackingStoreContentsRect());
+    clampToContentsRectIfRectIsInfinite(rect, size());
     return enclosingIntRect(rect);
 }
 
@@ -997,7 +992,7 @@ void CoordinatedGraphicsLayer::updateContentBuffers()
 
     if (m_pendingVisibleRectAdjustment) {
         m_pendingVisibleRectAdjustment = false;
-        m_mainBackingStore->coverWithTilesIfNeeded();
+        m_mainBackingStore->createTilesIfNeeded(transformedVisibleRect(), IntRect(0, 0, size().width(), size().height()));
     }
 
     m_mainBackingStore->updateTileBuffers();
index f054af5..c4df4f2 100644 (file)
@@ -126,13 +126,12 @@ public:
     void setFixedToViewport(bool isFixed);
 
     IntRect coverRect() const { return m_mainBackingStore ? m_mainBackingStore->mapToContents(m_mainBackingStore->coverRect()) : IntRect(); }
+    IntRect transformedVisibleRect();
 
     // TiledBackingStoreClient
     virtual void tiledBackingStorePaint(GraphicsContext*, const IntRect&) override;
     virtual void didUpdateTileBuffers() override;
     virtual void tiledBackingStoreHasPendingTileCreation() override;
-    virtual IntRect tiledBackingStoreContentsRect() override;
-    virtual IntRect tiledBackingStoreVisibleRect() override;
     virtual void createTile(uint32_t tileID, float) override;
     virtual void updateTile(uint32_t tileID, const SurfaceUpdateInfo&, const IntRect&) override;
     virtual void removeTile(uint32_t tileID) override;
index 277c0c1..88d54d2 100644 (file)
@@ -54,14 +54,14 @@ void TiledBackingStore::setTrajectoryVector(const FloatPoint& trajectoryVector)
     m_pendingTrajectoryVector.normalize();
 }
 
-void TiledBackingStore::coverWithTilesIfNeeded()
+void TiledBackingStore::createTilesIfNeeded(const IntRect& unscaledVisibleRect, const IntRect& contentsRect)
 {
-    IntRect visibleRect = this->visibleRect();
-    IntRect rect = mapFromContents(m_client->tiledBackingStoreContentsRect());
+    IntRect scaledContentsRect = mapFromContents(contentsRect);
+    IntRect visibleRect = mapFromContents(unscaledVisibleRect);
 
-    bool didChange = m_trajectoryVector != m_pendingTrajectoryVector || m_visibleRect != visibleRect || m_rect != rect;
+    bool didChange = m_trajectoryVector != m_pendingTrajectoryVector || m_visibleRect != visibleRect || m_rect != scaledContentsRect;
     if (didChange || m_pendingTileCreation)
-        createTiles();
+        createTiles(visibleRect, scaledContentsRect);
 }
 
 void TiledBackingStore::invalidate(const IntRect& contentsDirtyRect)
@@ -104,11 +104,6 @@ void TiledBackingStore::updateTileBuffers()
         m_client->didUpdateTileBuffers();
 }
 
-IntRect TiledBackingStore::visibleRect() const
-{
-    return mapFromContents(m_client->tiledBackingStoreVisibleRect());
-}
-
 double TiledBackingStore::tileDistance(const IntRect& viewport, const Tile::Coordinate& tileCoordinate) const
 {
     if (viewport.intersects(tileRectForCoordinate(tileCoordinate)))
@@ -120,10 +115,9 @@ double TiledBackingStore::tileDistance(const IntRect& viewport, const Tile::Coor
     return std::max(abs(centerCoordinate.y() - tileCoordinate.y()), abs(centerCoordinate.x() - tileCoordinate.x()));
 }
 
-// Returns a ratio between 0.0f and 1.0f of the surface of contentsRect covered by rendered tiles.
-float TiledBackingStore::coverageRatio(const WebCore::IntRect& contentsRect) const
+// Returns a ratio between 0.0f and 1.0f of the surface covered by rendered tiles.
+float TiledBackingStore::coverageRatio(const WebCore::IntRect& dirtyRect) const
 {
-    IntRect dirtyRect = mapFromContents(contentsRect);
     float rectArea = dirtyRect.width() * dirtyRect.height();
     float coverArea = 0.0f;
 
@@ -145,17 +139,16 @@ float TiledBackingStore::coverageRatio(const WebCore::IntRect& contentsRect) con
 
 bool TiledBackingStore::visibleAreaIsCovered() const
 {
-    IntRect boundedVisibleContentsRect = intersection(m_client->tiledBackingStoreVisibleRect(), m_client->tiledBackingStoreContentsRect());
-    return coverageRatio(boundedVisibleContentsRect) == 1.0f;
+    return coverageRatio(intersection(m_visibleRect, m_rect)) == 1.0f;
 }
 
-void TiledBackingStore::createTiles()
+void TiledBackingStore::createTiles(const IntRect& visibleRect, const IntRect& scaledContentsRect)
 {
     // Update our backing store geometry.
     const IntRect previousRect = m_rect;
-    m_rect = mapFromContents(m_client->tiledBackingStoreContentsRect());
+    m_rect = scaledContentsRect;
     m_trajectoryVector = m_pendingTrajectoryVector;
-    m_visibleRect = visibleRect();
+    m_visibleRect = visibleRect;
 
     if (m_rect.isEmpty()) {
         setCoverRect(IntRect());
@@ -373,9 +366,9 @@ void TiledBackingStore::setKeepRect(const IntRect& keepRect)
     m_keepRect = keepRect;
 }
 
-void TiledBackingStore::removeAllNonVisibleTiles()
+void TiledBackingStore::removeAllNonVisibleTiles(const IntRect& unscaledVisibleRect, const IntRect& contentsRect)
 {
-    IntRect boundedVisibleRect = mapFromContents(intersection(m_client->tiledBackingStoreVisibleRect(), m_client->tiledBackingStoreContentsRect()));
+    IntRect boundedVisibleRect = mapFromContents(intersection(unscaledVisibleRect, contentsRect));
     setKeepRect(boundedVisibleRect);
 }
 
index a13675a..3ae3295 100644 (file)
@@ -44,7 +44,7 @@ public:
     TiledBackingStoreClient* client() { return m_client; }
 
     void setTrajectoryVector(const FloatPoint&);
-    void coverWithTilesIfNeeded();
+    void createTilesIfNeeded(const IntRect& unscaledVisibleRect, const IntRect& contentsRect);
 
     float contentsScale() { return m_contentsScale; }
 
@@ -61,20 +61,18 @@ public:
 
     IntRect coverRect() const { return m_coverRect; }
     bool visibleAreaIsCovered() const;
-    void removeAllNonVisibleTiles();
+    void removeAllNonVisibleTiles(const IntRect& unscaledVisibleRect, const IntRect& contentsRect);
 
     void setSupportsAlpha(bool);
 
 private:
-    void createTiles();
+    void createTiles(const IntRect& visibleRect, const IntRect& scaledContentsRect);
     void computeCoverAndKeepRect(const IntRect& visibleRect, IntRect& coverRect, IntRect& keepRect) const;
 
     bool resizeEdgeTiles();
     void setCoverRect(const IntRect& rect) { m_coverRect = rect; }
     void setKeepRect(const IntRect&);
 
-    IntRect visibleRect() const;
-
     float coverageRatio(const IntRect&) const;
     void adjustForContentsRect(IntRect&) const;
 
index ae9451f..7d49d49 100644 (file)
@@ -26,7 +26,6 @@ namespace WebCore {
 
 #if USE(COORDINATED_GRAPHICS)
 
-class Color;
 class GraphicsContext;
 class SurfaceUpdateInfo;
 
@@ -35,9 +34,7 @@ public:
     virtual ~TiledBackingStoreClient() { }
     virtual void tiledBackingStorePaint(GraphicsContext*, const IntRect&) = 0;
     virtual void didUpdateTileBuffers() = 0;
-    virtual void tiledBackingStoreHasPendingTileCreation() { }
-    virtual IntRect tiledBackingStoreContentsRect() = 0;
-    virtual IntRect tiledBackingStoreVisibleRect() = 0;
+    virtual void tiledBackingStoreHasPendingTileCreation() = 0;
 
     virtual void createTile(uint32_t tileID, float) = 0;
     virtual void updateTile(uint32_t tileID, const SurfaceUpdateInfo&, const IntRect&) = 0;