[SCM] WebKit Debian packaging branch, webkit-1.3, updated. upstream/1.3.7-4207-g178b198

enne at google.com enne at google.com
Sun Feb 20 23:19:22 UTC 2011


The following commit has been merged in the webkit-1.3 branch:
commit 3ac1cb06b4f4c57e47f024e48b48eb3e4fb0a48c
Author: enne at google.com <enne at google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Jan 19 22:29:13 2011 +0000

    2011-01-19  Adrienne Walker  <enne at google.com>
    
            Reviewed by Kenneth Russell.
    
            [chromium] Tiled compositor should use texture manager
            https://bugs.webkit.org/show_bug.cgi?id=52418
    
            Test: compositing/
    
            * platform/graphics/chromium/LayerRendererChromium.cpp:
            (WebCore::LayerRendererChromium::~LayerRendererChromium):
            (WebCore::LayerRendererChromium::cleanupSharedObjects):
            * platform/graphics/chromium/LayerTilerChromium.cpp:
            (WebCore::LayerTilerChromium::LayerTilerChromium):
            (WebCore::LayerTilerChromium::reset):
            (WebCore::LayerTilerChromium::createTile):
            (WebCore::LayerTilerChromium::update):
            (WebCore::LayerTilerChromium::draw):
            * platform/graphics/chromium/LayerTilerChromium.h:
            (WebCore::LayerTilerChromium::Tile::Tile):
            (WebCore::LayerTilerChromium::Tile::texture):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76165 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 6ee4a0c..3b44eea 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,25 @@
+2011-01-19  Adrienne Walker  <enne at google.com>
+
+        Reviewed by Kenneth Russell.
+
+        [chromium] Tiled compositor should use texture manager
+        https://bugs.webkit.org/show_bug.cgi?id=52418
+
+        Test: compositing/
+
+        * platform/graphics/chromium/LayerRendererChromium.cpp:
+        (WebCore::LayerRendererChromium::~LayerRendererChromium):
+        (WebCore::LayerRendererChromium::cleanupSharedObjects):
+        * platform/graphics/chromium/LayerTilerChromium.cpp:
+        (WebCore::LayerTilerChromium::LayerTilerChromium):
+        (WebCore::LayerTilerChromium::reset):
+        (WebCore::LayerTilerChromium::createTile):
+        (WebCore::LayerTilerChromium::update):
+        (WebCore::LayerTilerChromium::draw):
+        * platform/graphics/chromium/LayerTilerChromium.h:
+        (WebCore::LayerTilerChromium::Tile::Tile):
+        (WebCore::LayerTilerChromium::Tile::texture):
+
 2011-01-19  Stephen White  <senorblanco at chromium.org>
 
         Unreviewed; build fix for chromium.
diff --git a/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp b/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
index 8d77bea..728339e 100644
--- a/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
+++ b/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
@@ -119,12 +119,6 @@ LayerRendererChromium::LayerRendererChromium(PassRefPtr<GraphicsContext3D> conte
 LayerRendererChromium::~LayerRendererChromium()
 {
     cleanupSharedObjects();
-
-    // Because the tilers need to clean up textures, clean them up explicitly
-    // before the GraphicsContext3D is destroyed.
-    m_rootLayerTiler.clear();
-    m_horizontalScrollbarTiler.clear();
-    m_verticalScrollbarTiler.clear();
 }
 
 GraphicsContext3D* LayerRendererChromium::context()
@@ -795,6 +789,11 @@ void LayerRendererChromium::cleanupSharedObjects()
     if (m_offscreenFramebufferId)
         GLC(m_context.get(), m_context->deleteFramebuffer(m_offscreenFramebufferId));
 
+    // Clear tilers before the texture manager, as they have references to textures.
+    m_rootLayerTiler.clear();
+    m_horizontalScrollbarTiler.clear();
+    m_verticalScrollbarTiler.clear();
+
     m_textureManager.clear();
 }
 
diff --git a/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.cpp b/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.cpp
index b4b4a72..6b65e66 100644
--- a/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.cpp
+++ b/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.cpp
@@ -33,6 +33,7 @@
 #include "GraphicsContext.h"
 #include "GraphicsContext3D.h"
 #include "LayerRendererChromium.h"
+#include "LayerTexture.h"
 
 #if PLATFORM(SKIA)
 #include "NativeImageSkia.h"
@@ -54,7 +55,8 @@ PassOwnPtr<LayerTilerChromium> LayerTilerChromium::create(LayerRendererChromium*
 }
 
 LayerTilerChromium::LayerTilerChromium(LayerRendererChromium* layerRenderer, const IntSize& tileSize)
-    : m_layerRenderer(layerRenderer)
+    : m_skipsDraw(false)
+    , m_layerRenderer(layerRenderer)
 {
     setTileSize(tileSize);
 }
@@ -83,17 +85,7 @@ void LayerTilerChromium::setTileSize(const IntSize& size)
 
 void LayerTilerChromium::reset()
 {
-    for (size_t i = 0; i < m_tiles.size(); ++i) {
-        if (!m_tiles[i])
-            continue;
-        layerRenderer()->deleteLayerTexture(m_tiles[i]->releaseTextureId());
-    }
     m_tiles.clear();
-    for (size_t i = 0; i < m_unusedTiles.size(); ++i) {
-        if (!m_unusedTiles[i])
-            continue;
-        layerRenderer()->deleteLayerTexture(m_unusedTiles[i]->releaseTextureId());
-    }
     m_unusedTiles.clear();
 
     m_layerSize = IntSize();
@@ -110,12 +102,9 @@ LayerTilerChromium::Tile* LayerTilerChromium::createTile(int i, int j)
         m_tiles[index] = m_unusedTiles.last().release();
         m_unusedTiles.removeLast();
     } else {
-        const unsigned int textureId = layerRenderer()->createLayerTexture();
-        OwnPtr<Tile> tile = adoptPtr(new Tile(textureId));
-
         GraphicsContext3D* context = layerRendererContext();
-        GLC(context, context->texImage2DResourceSafe(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, m_tileSize.width(), m_tileSize.height(), 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE));
-
+        TextureManager* manager = layerRenderer()->textureManager();
+        OwnPtr<Tile> tile = adoptPtr(new Tile(LayerTexture::create(context, manager)));
         m_tiles[index] = tile.release();
     }
 
@@ -238,6 +227,9 @@ void LayerTilerChromium::invalidateEntireLayer()
 
 void LayerTilerChromium::update(TilePaintInterface& painter, const IntRect& contentRect)
 {
+    if (m_skipsDraw)
+        return;
+
     // Invalidate old tiles that were previously used but aren't in use this
     // frame so that they can get reused for new tiles.
     IntRect layerRect = contentRectToLayerRect(contentRect);
@@ -256,6 +248,8 @@ void LayerTilerChromium::update(TilePaintInterface& painter, const IntRect& cont
             Tile* tile = m_tiles[tileIndex(i, j)].get();
             if (!tile)
                 tile = createTile(i, j);
+            if (!tile->texture()->isValid(m_tileSize, GraphicsContext3D::RGBA))
+                tile->m_dirtyLayerRect = tileLayerRect(i, j);
             dirtyLayerRect.unite(tile->m_dirtyLayerRect);
         }
     }
@@ -318,6 +312,12 @@ void LayerTilerChromium::update(TilePaintInterface& painter, const IntRect& cont
             if (sourceRect.isEmpty())
                 continue;
 
+            if (!tile->texture()->reserve(m_tileSize, GraphicsContext3D::RGBA)) {
+                m_skipsDraw = true;
+                reset();
+                return;
+            }
+
             // Calculate tile-space rectangle to upload into.
             IntRect destRect(IntPoint(sourceRect.x() - anchor.x(), sourceRect.y() - anchor.y()), sourceRect.size());
             ASSERT(destRect.x() >= 0);
@@ -342,7 +342,7 @@ void LayerTilerChromium::update(TilePaintInterface& painter, const IntRect& cont
                 pixelSource = &m_tilePixels[0];
             }
 
-            GLC(context, context->bindTexture(GraphicsContext3D::TEXTURE_2D, tile->textureId()));
+            tile->texture()->bindTexture();
             GLC(context, context->texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, destRect.x(), destRect.y(), destRect.width(), destRect.height(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, pixelSource));
 
             tile->clearDirty();
@@ -357,6 +357,9 @@ void LayerTilerChromium::setLayerPosition(const IntPoint& layerPosition)
 
 void LayerTilerChromium::draw(const IntRect& contentRect)
 {
+    if (m_skipsDraw)
+        return;
+
     // We reuse the shader program used by ContentLayerChromium.
     GraphicsContext3D* context = layerRendererContext();
     const ContentLayerChromium::SharedValues* contentLayerValues = layerRenderer()->contentLayerSharedValues();
@@ -370,13 +373,15 @@ void LayerTilerChromium::draw(const IntRect& contentRect)
             Tile* tile = m_tiles[tileIndex(i, j)].get();
             ASSERT(tile);
 
-            GLC(context, context->bindTexture(GraphicsContext3D::TEXTURE_2D, tile->textureId()));
+            tile->texture()->bindTexture();
 
             TransformationMatrix tileMatrix;
             IntRect tileRect = tileContentRect(i, j);
             tileMatrix.translate3d(tileRect.x() - contentRect.x() + tileRect.width() / 2.0, tileRect.y() - contentRect.y() + tileRect.height() / 2.0, 0);
 
             LayerChromium::drawTexturedQuad(context, layerRenderer()->projectionMatrix(), tileMatrix, m_tileSize.width(), m_tileSize.height(), 1, contentLayerValues->shaderMatrixLocation(), contentLayerValues->shaderAlphaLocation());
+
+            tile->texture()->unreserve();
         }
     }
 }
@@ -410,21 +415,6 @@ void LayerTilerChromium::growLayerToContain(const IntRect& contentRect)
     resizeLayer(newSize);
 }
 
-LayerTilerChromium::Tile::~Tile()
-{
-    // Each tile doesn't have a reference to the context, so can't clean up
-    // its own texture.  If this assert is hit, then the LayerTilerChromium
-    // destructor didn't clean this up.
-    ASSERT(!m_textureId);
-}
-
-unsigned int LayerTilerChromium::Tile::releaseTextureId()
-{
-    unsigned int id = m_textureId;
-    m_textureId = 0;
-    return id;
-}
-
 } // namespace WebCore
 
 #endif // USE(ACCELERATED_COMPOSITING)
diff --git a/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.h b/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.h
index c066fdf..05f5242 100644
--- a/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.h
+++ b/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.h
@@ -30,6 +30,7 @@
 #if USE(ACCELERATED_COMPOSITING)
 
 #include "LayerChromium.h"
+#include "LayerTexture.h"
 #include <wtf/OwnArrayPtr.h>
 
 namespace WebCore {
@@ -61,13 +62,11 @@ public:
 private:
     LayerTilerChromium(LayerRendererChromium* layerRenderer, const IntSize& tileSize);
 
-    class Tile {
+    class Tile : public Noncopyable {
     public:
-        explicit Tile(unsigned int textureId) : m_textureId(textureId) { }
-        ~Tile();
+        explicit Tile(PassOwnPtr<LayerTexture> tex) : m_tex(tex) {}
 
-        unsigned int textureId() const { return m_textureId; }
-        unsigned int releaseTextureId();
+        LayerTexture* texture() { return m_tex.get(); }
 
         bool dirty() const { return !m_dirtyLayerRect.isEmpty(); }
         void clearDirty() { m_dirtyLayerRect = IntRect(); }
@@ -75,7 +74,7 @@ private:
         // Layer-space dirty rectangle that needs to be repainted.
         IntRect m_dirtyLayerRect;
     private:
-        unsigned int m_textureId;
+        OwnPtr<LayerTexture> m_tex;
     };
 
     void resizeLayer(const IntSize& size);
@@ -105,6 +104,8 @@ private:
     IntRect m_lastUpdateLayerRect;
     IntPoint m_layerPosition;
 
+    bool m_skipsDraw;
+
     // Logical 2D array of tiles (dimensions of m_layerTileSize)
     Vector<OwnPtr<Tile> > m_tiles;
     // Linear array of unused tiles.

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list