Title: [107803] trunk/Source
Revision
107803
Author
[email protected]
Date
2012-02-15 05:06:02 -0800 (Wed, 15 Feb 2012)

Log Message

Source/WebCore: [Qt] Be smarter with tile usages during tiling
https://bugs.webkit.org/show_bug.cgi?id=78243

Patch by Kenneth Rohde Christiansen <[email protected]> on 2012-02-15
Reviewed by Simon Hausmann.

The keep rect used to know what existing tiles to keep around, is now a
padding (in tile dimensions) around the usual cover rect. With usual,
I mean to point out that we take our panning optimization into account.

We also do a good effort at keeping the amount of tiles steady, by not
simply intersecting our areas with the contentRect, but moving it
first into legal bounds and then expanding in opposite direction to
cover a similar amount of pixels.

In the future the cover area should be calculated given available
system memory.

* platform/graphics/TiledBackingStore.cpp:
(WebCore):
(WebCore::TiledBackingStore::TiledBackingStore):
(WebCore::TiledBackingStore::createTiles):
(WebCore::TiledBackingStore::adjustForContentsRect):
(WebCore::TiledBackingStore::computeCoverAndKeepRect):
(WebCore::TiledBackingStore::tileRectForCoordinate):
* platform/graphics/TiledBackingStore.h:
(TiledBackingStore):

Source/WebKit/qt: [Qt] Be smarted with tile usages during tiling
https://bugs.webkit.org/show_bug.cgi?id=78243

Patch by Kenneth Rohde Christiansen <[email protected]> on 2012-02-15
Reviewed by Simon Hausmann.

Remove internal API used by Symbian.

* Api/qwebpage.cpp:
(QWebPagePrivate::dynamicPropertyChangeEvent):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (107802 => 107803)


--- trunk/Source/WebCore/ChangeLog	2012-02-15 12:54:57 UTC (rev 107802)
+++ trunk/Source/WebCore/ChangeLog	2012-02-15 13:06:02 UTC (rev 107803)
@@ -1,3 +1,32 @@
+2012-02-15  Kenneth Rohde Christiansen  <[email protected]>
+
+        [Qt] Be smarter with tile usages during tiling
+        https://bugs.webkit.org/show_bug.cgi?id=78243
+
+        Reviewed by Simon Hausmann.
+
+        The keep rect used to know what existing tiles to keep around, is now a
+        padding (in tile dimensions) around the usual cover rect. With usual,
+        I mean to point out that we take our panning optimization into account.
+
+        We also do a good effort at keeping the amount of tiles steady, by not
+        simply intersecting our areas with the contentRect, but moving it
+        first into legal bounds and then expanding in opposite direction to
+        cover a similar amount of pixels.
+
+        In the future the cover area should be calculated given available
+        system memory.
+
+        * platform/graphics/TiledBackingStore.cpp:
+        (WebCore):
+        (WebCore::TiledBackingStore::TiledBackingStore):
+        (WebCore::TiledBackingStore::createTiles):
+        (WebCore::TiledBackingStore::adjustForContentsRect):
+        (WebCore::TiledBackingStore::computeCoverAndKeepRect):
+        (WebCore::TiledBackingStore::tileRectForCoordinate):
+        * platform/graphics/TiledBackingStore.h:
+        (TiledBackingStore):
+
 2012-02-13  Vsevolod Vlasov  <[email protected]>
 
         Web Inspector: [InspectorIndexedDB] Pass data entries from object stores and indexes to front-end.

Modified: trunk/Source/WebCore/platform/graphics/TiledBackingStore.cpp (107802 => 107803)


--- trunk/Source/WebCore/platform/graphics/TiledBackingStore.cpp	2012-02-15 12:54:57 UTC (rev 107802)
+++ trunk/Source/WebCore/platform/graphics/TiledBackingStore.cpp	2012-02-15 13:06:02 UTC (rev 107803)
@@ -27,8 +27,7 @@
 
 namespace WebCore {
     
-static const int defaultTileWidth = 512;
-static const int defaultTileHeight = 512;
+static const int defaultTileDimension = 512;
 
 static IntPoint innerBottomRight(const IntRect& rect)
 {
@@ -41,15 +40,13 @@
     , m_backend(backend)
     , m_tileBufferUpdateTimer(new TileTimer(this, &TiledBackingStore::tileBufferUpdateTimerFired))
     , m_tileCreationTimer(new TileTimer(this, &TiledBackingStore::tileCreationTimerFired))
-    , m_tileSize(defaultTileWidth, defaultTileHeight)
+    , m_tileSize(defaultTileDimension, defaultTileDimension)
     , m_tileCreationDelay(0.01)
-    , m_keepAreaMultiplier(3.5f)
-    , m_coverAreaMultiplier(2.5f)
+    , m_coverAreaMultiplier(2.0f)
     , m_contentsScale(1.f)
     , m_pendingScale(0)
     , m_contentsFrozen(false)
 {
-    ASSERT(m_coverAreaMultiplier <= m_keepAreaMultiplier);
 }
 
 TiledBackingStore::~TiledBackingStore()
@@ -57,7 +54,7 @@
     delete m_tileBufferUpdateTimer;
     delete m_tileCreationTimer;
 }
-    
+
 void TiledBackingStore::setTileSize(const IntSize& size)
 {
     m_tileSize = size;
@@ -70,14 +67,6 @@
     m_tileCreationDelay = delay;
 }
 
-void TiledBackingStore::setKeepAndCoverAreaMultipliers(float keepMultiplier, float coverMultiplier)
-{
-    ASSERT(coverMultiplier <= keepMultiplier);
-    m_keepAreaMultiplier = keepMultiplier;
-    m_coverAreaMultiplier = coverMultiplier;
-    startTileCreationTimer();
-}
-
 void TiledBackingStore::setVisibleRectTrajectoryVector(const FloatPoint& vector)
 {
     if (m_visibleRectTrajectoryVector == vector)
@@ -256,18 +245,18 @@
     // Resize tiles on edges in case the contents size has changed.
     bool didResizeTiles = resizeEdgeTiles();
 
-    IntRect keepRect = computeKeepRect(visibleRect);
-    
+    IntRect keepRect;
+    IntRect coverRect;
+    computeCoverAndKeepRect(visibleRect, coverRect, keepRect);
+
     dropTilesOutsideRect(keepRect);
     
-    IntRect coverRect = computeCoverRect(visibleRect);
-    ASSERT(keepRect.contains(coverRect));
-    
     // Search for the tile position closest to the viewport center that does not yet contain a tile. 
     // Which position is considered the closest depends on the tileDistance function.
     double shortestDistance = std::numeric_limits<double>::infinity();
     Vector<Tile::Coordinate> tilesToCreate;
     unsigned requiredTileCount = 0;
+
     Tile::Coordinate topLeft = tileCoordinateForPoint(coverRect.location());
     Tile::Coordinate bottomRight = tileCoordinateForPoint(innerBottomRight(coverRect));
     for (unsigned yCoordinate = topLeft.y(); yCoordinate <= bottomRight.y(); ++yCoordinate) {
@@ -287,7 +276,7 @@
             tilesToCreate.append(currentCoordinate);
         }
     }
-    
+
     // Now construct the tile(s)
     unsigned tilesToCreateCount = tilesToCreate.size();
     for (unsigned n = 0; n < tilesToCreateCount; ++n) {
@@ -305,42 +294,78 @@
         m_tileCreationTimer->startOneShot(m_tileCreationDelay);
 }
 
-IntRect TiledBackingStore::computeKeepRect(const IntRect& visibleRect) const
+void TiledBackingStore::adjustForContentsRect(IntRect& rect) const
 {
-    IntRect result = visibleRect;
-    // Inflates to both sides, so divide the inflate delta by 2.
-    result.inflateX(visibleRect.width() * (m_keepAreaMultiplier - 1) / 2);
-    result.inflateY(visibleRect.height() * (m_keepAreaMultiplier - 1) / 2);
-    result.intersect(contentsRect());
+    IntRect bounds = contentsRect();
+    IntSize candidateSize = rect.size();
 
-    return result;
+    // We will try to keep the cover and keep rect the same size at all time, which
+    // might not be the case when at the content edges.
+
+    // We start by moving when at the edges.
+    rect.move(std::max(0, bounds.x() - rect.x()), std::max(0, bounds.y() - rect.y()));
+    rect.move(std::min(0, bounds.maxX() - rect.maxX()), std::min(0, bounds.maxY() - rect.maxY()));
+
+    rect.intersect(bounds);
+
+    if (rect.size() == candidateSize)
+        return;
+
+    // Even now we might cover more than the content area so let's inflate in the
+    // opposite directions.
+    int pixelsCovered = candidateSize.width() * candidateSize.height();
+
+    if (rect.width() != candidateSize.width())
+        rect.inflateY(((pixelsCovered / rect.width()) - rect.height()) / 2);
+    if (rect.height() != candidateSize.height())
+        rect.inflateX(((pixelsCovered / rect.height()) - rect.width()) / 2);
+
+    rect.intersect(bounds);
 }
 
-// A null trajectory vector means that tiles intersecting all the coverArea (i.e. visibleRect * coverMultiplier) will be created.
-// A non-null trajectory vector will shrink the intersection rect to visibleRect plus its expansion from its
-// center toward the cover area edges in the direction of the given vector.
-// E.g. if visibleRect == (10,10)5x5 and coverMultiplier == 3.0:
-// a (0,0) trajectory vector will create tiles intersecting (5,5)15x15,
-// a (1,0) trajectory vector will create tiles intersecting (10,10)10x5,
-// and a (1,1) trajectory vector will create tiles intersecting (10,10)10x10.
-IntRect TiledBackingStore::computeCoverRect(const IntRect& visibleRect) const
+void TiledBackingStore::computeCoverAndKeepRect(const IntRect& visibleRect, IntRect& coverRect, IntRect& keepRect) const
 {
-    IntRect result = visibleRect;
-    float trajectoryVectorNorm = sqrt(pow(m_visibleRectTrajectoryVector.x(), 2) + pow(m_visibleRectTrajectoryVector.y(), 2));
-    if (trajectoryVectorNorm > 0) {
-        // Multiply the vector by the distance to the edge of the cover area.
-        float trajectoryVectorMultiplier = (m_coverAreaMultiplier - 1) / 2;
-        // Unite the visible rect with a "ghost" of the visible rect moved in the direction of the trajectory vector.
-        result.move(result.width() * m_visibleRectTrajectoryVector.x() / trajectoryVectorNorm * trajectoryVectorMultiplier,
-                    result.height() * m_visibleRectTrajectoryVector.y() / trajectoryVectorNorm * trajectoryVectorMultiplier);
-        result.unite(visibleRect);
-    } else {
-        result.inflateX(visibleRect.width() * (m_coverAreaMultiplier - 1) / 2);
-        result.inflateY(visibleRect.height() * (m_coverAreaMultiplier - 1) / 2);
+    coverRect = visibleRect;
+    keepRect = visibleRect;
+
+    // If we cover more that the actual viewport we can be smart about which tiles we choose to render.
+    if (m_coverAreaMultiplier > 1) {
+        // The initial cover area covers equally in each direction, according to the coverAreaMultiplier.
+        coverRect.inflateX(visibleRect.width() * (m_coverAreaMultiplier - 1) / 2);
+        coverRect.inflateY(visibleRect.height() * (m_coverAreaMultiplier - 1) / 2);
+        keepRect = coverRect;
+
+        float trajectoryVectorNorm = sqrt(pow(m_visibleRectTrajectoryVector.x(), 2) + pow(m_visibleRectTrajectoryVector.y(), 2));
+        if (trajectoryVectorNorm) {
+            // A null trajectory vector (no motion) means that tiles for the coverArea will be created.
+            // A non-null trajectory vector will shrink the covered rect to visibleRect plus its expansion from its
+            // center toward the cover area edges in the direction of the given vector.
+
+            // E.g. if visibleRect == (10,10)5x5 and coverAreaMultiplier == 3.0:
+            // a (0,0) trajectory vector will create tiles intersecting (5,5)15x15,
+            // a (1,0) trajectory vector will create tiles intersecting (10,10)10x5,
+            // and a (1,1) trajectory vector will create tiles intersecting (10,10)10x10.
+
+            // Multiply the vector by the distance to the edge of the cover area.
+            float trajectoryVectorMultiplier = (m_coverAreaMultiplier - 1) / 2;
+
+            // Unite the visible rect with a "ghost" of the visible rect moved in the direction of the trajectory vector.
+            coverRect = visibleRect;
+            coverRect.move(coverRect.width() * m_visibleRectTrajectoryVector.x() / trajectoryVectorNorm * trajectoryVectorMultiplier,
+                           coverRect.height() * m_visibleRectTrajectoryVector.y() / trajectoryVectorNorm * trajectoryVectorMultiplier);
+
+            coverRect.unite(visibleRect);
+        }
     }
-    result.intersect(contentsRect());
 
-    return result;
+    ASSERT(keepRect.contains(coverRect));
+
+    // The keep rect is an inflated version of the cover rect, inflated in tile dimensions.
+    keepRect.inflateX(m_tileSize.width() / 2);
+    keepRect.inflateY(m_tileSize.height() / 2);
+
+    adjustForContentsRect(coverRect);
+    adjustForContentsRect(keepRect);
 }
 
 bool TiledBackingStore::resizeEdgeTiles()
@@ -422,9 +447,9 @@
 IntRect TiledBackingStore::tileRectForCoordinate(const Tile::Coordinate& coordinate) const
 {
     IntRect rect(coordinate.x() * m_tileSize.width(),
-        coordinate.y() * m_tileSize.height(),
-        m_tileSize.width(),
-        m_tileSize.height());
+                 coordinate.y() * m_tileSize.height(),
+                 m_tileSize.width(),
+                 m_tileSize.height());
 
     rect.intersect(contentsRect());
     return rect;

Modified: trunk/Source/WebCore/platform/graphics/TiledBackingStore.h (107802 => 107803)


--- trunk/Source/WebCore/platform/graphics/TiledBackingStore.h	2012-02-15 12:54:57 UTC (rev 107802)
+++ trunk/Source/WebCore/platform/graphics/TiledBackingStore.h	2012-02-15 13:06:02 UTC (rev 107803)
@@ -56,20 +56,13 @@
 
     void invalidate(const IntRect& dirtyRect);
     void paint(GraphicsContext*, const IntRect&);
-    
+
     IntSize tileSize() { return m_tileSize; }
     void setTileSize(const IntSize&);
     
     double tileCreationDelay() const { return m_tileCreationDelay; }
     void setTileCreationDelay(double delay);
     
-    // Tiled are dropped outside the keep area, and created for cover area. The values a relative to the viewport size.
-    void getKeepAndCoverAreaMultipliers(float& keepMultiplier, float& coverMultiplier)
-    {
-        keepMultiplier = m_keepAreaMultiplier;
-        coverMultiplier = m_coverAreaMultiplier;
-    }
-    void setKeepAndCoverAreaMultipliers(float keepMultiplier, float coverMultiplier);
     void setVisibleRectTrajectoryVector(const FloatPoint&);
 
     IntRect mapToContents(const IntRect&) const;
@@ -90,8 +83,7 @@
     void tileCreationTimerFired(TileTimer*);
     
     void createTiles();
-    IntRect computeKeepRect(const IntRect& visibleRect) const;
-    IntRect computeCoverRect(const IntRect& visibleRect) const;
+    void computeCoverAndKeepRect(const IntRect& visibleRect, IntRect& coverRect, IntRect& keepRect) const;
     
     void commitScaleChange();
 
@@ -102,6 +94,7 @@
     void setTile(const Tile::Coordinate& coordinate, PassRefPtr<Tile> tile);
     void removeTile(const Tile::Coordinate& coordinate);
 
+    void adjustForContentsRect(IntRect&) const;
     IntRect contentsRect() const;
     
     void paintCheckerPattern(GraphicsContext*, const IntRect&, const Tile::Coordinate&);
@@ -119,7 +112,6 @@
 
     IntSize m_tileSize;
     double m_tileCreationDelay;
-    float m_keepAreaMultiplier;
     float m_coverAreaMultiplier;
     FloatPoint m_visibleRectTrajectoryVector;
     

Modified: trunk/Source/WebKit/qt/Api/qwebpage.cpp (107802 => 107803)


--- trunk/Source/WebKit/qt/Api/qwebpage.cpp	2012-02-15 12:54:57 UTC (rev 107802)
+++ trunk/Source/WebKit/qt/Api/qwebpage.cpp	2012-02-15 13:06:02 UTC (rev 107803)
@@ -1198,43 +1198,6 @@
             }
         }
     }
-#if USE(TILED_BACKING_STORE)
-    else if (event->propertyName() == "_q_TiledBackingStoreTileSize") {
-        WebCore::Frame* frame = QWebFramePrivate::core(q->mainFrame());
-        if (!frame->tiledBackingStore())
-            return;
-        QSize tileSize = q->property("_q_TiledBackingStoreTileSize").toSize();
-        frame->tiledBackingStore()->setTileSize(tileSize);
-    } else if (event->propertyName() == "_q_TiledBackingStoreTileCreationDelay") {
-        WebCore::Frame* frame = QWebFramePrivate::core(q->mainFrame());
-        if (!frame->tiledBackingStore())
-            return;
-        int tileCreationDelay = q->property("_q_TiledBackingStoreTileCreationDelay").toInt();
-        frame->tiledBackingStore()->setTileCreationDelay(static_cast<double>(tileCreationDelay) / 1000.);
-    } else if (event->propertyName() == "_q_TiledBackingStoreKeepAreaMultiplier") {
-        WebCore::Frame* frame = QWebFramePrivate::core(q->mainFrame());
-        if (!frame->tiledBackingStore())
-            return;
-        float keepMultiplier;
-        float coverMultiplier;
-        frame->tiledBackingStore()->getKeepAndCoverAreaMultipliers(keepMultiplier, coverMultiplier);
-        QSizeF qSize = q->property("_q_TiledBackingStoreKeepAreaMultiplier").toSizeF();
-        // setKeepAndCoverAreaMultipliers do not use FloatSize anymore, keep only the height part.
-        keepMultiplier = qSize.height();
-        frame->tiledBackingStore()->setKeepAndCoverAreaMultipliers(keepMultiplier, coverMultiplier);
-    } else if (event->propertyName() == "_q_TiledBackingStoreCoverAreaMultiplier") {
-        WebCore::Frame* frame = QWebFramePrivate::core(q->mainFrame());
-        if (!frame->tiledBackingStore())
-            return;
-        float keepMultiplier;
-        float coverMultiplier;
-        frame->tiledBackingStore()->getKeepAndCoverAreaMultipliers(keepMultiplier, coverMultiplier);
-        QSizeF qSize = q->property("_q_TiledBackingStoreCoverAreaMultiplier").toSizeF();
-        // setKeepAndCoverAreaMultipliers do not use FloatSize anymore, keep only the height part.
-        coverMultiplier = qSize.height();
-        frame->tiledBackingStore()->setKeepAndCoverAreaMultipliers(keepMultiplier, coverMultiplier);
-    }
-#endif
     else if (event->propertyName() == "_q_webInspectorServerPort") {
         InspectorServerQt* inspectorServer = InspectorServerQt::server();
         inspectorServer->listen(inspectorServerPort());

Modified: trunk/Source/WebKit/qt/ChangeLog (107802 => 107803)


--- trunk/Source/WebKit/qt/ChangeLog	2012-02-15 12:54:57 UTC (rev 107802)
+++ trunk/Source/WebKit/qt/ChangeLog	2012-02-15 13:06:02 UTC (rev 107803)
@@ -1,3 +1,15 @@
+2012-02-15  Kenneth Rohde Christiansen  <[email protected]>
+
+        [Qt] Be smarted with tile usages during tiling
+        https://bugs.webkit.org/show_bug.cgi?id=78243
+
+        Reviewed by Simon Hausmann.
+
+        Remove internal API used by Symbian.
+
+        * Api/qwebpage.cpp:
+        (QWebPagePrivate::dynamicPropertyChangeEvent):
+
 2012-02-15  No'am Rosenthal  <[email protected]>
 
         [Texmap] Divide TextureMapperNode.cpp to 3 files.
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to