[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 13:49:34 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 3c78c631e75748aab1fc8b7f96d413af9cf93baf
Author: vangelis at chromium.org <vangelis at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Sep 27 23:35:40 2010 +0000

    2010-09-27  Vangelis Kokkevis  <vangelis at chromium.org>
    
            Reviewed by James Robinson.
    
            [chromium] WebViewImpl now holds a ref counted pointer to the LayerRendererChromium
            to ensure that the compositor does not get destroyed before the layers used
            by it do. This was done to ensure that layers properly clean up their texture
            resources on destruction.
            https://bugs.webkit.org/show_bug.cgi?id=46139
    
            * src/WebViewImpl.cpp:
            (WebKit::WebViewImpl::setIsAcceleratedCompositingActive):
            * src/WebViewImpl.h:
    2010-09-27  Vangelis Kokkevis  <vangelis at chromium.org>
    
            Reviewed by James Robinson.
    
            [chromium] Making LayerChromium's destructor virtual so that the appropriate
            derived class destructors get called when the layer tree is taken down.
            ContentLayerChromium and its derived types (ImageLayerChromium for now) will
            free up the texture allocated for their contents upon destruction. To avoid
            having the LayerRendererChromium destructor getting called before the layers
            are destroyed and thus leaving their textures orphaned, the layers now hold
            a ref counted pointer to the renderer that uses them.
            https://bugs.webkit.org/show_bug.cgi?id=46139
    
            * platform/graphics/chromium/ContentLayerChromium.cpp:
            (WebCore::ContentLayerChromium::~ContentLayerChromium):
            (WebCore::ContentLayerChromium::setLayerRenderer):
            (WebCore::ContentLayerChromium::cleanupResources):
            * platform/graphics/chromium/ContentLayerChromium.h:
            * platform/graphics/chromium/LayerChromium.cpp:
            (WebCore::LayerChromium::setLayerRenderer):
            * platform/graphics/chromium/LayerChromium.h:
            (WebCore::LayerChromium::layerRenderer):
            * platform/graphics/chromium/LayerRendererChromium.cpp:
            (WebCore::LayerRendererChromium::create):
            (WebCore::LayerRendererChromium::deleteLayerTexture):
            (WebCore::LayerRendererChromium::cleanupSharedObjects):
            * platform/graphics/chromium/LayerRendererChromium.h:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@68442 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index ac75c44..28b7ea6 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,31 @@
+2010-09-27  Vangelis Kokkevis  <vangelis at chromium.org>
+
+        Reviewed by James Robinson.
+
+        [chromium] Making LayerChromium's destructor virtual so that the appropriate
+        derived class destructors get called when the layer tree is taken down.
+        ContentLayerChromium and its derived types (ImageLayerChromium for now) will
+        free up the texture allocated for their contents upon destruction. To avoid
+        having the LayerRendererChromium destructor getting called before the layers
+        are destroyed and thus leaving their textures orphaned, the layers now hold
+        a ref counted pointer to the renderer that uses them.
+        https://bugs.webkit.org/show_bug.cgi?id=46139
+
+        * platform/graphics/chromium/ContentLayerChromium.cpp:
+        (WebCore::ContentLayerChromium::~ContentLayerChromium):
+        (WebCore::ContentLayerChromium::setLayerRenderer):
+        (WebCore::ContentLayerChromium::cleanupResources):
+        * platform/graphics/chromium/ContentLayerChromium.h:
+        * platform/graphics/chromium/LayerChromium.cpp:
+        (WebCore::LayerChromium::setLayerRenderer):
+        * platform/graphics/chromium/LayerChromium.h:
+        (WebCore::LayerChromium::layerRenderer):
+        * platform/graphics/chromium/LayerRendererChromium.cpp:
+        (WebCore::LayerRendererChromium::create):
+        (WebCore::LayerRendererChromium::deleteLayerTexture):
+        (WebCore::LayerRendererChromium::cleanupSharedObjects):
+        * platform/graphics/chromium/LayerRendererChromium.h:
+
 2010-09-27  Erik Arvidsson  <arv at chromium.org>
 
         Reviewed by Darin Adler.
diff --git a/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp b/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp
index 86be8da..8dda4d6 100644
--- a/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp
+++ b/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp
@@ -126,10 +126,28 @@ ContentLayerChromium::ContentLayerChromium(GraphicsLayerChromium* owner)
 
 ContentLayerChromium::~ContentLayerChromium()
 {
-    if (m_contentsTexture)
-        GLC(layerRendererContext(), layerRendererContext()->deleteTexture(m_contentsTexture));
+    cleanupResources();
 }
 
+void ContentLayerChromium::setLayerRenderer(LayerRendererChromium* renderer)
+{
+    // If we're changing layer renderers then we need to free up any resources
+    // allocated by the old renderer.
+    if (layerRenderer() && layerRenderer() != renderer)
+        cleanupResources();
+
+    LayerChromium::setLayerRenderer(renderer);
+}
+
+void ContentLayerChromium::cleanupResources()
+{
+    if (layerRenderer()) {
+        if (m_contentsTexture) {
+            layerRenderer()->deleteLayerTexture(m_contentsTexture);
+            m_contentsTexture = 0;
+        }
+    }
+}
 
 void ContentLayerChromium::updateContents()
 {
diff --git a/WebCore/platform/graphics/chromium/ContentLayerChromium.h b/WebCore/platform/graphics/chromium/ContentLayerChromium.h
index a79189f..412ba06 100644
--- a/WebCore/platform/graphics/chromium/ContentLayerChromium.h
+++ b/WebCore/platform/graphics/chromium/ContentLayerChromium.h
@@ -44,11 +44,12 @@ class ContentLayerChromium : public LayerChromium {
 public:
     static PassRefPtr<ContentLayerChromium> create(GraphicsLayerChromium* owner = 0);
 
-    ~ContentLayerChromium();
+    virtual ~ContentLayerChromium();
 
     virtual void updateContents();
     virtual void draw();
     virtual bool drawsContent() { return m_owner && m_owner->drawsContent(); }
+    virtual void setLayerRenderer(LayerRendererChromium*);
 
     // Stores values that are shared between instances of this class that are
     // associated with the same LayerRendererChromium (and hence the same GL
@@ -79,6 +80,8 @@ protected:
     void updateTextureRect(void* pixels, const IntSize& bitmapSize, const IntSize& requiredTextureSize,
                            const IntRect& updateRect, unsigned textureId);
 
+    void cleanupResources();
+
     unsigned m_contentsTexture;
     IntSize m_allocatedTextureSize;
     bool m_skipsDraw;
diff --git a/WebCore/platform/graphics/chromium/LayerChromium.cpp b/WebCore/platform/graphics/chromium/LayerChromium.cpp
index e36c69d..98ba3f0 100644
--- a/WebCore/platform/graphics/chromium/LayerChromium.cpp
+++ b/WebCore/platform/graphics/chromium/LayerChromium.cpp
@@ -174,9 +174,6 @@ LayerChromium::~LayerChromium()
 
 void LayerChromium::setLayerRenderer(LayerRendererChromium* renderer)
 {
-    // It's not expected that layers will ever switch renderers.
-    ASSERT(!renderer || !m_layerRenderer || renderer == m_layerRenderer);
-
     m_layerRenderer = renderer;
 }
 
diff --git a/WebCore/platform/graphics/chromium/LayerChromium.h b/WebCore/platform/graphics/chromium/LayerChromium.h
index 5a493e6..0a66318 100644
--- a/WebCore/platform/graphics/chromium/LayerChromium.h
+++ b/WebCore/platform/graphics/chromium/LayerChromium.h
@@ -62,7 +62,7 @@ class LayerChromium : public RefCounted<LayerChromium> {
 public:
     static PassRefPtr<LayerChromium> create(GraphicsLayerChromium* owner = 0);
 
-    ~LayerChromium();
+    virtual ~LayerChromium();
 
     const LayerChromium* rootLayer() const;
     LayerChromium* superlayer() const;
@@ -147,7 +147,9 @@ public:
 
     bool preserves3D() { return m_owner && m_owner->preserves3D(); }
 
-    void setLayerRenderer(LayerRendererChromium*);
+    // Derived types must override this method if they need to react to a change
+    // in the LayerRendererChromium.
+    virtual void setLayerRenderer(LayerRendererChromium*);
 
     void setOwner(GraphicsLayerChromium* owner) { m_owner = owner; }
 
@@ -200,7 +202,7 @@ protected:
     GraphicsLayerChromium* m_owner;
     LayerChromium(GraphicsLayerChromium* owner);
 
-    LayerRendererChromium* layerRenderer() const { return m_layerRenderer; }
+    LayerRendererChromium* layerRenderer() const { return m_layerRenderer.get(); }
     GraphicsContext3D* layerRendererContext() const;
 
     static void drawTexturedQuad(GraphicsContext3D*, const TransformationMatrix& projectionMatrix, const TransformationMatrix& layerMatrix,
@@ -260,7 +262,7 @@ private:
     bool m_needsDisplayOnBoundsChange;
 
     // Points to the layer renderer that updates and draws this layer.
-    LayerRendererChromium* m_layerRenderer;
+    RefPtr<LayerRendererChromium> m_layerRenderer;
 
     FloatRect m_frame;
     TransformationMatrix m_transform;
diff --git a/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp b/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
index 6a20887..ce9533d 100644
--- a/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
+++ b/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
@@ -73,12 +73,12 @@ static inline bool compareLayerZ(const LayerChromium* a, const LayerChromium* b)
     return transformA.m43() < transformB.m43();
 }
 
-PassOwnPtr<LayerRendererChromium> LayerRendererChromium::create(PassOwnPtr<GraphicsContext3D> context)
+PassRefPtr<LayerRendererChromium> LayerRendererChromium::create(PassOwnPtr<GraphicsContext3D> context)
 {
     if (!context)
         return 0;
 
-    OwnPtr<LayerRendererChromium> layerRenderer(new LayerRendererChromium(context));
+    RefPtr<LayerRendererChromium> layerRenderer(adoptRef(new LayerRendererChromium(context)));
     if (!layerRenderer->hardwareCompositing())
         return 0;
 
@@ -380,6 +380,14 @@ unsigned LayerRendererChromium::createLayerTexture()
     return textureId;
 }
 
+void LayerRendererChromium::deleteLayerTexture(unsigned textureId)
+{
+    if (!textureId)
+        return;
+
+    GLC(m_context, m_context->deleteTexture(textureId));
+}
+
 // Returns true if any part of the layer falls within the visibleRect
 bool LayerRendererChromium::isLayerVisible(LayerChromium* layer, const TransformationMatrix& matrix, const IntRect& visibleRect)
 {
@@ -738,7 +746,7 @@ void LayerRendererChromium::cleanupSharedObjects()
     }
 
     if (m_rootLayerTextureId) {
-        GLC(m_context, m_context->deleteTexture(m_rootLayerTextureId));
+        deleteLayerTexture(m_rootLayerTextureId);
         m_rootLayerTextureId = 0;
     }
 }
diff --git a/WebCore/platform/graphics/chromium/LayerRendererChromium.h b/WebCore/platform/graphics/chromium/LayerRendererChromium.h
index c733228..a051c2e 100644
--- a/WebCore/platform/graphics/chromium/LayerRendererChromium.h
+++ b/WebCore/platform/graphics/chromium/LayerRendererChromium.h
@@ -42,6 +42,8 @@
 #include <wtf/HashMap.h>
 #include <wtf/Noncopyable.h>
 #include <wtf/PassOwnPtr.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
 #include <wtf/Vector.h>
 
 #if PLATFORM(CG)
@@ -54,9 +56,9 @@ namespace WebCore {
 class GraphicsContext3D;
 
 // Class that handles drawing of composited render layers using GL.
-class LayerRendererChromium : public Noncopyable {
+class LayerRendererChromium : public RefCounted<LayerRendererChromium> {
 public:
-    static PassOwnPtr<LayerRendererChromium> create(PassOwnPtr<GraphicsContext3D> graphicsContext3D);
+    static PassRefPtr<LayerRendererChromium> create(PassOwnPtr<GraphicsContext3D> graphicsContext3D);
 
     LayerRendererChromium(PassOwnPtr<GraphicsContext3D> graphicsContext3D);
     ~LayerRendererChromium();
@@ -90,6 +92,7 @@ public:
     GraphicsContext* rootLayerGraphicsContext() const { return m_rootLayerGraphicsContext.get(); }
 
     unsigned createLayerTexture();
+    void deleteLayerTexture(unsigned);
 
     static void debugGLCall(GraphicsContext3D*, const char* command, const char* file, int line);
 
diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog
index 6528e9e..5636de1 100644
--- a/WebKit/chromium/ChangeLog
+++ b/WebKit/chromium/ChangeLog
@@ -1,3 +1,17 @@
+2010-09-27  Vangelis Kokkevis  <vangelis at chromium.org>
+
+        Reviewed by James Robinson.
+
+        [chromium] WebViewImpl now holds a ref counted pointer to the LayerRendererChromium
+        to ensure that the compositor does not get destroyed before the layers used
+        by it do. This was done to ensure that layers properly clean up their texture
+        resources on destruction.
+        https://bugs.webkit.org/show_bug.cgi?id=46139
+
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::setIsAcceleratedCompositingActive):
+        * src/WebViewImpl.h:
+
 2010-09-24  Zhenyao Mo  <zmo at google.com>
 
         Reviewed by Kenneth Russell.
diff --git a/WebKit/chromium/src/WebViewImpl.cpp b/WebKit/chromium/src/WebViewImpl.cpp
index b467517..b12a7c8 100644
--- a/WebKit/chromium/src/WebViewImpl.cpp
+++ b/WebKit/chromium/src/WebViewImpl.cpp
@@ -2311,6 +2311,8 @@ void WebViewImpl::setIsAcceleratedCompositingActive(bool active)
             m_compositorCreationFailed = true;
         }
     } else {
+        if (m_layerRenderer)
+            m_layerRenderer->setRootLayer(0);
         m_layerRenderer = 0;
         m_isAcceleratedCompositingActive = false;
     }
diff --git a/WebKit/chromium/src/WebViewImpl.h b/WebKit/chromium/src/WebViewImpl.h
index 8ceffd3..c56dd8c 100644
--- a/WebKit/chromium/src/WebViewImpl.h
+++ b/WebKit/chromium/src/WebViewImpl.h
@@ -523,7 +523,7 @@ private:
 
 #if USE(ACCELERATED_COMPOSITING)
     WebCore::IntRect m_scrollDamage;
-    OwnPtr<WebCore::LayerRendererChromium> m_layerRenderer;
+    RefPtr<WebCore::LayerRendererChromium> m_layerRenderer;
     bool m_isAcceleratedCompositingActive;
     bool m_compositorCreationFailed;
 #endif

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list