From f82cc5ec8eae9cc067698e2441d9e87e62aa37cb Mon Sep 17 00:00:00 2001 From: "commit-queue@webkit.org" Date: Tue, 20 Sep 2011 01:49:52 +0000 Subject: [PATCH] [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 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): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@95506 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebCore/ChangeLog | 22 ++++++++++++++++++++++ .../graphics/chromium/ContentLayerChromium.h | 2 +- .../graphics/chromium/ImageLayerChromium.cpp | 5 ++--- .../graphics/chromium/ImageLayerChromium.h | 2 +- .../graphics/chromium/LayerTextureUpdater.h | 6 ++---- .../chromium/LayerTextureUpdaterCanvas.cpp | 8 ++++---- .../graphics/chromium/LayerTextureUpdaterCanvas.h | 8 +++----- .../graphics/chromium/TiledLayerChromium.cpp | 5 +++++ 8 files changed, 40 insertions(+), 18 deletions(-) diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 34f3011..2eaf990 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,25 @@ +2011-09-19 James Robinson + + [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 Eliminate Length::undefinedLength = -1 and replace with Undefined LengthType. diff --git a/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h b/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h index 4e4a3ff..a21bc68 100644 --- a/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h +++ b/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h @@ -59,7 +59,7 @@ private: virtual void createTextureUpdater(const CCLayerTreeHost*); virtual LayerTextureUpdater* textureUpdater() const { return m_textureUpdater.get(); } - OwnPtr m_textureUpdater; + RefPtr m_textureUpdater; }; } diff --git a/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp index 48b31d4..ebc90f3 100644 --- a/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp +++ b/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp @@ -45,11 +45,10 @@ namespace WebCore { class ImageLayerTextureUpdater : public LayerTextureUpdater { - WTF_MAKE_NONCOPYABLE(ImageLayerTextureUpdater); public: - static PassOwnPtr create(bool useMapTexSubImage) + static PassRefPtr create(bool useMapTexSubImage) { - return adoptPtr(new ImageLayerTextureUpdater(useMapTexSubImage)); + return adoptRef(new ImageLayerTextureUpdater(useMapTexSubImage)); } virtual ~ImageLayerTextureUpdater() { } diff --git a/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.h b/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.h index ad5e696..1afccfe 100644 --- a/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.h +++ b/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.h @@ -70,7 +70,7 @@ private: NativeImagePtr m_imageForCurrentFrame; RefPtr m_contents; - OwnPtr m_textureUpdater; + RefPtr m_textureUpdater; }; } diff --git a/Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h b/Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h index 5c6eb20..2623778 100644 --- a/Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h +++ b/Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h @@ -30,7 +30,7 @@ #if USE(ACCELERATED_COMPOSITING) #include "GraphicsTypes3D.h" -#include +#include namespace WebCore { @@ -39,10 +39,8 @@ class IntRect; class IntSize; class ManagedTexture; -class LayerTextureUpdater { - WTF_MAKE_NONCOPYABLE(LayerTextureUpdater); +class LayerTextureUpdater : public RefCounted { public: - LayerTextureUpdater() { } virtual ~LayerTextureUpdater() { } enum Orientation { diff --git a/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp b/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp index c14cb4b..6cecc2a 100644 --- a/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp +++ b/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp @@ -61,9 +61,9 @@ void LayerTextureUpdaterCanvas::paintContents(GraphicsContext& context, const In m_contentRect = contentRect; } -PassOwnPtr LayerTextureUpdaterBitmap::create(PassOwnPtr painter, bool useMapTexSubImage) +PassRefPtr LayerTextureUpdaterBitmap::create(PassOwnPtr painter, bool useMapTexSubImage) { - return adoptPtr(new LayerTextureUpdaterBitmap(painter, useMapTexSubImage)); + return adoptRef(new LayerTextureUpdaterBitmap(painter, useMapTexSubImage)); } LayerTextureUpdaterBitmap::LayerTextureUpdaterBitmap(PassOwnPtr painter, bool useMapTexSubImage) @@ -103,9 +103,9 @@ void LayerTextureUpdaterBitmap::updateTextureRect(GraphicsContext3D* context, Ma #if !USE(THREADED_COMPOSITING) #if USE(SKIA) -PassOwnPtr LayerTextureUpdaterSkPicture::create(PassOwnPtr painter) +PassRefPtr LayerTextureUpdaterSkPicture::create(PassOwnPtr painter) { - return adoptPtr(new LayerTextureUpdaterSkPicture(painter)); + return adoptRef(new LayerTextureUpdaterSkPicture(painter)); } LayerTextureUpdaterSkPicture::LayerTextureUpdaterSkPicture(PassOwnPtr painter) diff --git a/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.h b/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.h index 6572997..49cb216 100644 --- a/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.h +++ b/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.h @@ -34,6 +34,7 @@ #include "LayerTextureUpdater.h" #include "PlatformCanvas.h" #include +#include #if USE(SKIA) #include "SkPicture.h" @@ -50,7 +51,6 @@ class LayerPainterChromium; // A LayerTextureUpdater with an internal canvas. class LayerTextureUpdaterCanvas : public LayerTextureUpdater { - WTF_MAKE_NONCOPYABLE(LayerTextureUpdaterCanvas); protected: explicit LayerTextureUpdaterCanvas(PassOwnPtr); @@ -65,9 +65,8 @@ private: // A LayerTextureUpdater with an internal bitmap canvas. class LayerTextureUpdaterBitmap : public LayerTextureUpdaterCanvas { - WTF_MAKE_NONCOPYABLE(LayerTextureUpdaterBitmap); public: - static PassOwnPtr create(PassOwnPtr, bool useMapTexSubImage); + static PassRefPtr create(PassOwnPtr, bool useMapTexSubImage); virtual Orientation orientation() { return LayerTextureUpdater::BottomUpOrientation; } virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat); @@ -82,9 +81,8 @@ private: #if USE(SKIA) class LayerTextureUpdaterSkPicture : public LayerTextureUpdaterCanvas { - WTF_MAKE_NONCOPYABLE(LayerTextureUpdaterSkPicture); public: - static PassOwnPtr create(PassOwnPtr); + static PassRefPtr create(PassOwnPtr); virtual ~LayerTextureUpdaterSkPicture(); virtual Orientation orientation() { return LayerTextureUpdater::TopDownOrientation; } diff --git a/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp index 7a34a6e..42693ea 100644 --- a/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp +++ b/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp @@ -415,6 +415,11 @@ void TiledLayerChromium::prepareToUpdate(const IntRect& contentRect) 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 protector(textureUpdater()); textureUpdater()->prepareToUpdate(m_paintRect, m_tiler->tileSize(), m_tiler->hasBorderTexels()); } -- 2.7.4