From 4b83315e1d0cd55c24aba2672347ea304dd80783 Mon Sep 17 00:00:00 2001 From: "jamesr@google.com" Date: Tue, 27 Sep 2011 19:41:24 +0000 Subject: [PATCH] [chromium] LayerRenderChromium asserts about leaking textures. https://bugs.webkit.org/show_bug.cgi?id=68190 Reviewed by Kenneth Russell. This introduces an interface TextureAllocator that the TextureManager uses to allocate/deallocate textures. This means that TextureManager does not need to depend directly on GraphicsContext3D, other than for the format enum type, making it more testable. It also allows us to track the allocations by subclassing TextureAllocator to make sure we aren't leaking any textures. * WebCore.gypi: * platform/graphics/chromium/Canvas2DLayerChromium.cpp: (WebCore::Canvas2DLayerChromium::updateCompositorResources): * platform/graphics/chromium/Canvas2DLayerChromium.h: * platform/graphics/chromium/ImageLayerChromium.cpp: (WebCore::ImageLayerTextureUpdater::updateTextureRect): * platform/graphics/chromium/LayerChromium.h: (WebCore::LayerChromium::updateCompositorResources): * platform/graphics/chromium/LayerRendererChromium.cpp: (WebCore::LayerRendererChromium::LayerRendererChromium): (WebCore::LayerRendererChromium::releaseRenderSurfaceTextures): (WebCore::LayerRendererChromium::drawLayers): (WebCore::LayerRendererChromium::useRenderSurface): (WebCore::LayerRendererChromium::initializeSharedObjects): (WebCore::LayerRendererChromium::cleanupSharedObjects): * platform/graphics/chromium/LayerRendererChromium.h: (WebCore::LayerRendererChromium::renderSurfaceTextureAllocator): (WebCore::LayerRendererChromium::contentsTextureAllocator): * platform/graphics/chromium/LayerTextureUpdater.h: * platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp: (WebCore::LayerTextureUpdaterBitmap::updateTextureRect): (WebCore::LayerTextureUpdaterSkPicture::updateTextureRect): * platform/graphics/chromium/LayerTextureUpdaterCanvas.h: * platform/graphics/chromium/ManagedTexture.cpp: (WebCore::ManagedTexture::bindTexture): (WebCore::ManagedTexture::framebufferTexture2D): * platform/graphics/chromium/ManagedTexture.h: * platform/graphics/chromium/TextureManager.cpp: (WebCore::TextureManager::memoryUseBytes): (WebCore::TextureManager::deleteEvictedTextures): (WebCore::TextureManager::evictAndDeleteAllTextures): (WebCore::TextureManager::removeTexture): (WebCore::TextureManager::allocateTexture): (WebCore::TextureManager::requestTexture): * platform/graphics/chromium/TextureManager.h: (WebCore::TextureAllocator::~TextureAllocator): * platform/graphics/chromium/TiledLayerChromium.cpp: (WebCore::TiledLayerChromium::updateCompositorResources): * platform/graphics/chromium/TiledLayerChromium.h: * platform/graphics/chromium/TrackingTextureAllocator.cpp: Added. (WebCore::TrackingTextureAllocator::TrackingTextureAllocator): (WebCore::TrackingTextureAllocator::~TrackingTextureAllocator): (WebCore::TrackingTextureAllocator::createTexture): (WebCore::TrackingTextureAllocator::deleteTexture): * platform/graphics/chromium/TrackingTextureAllocator.h: Copied from Source/WebCore/platform/graphics/chromium/ManagedTexture.h. (WebCore::TrackingTextureAllocator::create): (WebCore::TrackingTextureAllocator::currentMemoryUseBytes): * platform/graphics/chromium/VideoLayerChromium.cpp: (WebCore::VideoLayerChromium::updateCompositorResources): (WebCore::VideoLayerChromium::updateTexture): * platform/graphics/chromium/VideoLayerChromium.h: * platform/graphics/chromium/WebGLLayerChromium.cpp: (WebCore::WebGLLayerChromium::updateCompositorResources): * platform/graphics/chromium/WebGLLayerChromium.h: * platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp: (WebCore::CCHeadsUpDisplay::draw): * platform/graphics/chromium/cc/CCLayerTreeHost.cpp: (WebCore::CCLayerTreeHost::~CCLayerTreeHost): (WebCore::CCLayerTreeHost::deleteContentsTexturesOnCCThread): (WebCore::CCLayerTreeHost::commitToOnCCThread): (WebCore::CCLayerTreeHost::didRecreateGraphicsContext): (WebCore::CCLayerTreeHost::updateCompositorResources): * platform/graphics/chromium/cc/CCLayerTreeHost.h: * platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp: (WebCore::CCLayerTreeHostImpl::contentsTextureAllocator): (WebCore::CCLayerTreeHostImpl::initializeLayerRenderer): * platform/graphics/chromium/cc/CCLayerTreeHostImpl.h: * platform/graphics/chromium/cc/CCRenderSurface.cpp: (WebCore::CCRenderSurface::drawSurface): * platform/graphics/chromium/cc/CCSingleThreadProxy.cpp: (WebCore::CCSingleThreadProxy::setNeedsCommit): (WebCore::CCSingleThreadProxy::stop): (WebCore::CCSingleThreadProxy::recreateContextIfNeeded): (WebCore::CCSingleThreadProxy::commitIfNeeded): * platform/graphics/chromium/cc/CCThreadProxy.cpp: (WebCore::CCThreadProxy::commitOnCCThread): (WebCore::CCThreadProxy::layerTreeHostClosedOnCCThread): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@96141 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebCore/ChangeLog | 90 ++++++++++++++++++++++ Source/WebCore/WebCore.gypi | 2 + .../graphics/chromium/Canvas2DLayerChromium.cpp | 2 +- .../graphics/chromium/Canvas2DLayerChromium.h | 2 +- .../graphics/chromium/ImageLayerChromium.cpp | 4 +- .../platform/graphics/chromium/LayerChromium.h | 2 +- .../graphics/chromium/LayerRendererChromium.cpp | 41 +++------- .../graphics/chromium/LayerRendererChromium.h | 14 ++-- .../graphics/chromium/LayerTextureUpdater.h | 3 +- .../chromium/LayerTextureUpdaterCanvas.cpp | 8 +- .../graphics/chromium/LayerTextureUpdaterCanvas.h | 4 +- .../platform/graphics/chromium/ManagedTexture.cpp | 8 +- .../platform/graphics/chromium/ManagedTexture.h | 5 +- .../platform/graphics/chromium/TextureManager.cpp | 58 +++++++------- .../platform/graphics/chromium/TextureManager.h | 23 ++++-- .../graphics/chromium/TiledLayerChromium.cpp | 6 +- .../graphics/chromium/TiledLayerChromium.h | 2 +- .../graphics/chromium/TrackingTextureAllocator.cpp | 69 +++++++++++++++++ .../graphics/chromium/TrackingTextureAllocator.h | 57 ++++++++++++++ .../graphics/chromium/VideoLayerChromium.cpp | 8 +- .../graphics/chromium/VideoLayerChromium.h | 4 +- .../graphics/chromium/WebGLLayerChromium.cpp | 2 +- .../graphics/chromium/WebGLLayerChromium.h | 2 +- .../graphics/chromium/cc/CCHeadsUpDisplay.cpp | 4 +- .../graphics/chromium/cc/CCLayerTreeHost.cpp | 28 +++---- .../graphics/chromium/cc/CCLayerTreeHost.cpp.rej | 17 ++++ .../graphics/chromium/cc/CCLayerTreeHost.h | 10 +-- .../graphics/chromium/cc/CCLayerTreeHostImpl.cpp | 11 +-- .../graphics/chromium/cc/CCLayerTreeHostImpl.h | 2 + .../graphics/chromium/cc/CCRenderSurface.cpp | 2 +- .../graphics/chromium/cc/CCSingleThreadProxy.cpp | 7 +- .../graphics/chromium/cc/CCThreadProxy.cpp | 4 +- 32 files changed, 360 insertions(+), 141 deletions(-) create mode 100644 Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.cpp create mode 100644 Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.h create mode 100644 Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp.rej diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 42041d0..600ebbd 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,93 @@ +2011-09-27 James Robinson + + [chromium] LayerRenderChromium asserts about leaking textures. + https://bugs.webkit.org/show_bug.cgi?id=68190 + + Reviewed by Kenneth Russell. + + This introduces an interface TextureAllocator that the TextureManager uses to allocate/deallocate textures. + This means that TextureManager does not need to depend directly on GraphicsContext3D, other than for the format + enum type, making it more testable. It also allows us to track the allocations by subclassing TextureAllocator + to make sure we aren't leaking any textures. + + * WebCore.gypi: + * platform/graphics/chromium/Canvas2DLayerChromium.cpp: + (WebCore::Canvas2DLayerChromium::updateCompositorResources): + * platform/graphics/chromium/Canvas2DLayerChromium.h: + * platform/graphics/chromium/ImageLayerChromium.cpp: + (WebCore::ImageLayerTextureUpdater::updateTextureRect): + * platform/graphics/chromium/LayerChromium.h: + (WebCore::LayerChromium::updateCompositorResources): + * platform/graphics/chromium/LayerRendererChromium.cpp: + (WebCore::LayerRendererChromium::LayerRendererChromium): + (WebCore::LayerRendererChromium::releaseRenderSurfaceTextures): + (WebCore::LayerRendererChromium::drawLayers): + (WebCore::LayerRendererChromium::useRenderSurface): + (WebCore::LayerRendererChromium::initializeSharedObjects): + (WebCore::LayerRendererChromium::cleanupSharedObjects): + * platform/graphics/chromium/LayerRendererChromium.h: + (WebCore::LayerRendererChromium::renderSurfaceTextureAllocator): + (WebCore::LayerRendererChromium::contentsTextureAllocator): + * platform/graphics/chromium/LayerTextureUpdater.h: + * platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp: + (WebCore::LayerTextureUpdaterBitmap::updateTextureRect): + (WebCore::LayerTextureUpdaterSkPicture::updateTextureRect): + * platform/graphics/chromium/LayerTextureUpdaterCanvas.h: + * platform/graphics/chromium/ManagedTexture.cpp: + (WebCore::ManagedTexture::bindTexture): + (WebCore::ManagedTexture::framebufferTexture2D): + * platform/graphics/chromium/ManagedTexture.h: + * platform/graphics/chromium/TextureManager.cpp: + (WebCore::TextureManager::memoryUseBytes): + (WebCore::TextureManager::deleteEvictedTextures): + (WebCore::TextureManager::evictAndDeleteAllTextures): + (WebCore::TextureManager::removeTexture): + (WebCore::TextureManager::allocateTexture): + (WebCore::TextureManager::requestTexture): + * platform/graphics/chromium/TextureManager.h: + (WebCore::TextureAllocator::~TextureAllocator): + * platform/graphics/chromium/TiledLayerChromium.cpp: + (WebCore::TiledLayerChromium::updateCompositorResources): + * platform/graphics/chromium/TiledLayerChromium.h: + * platform/graphics/chromium/TrackingTextureAllocator.cpp: Added. + (WebCore::TrackingTextureAllocator::TrackingTextureAllocator): + (WebCore::TrackingTextureAllocator::~TrackingTextureAllocator): + (WebCore::TrackingTextureAllocator::createTexture): + (WebCore::TrackingTextureAllocator::deleteTexture): + * platform/graphics/chromium/TrackingTextureAllocator.h: Copied from Source/WebCore/platform/graphics/chromium/ManagedTexture.h. + (WebCore::TrackingTextureAllocator::create): + (WebCore::TrackingTextureAllocator::currentMemoryUseBytes): + * platform/graphics/chromium/VideoLayerChromium.cpp: + (WebCore::VideoLayerChromium::updateCompositorResources): + (WebCore::VideoLayerChromium::updateTexture): + * platform/graphics/chromium/VideoLayerChromium.h: + * platform/graphics/chromium/WebGLLayerChromium.cpp: + (WebCore::WebGLLayerChromium::updateCompositorResources): + * platform/graphics/chromium/WebGLLayerChromium.h: + * platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp: + (WebCore::CCHeadsUpDisplay::draw): + * platform/graphics/chromium/cc/CCLayerTreeHost.cpp: + (WebCore::CCLayerTreeHost::~CCLayerTreeHost): + (WebCore::CCLayerTreeHost::deleteContentsTexturesOnCCThread): + (WebCore::CCLayerTreeHost::commitToOnCCThread): + (WebCore::CCLayerTreeHost::didRecreateGraphicsContext): + (WebCore::CCLayerTreeHost::updateCompositorResources): + * platform/graphics/chromium/cc/CCLayerTreeHost.h: + * platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp: + (WebCore::CCLayerTreeHostImpl::contentsTextureAllocator): + (WebCore::CCLayerTreeHostImpl::initializeLayerRenderer): + * platform/graphics/chromium/cc/CCLayerTreeHostImpl.h: + * platform/graphics/chromium/cc/CCRenderSurface.cpp: + (WebCore::CCRenderSurface::drawSurface): + * platform/graphics/chromium/cc/CCSingleThreadProxy.cpp: + (WebCore::CCSingleThreadProxy::setNeedsCommit): + (WebCore::CCSingleThreadProxy::stop): + (WebCore::CCSingleThreadProxy::recreateContextIfNeeded): + (WebCore::CCSingleThreadProxy::commitIfNeeded): + * platform/graphics/chromium/cc/CCThreadProxy.cpp: + (WebCore::CCThreadProxy::commitOnCCThread): + (WebCore::CCThreadProxy::layerTreeHostClosedOnCCThread): + 2011-06-28 Robert Hogan Reviewed by David Hyatt. diff --git a/Source/WebCore/WebCore.gypi b/Source/WebCore/WebCore.gypi index 4d27aa3..be0a943 100644 --- a/Source/WebCore/WebCore.gypi +++ b/Source/WebCore/WebCore.gypi @@ -3465,6 +3465,8 @@ 'platform/graphics/chromium/ShaderChromium.h', 'platform/graphics/chromium/SimpleFontDataChromiumWin.cpp', 'platform/graphics/chromium/SimpleFontDataLinux.cpp', + 'platform/graphics/chromium/TrackingTextureAllocator.cpp', + 'platform/graphics/chromium/TrackingTextureAllocator.h', 'platform/graphics/chromium/TextureManager.cpp', 'platform/graphics/chromium/TextureManager.h', 'platform/graphics/chromium/TiledLayerChromium.cpp', diff --git a/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp index 79d04f3..0e0da80 100644 --- a/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp +++ b/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp @@ -64,7 +64,7 @@ bool Canvas2DLayerChromium::drawsContent() const && (m_context->getExtensions()->getGraphicsResetStatusARB() == GraphicsContext3D::NO_ERROR)); } -void Canvas2DLayerChromium::updateCompositorResources(GraphicsContext3D*) +void Canvas2DLayerChromium::updateCompositorResources(GraphicsContext3D*, TextureAllocator*) { if (m_dirtyRect.isEmpty() || !drawsContent()) return; diff --git a/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.h b/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.h index a15f588..0f332f4 100644 --- a/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.h +++ b/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.h @@ -46,7 +46,7 @@ public: static PassRefPtr create(GraphicsContext3D*); virtual ~Canvas2DLayerChromium(); virtual bool drawsContent() const; - virtual void updateCompositorResources(GraphicsContext3D*); + virtual void updateCompositorResources(GraphicsContext3D*, TextureAllocator*); void setTextureChanged(); diff --git a/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp index ebc90f3..9415de4 100644 --- a/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp +++ b/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp @@ -66,9 +66,9 @@ public: m_texSubImage.setSubImageSize(tileSize); } - virtual void updateTextureRect(GraphicsContext3D* context, ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect) + virtual void updateTextureRect(GraphicsContext3D* context, TextureAllocator* allocator, ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect) { - texture->bindTexture(context); + texture->bindTexture(context, allocator); // Source rect should never go outside the image pixels, even if this // is requested because the texture extends outside the image. diff --git a/Source/WebCore/platform/graphics/chromium/LayerChromium.h b/Source/WebCore/platform/graphics/chromium/LayerChromium.h index 331e6c1..5e138190 100644 --- a/Source/WebCore/platform/graphics/chromium/LayerChromium.h +++ b/Source/WebCore/platform/graphics/chromium/LayerChromium.h @@ -152,7 +152,7 @@ public: // These methods typically need to be overwritten by derived classes. virtual bool drawsContent() const { return false; } virtual void paintContentsIfDirty() { } - virtual void updateCompositorResources(GraphicsContext3D*) { } + virtual void updateCompositorResources(GraphicsContext3D*, TextureAllocator*) { } virtual void setIsMask(bool) {} virtual void unreserveContentsTexture() { } virtual void bindContentsTexture() { } diff --git a/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp b/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp index 4058889..febdec5 100644 --- a/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp +++ b/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp @@ -51,6 +51,7 @@ #include "TextureManager.h" #include "TreeSynchronizer.h" #include "TraceEvent.h" +#include "TrackingTextureAllocator.h" #include "WebGLLayerChromium.h" #include "cc/CCLayerImpl.h" #include "cc/CCLayerTreeHostCommon.h" @@ -147,7 +148,6 @@ LayerRendererChromium::LayerRendererChromium(CCLayerTreeHostImpl* owner, : m_owner(owner) , m_currentRenderSurface(0) , m_offscreenFramebufferId(0) - , m_contentsTextureMemoryUseBytes(0) , m_context(context) , m_defaultRenderSurface(0) , m_sharedGeometryQuad(FloatRect(-0.5f, -0.5f, 1.0f, 1.0f)) @@ -214,7 +214,7 @@ void LayerRendererChromium::debugGLCall(GraphicsContext3D* context, const char* void LayerRendererChromium::releaseRenderSurfaceTextures() { - m_renderSurfaceTextureManager->evictAndDeleteAllTextures(m_context.get()); + m_renderSurfaceTextureManager->evictAndDeleteAllTextures(m_renderSurfaceTextureAllocator.get()); } void LayerRendererChromium::viewportChanged() @@ -237,14 +237,15 @@ void LayerRendererChromium::drawLayers() if (!rootLayer()) return; - m_renderSurfaceTextureManager->setMemoryLimitBytes(TextureManager::highLimitBytes() - m_contentsTextureMemoryUseBytes); + size_t contentsMemoryUseBytes = m_contentsTextureAllocator->currentMemoryUseBytes(); + m_renderSurfaceTextureManager->setMemoryLimitBytes(TextureManager::highLimitBytes() - contentsMemoryUseBytes); drawLayersInternal(); - if (TextureManager::reclaimLimitBytes() > m_contentsTextureMemoryUseBytes) - m_renderSurfaceTextureManager->reduceMemoryToLimit(TextureManager::reclaimLimitBytes() - m_contentsTextureMemoryUseBytes); + if (TextureManager::reclaimLimitBytes() > contentsMemoryUseBytes) + m_renderSurfaceTextureManager->reduceMemoryToLimit(TextureManager::reclaimLimitBytes() - contentsMemoryUseBytes); else m_renderSurfaceTextureManager->reduceMemoryToLimit(0); - m_renderSurfaceTextureManager->deleteEvictedTextures(m_context.get()); + m_renderSurfaceTextureManager->deleteEvictedTextures(m_renderSurfaceTextureAllocator.get()); if (settings().compositeOffscreen) copyOffscreenTextureToDisplay(); @@ -436,29 +437,6 @@ void LayerRendererChromium::getFramebufferPixels(void *pixels, const IntRect& re GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, pixels)); } -// FIXME: This method should eventually be replaced by a proper texture manager. -unsigned LayerRendererChromium::createLayerTexture() -{ - unsigned textureId = 0; - GLC(m_context.get(), textureId = m_context->createTexture()); - GLC(m_context.get(), m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, textureId)); - // Do basic linear filtering on resize. - GLC(m_context.get(), m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR)); - GLC(m_context.get(), m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR)); - // NPOT textures in GL ES only work when the wrap mode is set to GraphicsContext3D::CLAMP_TO_EDGE. - GLC(m_context.get(), m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE)); - GLC(m_context.get(), m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE)); - return textureId; -} - -void LayerRendererChromium::deleteLayerTexture(unsigned textureId) -{ - if (!textureId) - return; - - GLC(m_context.get(), 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) { @@ -516,7 +494,7 @@ bool LayerRendererChromium::useRenderSurface(CCRenderSurface* renderSurface) if (!renderSurface->prepareContentsTexture(this)) return false; - renderSurface->contentsTexture()->framebufferTexture2D(m_context.get()); + renderSurface->contentsTexture()->framebufferTexture2D(m_context.get(), m_renderSurfaceTextureAllocator.get()); #if !defined ( NDEBUG ) if (m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) != GraphicsContext3D::FRAMEBUFFER_COMPLETE) { @@ -635,6 +613,8 @@ bool LayerRendererChromium::initializeSharedObjects() GLC(m_context.get(), m_context->flush()); m_renderSurfaceTextureManager = TextureManager::create(TextureManager::highLimitBytes(), m_capabilities.maxTextureSize); + m_contentsTextureAllocator = TrackingTextureAllocator::create(m_context.get()); + m_renderSurfaceTextureAllocator = TrackingTextureAllocator::create(m_context.get()); return true; } @@ -843,7 +823,6 @@ void LayerRendererChromium::cleanupSharedObjects() if (m_offscreenFramebufferId) GLC(m_context.get(), m_context->deleteFramebuffer(m_offscreenFramebufferId)); - ASSERT(!m_contentsTextureMemoryUseBytes); releaseRenderSurfaceTextures(); } diff --git a/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h b/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h index 5984c13..0fd8965 100644 --- a/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h +++ b/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h @@ -38,6 +38,7 @@ #include "FloatQuad.h" #include "IntRect.h" #include "LayerChromium.h" +#include "TrackingTextureAllocator.h" #include "VideoLayerChromium.h" #include "cc/CCCanvasLayerImpl.h" #include "cc/CCHeadsUpDisplay.h" @@ -68,6 +69,7 @@ class CCLayerTreeHostImpl; class GeometryBinding; class GraphicsContext3D; class NonCompositedContentHost; +class TrackingTextureAllocator; // Class that handles drawing of composited render layers using GL. class LayerRendererChromium { @@ -78,7 +80,7 @@ public: // Must be called in order to allow the LayerRendererChromium to destruct void close(); - virtual ~LayerRendererChromium(); + ~LayerRendererChromium(); const CCSettings& settings() const { return m_owner->settings(); } const LayerRendererCapabilities& capabilities() const { return m_capabilities; } @@ -105,9 +107,6 @@ public: void setZoomAnimatorTransform(const TransformationMatrix& t) { m_zoomAnimatorTransform = t; } - unsigned createLayerTexture(); - void deleteLayerTexture(unsigned); - static void debugGLCall(GraphicsContext3D*, const char* command, const char* file, int line); const TransformationMatrix& projectionMatrix() const { return m_projectionMatrix; } @@ -133,6 +132,8 @@ public: void getFramebufferPixels(void *pixels, const IntRect& rect); TextureManager* renderSurfaceTextureManager() const { return m_renderSurfaceTextureManager.get(); } + TextureAllocator* renderSurfaceTextureAllocator() const { return m_renderSurfaceTextureAllocator.get(); } + TextureAllocator* contentsTextureAllocator() const { return m_contentsTextureAllocator.get(); } CCHeadsUpDisplay* headsUpDisplay() { return m_headsUpDisplay.get(); } @@ -148,8 +149,6 @@ public: typedef Vector > CCLayerList; - void setContentsTextureMemoryUseBytes(size_t contentsTextureMemoryUseBytes) { m_contentsTextureMemoryUseBytes = contentsTextureMemoryUseBytes; } - static void toGLMatrix(float*, const TransformationMatrix&); void drawTexturedQuad(const TransformationMatrix& layerMatrix, float width, float height, float opacity, const FloatQuad&, @@ -213,8 +212,9 @@ private: OwnPtr m_videoLayerRGBAProgram; OwnPtr m_videoLayerYUVProgram; - size_t m_contentsTextureMemoryUseBytes; OwnPtr m_renderSurfaceTextureManager; + OwnPtr m_contentsTextureAllocator; + OwnPtr m_renderSurfaceTextureAllocator; OwnPtr m_headsUpDisplay; diff --git a/Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h b/Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h index 2623778..3d8597e 100644 --- a/Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h +++ b/Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h @@ -38,6 +38,7 @@ class GraphicsContext3D; class IntRect; class IntSize; class ManagedTexture; +class TextureAllocator; class LayerTextureUpdater : public RefCounted { public: @@ -61,7 +62,7 @@ public: // If the format is TexelFormatBGRA, vec4.x is blue and vec4.z is red. virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat) = 0; virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels) = 0; - virtual void updateTextureRect(GraphicsContext3D*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect) = 0; + virtual void updateTextureRect(GraphicsContext3D*, TextureAllocator*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect) = 0; }; } // namespace WebCore diff --git a/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp b/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp index 6cecc2a..e35006f 100644 --- a/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp +++ b/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp @@ -93,11 +93,11 @@ void LayerTextureUpdaterBitmap::prepareToUpdate(const IntRect& contentRect, cons paintContents(*canvasPainter.context(), contentRect); } -void LayerTextureUpdaterBitmap::updateTextureRect(GraphicsContext3D* context, ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect) +void LayerTextureUpdaterBitmap::updateTextureRect(GraphicsContext3D* context, TextureAllocator* allocator, ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect) { PlatformCanvas::AutoLocker locker(&m_canvas); - texture->bindTexture(context); + texture->bindTexture(context, allocator); m_texSubImage.upload(locker.pixels(), contentRect(), sourceRect, destRect, texture->format(), context); } @@ -145,7 +145,7 @@ void LayerTextureUpdaterSkPicture::prepareToUpdate(const IntRect& contentRect, c m_picture.endRecording(); } -void LayerTextureUpdaterSkPicture::updateTextureRect(GraphicsContext3D* compositorContext, ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect) +void LayerTextureUpdaterSkPicture::updateTextureRect(GraphicsContext3D* compositorContext, TextureAllocator* allocator, ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect) { ASSERT(!m_context || m_context == compositorContext); m_context = compositorContext; @@ -160,7 +160,7 @@ void LayerTextureUpdaterSkPicture::updateTextureRect(GraphicsContext3D* composit // Bind texture. context()->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo); - texture->framebufferTexture2D(context()); + texture->framebufferTexture2D(context(), allocator); ASSERT(context()->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) == GraphicsContext3D::FRAMEBUFFER_COMPLETE); // Make sure SKIA uses the correct GL context. diff --git a/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.h b/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.h index 49cb216..4849a1a 100644 --- a/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.h +++ b/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.h @@ -71,7 +71,7 @@ public: virtual Orientation orientation() { return LayerTextureUpdater::BottomUpOrientation; } virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat); virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels); - virtual void updateTextureRect(GraphicsContext3D*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect); + virtual void updateTextureRect(GraphicsContext3D*, TextureAllocator*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect); private: LayerTextureUpdaterBitmap(PassOwnPtr, bool useMapTexSubImage); @@ -88,7 +88,7 @@ public: virtual Orientation orientation() { return LayerTextureUpdater::TopDownOrientation; } virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat); virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels); - virtual void updateTextureRect(GraphicsContext3D*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect); + virtual void updateTextureRect(GraphicsContext3D*, TextureAllocator*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect); private: explicit LayerTextureUpdaterSkPicture(PassOwnPtr); diff --git a/Source/WebCore/platform/graphics/chromium/ManagedTexture.cpp b/Source/WebCore/platform/graphics/chromium/ManagedTexture.cpp index f1f818b..5bbff6a 100644 --- a/Source/WebCore/platform/graphics/chromium/ManagedTexture.cpp +++ b/Source/WebCore/platform/graphics/chromium/ManagedTexture.cpp @@ -80,19 +80,19 @@ void ManagedTexture::unreserve() m_textureManager->unprotectTexture(m_token); } -void ManagedTexture::bindTexture(GraphicsContext3D* context) +void ManagedTexture::bindTexture(GraphicsContext3D* context, TextureAllocator* allocator) { ASSERT(m_textureManager->hasTexture(m_token)); if (!m_textureId) - m_textureId = m_textureManager->allocateTexture(context, m_token); + m_textureId = m_textureManager->allocateTexture(allocator, m_token); context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_textureId); } -void ManagedTexture::framebufferTexture2D(GraphicsContext3D* context) +void ManagedTexture::framebufferTexture2D(GraphicsContext3D* context, TextureAllocator* allocator) { ASSERT(m_textureManager->hasTexture(m_token)); if (!m_textureId) - m_textureId = m_textureManager->allocateTexture(context, m_token); + m_textureId = m_textureManager->allocateTexture(allocator, m_token); context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, m_textureId, 0); } diff --git a/Source/WebCore/platform/graphics/chromium/ManagedTexture.h b/Source/WebCore/platform/graphics/chromium/ManagedTexture.h index 862e867..4d43809 100644 --- a/Source/WebCore/platform/graphics/chromium/ManagedTexture.h +++ b/Source/WebCore/platform/graphics/chromium/ManagedTexture.h @@ -36,7 +36,6 @@ namespace WebCore { class GraphicsContext3D; -class TextureManager; class ManagedTexture { WTF_MAKE_NONCOPYABLE(ManagedTexture); @@ -56,8 +55,8 @@ public: return m_textureManager->isProtected(m_token); } - void bindTexture(GraphicsContext3D*); - void framebufferTexture2D(GraphicsContext3D*); + void bindTexture(GraphicsContext3D*, TextureAllocator*); + void framebufferTexture2D(GraphicsContext3D*, TextureAllocator*); IntSize size() const { return m_size; } unsigned format() const { return m_format; } diff --git a/Source/WebCore/platform/graphics/chromium/TextureManager.cpp b/Source/WebCore/platform/graphics/chromium/TextureManager.cpp index 9a068dc..c600d9e 100644 --- a/Source/WebCore/platform/graphics/chromium/TextureManager.cpp +++ b/Source/WebCore/platform/graphics/chromium/TextureManager.cpp @@ -32,18 +32,6 @@ namespace WebCore { -static size_t memoryUseBytes(IntSize size, GC3Denum textureFormat) -{ - // FIXME: This assumes all textures are 1 byte/component. - const GC3Denum type = GraphicsContext3D::UNSIGNED_BYTE; - unsigned int componentsPerPixel = 4; - unsigned int bytesPerComponent = 1; - if (!GraphicsContext3D::computeFormatAndTypeParameters(textureFormat, type, &componentsPerPixel, &bytesPerComponent)) - ASSERT_NOT_REACHED(); - - return size.width() * size.height() * componentsPerPixel * bytesPerComponent; -} - size_t TextureManager::highLimitBytes() { return 128 * 1024 * 1024; @@ -59,6 +47,19 @@ size_t TextureManager::lowLimitBytes() return 3 * 1024 * 1024; } +size_t TextureManager::memoryUseBytes(const IntSize& size, GC3Denum textureFormat) +{ + // FIXME: This assumes all textures are 1 byte/component. + const GC3Denum type = GraphicsContext3D::UNSIGNED_BYTE; + unsigned int componentsPerPixel = 4; + unsigned int bytesPerComponent = 1; + if (!GraphicsContext3D::computeFormatAndTypeParameters(textureFormat, type, &componentsPerPixel, &bytesPerComponent)) + ASSERT_NOT_REACHED(); + + return size.width() * size.height() * componentsPerPixel * bytesPerComponent; +} + + TextureManager::TextureManager(size_t memoryLimitBytes, int maxTextureSize) : m_memoryLimitBytes(memoryLimitBytes) , m_memoryUseBytes(0) @@ -152,26 +153,26 @@ void TextureManager::addTexture(TextureToken token, TextureInfo info) m_textureLRUSet.add(token); } -void TextureManager::deleteEvictedTextures(GraphicsContext3D* context) +void TextureManager::deleteEvictedTextures(TextureAllocator* allocator) { - if (context) { + if (allocator) { for (size_t i = 0; i < m_evictedTextures.size(); ++i) { if (m_evictedTextures[i].textureId) { #ifndef NDEBUG - ASSERT(m_evictedTextures[i].allocatingContext == context); + ASSERT(m_evictedTextures[i].allocator == allocator); #endif - GLC(context, context->deleteTexture(m_evictedTextures[i].textureId)); + allocator->deleteTexture(m_evictedTextures[i].textureId, m_evictedTextures[i].size, m_evictedTextures[i].format); } } } m_evictedTextures.clear(); } -void TextureManager::evictAndDeleteAllTextures(GraphicsContext3D* context) +void TextureManager::evictAndDeleteAllTextures(TextureAllocator* allocator) { unprotectAllTextures(); reduceMemoryToLimit(0); - deleteEvictedTextures(context); + deleteEvictedTextures(allocator); } void TextureManager::removeTexture(TextureToken token, TextureInfo info) @@ -184,32 +185,25 @@ void TextureManager::removeTexture(TextureToken token, TextureInfo info) m_textureLRUSet.remove(token); EvictionEntry entry; entry.textureId = info.textureId; + entry.size = info.size; + entry.format = info.format; #ifndef NDEBUG - entry.allocatingContext = info.allocatingContext; + entry.allocator = info.allocator; #endif m_evictedTextures.append(entry); } -unsigned TextureManager::allocateTexture(GraphicsContext3D* context, TextureToken token) +unsigned TextureManager::allocateTexture(TextureAllocator* allocator, TextureToken token) { TextureMap::iterator it = m_textures.find(token); ASSERT(it != m_textures.end()); TextureInfo* info = &it.get()->second; ASSERT(info->isProtected); - unsigned textureId; - GLC(context, textureId = context->createTexture()); - GLC(context, context->bindTexture(GraphicsContext3D::TEXTURE_2D, textureId)); - // Do basic linear filtering on resize. - GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR)); - GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR)); - // NPOT textures in GL ES only work when the wrap mode is set to GraphicsContext3D::CLAMP_TO_EDGE. - GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE)); - GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE)); - GLC(context, context->texImage2DResourceSafe(GraphicsContext3D::TEXTURE_2D, 0, info->format, info->size.width(), info->size.height(), 0, info->format, GraphicsContext3D::UNSIGNED_BYTE)); + unsigned textureId = allocator->createTexture(info->size, info->format); info->textureId = textureId; #ifndef NDEBUG - info->allocatingContext = context; + info->allocator = allocator; #endif return textureId; } @@ -239,7 +233,7 @@ bool TextureManager::requestTexture(TextureToken token, IntSize size, unsigned f info.textureId = 0; info.isProtected = true; #ifndef NDEBUG - info.allocatingContext = 0; + info.allocator = 0; #endif addTexture(token, info); return true; diff --git a/Source/WebCore/platform/graphics/chromium/TextureManager.h b/Source/WebCore/platform/graphics/chromium/TextureManager.h index 2105c57..f327b4c 100644 --- a/Source/WebCore/platform/graphics/chromium/TextureManager.h +++ b/Source/WebCore/platform/graphics/chromium/TextureManager.h @@ -37,6 +37,15 @@ namespace WebCore { typedef int TextureToken; +class TextureAllocator { +public: + virtual unsigned createTexture(const IntSize&, GC3Denum format) = 0; + virtual void deleteTexture(unsigned texture, const IntSize&, GC3Denum) = 0; + +protected: + virtual ~TextureAllocator() { } +}; + class TextureManager { WTF_MAKE_NONCOPYABLE(TextureManager); public: @@ -52,6 +61,8 @@ public: // The maximum texture memory usage when asked to release textures. static size_t lowLimitBytes(); + static size_t memoryUseBytes(const IntSize&, GC3Denum format); + void setMemoryLimitBytes(size_t); TextureToken getToken(); @@ -65,10 +76,10 @@ public: void unprotectAllTextures(); bool isProtected(TextureToken); - unsigned allocateTexture(GraphicsContext3D*, TextureToken); - void deleteEvictedTextures(GraphicsContext3D*); + unsigned allocateTexture(TextureAllocator*, TextureToken); + void deleteEvictedTextures(TextureAllocator*); - void evictAndDeleteAllTextures(GraphicsContext3D*); + void evictAndDeleteAllTextures(TextureAllocator*); void reduceMemoryToLimit(size_t); size_t currentMemoryUseBytes() const { return m_memoryUseBytes; } @@ -82,7 +93,7 @@ private: unsigned textureId; bool isProtected; #ifndef NDEBUG - GraphicsContext3D* allocatingContext; + TextureAllocator* allocator; #endif }; @@ -100,8 +111,10 @@ private: struct EvictionEntry { unsigned textureId; + IntSize size; + GC3Denum format; #ifndef NDEBUG - GraphicsContext3D* allocatingContext; + TextureAllocator* allocator; #endif }; diff --git a/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp index 42693ea..0edf505 100644 --- a/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp +++ b/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp @@ -151,7 +151,7 @@ void TiledLayerChromium::setLayerTreeHost(CCLayerTreeHost* host) isNonCompositedContent() ? CCLayerTilingData::NoBorderTexels : CCLayerTilingData::HasBorderTexels); } -void TiledLayerChromium::updateCompositorResources(GraphicsContext3D* context) +void TiledLayerChromium::updateCompositorResources(GraphicsContext3D* context, TextureAllocator* allocator) { // Painting could cause compositing to get turned off, which may cause the tiler to become invalidated mid-update. if (m_skipsDraw || m_updateRect.isEmpty() || !m_tiler->numTiles()) @@ -197,13 +197,13 @@ void TiledLayerChromium::updateCompositorResources(GraphicsContext3D* context) if (paintOffset.y() + destRect.height() > m_paintRect.height()) CRASH(); - tile->texture()->bindTexture(context); + tile->texture()->bindTexture(context, allocator); const GC3Dint filter = m_tiler->hasBorderTexels() ? GraphicsContext3D::LINEAR : GraphicsContext3D::NEAREST; GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, filter)); GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, filter)); GLC(context, context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0)); - textureUpdater()->updateTextureRect(context, tile->texture(), sourceRect, destRect); + textureUpdater()->updateTextureRect(context, allocator, tile->texture(), sourceRect, destRect); tile->clearDirty(); } } diff --git a/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h b/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h index 7320d4b..d73bd0f 100644 --- a/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h +++ b/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h @@ -43,7 +43,7 @@ public: virtual ~TiledLayerChromium(); - virtual void updateCompositorResources(GraphicsContext3D*); + virtual void updateCompositorResources(GraphicsContext3D*, TextureAllocator*); virtual void setIsMask(bool); virtual void pushPropertiesTo(CCLayerImpl*); diff --git a/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.cpp b/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.cpp new file mode 100644 index 0000000..2b05def --- /dev/null +++ b/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.cpp @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2011, Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#include "TrackingTextureAllocator.h" + +#include "IntRect.h" +#include "LayerRendererChromium.h" // For the GLC() macro + +namespace WebCore { + +TrackingTextureAllocator::TrackingTextureAllocator(PassRefPtr context) + : m_context(context) + , m_currentMemoryUseBytes(0) +{ +} + +TrackingTextureAllocator::~TrackingTextureAllocator() +{ + ASSERT(!m_currentMemoryUseBytes); +} + +unsigned TrackingTextureAllocator::createTexture(const IntSize& size, GC3Denum format) +{ + m_currentMemoryUseBytes += TextureManager::memoryUseBytes(size, format); + + unsigned textureId = 0; + GLC(m_context.get(), textureId = m_context->createTexture()); + GLC(m_context.get(), m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, textureId)); + // Do basic linear filtering on resize. + GLC(m_context.get(), m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR)); + GLC(m_context.get(), m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR)); + // NPOT textures in GL ES only work when the wrap mode is set to GraphicsContext3D::CLAMP_TO_EDGE. + GLC(m_context.get(), m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE)); + GLC(m_context.get(), m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE)); + GLC(m_context.get(), m_context->texImage2DResourceSafe(GraphicsContext3D::TEXTURE_2D, 0, format, size.width(), size.height(), 0, format, GraphicsContext3D::UNSIGNED_BYTE)); + return textureId; +} + +void TrackingTextureAllocator::deleteTexture(unsigned textureId, const IntSize& size, GC3Denum format) +{ + m_currentMemoryUseBytes -= TextureManager::memoryUseBytes(size, format); + GLC(m_context.get(), m_context->deleteTexture(textureId)); +} + +} + diff --git a/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.h b/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.h new file mode 100644 index 0000000..e504eea --- /dev/null +++ b/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2011, Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef TrackingTextureAllocator_h +#define TrackingTextureAllocator_h + +#include "GraphicsContext3D.h" +#include "TextureManager.h" +#include + +namespace WebCore { + +class TrackingTextureAllocator : public TextureAllocator { + WTF_MAKE_NONCOPYABLE(TrackingTextureAllocator); +public: + static PassOwnPtr create(PassRefPtr context) + { + return adoptPtr(new TrackingTextureAllocator(context)); + } + virtual ~TrackingTextureAllocator(); + + virtual unsigned createTexture(const IntSize&, GC3Denum format); + virtual void deleteTexture(unsigned texture, const IntSize&, GC3Denum format); + + size_t currentMemoryUseBytes() const { return m_currentMemoryUseBytes; } + +protected: + explicit TrackingTextureAllocator(PassRefPtr); + + RefPtr m_context; + size_t m_currentMemoryUseBytes; +}; + +} + +#endif diff --git a/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.cpp index f485c36..8e929dd 100644 --- a/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.cpp +++ b/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.cpp @@ -78,7 +78,7 @@ void VideoLayerChromium::cleanupResources() releaseCurrentFrame(); } -void VideoLayerChromium::updateCompositorResources(GraphicsContext3D* context) +void VideoLayerChromium::updateCompositorResources(GraphicsContext3D* context, TextureAllocator* allocator) { if (!m_delegate) return; @@ -130,7 +130,7 @@ void VideoLayerChromium::updateCompositorResources(GraphicsContext3D* context) Texture& texture = m_textures[plane]; ASSERT(texture.m_texture); ASSERT(frame->requiredTextureSize(plane) == texture.m_texture->size()); - updateTexture(context, texture, frame->data(plane)); + updateTexture(context, allocator, texture, frame->data(plane)); } m_planes = frame->planes(); @@ -247,12 +247,12 @@ IntSize VideoLayerChromium::computeVisibleSize(const VideoFrameChromium* frame, return IntSize(visibleWidth, visibleHeight); } -void VideoLayerChromium::updateTexture(GraphicsContext3D* context, Texture& texture, const void* data) const +void VideoLayerChromium::updateTexture(GraphicsContext3D* context, TextureAllocator* allocator, Texture& texture, const void* data) const { ASSERT(context); ASSERT(texture.m_texture); - texture.m_texture->bindTexture(context); + texture.m_texture->bindTexture(context, allocator); GC3Denum format = texture.m_texture->format(); IntSize dimensions = texture.m_texture->size(); diff --git a/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.h b/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.h index f2cca44..b5fe3a6 100644 --- a/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.h +++ b/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.h @@ -50,7 +50,7 @@ public: virtual PassRefPtr createCCLayerImpl(); - virtual void updateCompositorResources(GraphicsContext3D*); + virtual void updateCompositorResources(GraphicsContext3D*, TextureAllocator*); virtual bool drawsContent() const { return true; } // This function is called by VideoFrameProvider. When this method is called @@ -76,7 +76,7 @@ private: static IntSize computeVisibleSize(const VideoFrameChromium*, unsigned plane); bool texturesValid(); bool reserveTextures(const VideoFrameChromium*, GC3Denum textureFormat); - void updateTexture(GraphicsContext3D*, Texture&, const void*) const; + void updateTexture(GraphicsContext3D*, TextureAllocator*, Texture&, const void*) const; void resetFrameParameters(); diff --git a/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.cpp index a6a99e9..32ba6a3 100644 --- a/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.cpp +++ b/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.cpp @@ -65,7 +65,7 @@ bool WebGLLayerChromium::drawsContent() const return (m_context && m_context->getExtensions()->getGraphicsResetStatusARB() == GraphicsContext3D::NO_ERROR); } -void WebGLLayerChromium::updateCompositorResources(GraphicsContext3D* rendererContext) +void WebGLLayerChromium::updateCompositorResources(GraphicsContext3D* rendererContext, TextureAllocator*) { if (!drawsContent()) return; diff --git a/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.h b/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.h index a58d562..7236bac 100644 --- a/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.h +++ b/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.h @@ -50,7 +50,7 @@ public: virtual ~WebGLLayerChromium(); virtual bool drawsContent() const; - virtual void updateCompositorResources(GraphicsContext3D*); + virtual void updateCompositorResources(GraphicsContext3D*, TextureAllocator*); void setTextureUpdated(); bool paintRenderedResultsToCanvas(ImageBuffer*); diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp index dc27148..864c88f 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp +++ b/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp @@ -126,7 +126,7 @@ void CCHeadsUpDisplay::draw() { PlatformCanvas::AutoLocker locker(&canvas); - m_hudTexture->bindTexture(context); + m_hudTexture->bindTexture(context, m_layerRenderer->renderSurfaceTextureAllocator()); bool uploadedViaMap = false; if (m_useMapSubForUploads) { Extensions3DChromium* extensions = static_cast(context->getExtensions()); @@ -148,7 +148,7 @@ void CCHeadsUpDisplay::draw() const Program* program = m_layerRenderer->headsUpDisplayProgram(); ASSERT(program && program->initialized()); GLC(context, context->activeTexture(GraphicsContext3D::TEXTURE0)); - m_hudTexture->bindTexture(context); + m_hudTexture->bindTexture(context, m_layerRenderer->renderSurfaceTextureAllocator()); GLC(context, context->useProgram(program->program())); GLC(context, context->uniform1i(program->fragmentShader().samplerLocation(), 0)); diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp index a25bbe6..6ddd9bd 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp +++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp @@ -92,15 +92,13 @@ CCLayerTreeHost::~CCLayerTreeHost() m_proxy->stop(); m_proxy.clear(); clearPendingUpdate(); - ASSERT(!m_contentsTextureManager || !m_contentsTextureManager->currentMemoryUseBytes()); - m_contentsTextureManager.clear(); } -void CCLayerTreeHost::deleteContentsTextures(GraphicsContext3D* context) +void CCLayerTreeHost::deleteContentsTexturesOnCCThread(TextureAllocator* allocator) { ASSERT(CCProxy::isImplThread()); if (m_contentsTextureManager) - m_contentsTextureManager->evictAndDeleteAllTextures(context); + m_contentsTextureManager->evictAndDeleteAllTextures(allocator); } void CCLayerTreeHost::animateAndLayout(double frameBeginTime) @@ -115,23 +113,21 @@ void CCLayerTreeHost::animateAndLayout(double frameBeginTime) // code that is logically a main thread operation, e.g. deletion of a LayerChromium, // should be delayed until the CCLayerTreeHost::commitComplete, which will run // after the commit, but on the main thread. -void CCLayerTreeHost::commitTo(CCLayerTreeHostImpl* hostImpl) +void CCLayerTreeHost::commitToOnCCThread(CCLayerTreeHostImpl* hostImpl) { ASSERT(CCProxy::isImplThread()); TRACE_EVENT("CCLayerTreeHost::commitTo", this, 0); hostImpl->setSourceFrameNumber(frameNumber()); contentsTextureManager()->reduceMemoryToLimit(TextureManager::reclaimLimitBytes()); - contentsTextureManager()->deleteEvictedTextures(hostImpl->context()); + contentsTextureManager()->deleteEvictedTextures(hostImpl->contentsTextureAllocator()); - updateCompositorResources(m_updateList, hostImpl->context()); + updateCompositorResources(m_updateList, hostImpl->context(), hostImpl->contentsTextureAllocator()); hostImpl->setVisible(m_visible); hostImpl->setZoomAnimatorTransform(m_zoomAnimatorTransform); hostImpl->setViewport(viewportSize()); - hostImpl->layerRenderer()->setContentsTextureMemoryUseBytes(m_contentsTextureManager->currentMemoryUseBytes()); - // Synchronize trees, if one exists at all... if (rootLayer()) hostImpl->setRootLayer(TreeSynchronizer::synchronizeTrees(rootLayer(), hostImpl->rootLayer())); @@ -164,8 +160,6 @@ PassOwnPtr CCLayerTreeHost::createLayerTreeHostImpl() void CCLayerTreeHost::didRecreateGraphicsContext(bool success) { - m_contentsTextureManager->evictAndDeleteAllTextures(0); - if (rootLayer()) rootLayer()->cleanupResourcesRecursive(); m_client->didRecreateGraphicsContext(success); @@ -377,7 +371,7 @@ void CCLayerTreeHost::paintLayerContents(const LayerList& renderSurfaceLayerList } } -void CCLayerTreeHost::updateCompositorResources(const LayerList& renderSurfaceLayerList, GraphicsContext3D* context) +void CCLayerTreeHost::updateCompositorResources(const LayerList& renderSurfaceLayerList, GraphicsContext3D* context, TextureAllocator* allocator) { for (int surfaceIndex = renderSurfaceLayerList.size() - 1; surfaceIndex >= 0 ; --surfaceIndex) { LayerChromium* renderSurfaceLayer = renderSurfaceLayerList[surfaceIndex].get(); @@ -394,12 +388,12 @@ void CCLayerTreeHost::updateCompositorResources(const LayerList& renderSurfaceLa if (layer->renderSurface() && layer->renderSurface() != renderSurface) continue; - updateCompositorResources(layer, context); + updateCompositorResources(layer, context, allocator); } } } -void CCLayerTreeHost::updateCompositorResources(LayerChromium* layer, GraphicsContext3D* context) +void CCLayerTreeHost::updateCompositorResources(LayerChromium* layer, GraphicsContext3D* context, TextureAllocator* allocator) { if (layer->bounds().isEmpty()) return; @@ -408,12 +402,12 @@ void CCLayerTreeHost::updateCompositorResources(LayerChromium* layer, GraphicsCo return; if (layer->maskLayer()) - updateCompositorResources(layer->maskLayer(), context); + updateCompositorResources(layer->maskLayer(), context, allocator); if (layer->replicaLayer()) - updateCompositorResources(layer->replicaLayer(), context); + updateCompositorResources(layer->replicaLayer(), context, allocator); if (layer->drawsContent()) - layer->updateCompositorResources(context); + layer->updateCompositorResources(context, allocator); } void CCLayerTreeHost::clearPendingUpdate() diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp.rej b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp.rej new file mode 100644 index 0000000..930bec2 --- /dev/null +++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp.rej @@ -0,0 +1,17 @@ +--- Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp ++++ Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp +@@ -130,14 +140,12 @@ + contentsTextureManager()->deleteEvictedTextures(hostImpl->context()); + + updateCompositorResources(m_updateList, hostImpl->context()); +- clearPendingUpdate(); + + hostImpl->setVisible(m_visible); + hostImpl->setZoomAnimatorScale(m_zoomAnimatorScale); + hostImpl->setViewport(viewportSize()); + + hostImpl->layerRenderer()->setContentsTextureMemoryUseBytes(m_contentsTextureManager->currentMemoryUseBytes()); +- m_contentsTextureManager->unprotectAllTextures(); + + // Synchronize trees, if one exists at all... + if (rootLayer()) diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h index e35968f..c905094 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h +++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h @@ -45,6 +45,7 @@ class CCThread; class GraphicsContext3D; class LayerChromium; class LayerPainterChromium; +class TextureAllocator; class TextureManager; class CCLayerTreeHostClient { @@ -98,7 +99,7 @@ public: // CCLayerTreeHost interface to CCProxy. void animateAndLayout(double frameBeginTime); void commitComplete(); - void commitTo(CCLayerTreeHostImpl*); + void commitToOnCCThread(CCLayerTreeHostImpl*); PassOwnPtr createCompositorThread(); PassRefPtr createLayerTreeHostContext3D(); virtual PassOwnPtr createLayerTreeHostImpl(); @@ -106,6 +107,7 @@ public: #if !USE(THREADED_COMPOSITING) void scheduleComposite(); #endif + void deleteContentsTexturesOnCCThread(TextureAllocator*); // CCLayerTreeHost interface to WebView. bool animating() const { return m_animating; } @@ -152,8 +154,6 @@ public: void updateLayers(); - void deleteContentsTextures(GraphicsContext3D*); - protected: CCLayerTreeHost(CCLayerTreeHostClient*, PassRefPtr rootLayer, const CCSettings&); bool initialize(); @@ -163,8 +163,8 @@ private: void paintLayerContents(const LayerList&); void updateLayers(LayerChromium*); - void updateCompositorResources(const LayerList&, GraphicsContext3D*); - void updateCompositorResources(LayerChromium*, GraphicsContext3D*); + void updateCompositorResources(const LayerList&, GraphicsContext3D*, TextureAllocator*); + void updateCompositorResources(LayerChromium*, GraphicsContext3D*, TextureAllocator*); void clearPendingUpdate(); bool m_animating; diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp index 5961216..5497d66 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp +++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp @@ -98,6 +98,11 @@ const LayerRendererCapabilities& CCLayerTreeHostImpl::layerRendererCapabilities( return m_layerRenderer->capabilities(); } +TextureAllocator* CCLayerTreeHostImpl::contentsTextureAllocator() const +{ + return m_layerRenderer->contentsTextureAllocator(); +} + void CCLayerTreeHostImpl::present() { ASSERT(m_layerRenderer && !isContextLost()); @@ -134,12 +139,8 @@ bool CCLayerTreeHostImpl::initializeLayerRenderer(PassRefPtr layerRenderer = LayerRendererChromium::create(this, context); } - // If we had a previous layer renderer, then its context must have been lost along with all of its resources. - // Let the old layer renderer known its resources are gone. - if (m_layerRenderer) { - m_layerRenderer->setContentsTextureMemoryUseBytes(0); + if (m_layerRenderer) m_layerRenderer->close(); - } m_layerRenderer = layerRenderer.release(); return m_layerRenderer; diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h index 19cfce2..d938e3a 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h +++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h @@ -37,6 +37,7 @@ namespace WebCore { class CCCompletionEvent; class CCLayerImpl; class LayerRendererChromium; +class TextureAllocator; struct LayerRendererCapabilities; class TransformationMatrix; @@ -61,6 +62,7 @@ public: bool isContextLost(); LayerRendererChromium* layerRenderer() { return m_layerRenderer.get(); } const LayerRendererCapabilities& layerRendererCapabilities() const; + TextureAllocator* contentsTextureAllocator() const; void present(); diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.cpp index a52a6c3..3273bef 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.cpp +++ b/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.cpp @@ -187,7 +187,7 @@ void CCRenderSurface::drawSurface(LayerRendererChromium* layerRenderer, CCLayerI GLC(context3D, context3D->activeTexture(GraphicsContext3D::TEXTURE0)); GLC(context3D, context3D->uniform1i(program->fragmentShader().samplerLocation(), 0)); - m_contentsTexture->bindTexture(context3D); + m_contentsTexture->bindTexture(context3D, layerRenderer->renderSurfaceTextureAllocator()); if (shaderMaskSamplerLocation != -1) { GLC(context3D, context3D->activeTexture(GraphicsContext3D::TEXTURE1)); diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp index 9acdc64..97bcea5 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp +++ b/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp @@ -160,7 +160,7 @@ void CCSingleThreadProxy::setNeedsCommit() { ScopedSetImplThread impl; m_layerTreeHostImpl->beginCommit(); - m_layerTreeHost->commitTo(m_layerTreeHostImpl.get()); + m_layerTreeHost->commitToOnCCThread(m_layerTreeHostImpl.get()); m_layerTreeHostImpl->commitComplete(); } m_layerTreeHost->commitComplete(); @@ -190,7 +190,7 @@ void CCSingleThreadProxy::stop() ASSERT(CCProxy::isMainThread()); { ScopedSetImplThread impl; - m_layerTreeHost->deleteContentsTextures(m_layerTreeHostImpl->context()); + m_layerTreeHost->deleteContentsTexturesOnCCThread(m_layerTreeHostImpl->contentsTextureAllocator()); m_layerTreeHostImpl.clear(); } m_layerTreeHost = 0; @@ -227,6 +227,7 @@ bool CCSingleThreadProxy::recreateContextIfNeeded() bool ok; { ScopedSetImplThread impl; + m_layerTreeHost->deleteContentsTexturesOnCCThread(m_layerTreeHostImpl->contentsTextureAllocator()); ok = m_layerTreeHostImpl->initializeLayerRenderer(context); if (ok) m_layerRendererCapabilitiesForMainThread = m_layerTreeHostImpl->layerRendererCapabilities(); @@ -263,7 +264,7 @@ void CCSingleThreadProxy::commitIfNeeded() { ScopedSetImplThread impl; m_layerTreeHostImpl->beginCommit(); - m_layerTreeHost->commitTo(m_layerTreeHostImpl.get()); + m_layerTreeHost->commitToOnCCThread(m_layerTreeHostImpl.get()); m_layerTreeHostImpl->commitComplete(); } m_layerTreeHost->commitComplete(); diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp index a1e71da..823c78f 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp +++ b/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp @@ -345,7 +345,7 @@ void CCThreadProxy::commitOnCCThread(CCCompletionEvent* completion) return; } m_layerTreeHostImpl->beginCommit(); - m_layerTreeHost->commitTo(m_layerTreeHostImpl.get()); + m_layerTreeHost->commitToOnCCThread(m_layerTreeHostImpl.get()); m_layerTreeHostImpl->commitComplete(); completion->signal(); @@ -430,7 +430,7 @@ void CCThreadProxy::layerTreeHostClosedOnCCThread(CCCompletionEvent* completion) { TRACE_EVENT("CCThreadProxy::layerTreeHostClosedOnCCThread", this, 0); ASSERT(isImplThread()); - m_layerTreeHost->deleteContentsTextures(m_layerTreeHostImpl->context()); + m_layerTreeHost->deleteContentsTexturesOnCCThread(m_layerTreeHostImpl->contentsTextureAllocator()); m_layerTreeHostImpl.clear(); completion->signal(); } -- 2.7.4