Title: [90260] trunk/Source/WebCore
Revision
90260
Author
[email protected]
Date
2011-07-01 12:24:59 -0700 (Fri, 01 Jul 2011)

Log Message

2011-07-01  Vangelis Kokkevis  <[email protected]>

        Reviewed by James Robinson.

        [chromium] Reserve all tile textures at layer update time to guarantee
        that they will be available at draw time.
        https://bugs.webkit.org/show_bug.cgi?id=63760

        In addition, this patch unreserves textures used by RenderSurface's
        right after the RenderSurface has been used to free up memory for
        subsequent RenderSurfaces.

        This patch also "fixes" the pages that display a blue background when
        running out of texture memory as the root layer tiles get reserved first
        and are guaranteed to get textures.

        * platform/graphics/chromium/ContentLayerChromium.cpp:
        (WebCore::ContentLayerChromium::ContentLayerChromium):
        (WebCore::ContentLayerChromium::visibleLayerRect):
        (WebCore::ContentLayerChromium::setIsMask):
        * platform/graphics/chromium/ContentLayerChromium.h:
        * platform/graphics/chromium/ImageLayerChromium.cpp:
        (WebCore::ImageLayerChromium::paintContentsIfDirty):
        * platform/graphics/chromium/LayerRendererChromium.cpp:
        (WebCore::LayerRendererChromium::paintLayerContents):
        (WebCore::LayerRendererChromium::drawLayer):
        (WebCore::LayerRendererChromium::initializeSharedObjects):
        * platform/graphics/chromium/LayerTexture.cpp:
        (WebCore::LayerTexture::unreserve):
        * platform/graphics/chromium/LayerTexture.h:
        * platform/graphics/chromium/LayerTilerChromium.cpp:
        (WebCore::LayerTilerChromium::prepareToUpdate):
        (WebCore::LayerTilerChromium::updateRect):
        (WebCore::LayerTilerChromium::drawTiles):
        * platform/graphics/chromium/RenderSurfaceChromium.cpp:
        (WebCore::RenderSurfaceChromium::releaseContentsTexture):
        * platform/graphics/chromium/RenderSurfaceChromium.h:
        * platform/graphics/chromium/TextureManager.cpp:
        (WebCore::TextureManager::unprotectTexture):
        * platform/graphics/chromium/TextureManager.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (90259 => 90260)


--- trunk/Source/WebCore/ChangeLog	2011-07-01 19:23:21 UTC (rev 90259)
+++ trunk/Source/WebCore/ChangeLog	2011-07-01 19:24:59 UTC (rev 90260)
@@ -1,3 +1,44 @@
+2011-07-01  Vangelis Kokkevis  <[email protected]>
+
+        Reviewed by James Robinson.
+
+        [chromium] Reserve all tile textures at layer update time to guarantee
+        that they will be available at draw time.
+        https://bugs.webkit.org/show_bug.cgi?id=63760
+
+        In addition, this patch unreserves textures used by RenderSurface's
+        right after the RenderSurface has been used to free up memory for
+        subsequent RenderSurfaces.
+        
+        This patch also "fixes" the pages that display a blue background when
+        running out of texture memory as the root layer tiles get reserved first
+        and are guaranteed to get textures.
+
+        * platform/graphics/chromium/ContentLayerChromium.cpp:
+        (WebCore::ContentLayerChromium::ContentLayerChromium):
+        (WebCore::ContentLayerChromium::visibleLayerRect):
+        (WebCore::ContentLayerChromium::setIsMask):
+        * platform/graphics/chromium/ContentLayerChromium.h:
+        * platform/graphics/chromium/ImageLayerChromium.cpp:
+        (WebCore::ImageLayerChromium::paintContentsIfDirty):
+        * platform/graphics/chromium/LayerRendererChromium.cpp:
+        (WebCore::LayerRendererChromium::paintLayerContents):
+        (WebCore::LayerRendererChromium::drawLayer):
+        (WebCore::LayerRendererChromium::initializeSharedObjects):
+        * platform/graphics/chromium/LayerTexture.cpp:
+        (WebCore::LayerTexture::unreserve):
+        * platform/graphics/chromium/LayerTexture.h:
+        * platform/graphics/chromium/LayerTilerChromium.cpp:
+        (WebCore::LayerTilerChromium::prepareToUpdate):
+        (WebCore::LayerTilerChromium::updateRect):
+        (WebCore::LayerTilerChromium::drawTiles):
+        * platform/graphics/chromium/RenderSurfaceChromium.cpp:
+        (WebCore::RenderSurfaceChromium::releaseContentsTexture):
+        * platform/graphics/chromium/RenderSurfaceChromium.h:
+        * platform/graphics/chromium/TextureManager.cpp:
+        (WebCore::TextureManager::unprotectTexture):
+        * platform/graphics/chromium/TextureManager.h:
+
 2011-07-01  Jungshik Shin  <[email protected]>
 
         Reviewed by Alexey Proskuryakov.

Modified: trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp (90259 => 90260)


--- trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp	2011-07-01 19:23:21 UTC (rev 90259)
+++ trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp	2011-07-01 19:24:59 UTC (rev 90260)
@@ -92,6 +92,7 @@
 ContentLayerChromium::ContentLayerChromium(GraphicsLayerChromium* owner)
     : LayerChromium(owner)
     , m_tilingOption(ContentLayerChromium::AutoTile)
+    , m_isMask(false)
 {
 }
 
@@ -165,6 +166,12 @@
         return targetSurfaceRect;
 
     const IntRect layerBoundRect = layerBounds();
+
+    // Mask layers don't have their own draw transform so we return the entire
+    // layer bounds as the visible rect.
+    if (m_isMask)
+        return layerBoundRect;
+
     const TransformationMatrix transform = tilingTransform();
 
     // Is this layer fully contained within the target surface?
@@ -282,6 +289,7 @@
 void ContentLayerChromium::setIsMask(bool isMask)
 {
     setTilingOption(isMask ? NeverTile : AutoTile);
+    m_isMask = isMask;
 }
 
 static void writeIndent(TextStream& ts, int indent)

Modified: trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h (90259 => 90260)


--- trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h	2011-07-01 19:23:21 UTC (rev 90259)
+++ trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h	2011-07-01 19:24:59 UTC (rev 90260)
@@ -85,6 +85,7 @@
     OwnPtr<LayerTextureUpdater> m_textureUpdater;
     OwnPtr<LayerTilerChromium> m_tiler;
     TilingOption m_tilingOption;
+    bool m_isMask;
 };
 
 }

Modified: trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp (90259 => 90260)


--- trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp	2011-07-01 19:23:21 UTC (rev 90259)
+++ trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp	2011-07-01 19:24:59 UTC (rev 90260)
@@ -140,7 +140,7 @@
     setNeedsDisplay();
 }
 
-void ImageLayerChromium::paintContentsIfDirty(const IntRect&)
+void ImageLayerChromium::paintContentsIfDirty(const IntRect& targetSurfaceRect)
 {
     ASSERT(layerRenderer());
 
@@ -154,8 +154,12 @@
             m_tiler->invalidateRect(paintRect);
             m_dirtyRect = IntRect();
         }
-        m_tiler->prepareToUpdate(paintRect, m_textureUpdater.get());
     }
+    IntRect layerRect = visibleLayerRect(targetSurfaceRect);
+    if (layerRect.isEmpty())
+        return;
+
+    m_tiler->prepareToUpdate(layerRect, m_textureUpdater.get());
 }
 
 void ImageLayerChromium::updateCompositorResources()

Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp (90259 => 90260)


--- trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp	2011-07-01 19:23:21 UTC (rev 90259)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp	2011-07-01 19:24:59 UTC (rev 90260)
@@ -401,9 +401,8 @@
               continue;
 
             IntRect targetSurfaceRect = ccLayerImpl->targetRenderSurface() ? ccLayerImpl->targetRenderSurface()->contentRect() : m_defaultRenderSurface->contentRect();
-            IntRect scissorRect = layer->ccLayerImpl()->scissorRect();
-            if (!scissorRect.isEmpty())
-                targetSurfaceRect.intersect(scissorRect);
+            if (layer->ccLayerImpl()->usesLayerScissor())
+                targetSurfaceRect.intersect(layer->ccLayerImpl()->scissorRect());
 
             if (layer->drawsContent())
                 layer->paintContentsIfDirty(targetSurfaceRect);
@@ -949,29 +948,25 @@
 {
     if (layer->renderSurface() && layer->renderSurface() != targetSurface) {
         layer->renderSurface()->draw(layer->getDrawRect());
+        layer->renderSurface()->releaseContentsTexture();
         return;
     }
 
     if (!layer->drawsContent())
         return;
 
-    if (layer->bounds().isEmpty()) {
-        layer->unreserveContentsTexture();
+    if (layer->bounds().isEmpty())
         return;
-    }
 
     if (layer->usesLayerScissor())
         setScissorToRect(layer->scissorRect());
     else
         GLC(m_context.get(), m_context->disable(GraphicsContext3D::SCISSOR_TEST));
-    IntRect targetSurfaceRect = m_currentRenderSurface ? m_currentRenderSurface->contentRect() : m_defaultRenderSurface->contentRect();
-
-    // Check if the layer falls within the visible bounds of the page.
-    IntRect layerRect = layer->getDrawRect();
-    bool isLayerVisible = targetSurfaceRect.intersects(layerRect);
-    if (!isLayerVisible) {
-        layer->unreserveContentsTexture();
-        return;
+    
+    IntRect targetSurfaceRect = layer->targetRenderSurface() ? layer->targetRenderSurface()->contentRect() : m_defaultRenderSurface->contentRect();
+    if (layer->usesLayerScissor()) {
+        IntRect scissorRect = layer->scissorRect();
+        targetSurfaceRect.intersect(scissorRect);
     }
 
     // FIXME: Need to take into account the commulative render surface transforms all the way from
@@ -986,10 +981,8 @@
         FloatPoint3D xAxis(horizontalDir.width(), horizontalDir.height(), 0);
         FloatPoint3D yAxis(verticalDir.width(), verticalDir.height(), 0);
         FloatPoint3D zAxis = xAxis.cross(yAxis);
-        if (zAxis.z() < 0) {
-            layer->unreserveContentsTexture();
+        if (zAxis.z() < 0)
             return;
-        }
     }
 
     layer->draw(targetSurfaceRect);

Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerTexture.cpp (90259 => 90260)


--- trunk/Source/WebCore/platform/graphics/chromium/LayerTexture.cpp	2011-07-01 19:23:21 UTC (rev 90259)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerTexture.cpp	2011-07-01 19:24:59 UTC (rev 90260)
@@ -71,6 +71,14 @@
     return m_textureId;
 }
 
+void LayerTexture::unreserve()
+{
+    if (!m_token)
+        return;
+
+    m_textureManager->unprotectTexture(m_token);
+}
+
 void LayerTexture::bindTexture()
 {
     ASSERT(m_textureManager->hasTexture(m_token));

Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerTexture.h (90259 => 90260)


--- trunk/Source/WebCore/platform/graphics/chromium/LayerTexture.h	2011-07-01 19:23:21 UTC (rev 90259)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerTexture.h	2011-07-01 19:24:59 UTC (rev 90260)
@@ -50,6 +50,7 @@
     unsigned format() const { return m_format; }
     bool isValid(const IntSize&, unsigned format);
     bool reserve(const IntSize&, unsigned format);
+    void unreserve();
     bool isReserved()
     {
         ASSERT(m_textureManager);

Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.cpp (90259 => 90260)


--- trunk/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.cpp	2011-07-01 19:23:21 UTC (rev 90259)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.cpp	2011-07-01 19:24:59 UTC (rev 90260)
@@ -228,7 +228,9 @@
 
 void LayerTilerChromium::prepareToUpdate(const IntRect& contentRect, LayerTextureUpdater* textureUpdater)
 {
-    if (m_skipsDraw || contentRect.isEmpty()) {
+    m_skipsDraw = false;
+
+    if (contentRect.isEmpty()) {
         m_updateRect = IntRect();
         return;
     }
@@ -255,8 +257,13 @@
                 tile = createTile(i, j);
             if (!tile->texture()->isValid(m_tileSize, m_textureFormat))
                 tile->m_dirtyLayerRect = tileLayerRect(tile);
-            else
-                tile->texture()->reserve(m_tileSize, m_textureFormat);
+
+            if (!tile->texture()->reserve(m_tileSize, m_textureFormat)) {
+                m_skipsDraw = true;
+                reset();
+                return;
+            }
+
             dirtyLayerRect.unite(tile->m_dirtyLayerRect);
         }
     }
@@ -276,7 +283,7 @@
 void LayerTilerChromium::updateRect(LayerTextureUpdater* textureUpdater)
 {
     // Painting could cause compositing to get turned off, which may cause the tiler to become invalidated mid-update.
-    if (!m_tilingData.totalSizeX() || !m_tilingData.totalSizeY() || m_updateRect.isEmpty() || !numTiles())
+    if (!m_tilingData.totalSizeX() || !m_tilingData.totalSizeY() || m_updateRect.isEmpty() || !numTiles() || m_skipsDraw)
         return;
 
     GraphicsContext3D* context = layerRendererContext();
@@ -301,13 +308,7 @@
             if (sourceRect.isEmpty())
                 continue;
 
-            if (!tile->texture()->isReserved()) {
-                if (!tile->texture()->reserve(m_tileSize, m_textureFormat)) {
-                    m_skipsDraw = true;
-                    reset();
-                    return;
-                }
-            }
+            ASSERT(tile->texture()->isReserved());
 
             // Calculate tile-space rectangle to upload into.
             IntRect destRect(IntPoint(sourceRect.x() - anchor.x(), sourceRect.y() - anchor.y()), sourceRect.size());
@@ -389,6 +390,8 @@
             if (!tile)
                 continue;
 
+            ASSERT(tile->texture()->isReserved());
+
             tile->texture()->bindTexture();
 
             TransformationMatrix tileMatrix(globalTransform);

Modified: trunk/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.cpp (90259 => 90260)


--- trunk/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.cpp	2011-07-01 19:23:21 UTC (rev 90259)
+++ trunk/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.cpp	2011-07-01 19:24:59 UTC (rev 90260)
@@ -98,6 +98,13 @@
     return true;
 }
 
+void RenderSurfaceChromium::releaseContentsTexture()
+{
+    if (m_skipsDraw || !m_contentsTexture)
+        return;
+    m_contentsTexture->unreserve();
+}
+
 void RenderSurfaceChromium::drawSurface(CCLayerImpl* maskLayer, const TransformationMatrix& drawTransform)
 {
     GraphicsContext3D* context3D = layerRenderer()->context();

Modified: trunk/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.h (90259 => 90260)


--- trunk/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.h	2011-07-01 19:23:21 UTC (rev 90259)
+++ trunk/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.h	2011-07-01 19:24:59 UTC (rev 90260)
@@ -51,6 +51,7 @@
     ~RenderSurfaceChromium();
 
     bool prepareContentsTexture();
+    void releaseContentsTexture();
     void cleanupResources();
     void draw(const IntRect& targetSurfaceRect);
 

Modified: trunk/Source/WebCore/platform/graphics/chromium/TextureManager.cpp (90259 => 90260)


--- trunk/Source/WebCore/platform/graphics/chromium/TextureManager.cpp	2011-07-01 19:23:21 UTC (rev 90259)
+++ trunk/Source/WebCore/platform/graphics/chromium/TextureManager.cpp	2011-07-01 19:24:59 UTC (rev 90260)
@@ -84,6 +84,13 @@
     m_textures.add(token, info);
 }
 
+void TextureManager::unprotectTexture(TextureToken token)
+{
+    TextureMap::iterator it = m_textures.find(token);
+    if (it != m_textures.end())
+        it->second.isProtected = false;
+}
+
 void TextureManager::unprotectAllTextures()
 {
     for (TextureMap::iterator it = m_textures.begin(); it != m_textures.end(); ++it)

Modified: trunk/Source/WebCore/platform/graphics/chromium/TextureManager.h (90259 => 90260)


--- trunk/Source/WebCore/platform/graphics/chromium/TextureManager.h	2011-07-01 19:23:21 UTC (rev 90259)
+++ trunk/Source/WebCore/platform/graphics/chromium/TextureManager.h	2011-07-01 19:24:59 UTC (rev 90260)
@@ -52,6 +52,7 @@
     unsigned requestTexture(TextureToken, IntSize, unsigned textureFormat, bool* newTexture = 0);
 
     void protectTexture(TextureToken);
+    void unprotectTexture(TextureToken);
     void unprotectAllTextures();
     bool isProtected(TextureToken);
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to