Title: [124550] trunk/Source
Revision
124550
Author
[email protected]
Date
2012-08-02 19:26:44 -0700 (Thu, 02 Aug 2012)

Log Message

[BlackBerry] Add default implementation of GraphicsLayerClient::contentsVisible()
https://bugs.webkit.org/show_bug.cgi?id=93036

Patch by Arvid Nilsson <[email protected]> on 2012-08-02
Reviewed by George Staikos.

Source/WebCore:

Returning true by default would cause memory usage to balloon, because
the LayerTiler would believe every tile is visible and always needs to
be rendered. Instead, we choose to return false by default, relying
entirely on reactive rendering through render jobs.

However this revealed a subtle bug. If the entire layer was invalidated
every frame, checkerboard would never resolve with this default
implementation.

Fixed by not clearing render jobs when the entire layer is invalidated,
thus making us robust against an incomplete contentsVisible
implementation.

Also removed dead code related to the deprecated
LayerTiler::m_tilesWebKitThread mechanism, which has been replaced by
the implicit visibility management resulting from render jobs.

With m_tilesWebKitThread out of the way, rename m_tilesCompositingThread
to be simply m_tiles.

PR 187458

This is not currently testable using BlackBerry testing infrastructure.

* platform/graphics/GraphicsLayerClient.h:
(WebCore::GraphicsLayerClient::contentsVisible): Gets a default implementation instead of being pure virtual.
* platform/graphics/blackberry/LayerTile.cpp:
(WebCore::LayerTile::LayerTile): Merged LayerTileData into LayerTile now that m_tilesWebKitThread is gone.
* platform/graphics/blackberry/LayerTile.h:
(LayerTile):
* platform/graphics/blackberry/LayerTiler.cpp:
(WebCore::LayerTiler::~LayerTiler):
(WebCore::LayerTiler::updateTextureContentsIfNeeded): Bug fix to make us robust against the new default implementation of GraphicsLayerClient::contentsVisible()
(WebCore::LayerTiler::shouldPerformRenderJob):
(WebCore::LayerTiler::layerVisibilityChanged):
(WebCore::LayerTiler::uploadTexturesIfNeeded):
(WebCore::LayerTiler::drawTexturesInternal):
(WebCore::LayerTiler::deleteTextures):
(WebCore::LayerTiler::pruneTextures):
(WebCore::LayerTiler::bindContentsTexture):
* platform/graphics/blackberry/LayerTiler.h:
(LayerTiler):

Source/WebKit/blackberry:

Remove implementation of GraphicsLayerClient::contentsVisible() now
that it has a default implementation.

This also fixes a bug where memory usage for the inspector highlight
overlay would balloon because it returned true from contentsVisible()
which would cause the LayerTiler to populate all tiles. The default
implementation returns false instead.

PR 187458, 184377

* WebCoreSupport/InspectorOverlay.cpp:
(WebCore::InspectorOverlay::showRepaintCounter):
* WebCoreSupport/InspectorOverlay.h:
(InspectorOverlay):
* WebKitSupport/DefaultTapHighlight.h:
* WebKitSupport/SelectionOverlay.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (124549 => 124550)


--- trunk/Source/WebCore/ChangeLog	2012-08-03 02:05:51 UTC (rev 124549)
+++ trunk/Source/WebCore/ChangeLog	2012-08-03 02:26:44 UTC (rev 124550)
@@ -1,3 +1,53 @@
+2012-08-02  Arvid Nilsson  <[email protected]>
+
+        [BlackBerry] Add default implementation of GraphicsLayerClient::contentsVisible()
+        https://bugs.webkit.org/show_bug.cgi?id=93036
+
+        Reviewed by George Staikos.
+
+        Returning true by default would cause memory usage to balloon, because
+        the LayerTiler would believe every tile is visible and always needs to
+        be rendered. Instead, we choose to return false by default, relying
+        entirely on reactive rendering through render jobs.
+
+        However this revealed a subtle bug. If the entire layer was invalidated
+        every frame, checkerboard would never resolve with this default
+        implementation.
+
+        Fixed by not clearing render jobs when the entire layer is invalidated,
+        thus making us robust against an incomplete contentsVisible
+        implementation.
+
+        Also removed dead code related to the deprecated
+        LayerTiler::m_tilesWebKitThread mechanism, which has been replaced by
+        the implicit visibility management resulting from render jobs.
+
+        With m_tilesWebKitThread out of the way, rename m_tilesCompositingThread
+        to be simply m_tiles.
+
+        PR 187458
+
+        This is not currently testable using BlackBerry testing infrastructure.
+
+        * platform/graphics/GraphicsLayerClient.h:
+        (WebCore::GraphicsLayerClient::contentsVisible): Gets a default implementation instead of being pure virtual.
+        * platform/graphics/blackberry/LayerTile.cpp:
+        (WebCore::LayerTile::LayerTile): Merged LayerTileData into LayerTile now that m_tilesWebKitThread is gone.
+        * platform/graphics/blackberry/LayerTile.h:
+        (LayerTile):
+        * platform/graphics/blackberry/LayerTiler.cpp:
+        (WebCore::LayerTiler::~LayerTiler):
+        (WebCore::LayerTiler::updateTextureContentsIfNeeded): Bug fix to make us robust against the new default implementation of GraphicsLayerClient::contentsVisible()
+        (WebCore::LayerTiler::shouldPerformRenderJob):
+        (WebCore::LayerTiler::layerVisibilityChanged):
+        (WebCore::LayerTiler::uploadTexturesIfNeeded):
+        (WebCore::LayerTiler::drawTexturesInternal):
+        (WebCore::LayerTiler::deleteTextures):
+        (WebCore::LayerTiler::pruneTextures):
+        (WebCore::LayerTiler::bindContentsTexture):
+        * platform/graphics/blackberry/LayerTiler.h:
+        (LayerTiler):
+
 2012-08-02  Keishi Hattori  <[email protected]>
 
         Slider should snap to datalist tick marks

Modified: trunk/Source/WebCore/platform/graphics/GraphicsLayerClient.h (124549 => 124550)


--- trunk/Source/WebCore/platform/graphics/GraphicsLayerClient.h	2012-08-03 02:05:51 UTC (rev 124549)
+++ trunk/Source/WebCore/platform/graphics/GraphicsLayerClient.h	2012-08-03 02:26:44 UTC (rev 124550)
@@ -86,7 +86,7 @@
 #endif
 
 #if PLATFORM(BLACKBERRY)
-    virtual bool contentsVisible(const GraphicsLayer*, const IntRect& contentRect) const = 0;
+    virtual bool contentsVisible(const GraphicsLayer*, const IntRect& contentRect) const { return false; }
 #endif
 };
 

Modified: trunk/Source/WebCore/platform/graphics/blackberry/LayerTile.cpp (124549 => 124550)


--- trunk/Source/WebCore/platform/graphics/blackberry/LayerTile.cpp	2012-08-03 02:05:51 UTC (rev 124549)
+++ trunk/Source/WebCore/platform/graphics/blackberry/LayerTile.cpp	2012-08-03 02:26:44 UTC (rev 124550)
@@ -28,6 +28,7 @@
 
 LayerTile::LayerTile()
     : m_contentsDirty(false)
+    , m_visible(false)
 {
 }
 

Modified: trunk/Source/WebCore/platform/graphics/blackberry/LayerTile.h (124549 => 124550)


--- trunk/Source/WebCore/platform/graphics/blackberry/LayerTile.h	2012-08-03 02:05:51 UTC (rev 124549)
+++ trunk/Source/WebCore/platform/graphics/blackberry/LayerTile.h	2012-08-03 02:26:44 UTC (rev 124550)
@@ -33,20 +33,7 @@
 class IntRect;
 class TileIndex;
 
-class LayerTileData {
-public:
-    LayerTileData()
-        : m_visible(false)
-    {
-    }
-
-    bool isVisible() const { return m_visible; }
-
-protected:
-    bool m_visible;
-};
-
-class LayerTile : public LayerTileData {
+class LayerTile {
     WTF_MAKE_FAST_ALLOCATED;
 public:
     LayerTile();
@@ -76,7 +63,8 @@
 
     // Never assign to m_texture directly, use setTexture() above.
     RefPtr<Texture> m_texture;
-    bool m_contentsDirty;
+    bool m_contentsDirty : 1;
+    bool m_visible : 1;
 };
 
 }

Modified: trunk/Source/WebCore/platform/graphics/blackberry/LayerTiler.cpp (124549 => 124550)


--- trunk/Source/WebCore/platform/graphics/blackberry/LayerTiler.cpp	2012-08-03 02:05:51 UTC (rev 124549)
+++ trunk/Source/WebCore/platform/graphics/blackberry/LayerTiler.cpp	2012-08-03 02:26:44 UTC (rev 124550)
@@ -83,7 +83,7 @@
     // Someone should have called LayerTiler::deleteTextures()
     // before now. We can't call it here because we have no
     // OpenGL context.
-    ASSERT(m_tilesCompositingThread.isEmpty());
+    ASSERT(m_tiles.isEmpty());
 }
 
 void LayerTiler::layerWebKitThreadDestroyed()
@@ -167,16 +167,21 @@
         dirtyRect = IntRect(IntPoint::zero(), requiredTextureSize);
     }
 
+    // If the new size is empty, clear the visibility jobs
+    if (requiredTextureSize.isEmpty() && renderJobs.size()) {
+        renderJobs.clear();
+
+        MutexLocker locker(m_renderJobsMutex);
+        m_renderJobs.clear();
+    }
+
     // If we need display because we no longer need to be displayed, due to texture size becoming 0 x 0,
     // or if we're re-rendering the whole thing anyway, clear old texture jobs.
-    HashSet<TileIndex> finishedJobs;
-    if (requiredTextureSize.isEmpty() || dirtyRect == IntRect(IntPoint::zero(), requiredTextureSize)) {
-        {
-            MutexLocker locker(m_renderJobsMutex);
-            m_renderJobs.clear();
-        }
+    if (requiredTextureSize.isEmpty() || dirtyRect == IntRect(IntPoint::zero(), requiredTextureSize))
         clearTextureJobs();
-    } else if (!renderJobs.isEmpty()) {
+
+    HashSet<TileIndex> finishedJobs;
+    if (!renderJobs.isEmpty()) {
         if (Image* image = m_layer->contents()) {
             bool isOpaque = false;
             if (image->isBitmapImage())
@@ -218,6 +223,7 @@
     }
 
     bool didResize = false;
+    IntRect previousTextureRect(IntPoint::zero(), m_pendingTextureSize);
     if (m_pendingTextureSize != requiredTextureSize) {
         didResize = true;
         m_pendingTextureSize = requiredTextureSize;
@@ -245,9 +251,10 @@
     IntPoint topLeft = dirtyRect.minXMinYCorner();
     IntPoint bottomRight = dirtyRect.maxXMaxYCorner(); // This is actually a pixel below and to the right of the dirtyRect.
 
-    IntSize tileMaximumSize = tileSize();
-    bool wasOneTile = m_tilesWebKitThread.size() == 1;
-    bool isOneTile = m_pendingTextureSize.width() <= tileMaximumSize.width() && m_pendingTextureSize.height() <= tileMaximumSize.height();
+    IntSize tileMaximumSize(tileSize());
+    IntRect rectForOneTile(IntPoint::zero(), tileMaximumSize);
+    bool wasOneTile = rectForOneTile.contains(previousTextureRect);
+    bool isOneTile = rectForOneTile.contains(IntRect(IntPoint::zero(), m_pendingTextureSize));
     IntPoint origin = originOfTile(indexOfTile(topLeft));
     IntRect tileRect;
     for (tileRect.setX(origin.x()); tileRect.x() < bottomRight.x(); tileRect.setX(tileRect.x() + tileMaximumSize.width())) {
@@ -312,17 +319,9 @@
 
 bool LayerTiler::shouldPerformRenderJob(const TileIndex& index, bool allowPrefill)
 {
-    // If the visibility information was propagated from the compositing
-    // thread, use that information.
-    // However, we are about to commit new layer properties that may make
-    // currently hidden layers visible. To avoid false negatives, we only allow
-    // the current state to be used to accept render jobs, not to reject them.
-    if (m_tilesWebKitThread.get(index).isVisible())
-        return true;
-
     // Tiles that are not currently visible on the compositing thread may still
     // deserve to be rendered if they should be prefilled...
-    if (allowPrefill && !m_tilesWebKitThread.contains(index) && shouldPrefillTile(index))
+    if (allowPrefill && shouldPrefillTile(index))
         return true;
 
     // Or if they are visible according to the state that's about to be
@@ -369,7 +368,7 @@
         m_renderJobs.clear();
     }
 
-    for (TileMap::iterator it = m_tilesCompositingThread.begin(); it != m_tilesCompositingThread.end(); ++it) {
+    for (TileMap::iterator it = m_tiles.begin(); it != m_tiles.end(); ++it) {
         TileIndex index = (*it).first;
         LayerTile* tile = (*it).second;
         tile->setVisible(false);
@@ -387,12 +386,12 @@
     for (TileJobsMap::const_iterator tileJobsIter = tileJobsMap.begin(); tileJobsIter != tileJobsIterEnd; ++tileJobsIter) {
         IntPoint origin = originOfTile(tileJobsIter->first);
 
-        LayerTile* tile = m_tilesCompositingThread.get(tileJobsIter->first);
+        LayerTile* tile = m_tiles.get(tileJobsIter->first);
         if (!tile) {
             if (origin.x() >= m_requiredTextureSize.width() || origin.y() >= m_requiredTextureSize.height())
                 continue;
             tile = new LayerTile();
-            m_tilesCompositingThread.add(tileJobsIter->first, tile);
+            m_tiles.add(tileJobsIter->first, tile);
         }
 
         IntRect tileRect(origin, tileSize());
@@ -516,10 +515,10 @@
     for (tileRect.setX(0); tileRect.x() < m_requiredTextureSize.width(); tileRect.setX(tileRect.x() + maxw)) {
         for (tileRect.setY(0); tileRect.y() < m_requiredTextureSize.height(); tileRect.setY(tileRect.y() + maxh)) {
             TileIndex index = indexOfTile(tileRect.location());
-            LayerTile* tile = m_tilesCompositingThread.get(index);
+            LayerTile* tile = m_tiles.get(index);
             if (!tile) {
                 tile = new LayerTile();
-                m_tilesCompositingThread.add(index, tile);
+                m_tiles.add(index, tile);
             }
 
             float x = index.i() * maxw * sx;
@@ -629,12 +628,10 @@
     // from WebKit thread to compositing thread, we don't need
     // any synchronization mechanism here, even though we are
     // touching some WebKit thread state.
-    m_tilesWebKitThread.clear();
-
-    if (m_tilesCompositingThread.size()) {
-        for (TileMap::iterator it = m_tilesCompositingThread.begin(); it != m_tilesCompositingThread.end(); ++it)
+    if (m_tiles.size()) {
+        for (TileMap::iterator it = m_tiles.begin(); it != m_tiles.end(); ++it)
             (*it).second->discardContents();
-        m_tilesCompositingThread.clear();
+        m_tiles.clear();
 
         m_contentsDirty = true;
     }
@@ -649,7 +646,7 @@
 {
     // Prune tiles that are no longer needed.
     Vector<TileIndex> tilesToDelete;
-    for (TileMap::iterator it = m_tilesCompositingThread.begin(); it != m_tilesCompositingThread.end(); ++it) {
+    for (TileMap::iterator it = m_tiles.begin(); it != m_tiles.end(); ++it) {
         TileIndex index = (*it).first;
 
         IntPoint origin = originOfTile(index);
@@ -658,7 +655,7 @@
     }
 
     for (Vector<TileIndex>::iterator it = tilesToDelete.begin(); it != tilesToDelete.end(); ++it) {
-        LayerTile* tile = m_tilesCompositingThread.take(*it);
+        LayerTile* tile = m_tiles.take(*it);
         tile->discardContents();
         delete tile;
     }
@@ -738,11 +735,11 @@
 
 void LayerTiler::bindContentsTexture(LayerCompositingThread*)
 {
-    ASSERT(m_tilesCompositingThread.size() == 1);
-    if (m_tilesCompositingThread.size() != 1)
+    ASSERT(m_tiles.size() == 1);
+    if (m_tiles.size() != 1)
         return;
 
-    const LayerTile* tile = m_tilesCompositingThread.begin()->second;
+    const LayerTile* tile = m_tiles.begin()->second;
 
     ASSERT(tile->hasTexture());
     if (!tile->hasTexture())

Modified: trunk/Source/WebCore/platform/graphics/blackberry/LayerTiler.h (124549 => 124550)


--- trunk/Source/WebCore/platform/graphics/blackberry/LayerTiler.h	2012-08-03 02:05:51 UTC (rev 124549)
+++ trunk/Source/WebCore/platform/graphics/blackberry/LayerTiler.h	2012-08-03 02:26:44 UTC (rev 124550)
@@ -138,7 +138,6 @@
     };
 
     typedef HashMap<TileIndex, LayerTile*> TileMap;
-    typedef HashMap<TileIndex, LayerTileData> VisibilityMap;
     typedef HashMap<TileIndex, const TextureJob*> TileJobsMap;
 
     IntSize tileSize() const { return m_tileSize; }
@@ -176,10 +175,8 @@
 
     LayerWebKitThread* m_layer;
 
-    TileMap m_tilesCompositingThread;
+    TileMap m_tiles; // Compositing thread only
 
-    VisibilityMap m_tilesWebKitThread;
-
     bool m_tilingDisabled;
 
     bool m_contentsDirty;

Modified: trunk/Source/WebKit/blackberry/ChangeLog (124549 => 124550)


--- trunk/Source/WebKit/blackberry/ChangeLog	2012-08-03 02:05:51 UTC (rev 124549)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2012-08-03 02:26:44 UTC (rev 124550)
@@ -1,3 +1,27 @@
+2012-08-02  Arvid Nilsson  <[email protected]>
+
+        [BlackBerry] Add default implementation of GraphicsLayerClient::contentsVisible()
+        https://bugs.webkit.org/show_bug.cgi?id=93036
+
+        Reviewed by George Staikos.
+
+        Remove implementation of GraphicsLayerClient::contentsVisible() now
+        that it has a default implementation.
+
+        This also fixes a bug where memory usage for the inspector highlight
+        overlay would balloon because it returned true from contentsVisible()
+        which would cause the LayerTiler to populate all tiles. The default
+        implementation returns false instead.
+
+        PR 187458, 184377
+
+        * WebCoreSupport/InspectorOverlay.cpp:
+        (WebCore::InspectorOverlay::showRepaintCounter):
+        * WebCoreSupport/InspectorOverlay.h:
+        (InspectorOverlay):
+        * WebKitSupport/DefaultTapHighlight.h:
+        * WebKitSupport/SelectionOverlay.h:
+
 2012-08-02  Antonio Gomes  <[email protected]>
 
         Unreviewed debug build fix (bug 92889)

Modified: trunk/Source/WebKit/blackberry/WebCoreSupport/InspectorOverlay.cpp (124549 => 124550)


--- trunk/Source/WebKit/blackberry/WebCoreSupport/InspectorOverlay.cpp	2012-08-03 02:05:51 UTC (rev 124549)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/InspectorOverlay.cpp	2012-08-03 02:26:44 UTC (rev 124550)
@@ -66,11 +66,6 @@
 {
     return m_webPage->m_page->settings()->showRepaintCounter();
 }
-
-bool InspectorOverlay::contentsVisible(const GraphicsLayer*, const IntRect& contentRect) const
-{
-    return true;
-}
 #endif
 
 InspectorOverlay::~InspectorOverlay() { }

Modified: trunk/Source/WebKit/blackberry/WebCoreSupport/InspectorOverlay.h (124549 => 124550)


--- trunk/Source/WebKit/blackberry/WebCoreSupport/InspectorOverlay.h	2012-08-03 02:05:51 UTC (rev 124549)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/InspectorOverlay.h	2012-08-03 02:26:44 UTC (rev 124550)
@@ -58,8 +58,6 @@
     virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const IntRect& inClip);
     virtual bool showDebugBorders(const GraphicsLayer*) const;
     virtual bool showRepaintCounter(const GraphicsLayer*) const;
-
-    virtual bool contentsVisible(const WebCore::GraphicsLayer*, const WebCore::IntRect& contentRect) const;
 #endif
 
 private:

Modified: trunk/Source/WebKit/blackberry/WebKitSupport/DefaultTapHighlight.h (124549 => 124550)


--- trunk/Source/WebKit/blackberry/WebKitSupport/DefaultTapHighlight.h	2012-08-03 02:05:51 UTC (rev 124549)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/DefaultTapHighlight.h	2012-08-03 02:26:44 UTC (rev 124550)
@@ -58,9 +58,7 @@
     virtual void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& inClip);
     virtual bool showDebugBorders(const WebCore::GraphicsLayer*) const { return false; }
     virtual bool showRepaintCounter(const WebCore::GraphicsLayer*) const { return false; }
-    virtual bool contentsVisible(const WebCore::GraphicsLayer*, const WebCore::IntRect& contentRect) const { return true; }
 
-
 private:
     DefaultTapHighlight(WebPagePrivate*);
 

Modified: trunk/Source/WebKit/blackberry/WebKitSupport/SelectionOverlay.h (124549 => 124550)


--- trunk/Source/WebKit/blackberry/WebKitSupport/SelectionOverlay.h	2012-08-03 02:05:51 UTC (rev 124549)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/SelectionOverlay.h	2012-08-03 02:26:44 UTC (rev 124550)
@@ -54,9 +54,7 @@
     virtual void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& inClip);
     virtual bool showDebugBorders(const WebCore::GraphicsLayer*) const { return false; }
     virtual bool showRepaintCounter(const WebCore::GraphicsLayer*) const { return false; }
-    virtual bool contentsVisible(const WebCore::GraphicsLayer*, const WebCore::IntRect& contentRect) const { return true; }
 
-
 private:
     SelectionOverlay(WebPagePrivate*);
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to