Title: [95506] trunk/Source/WebCore
Revision
95506
Author
[email protected]
Date
2011-09-19 18:49:52 -0700 (Mon, 19 Sep 2011)

Log Message

[chromium] ContentLayer's texture updater deleted during paint when compositing turns off in the middle of paint
https://bugs.webkit.org/show_bug.cgi?id=68405

Patch by James Robinson <[email protected]> on 2011-09-19
Reviewed by Kenneth Russell.

Make TiledLayerChromium's textureUpdater refcounted and hold an explicit reference during paint in case
compositing is turned off halfway through a paint.

* platform/graphics/chromium/ContentLayerChromium.h:
* platform/graphics/chromium/ImageLayerChromium.cpp:
(WebCore::ImageLayerTextureUpdater::create):
* platform/graphics/chromium/ImageLayerChromium.h:
* platform/graphics/chromium/LayerTextureUpdater.h:
* platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp:
(WebCore::LayerTextureUpdaterBitmap::create):
(WebCore::LayerTextureUpdaterSkPicture::create):
* platform/graphics/chromium/LayerTextureUpdaterCanvas.h:
* platform/graphics/chromium/TiledLayerChromium.cpp:
(WebCore::TiledLayerChromium::prepareToUpdate):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (95505 => 95506)


--- trunk/Source/WebCore/ChangeLog	2011-09-20 01:44:56 UTC (rev 95505)
+++ trunk/Source/WebCore/ChangeLog	2011-09-20 01:49:52 UTC (rev 95506)
@@ -1,3 +1,25 @@
+2011-09-19  James Robinson  <[email protected]>
+
+        [chromium] ContentLayer's texture updater deleted during paint when compositing turns off in the middle of paint
+        https://bugs.webkit.org/show_bug.cgi?id=68405
+
+        Reviewed by Kenneth Russell.
+
+        Make TiledLayerChromium's textureUpdater refcounted and hold an explicit reference during paint in case
+        compositing is turned off halfway through a paint.
+
+        * platform/graphics/chromium/ContentLayerChromium.h:
+        * platform/graphics/chromium/ImageLayerChromium.cpp:
+        (WebCore::ImageLayerTextureUpdater::create):
+        * platform/graphics/chromium/ImageLayerChromium.h:
+        * platform/graphics/chromium/LayerTextureUpdater.h:
+        * platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp:
+        (WebCore::LayerTextureUpdaterBitmap::create):
+        (WebCore::LayerTextureUpdaterSkPicture::create):
+        * platform/graphics/chromium/LayerTextureUpdaterCanvas.h:
+        * platform/graphics/chromium/TiledLayerChromium.cpp:
+        (WebCore::TiledLayerChromium::prepareToUpdate):
+
 2011-09-19  Luke Macpherson   <[email protected]>
 
         Eliminate Length::undefinedLength = -1 and replace with Undefined LengthType.

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


--- trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h	2011-09-20 01:44:56 UTC (rev 95505)
+++ trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h	2011-09-20 01:49:52 UTC (rev 95506)
@@ -59,7 +59,7 @@
     virtual void createTextureUpdater(const CCLayerTreeHost*);
     virtual LayerTextureUpdater* textureUpdater() const { return m_textureUpdater.get(); }
 
-    OwnPtr<LayerTextureUpdater> m_textureUpdater;
+    RefPtr<LayerTextureUpdater> m_textureUpdater;
 };
 
 }

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


--- trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp	2011-09-20 01:44:56 UTC (rev 95505)
+++ trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp	2011-09-20 01:49:52 UTC (rev 95506)
@@ -45,11 +45,10 @@
 namespace WebCore {
 
 class ImageLayerTextureUpdater : public LayerTextureUpdater {
-    WTF_MAKE_NONCOPYABLE(ImageLayerTextureUpdater);
 public:
-    static PassOwnPtr<ImageLayerTextureUpdater> create(bool useMapTexSubImage)
+    static PassRefPtr<ImageLayerTextureUpdater> create(bool useMapTexSubImage)
     {
-        return adoptPtr(new ImageLayerTextureUpdater(useMapTexSubImage));
+        return adoptRef(new ImageLayerTextureUpdater(useMapTexSubImage));
     }
 
     virtual ~ImageLayerTextureUpdater() { }

Modified: trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.h (95505 => 95506)


--- trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.h	2011-09-20 01:44:56 UTC (rev 95505)
+++ trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.h	2011-09-20 01:49:52 UTC (rev 95506)
@@ -70,7 +70,7 @@
     NativeImagePtr m_imageForCurrentFrame;
     RefPtr<Image> m_contents;
 
-    OwnPtr<ImageLayerTextureUpdater> m_textureUpdater;
+    RefPtr<ImageLayerTextureUpdater> m_textureUpdater;
 };
 
 }

Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h (95505 => 95506)


--- trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h	2011-09-20 01:44:56 UTC (rev 95505)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h	2011-09-20 01:49:52 UTC (rev 95506)
@@ -30,7 +30,7 @@
 #if USE(ACCELERATED_COMPOSITING)
 
 #include "GraphicsTypes3D.h"
-#include <wtf/Noncopyable.h>
+#include <wtf/RefCounted.h>
 
 namespace WebCore {
 
@@ -39,10 +39,8 @@
 class IntSize;
 class ManagedTexture;
 
-class LayerTextureUpdater {
-    WTF_MAKE_NONCOPYABLE(LayerTextureUpdater);
+class LayerTextureUpdater : public RefCounted<LayerTextureUpdater> {
 public:
-    LayerTextureUpdater() { }
     virtual ~LayerTextureUpdater() { }
 
     enum Orientation {

Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp (95505 => 95506)


--- trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp	2011-09-20 01:44:56 UTC (rev 95505)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp	2011-09-20 01:49:52 UTC (rev 95506)
@@ -61,9 +61,9 @@
     m_contentRect = contentRect;
 }
 
-PassOwnPtr<LayerTextureUpdaterBitmap> LayerTextureUpdaterBitmap::create(PassOwnPtr<LayerPainterChromium> painter, bool useMapTexSubImage)
+PassRefPtr<LayerTextureUpdaterBitmap> LayerTextureUpdaterBitmap::create(PassOwnPtr<LayerPainterChromium> painter, bool useMapTexSubImage)
 {
-    return adoptPtr(new LayerTextureUpdaterBitmap(painter, useMapTexSubImage));
+    return adoptRef(new LayerTextureUpdaterBitmap(painter, useMapTexSubImage));
 }
 
 LayerTextureUpdaterBitmap::LayerTextureUpdaterBitmap(PassOwnPtr<LayerPainterChromium> painter, bool useMapTexSubImage)
@@ -103,9 +103,9 @@
 
 #if !USE(THREADED_COMPOSITING)
 #if USE(SKIA)
-PassOwnPtr<LayerTextureUpdaterSkPicture> LayerTextureUpdaterSkPicture::create(PassOwnPtr<LayerPainterChromium> painter)
+PassRefPtr<LayerTextureUpdaterSkPicture> LayerTextureUpdaterSkPicture::create(PassOwnPtr<LayerPainterChromium> painter)
 {
-    return adoptPtr(new LayerTextureUpdaterSkPicture(painter));
+    return adoptRef(new LayerTextureUpdaterSkPicture(painter));
 }
 
 LayerTextureUpdaterSkPicture::LayerTextureUpdaterSkPicture(PassOwnPtr<LayerPainterChromium> painter)

Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.h (95505 => 95506)


--- trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.h	2011-09-20 01:44:56 UTC (rev 95505)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.h	2011-09-20 01:49:52 UTC (rev 95506)
@@ -34,6 +34,7 @@
 #include "LayerTextureUpdater.h"
 #include "PlatformCanvas.h"
 #include <wtf/PassOwnPtr.h>
+#include <wtf/PassRefPtr.h>
 
 #if USE(SKIA)
 #include "SkPicture.h"
@@ -50,7 +51,6 @@
 
 // A LayerTextureUpdater with an internal canvas.
 class LayerTextureUpdaterCanvas : public LayerTextureUpdater {
-    WTF_MAKE_NONCOPYABLE(LayerTextureUpdaterCanvas);
 protected:
     explicit LayerTextureUpdaterCanvas(PassOwnPtr<LayerPainterChromium>);
 
@@ -65,9 +65,8 @@
 
 // A LayerTextureUpdater with an internal bitmap canvas.
 class LayerTextureUpdaterBitmap : public LayerTextureUpdaterCanvas {
-    WTF_MAKE_NONCOPYABLE(LayerTextureUpdaterBitmap);
 public:
-    static PassOwnPtr<LayerTextureUpdaterBitmap> create(PassOwnPtr<LayerPainterChromium>, bool useMapTexSubImage);
+    static PassRefPtr<LayerTextureUpdaterBitmap> create(PassOwnPtr<LayerPainterChromium>, bool useMapTexSubImage);
 
     virtual Orientation orientation() { return LayerTextureUpdater::BottomUpOrientation; }
     virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat);
@@ -82,9 +81,8 @@
 
 #if USE(SKIA)
 class LayerTextureUpdaterSkPicture : public LayerTextureUpdaterCanvas {
-    WTF_MAKE_NONCOPYABLE(LayerTextureUpdaterSkPicture);
 public:
-    static PassOwnPtr<LayerTextureUpdaterSkPicture> create(PassOwnPtr<LayerPainterChromium>);
+    static PassRefPtr<LayerTextureUpdaterSkPicture> create(PassOwnPtr<LayerPainterChromium>);
     virtual ~LayerTextureUpdaterSkPicture();
 
     virtual Orientation orientation() { return LayerTextureUpdater::TopDownOrientation; }

Modified: trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp (95505 => 95506)


--- trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp	2011-09-20 01:44:56 UTC (rev 95505)
+++ trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp	2011-09-20 01:49:52 UTC (rev 95506)
@@ -415,6 +415,11 @@
     if (dirtyLayerRect.isEmpty())
         return;
 
+    // Calling prepareToUpdate() calls into WebKit to paint, which may have the side
+    // effect of disabling compositing, which causes our reference to the texture updater to be deleted.
+    // However, we can't free the memory backing the GraphicsContext until the paint finishes,
+    // so we grab a local reference here to hold the updater alive until the paint completes.
+    RefPtr<LayerTextureUpdater> protector(textureUpdater());
     textureUpdater()->prepareToUpdate(m_paintRect, m_tiler->tileSize(), m_tiler->hasBorderTexels());
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to