[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

vangelis at chromium.org vangelis at chromium.org
Wed Dec 22 14:44:24 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 5b29ab3a6e19d8ebab56f57fb8ddebeea38d6c6d
Author: vangelis at chromium.org <vangelis at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Oct 18 23:53:10 2010 +0000

    2010-10-18  Vangelis Kokkevis  <vangelis at chromium.org>
    
            Reviewed by James Robinson.
    
            [chromium] Prevent the creation of very large textures for layers by switching
            to "large layer" mode when a texture is larger than some fixed reasonable size
            (set to 2000 pixels for now).
            https://bugs.webkit.org/show_bug.cgi?id=47751
    
            The code also changes the large layer logic to use the current scissor rect used
            by the compositor instead of the visible rect to determine how to clip large layers.
            This will provide additional texture savings. In addition, the various layer rects
            have been converted to use integers instead of floats to preserve uniformity in the code.
    
            Tests: Existing large layer layout tests including huge-layer and huge-layer-img
    
            * platform/graphics/chromium/ContentLayerChromium.cpp:
            (WebCore::ContentLayerChromium::requiresClippedUpdateRect):
            (WebCore::ContentLayerChromium::calculateClippedUpdateRect):
            * platform/graphics/chromium/LayerChromium.cpp:
            (WebCore::LayerChromium::getDrawRect):
            * platform/graphics/chromium/LayerChromium.h:
            * platform/graphics/chromium/LayerRendererChromium.cpp:
            (WebCore::LayerRendererChromium::drawLayers):
            (WebCore::LayerRendererChromium::drawLayersRecursive):
            (WebCore::LayerRendererChromium::scissorToRect):
            * platform/graphics/chromium/LayerRendererChromium.h:
            (WebCore::LayerRendererChromium::currentScissorRect):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@70010 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index b85ec3a..f5b8972 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,32 @@
+2010-10-18  Vangelis Kokkevis  <vangelis at chromium.org>
+
+        Reviewed by James Robinson.
+
+        [chromium] Prevent the creation of very large textures for layers by switching
+        to "large layer" mode when a texture is larger than some fixed reasonable size
+        (set to 2000 pixels for now).
+        https://bugs.webkit.org/show_bug.cgi?id=47751
+
+        The code also changes the large layer logic to use the current scissor rect used
+        by the compositor instead of the visible rect to determine how to clip large layers.
+        This will provide additional texture savings. In addition, the various layer rects
+        have been converted to use integers instead of floats to preserve uniformity in the code.
+        
+        Tests: Existing large layer layout tests including huge-layer and huge-layer-img
+
+        * platform/graphics/chromium/ContentLayerChromium.cpp:
+        (WebCore::ContentLayerChromium::requiresClippedUpdateRect):
+        (WebCore::ContentLayerChromium::calculateClippedUpdateRect):
+        * platform/graphics/chromium/LayerChromium.cpp:
+        (WebCore::LayerChromium::getDrawRect):
+        * platform/graphics/chromium/LayerChromium.h:
+        * platform/graphics/chromium/LayerRendererChromium.cpp:
+        (WebCore::LayerRendererChromium::drawLayers):
+        (WebCore::LayerRendererChromium::drawLayersRecursive):
+        (WebCore::LayerRendererChromium::scissorToRect):
+        * platform/graphics/chromium/LayerRendererChromium.h:
+        (WebCore::LayerRendererChromium::currentScissorRect):
+
 2010-10-18  Jia Pu  <jpu at apple.com>
 
         Reviewed by Stephanie Lewis.
diff --git a/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp b/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp
index d6ccd79..18c70cc 100644
--- a/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp
+++ b/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp
@@ -143,7 +143,13 @@ void ContentLayerChromium::cleanupResources()
 
 bool ContentLayerChromium::requiresClippedUpdateRect() const
 {
-    return !layerRenderer()->checkTextureSize(m_bounds);
+    // To avoid allocating excessively large textures, switch into "large layer mode" if
+    // one of the layer's dimensions is larger than 2000 pixels or the current size
+    // of the visible rect. This is a temporary measure until layer tiling is implemented.
+    static const int maxLayerSize = 2000;
+    return (m_bounds.width() > max(maxLayerSize, layerRenderer()->rootLayerContentRect().width())
+            || m_bounds.height() > max(maxLayerSize, layerRenderer()->rootLayerContentRect().height())
+            || !layerRenderer()->checkTextureSize(m_bounds));
 }
 
 void ContentLayerChromium::calculateClippedUpdateRect(IntRect& dirtyRect, IntRect& drawRect) const
@@ -152,7 +158,7 @@ void ContentLayerChromium::calculateClippedUpdateRect(IntRect& dirtyRect, IntRec
     // 1) The minimal texture space rectangle to be uploaded, returned in dirtyRect.
     // 2) The content rect-relative rectangle to draw this texture in, returned in drawRect.
 
-    const IntRect contentRect = layerRenderer()->rootLayerContentRect();
+    const IntRect clipRect = layerRenderer()->currentScissorRect();
     const TransformationMatrix& transform = drawTransform();
     // The layer's draw transform points to the center of the layer, relative to
     // the content rect.  layerPos is the distance from the top left of the
@@ -160,7 +166,7 @@ void ContentLayerChromium::calculateClippedUpdateRect(IntRect& dirtyRect, IntRec
     const IntPoint layerPos(m_bounds.width() / 2 - transform.m41(),
                             m_bounds.height() / 2 - transform.m42());
     // Transform the contentRect into the space of the layer.
-    IntRect contentRectInLayerSpace(layerPos, contentRect.size());
+    IntRect contentRectInLayerSpace(layerPos, clipRect.size());
 
     // Clip the entire layer against the visible region in the content rect
     // and use that as the drawable texture, instead of the entire layer.
diff --git a/WebCore/platform/graphics/chromium/LayerChromium.cpp b/WebCore/platform/graphics/chromium/LayerChromium.cpp
index a1f7611..79f18f0 100644
--- a/WebCore/platform/graphics/chromium/LayerChromium.cpp
+++ b/WebCore/platform/graphics/chromium/LayerChromium.cpp
@@ -451,15 +451,12 @@ void LayerChromium::drawDebugBorder()
     GLC(context, context->drawElements(GraphicsContext3D::LINE_LOOP, 4, GraphicsContext3D::UNSIGNED_SHORT, 6 * sizeof(unsigned short)));
 }
 
-const FloatRect LayerChromium::getDrawRect() const
+const IntRect LayerChromium::getDrawRect() const
 {
     // Form the matrix used by the shader to map the corners of the layer's
     // bounds into the view space.
-    TransformationMatrix renderMatrix = drawTransform();
-    renderMatrix.scale3d(bounds().width(), bounds().height(), 1);
-
-    FloatRect layerRect(-0.5, -0.5, 1, 1);
-    FloatRect mappedRect = renderMatrix.mapRect(layerRect);
+    FloatRect layerRect(-0.5 * bounds().width(), -0.5 * bounds().height(), bounds().width(), bounds().height());
+    IntRect mappedRect = enclosingIntRect(drawTransform().mapRect(layerRect));
     return mappedRect;
 }
 
diff --git a/WebCore/platform/graphics/chromium/LayerChromium.h b/WebCore/platform/graphics/chromium/LayerChromium.h
index 7325189..3956e28 100644
--- a/WebCore/platform/graphics/chromium/LayerChromium.h
+++ b/WebCore/platform/graphics/chromium/LayerChromium.h
@@ -156,7 +156,7 @@ public:
     bool contentsDirty() { return m_contentsDirty; }
 
     // Returns the rect containtaining this layer in the current view's coordinate system.
-    const FloatRect getDrawRect() const;
+    const IntRect getDrawRect() const;
 
     // These methods typically need to be overwritten by derived classes.
     virtual bool drawsContent() { return false; }
diff --git a/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp b/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
index c11269b..e93e296 100644
--- a/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
+++ b/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
@@ -321,7 +321,7 @@ void LayerRendererChromium::drawLayers(const IntRect& visibleRect, const IntRect
 
     // Enable scissoring to avoid rendering composited layers over the scrollbars.
     GLC(m_context, m_context->enable(GraphicsContext3D::SCISSOR_TEST));
-    FloatRect scissorRect(contentRect);
+    IntRect scissorRect(contentRect);
 
     // The scissorRect should not include the scroll offset.
     scissorRect.move(-m_scrollPosition.x(), -m_scrollPosition.y());
@@ -334,7 +334,7 @@ void LayerRendererChromium::drawLayers(const IntRect& visibleRect, const IntRect
 
     // Traverse the layer tree one more time to draw the layers.
     for (size_t i = 0; i < sublayers.size(); i++)
-        drawLayersRecursive(sublayers[i].get(), scissorRect);
+        drawLayersRecursive(sublayers[i].get());
 
     GLC(m_context, m_context->disable(GraphicsContext3D::SCISSOR_TEST));
     GLC(m_context, m_context->disable(GraphicsContext3D::BLEND));
@@ -501,14 +501,14 @@ void LayerRendererChromium::drawLayerIntoStencilBuffer(LayerChromium* layer, boo
 }
 
 // Recursively walk the layer tree and draw the layers.
-void LayerRendererChromium::drawLayersRecursive(LayerChromium* layer, const FloatRect& scissorRect)
+void LayerRendererChromium::drawLayersRecursive(LayerChromium* layer)
 {
     static bool depthTestEnabledForSubtree = false;
     static int currentStencilValue = 0;
 
     // Check if the layer falls within the visible bounds of the page.
-    FloatRect layerRect = layer->getDrawRect();
-    bool isLayerVisible = scissorRect.intersects(layerRect);
+    IntRect layerRect = layer->getDrawRect();
+    bool isLayerVisible = m_currentScissorRect.intersects(layerRect);
 
     // Enable depth testing for this layer and all its descendants if preserves3D is set.
     bool mustClearDepth = false;
@@ -527,15 +527,16 @@ void LayerRendererChromium::drawLayersRecursive(LayerChromium* layer, const Floa
 
     // FIXME: We should check here if the layer has descendants that draw content
     // before we setup for clipping.
-    FloatRect currentScissorRect = scissorRect;
+    IntRect previousScissorRect = m_currentScissorRect;
     bool mustResetScissorRect = false;
     bool didStencilDraw = false;
     if (layer->masksToBounds()) {
         // If the layer isn't rotated then we can use scissoring otherwise we need
         // to clip using the stencil buffer.
         if (layer->drawTransform().isIdentityOrTranslation()) {
+            IntRect currentScissorRect = previousScissorRect;
             currentScissorRect.intersect(layerRect);
-            if (currentScissorRect != scissorRect) {
+            if (currentScissorRect != previousScissorRect) {
                 scissorToRect(currentScissorRect);
                 mustResetScissorRect = true;
             }
@@ -580,11 +581,11 @@ void LayerRendererChromium::drawLayersRecursive(LayerChromium* layer, const Floa
         std::stable_sort(sublayerList.begin(), sublayerList.end(), compareLayerZ);
 
         for (i = 0; i < sublayerList.size(); i++)
-            drawLayersRecursive(sublayerList[i], currentScissorRect);
+            drawLayersRecursive(sublayerList[i]);
     } else {
         const Vector<RefPtr<LayerChromium> >& sublayers = layer->getSublayers();
         for (size_t i = 0; i < sublayers.size(); i++)
-            drawLayersRecursive(sublayers[i].get(), currentScissorRect);
+            drawLayersRecursive(sublayers[i].get());
     }
 
     if (didStencilDraw) {
@@ -600,7 +601,7 @@ void LayerRendererChromium::drawLayersRecursive(LayerChromium* layer, const Floa
     }
 
     if (mustResetScissorRect) {
-        scissorToRect(scissorRect);
+        scissorToRect(previousScissorRect);
     }
 
     if (mustClearDepth) {
@@ -636,11 +637,12 @@ void LayerRendererChromium::drawLayer(LayerChromium* layer)
 
 // Sets the scissor region to the given rectangle. The coordinate system for the
 // scissorRect has its origin at the top left corner of the current visible rect.
-void LayerRendererChromium::scissorToRect(const FloatRect& scissorRect)
+void LayerRendererChromium::scissorToRect(const IntRect& scissorRect)
 {
     // Compute the lower left corner of the scissor rect.
-    float bottom = std::max((float)m_rootVisibleRect.height() - scissorRect.bottom(), 0.f);
+    int bottom = std::max(m_rootVisibleRect.height() - scissorRect.bottom(), 0);
     GLC(m_context, m_context->scissor(scissorRect.x(), bottom, scissorRect.width(), scissorRect.height()));
+    m_currentScissorRect = scissorRect;
 }
 
 bool LayerRendererChromium::makeContextCurrent()
diff --git a/WebCore/platform/graphics/chromium/LayerRendererChromium.h b/WebCore/platform/graphics/chromium/LayerRendererChromium.h
index 364971c..6a06105 100644
--- a/WebCore/platform/graphics/chromium/LayerRendererChromium.h
+++ b/WebCore/platform/graphics/chromium/LayerRendererChromium.h
@@ -92,6 +92,8 @@ public:
     unsigned createLayerTexture();
     void deleteLayerTexture(unsigned);
 
+    IntRect currentScissorRect() const { return m_currentScissorRect; }
+
     static void debugGLCall(GraphicsContext3D*, const char* command, const char* file, int line);
 
     const TransformationMatrix& projectionMatrix() const { return m_projectionMatrix; }
@@ -116,7 +118,7 @@ private:
 
     void updateLayersRecursive(LayerChromium* layer, const TransformationMatrix& parentMatrix, float opacity);
 
-    void drawLayersRecursive(LayerChromium*, const FloatRect& scissorRect);
+    void drawLayersRecursive(LayerChromium*);
 
     void drawLayer(LayerChromium*);
 
@@ -124,7 +126,7 @@ private:
 
     void drawLayerIntoStencilBuffer(LayerChromium*, bool decrement);
 
-    void scissorToRect(const FloatRect&);
+    void scissorToRect(const IntRect&);
 
     bool makeContextCurrent();
 
@@ -163,6 +165,7 @@ private:
 
     IntRect m_rootVisibleRect;
     IntRect m_rootContentRect;
+    IntRect m_currentScissorRect;
 
     int m_maxTextureSize;
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list