Changeset 96141 in webkit


Ignore:
Timestamp:
Sep 27, 2011 12:41:24 PM (13 years ago)
Author:
jamesr@google.com
Message:

[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):

Location:
trunk/Source/WebCore
Files:
2 added
29 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r96139 r96141  
     12011-09-27  James Robinson  <jamesr@chromium.org>
     2
     3        [chromium] LayerRenderChromium asserts about leaking textures.
     4        https://bugs.webkit.org/show_bug.cgi?id=68190
     5
     6        Reviewed by Kenneth Russell.
     7
     8        This introduces an interface TextureAllocator that the TextureManager uses to allocate/deallocate textures.
     9        This means that TextureManager does not need to depend directly on GraphicsContext3D, other than for the format
     10        enum type, making it more testable.  It also allows us to track the allocations by subclassing TextureAllocator
     11        to make sure we aren't leaking any textures.
     12
     13        * WebCore.gypi:
     14        * platform/graphics/chromium/Canvas2DLayerChromium.cpp:
     15        (WebCore::Canvas2DLayerChromium::updateCompositorResources):
     16        * platform/graphics/chromium/Canvas2DLayerChromium.h:
     17        * platform/graphics/chromium/ImageLayerChromium.cpp:
     18        (WebCore::ImageLayerTextureUpdater::updateTextureRect):
     19        * platform/graphics/chromium/LayerChromium.h:
     20        (WebCore::LayerChromium::updateCompositorResources):
     21        * platform/graphics/chromium/LayerRendererChromium.cpp:
     22        (WebCore::LayerRendererChromium::LayerRendererChromium):
     23        (WebCore::LayerRendererChromium::releaseRenderSurfaceTextures):
     24        (WebCore::LayerRendererChromium::drawLayers):
     25        (WebCore::LayerRendererChromium::useRenderSurface):
     26        (WebCore::LayerRendererChromium::initializeSharedObjects):
     27        (WebCore::LayerRendererChromium::cleanupSharedObjects):
     28        * platform/graphics/chromium/LayerRendererChromium.h:
     29        (WebCore::LayerRendererChromium::renderSurfaceTextureAllocator):
     30        (WebCore::LayerRendererChromium::contentsTextureAllocator):
     31        * platform/graphics/chromium/LayerTextureUpdater.h:
     32        * platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp:
     33        (WebCore::LayerTextureUpdaterBitmap::updateTextureRect):
     34        (WebCore::LayerTextureUpdaterSkPicture::updateTextureRect):
     35        * platform/graphics/chromium/LayerTextureUpdaterCanvas.h:
     36        * platform/graphics/chromium/ManagedTexture.cpp:
     37        (WebCore::ManagedTexture::bindTexture):
     38        (WebCore::ManagedTexture::framebufferTexture2D):
     39        * platform/graphics/chromium/ManagedTexture.h:
     40        * platform/graphics/chromium/TextureManager.cpp:
     41        (WebCore::TextureManager::memoryUseBytes):
     42        (WebCore::TextureManager::deleteEvictedTextures):
     43        (WebCore::TextureManager::evictAndDeleteAllTextures):
     44        (WebCore::TextureManager::removeTexture):
     45        (WebCore::TextureManager::allocateTexture):
     46        (WebCore::TextureManager::requestTexture):
     47        * platform/graphics/chromium/TextureManager.h:
     48        (WebCore::TextureAllocator::~TextureAllocator):
     49        * platform/graphics/chromium/TiledLayerChromium.cpp:
     50        (WebCore::TiledLayerChromium::updateCompositorResources):
     51        * platform/graphics/chromium/TiledLayerChromium.h:
     52        * platform/graphics/chromium/TrackingTextureAllocator.cpp: Added.
     53        (WebCore::TrackingTextureAllocator::TrackingTextureAllocator):
     54        (WebCore::TrackingTextureAllocator::~TrackingTextureAllocator):
     55        (WebCore::TrackingTextureAllocator::createTexture):
     56        (WebCore::TrackingTextureAllocator::deleteTexture):
     57        * platform/graphics/chromium/TrackingTextureAllocator.h: Copied from Source/WebCore/platform/graphics/chromium/ManagedTexture.h.
     58        (WebCore::TrackingTextureAllocator::create):
     59        (WebCore::TrackingTextureAllocator::currentMemoryUseBytes):
     60        * platform/graphics/chromium/VideoLayerChromium.cpp:
     61        (WebCore::VideoLayerChromium::updateCompositorResources):
     62        (WebCore::VideoLayerChromium::updateTexture):
     63        * platform/graphics/chromium/VideoLayerChromium.h:
     64        * platform/graphics/chromium/WebGLLayerChromium.cpp:
     65        (WebCore::WebGLLayerChromium::updateCompositorResources):
     66        * platform/graphics/chromium/WebGLLayerChromium.h:
     67        * platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp:
     68        (WebCore::CCHeadsUpDisplay::draw):
     69        * platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
     70        (WebCore::CCLayerTreeHost::~CCLayerTreeHost):
     71        (WebCore::CCLayerTreeHost::deleteContentsTexturesOnCCThread):
     72        (WebCore::CCLayerTreeHost::commitToOnCCThread):
     73        (WebCore::CCLayerTreeHost::didRecreateGraphicsContext):
     74        (WebCore::CCLayerTreeHost::updateCompositorResources):
     75        * platform/graphics/chromium/cc/CCLayerTreeHost.h:
     76        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
     77        (WebCore::CCLayerTreeHostImpl::contentsTextureAllocator):
     78        (WebCore::CCLayerTreeHostImpl::initializeLayerRenderer):
     79        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.h:
     80        * platform/graphics/chromium/cc/CCRenderSurface.cpp:
     81        (WebCore::CCRenderSurface::drawSurface):
     82        * platform/graphics/chromium/cc/CCSingleThreadProxy.cpp:
     83        (WebCore::CCSingleThreadProxy::setNeedsCommit):
     84        (WebCore::CCSingleThreadProxy::stop):
     85        (WebCore::CCSingleThreadProxy::recreateContextIfNeeded):
     86        (WebCore::CCSingleThreadProxy::commitIfNeeded):
     87        * platform/graphics/chromium/cc/CCThreadProxy.cpp:
     88        (WebCore::CCThreadProxy::commitOnCCThread):
     89        (WebCore::CCThreadProxy::layerTreeHostClosedOnCCThread):
     90
    1912011-06-28  Robert Hogan  <robert@webkit.org>
    292
  • trunk/Source/WebCore/WebCore.gypi

    r96073 r96141  
    34663466            'platform/graphics/chromium/SimpleFontDataChromiumWin.cpp',
    34673467            'platform/graphics/chromium/SimpleFontDataLinux.cpp',
     3468            'platform/graphics/chromium/TrackingTextureAllocator.cpp',
     3469            'platform/graphics/chromium/TrackingTextureAllocator.h',
    34683470            'platform/graphics/chromium/TextureManager.cpp',
    34693471            'platform/graphics/chromium/TextureManager.h',
  • trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp

    r95901 r96141  
    6565}
    6666
    67 void Canvas2DLayerChromium::updateCompositorResources(GraphicsContext3D*)
     67void Canvas2DLayerChromium::updateCompositorResources(GraphicsContext3D*, TextureAllocator*)
    6868{
    6969    if (m_dirtyRect.isEmpty() || !drawsContent())
  • trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.h

    r95901 r96141  
    4747    virtual ~Canvas2DLayerChromium();
    4848    virtual bool drawsContent() const;
    49     virtual void updateCompositorResources(GraphicsContext3D*);
     49    virtual void updateCompositorResources(GraphicsContext3D*, TextureAllocator*);
    5050
    5151    void setTextureChanged();
  • trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp

    r95901 r96141  
    6767    }
    6868
    69     virtual void updateTextureRect(GraphicsContext3D* context, ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect)
     69    virtual void updateTextureRect(GraphicsContext3D* context, TextureAllocator* allocator, ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect)
    7070    {
    71         texture->bindTexture(context);
     71        texture->bindTexture(context, allocator);
    7272
    7373        // Source rect should never go outside the image pixels, even if this
  • trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.h

    r95901 r96141  
    153153    virtual bool drawsContent() const { return false; }
    154154    virtual void paintContentsIfDirty() { }
    155     virtual void updateCompositorResources(GraphicsContext3D*) { }
     155    virtual void updateCompositorResources(GraphicsContext3D*, TextureAllocator*) { }
    156156    virtual void setIsMask(bool) {}
    157157    virtual void unreserveContentsTexture() { }
  • trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp

    r96066 r96141  
    5252#include "TreeSynchronizer.h"
    5353#include "TraceEvent.h"
     54#include "TrackingTextureAllocator.h"
    5455#include "WebGLLayerChromium.h"
    5556#include "cc/CCLayerImpl.h"
     
    148149    , m_currentRenderSurface(0)
    149150    , m_offscreenFramebufferId(0)
    150     , m_contentsTextureMemoryUseBytes(0)
    151151    , m_context(context)
    152152    , m_defaultRenderSurface(0)
     
    215215void LayerRendererChromium::releaseRenderSurfaceTextures()
    216216{
    217     m_renderSurfaceTextureManager->evictAndDeleteAllTextures(m_context.get());
     217    m_renderSurfaceTextureManager->evictAndDeleteAllTextures(m_renderSurfaceTextureAllocator.get());
    218218}
    219219
     
    238238        return;
    239239
    240     m_renderSurfaceTextureManager->setMemoryLimitBytes(TextureManager::highLimitBytes() - m_contentsTextureMemoryUseBytes);
     240    size_t contentsMemoryUseBytes = m_contentsTextureAllocator->currentMemoryUseBytes();
     241    m_renderSurfaceTextureManager->setMemoryLimitBytes(TextureManager::highLimitBytes() - contentsMemoryUseBytes);
    241242    drawLayersInternal();
    242243
    243     if (TextureManager::reclaimLimitBytes() > m_contentsTextureMemoryUseBytes)
    244         m_renderSurfaceTextureManager->reduceMemoryToLimit(TextureManager::reclaimLimitBytes() - m_contentsTextureMemoryUseBytes);
     244    if (TextureManager::reclaimLimitBytes() > contentsMemoryUseBytes)
     245        m_renderSurfaceTextureManager->reduceMemoryToLimit(TextureManager::reclaimLimitBytes() - contentsMemoryUseBytes);
    245246    else
    246247        m_renderSurfaceTextureManager->reduceMemoryToLimit(0);
    247     m_renderSurfaceTextureManager->deleteEvictedTextures(m_context.get());
     248    m_renderSurfaceTextureManager->deleteEvictedTextures(m_renderSurfaceTextureAllocator.get());
    248249
    249250    if (settings().compositeOffscreen)
     
    437438}
    438439
    439 // FIXME: This method should eventually be replaced by a proper texture manager.
    440 unsigned LayerRendererChromium::createLayerTexture()
    441 {
    442     unsigned textureId = 0;
    443     GLC(m_context.get(), textureId = m_context->createTexture());
    444     GLC(m_context.get(), m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, textureId));
    445     // Do basic linear filtering on resize.
    446     GLC(m_context.get(), m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR));
    447     GLC(m_context.get(), m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR));
    448     // NPOT textures in GL ES only work when the wrap mode is set to GraphicsContext3D::CLAMP_TO_EDGE.
    449     GLC(m_context.get(), m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE));
    450     GLC(m_context.get(), m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE));
    451     return textureId;
    452 }
    453 
    454 void LayerRendererChromium::deleteLayerTexture(unsigned textureId)
    455 {
    456     if (!textureId)
    457         return;
    458 
    459     GLC(m_context.get(), m_context->deleteTexture(textureId));
    460 }
    461 
    462440// Returns true if any part of the layer falls within the visibleRect
    463441bool LayerRendererChromium::isLayerVisible(LayerChromium* layer, const TransformationMatrix& matrix, const IntRect& visibleRect)
     
    517495        return false;
    518496
    519     renderSurface->contentsTexture()->framebufferTexture2D(m_context.get());
     497    renderSurface->contentsTexture()->framebufferTexture2D(m_context.get(), m_renderSurfaceTextureAllocator.get());
    520498
    521499#if !defined ( NDEBUG )
     
    636614
    637615    m_renderSurfaceTextureManager = TextureManager::create(TextureManager::highLimitBytes(), m_capabilities.maxTextureSize);
     616    m_contentsTextureAllocator = TrackingTextureAllocator::create(m_context.get());
     617    m_renderSurfaceTextureAllocator = TrackingTextureAllocator::create(m_context.get());
    638618    return true;
    639619}
     
    844824        GLC(m_context.get(), m_context->deleteFramebuffer(m_offscreenFramebufferId));
    845825
    846     ASSERT(!m_contentsTextureMemoryUseBytes);
    847826    releaseRenderSurfaceTextures();
    848827}
  • trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h

    r95988 r96141  
    3939#include "IntRect.h"
    4040#include "LayerChromium.h"
     41#include "TrackingTextureAllocator.h"
    4142#include "VideoLayerChromium.h"
    4243#include "cc/CCCanvasLayerImpl.h"
     
    6970class GraphicsContext3D;
    7071class NonCompositedContentHost;
     72class TrackingTextureAllocator;
    7173
    7274// Class that handles drawing of composited render layers using GL.
     
    7981    void close();
    8082
    81     virtual ~LayerRendererChromium();
     83    ~LayerRendererChromium();
    8284
    8385    const CCSettings& settings() const { return m_owner->settings(); }
     
    105107
    106108    void setZoomAnimatorTransform(const TransformationMatrix& t) { m_zoomAnimatorTransform = t; }
    107 
    108     unsigned createLayerTexture();
    109     void deleteLayerTexture(unsigned);
    110109
    111110    static void debugGLCall(GraphicsContext3D*, const char* command, const char* file, int line);
     
    134133
    135134    TextureManager* renderSurfaceTextureManager() const { return m_renderSurfaceTextureManager.get(); }
     135    TextureAllocator* renderSurfaceTextureAllocator() const { return m_renderSurfaceTextureAllocator.get(); }
     136    TextureAllocator* contentsTextureAllocator() const { return m_contentsTextureAllocator.get(); }
    136137
    137138    CCHeadsUpDisplay* headsUpDisplay() { return m_headsUpDisplay.get(); }
     
    148149
    149150    typedef Vector<RefPtr<CCLayerImpl> > CCLayerList;
    150 
    151     void setContentsTextureMemoryUseBytes(size_t contentsTextureMemoryUseBytes) { m_contentsTextureMemoryUseBytes = contentsTextureMemoryUseBytes; }
    152151
    153152    static void toGLMatrix(float*, const TransformationMatrix&);
     
    214213    OwnPtr<CCVideoLayerImpl::YUVProgram> m_videoLayerYUVProgram;
    215214
    216     size_t m_contentsTextureMemoryUseBytes;
    217215    OwnPtr<TextureManager> m_renderSurfaceTextureManager;
     216    OwnPtr<TrackingTextureAllocator> m_contentsTextureAllocator;
     217    OwnPtr<TrackingTextureAllocator> m_renderSurfaceTextureAllocator;
    218218
    219219    OwnPtr<CCHeadsUpDisplay> m_headsUpDisplay;
  • trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h

    r95901 r96141  
    3939class IntSize;
    4040class ManagedTexture;
     41class TextureAllocator;
    4142
    4243class LayerTextureUpdater : public RefCounted<LayerTextureUpdater> {
     
    6263    virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat) = 0;
    6364    virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels) = 0;
    64     virtual void updateTextureRect(GraphicsContext3D*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect) = 0;
     65    virtual void updateTextureRect(GraphicsContext3D*, TextureAllocator*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect) = 0;
    6566};
    6667
  • trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp

    r95901 r96141  
    9494}
    9595
    96 void LayerTextureUpdaterBitmap::updateTextureRect(GraphicsContext3D* context, ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect)
     96void LayerTextureUpdaterBitmap::updateTextureRect(GraphicsContext3D* context, TextureAllocator* allocator, ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect)
    9797{
    9898    PlatformCanvas::AutoLocker locker(&m_canvas);
    9999
    100     texture->bindTexture(context);
     100    texture->bindTexture(context, allocator);
    101101    m_texSubImage.upload(locker.pixels(), contentRect(), sourceRect, destRect, texture->format(), context);
    102102}
     
    146146}
    147147
    148 void LayerTextureUpdaterSkPicture::updateTextureRect(GraphicsContext3D* compositorContext, ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect)
     148void LayerTextureUpdaterSkPicture::updateTextureRect(GraphicsContext3D* compositorContext, TextureAllocator* allocator, ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect)
    149149{
    150150    ASSERT(!m_context || m_context == compositorContext);
     
    161161    // Bind texture.
    162162    context()->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo);
    163     texture->framebufferTexture2D(context());
     163    texture->framebufferTexture2D(context(), allocator);
    164164    ASSERT(context()->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) == GraphicsContext3D::FRAMEBUFFER_COMPLETE);
    165165
  • trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.h

    r95901 r96141  
    7272    virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat);
    7373    virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels);
    74     virtual void updateTextureRect(GraphicsContext3D*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect);
     74    virtual void updateTextureRect(GraphicsContext3D*, TextureAllocator*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect);
    7575
    7676private:
     
    8989    virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat);
    9090    virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels);
    91     virtual void updateTextureRect(GraphicsContext3D*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect);
     91    virtual void updateTextureRect(GraphicsContext3D*, TextureAllocator*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect);
    9292
    9393private:
  • trunk/Source/WebCore/platform/graphics/chromium/ManagedTexture.cpp

    r95901 r96141  
    8181}
    8282
    83 void ManagedTexture::bindTexture(GraphicsContext3D* context)
     83void ManagedTexture::bindTexture(GraphicsContext3D* context, TextureAllocator* allocator)
    8484{
    8585    ASSERT(m_textureManager->hasTexture(m_token));
    8686    if (!m_textureId)
    87         m_textureId = m_textureManager->allocateTexture(context, m_token);
     87        m_textureId = m_textureManager->allocateTexture(allocator, m_token);
    8888    context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_textureId);
    8989}
    9090
    91 void ManagedTexture::framebufferTexture2D(GraphicsContext3D* context)
     91void ManagedTexture::framebufferTexture2D(GraphicsContext3D* context, TextureAllocator* allocator)
    9292{
    9393    ASSERT(m_textureManager->hasTexture(m_token));
    9494    if (!m_textureId)
    95         m_textureId = m_textureManager->allocateTexture(context, m_token);
     95        m_textureId = m_textureManager->allocateTexture(allocator, m_token);
    9696    context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, m_textureId, 0);
    9797}
  • trunk/Source/WebCore/platform/graphics/chromium/ManagedTexture.h

    r95901 r96141  
    3737
    3838class GraphicsContext3D;
    39 class TextureManager;
    4039
    4140class ManagedTexture {
     
    5756    }
    5857
    59     void bindTexture(GraphicsContext3D*);
    60     void framebufferTexture2D(GraphicsContext3D*);
     58    void bindTexture(GraphicsContext3D*, TextureAllocator*);
     59    void framebufferTexture2D(GraphicsContext3D*, TextureAllocator*);
    6160
    6261    IntSize size() const { return m_size; }
  • trunk/Source/WebCore/platform/graphics/chromium/TextureManager.cpp

    r95901 r96141  
    3333namespace WebCore {
    3434
    35 static size_t memoryUseBytes(IntSize size, GC3Denum textureFormat)
     35size_t TextureManager::highLimitBytes()
     36{
     37    return 128 * 1024 * 1024;
     38}
     39
     40size_t TextureManager::reclaimLimitBytes()
     41{
     42    return 64 * 1024 * 1024;
     43}
     44
     45size_t TextureManager::lowLimitBytes()
     46{
     47    return 3 * 1024 * 1024;
     48}
     49
     50size_t TextureManager::memoryUseBytes(const IntSize& size, GC3Denum textureFormat)
    3651{
    3752    // FIXME: This assumes all textures are 1 byte/component.
     
    4560}
    4661
    47 size_t TextureManager::highLimitBytes()
    48 {
    49     return 128 * 1024 * 1024;
    50 }
    51 
    52 size_t TextureManager::reclaimLimitBytes()
    53 {
    54     return 64 * 1024 * 1024;
    55 }
    56 
    57 size_t TextureManager::lowLimitBytes()
    58 {
    59     return 3 * 1024 * 1024;
    60 }
    6162
    6263TextureManager::TextureManager(size_t memoryLimitBytes, int maxTextureSize)
     
    153154}
    154155
    155 void TextureManager::deleteEvictedTextures(GraphicsContext3D* context)
    156 {
    157     if (context) {
     156void TextureManager::deleteEvictedTextures(TextureAllocator* allocator)
     157{
     158    if (allocator) {
    158159        for (size_t i = 0; i < m_evictedTextures.size(); ++i) {
    159160            if (m_evictedTextures[i].textureId) {
    160161#ifndef NDEBUG
    161                 ASSERT(m_evictedTextures[i].allocatingContext == context);
    162 #endif
    163                 GLC(context, context->deleteTexture(m_evictedTextures[i].textureId));
     162                ASSERT(m_evictedTextures[i].allocator == allocator);
     163#endif
     164                allocator->deleteTexture(m_evictedTextures[i].textureId, m_evictedTextures[i].size, m_evictedTextures[i].format);
    164165            }
    165166        }
     
    168169}
    169170
    170 void TextureManager::evictAndDeleteAllTextures(GraphicsContext3D* context)
     171void TextureManager::evictAndDeleteAllTextures(TextureAllocator* allocator)
    171172{
    172173    unprotectAllTextures();
    173174    reduceMemoryToLimit(0);
    174     deleteEvictedTextures(context);
     175    deleteEvictedTextures(allocator);
    175176}
    176177
     
    185186    EvictionEntry entry;
    186187    entry.textureId = info.textureId;
    187 #ifndef NDEBUG
    188     entry.allocatingContext = info.allocatingContext;
     188    entry.size = info.size;
     189    entry.format = info.format;
     190#ifndef NDEBUG
     191    entry.allocator = info.allocator;
    189192#endif
    190193    m_evictedTextures.append(entry);
    191194}
    192195
    193 unsigned TextureManager::allocateTexture(GraphicsContext3D* context, TextureToken token)
     196unsigned TextureManager::allocateTexture(TextureAllocator* allocator, TextureToken token)
    194197{
    195198    TextureMap::iterator it = m_textures.find(token);
     
    198201    ASSERT(info->isProtected);
    199202
    200     unsigned textureId;
    201     GLC(context, textureId = context->createTexture());
    202     GLC(context, context->bindTexture(GraphicsContext3D::TEXTURE_2D, textureId));
    203     // Do basic linear filtering on resize.
    204     GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR));
    205     GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR));
    206     // NPOT textures in GL ES only work when the wrap mode is set to GraphicsContext3D::CLAMP_TO_EDGE.
    207     GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE));
    208     GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE));
    209     GLC(context, context->texImage2DResourceSafe(GraphicsContext3D::TEXTURE_2D, 0, info->format, info->size.width(), info->size.height(), 0, info->format, GraphicsContext3D::UNSIGNED_BYTE));
     203    unsigned textureId = allocator->createTexture(info->size, info->format);
    210204    info->textureId = textureId;
    211205#ifndef NDEBUG
    212     info->allocatingContext = context;
     206    info->allocator = allocator;
    213207#endif
    214208    return textureId;
     
    240234    info.isProtected = true;
    241235#ifndef NDEBUG
    242     info.allocatingContext = 0;
     236    info.allocator = 0;
    243237#endif
    244238    addTexture(token, info);
  • trunk/Source/WebCore/platform/graphics/chromium/TextureManager.h

    r95901 r96141  
    3838typedef int TextureToken;
    3939
     40class TextureAllocator {
     41public:
     42    virtual unsigned createTexture(const IntSize&, GC3Denum format) = 0;
     43    virtual void deleteTexture(unsigned texture, const IntSize&, GC3Denum) = 0;
     44
     45protected:
     46    virtual ~TextureAllocator() { }
     47};
     48
    4049class TextureManager {
    4150    WTF_MAKE_NONCOPYABLE(TextureManager);
     
    5362    static size_t lowLimitBytes();
    5463
     64    static size_t memoryUseBytes(const IntSize&, GC3Denum format);
     65
    5566    void setMemoryLimitBytes(size_t);
    5667
     
    6677    bool isProtected(TextureToken);
    6778
    68     unsigned allocateTexture(GraphicsContext3D*, TextureToken);
    69     void deleteEvictedTextures(GraphicsContext3D*);
     79    unsigned allocateTexture(TextureAllocator*, TextureToken);
     80    void deleteEvictedTextures(TextureAllocator*);
    7081
    71     void evictAndDeleteAllTextures(GraphicsContext3D*);
     82    void evictAndDeleteAllTextures(TextureAllocator*);
    7283
    7384    void reduceMemoryToLimit(size_t);
     
    8394        bool isProtected;
    8495#ifndef NDEBUG
    85         GraphicsContext3D* allocatingContext;
     96        TextureAllocator* allocator;
    8697#endif
    8798    };
     
    101112    struct EvictionEntry {
    102113        unsigned textureId;
     114        IntSize size;
     115        GC3Denum format;
    103116#ifndef NDEBUG
    104         GraphicsContext3D* allocatingContext;
     117        TextureAllocator* allocator;
    105118#endif
    106119    };
  • trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp

    r95901 r96141  
    152152}
    153153
    154 void TiledLayerChromium::updateCompositorResources(GraphicsContext3D* context)
     154void TiledLayerChromium::updateCompositorResources(GraphicsContext3D* context, TextureAllocator* allocator)
    155155{
    156156    // Painting could cause compositing to get turned off, which may cause the tiler to become invalidated mid-update.
     
    198198                CRASH();
    199199
    200             tile->texture()->bindTexture(context);
     200            tile->texture()->bindTexture(context, allocator);
    201201            const GC3Dint filter = m_tiler->hasBorderTexels() ? GraphicsContext3D::LINEAR : GraphicsContext3D::NEAREST;
    202202            GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, filter));
     
    204204            GLC(context, context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0));
    205205
    206             textureUpdater()->updateTextureRect(context, tile->texture(), sourceRect, destRect);
     206            textureUpdater()->updateTextureRect(context, allocator, tile->texture(), sourceRect, destRect);
    207207            tile->clearDirty();
    208208        }
  • trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h

    r95901 r96141  
    4444    virtual ~TiledLayerChromium();
    4545
    46     virtual void updateCompositorResources(GraphicsContext3D*);
     46    virtual void updateCompositorResources(GraphicsContext3D*, TextureAllocator*);
    4747    virtual void setIsMask(bool);
    4848
  • trunk/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.h

    r96140 r96141  
    11/*
    2  * Copyright (C) 2010, Google Inc. All rights reserved.
     2 * Copyright (C) 2011, Google Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2323 */
    2424
    25 #ifndef ManagedTexture_h
    26 #define ManagedTexture_h
     25#ifndef TrackingTextureAllocator_h
     26#define TrackingTextureAllocator_h
    2727
    28 #include "IntSize.h"
     28#include "GraphicsContext3D.h"
    2929#include "TextureManager.h"
    30 
    31 #include <wtf/FastAllocBase.h>
    32 #include <wtf/Noncopyable.h>
    33 #include <wtf/PassOwnPtr.h>
    34 #include <wtf/RefPtr.h>
     30#include <wtf/PassRefPtr.h>
    3531
    3632namespace WebCore {
    3733
    38 class GraphicsContext3D;
    39 class TextureManager;
     34class TrackingTextureAllocator : public TextureAllocator {
     35    WTF_MAKE_NONCOPYABLE(TrackingTextureAllocator);
     36public:
     37    static PassOwnPtr<TrackingTextureAllocator> create(PassRefPtr<GraphicsContext3D> context)
     38    {
     39        return adoptPtr(new TrackingTextureAllocator(context));
     40    }
     41    virtual ~TrackingTextureAllocator();
    4042
    41 class ManagedTexture {
    42     WTF_MAKE_NONCOPYABLE(ManagedTexture);
    43 public:
    44     static PassOwnPtr<ManagedTexture> create(TextureManager* manager)
    45     {
    46         return adoptPtr(new ManagedTexture(manager));
    47     }
    48     ~ManagedTexture();
     43    virtual unsigned createTexture(const IntSize&, GC3Denum format);
     44    virtual void deleteTexture(unsigned texture, const IntSize&, GC3Denum format);
    4945
    50     bool isValid(const IntSize&, unsigned format);
    51     bool reserve(const IntSize&, unsigned format);
    52     void unreserve();
    53     bool isReserved()
    54     {
    55         ASSERT(m_textureManager);
    56         return m_textureManager->isProtected(m_token);
    57     }
     46    size_t currentMemoryUseBytes() const { return m_currentMemoryUseBytes; }
    5847
    59     void bindTexture(GraphicsContext3D*);
    60     void framebufferTexture2D(GraphicsContext3D*);
     48protected:
     49    explicit TrackingTextureAllocator(PassRefPtr<GraphicsContext3D>);
    6150
    62     IntSize size() const { return m_size; }
    63     unsigned format() const { return m_format; }
    64     unsigned textureId() const { return m_textureId; }
    65 
    66 private:
    67     explicit ManagedTexture(TextureManager*);
    68 
    69     TextureManager* m_textureManager;
    70     TextureToken m_token;
    71     IntSize m_size;
    72     unsigned m_format;
    73     unsigned m_textureId;
     51    RefPtr<GraphicsContext3D> m_context;
     52    size_t m_currentMemoryUseBytes;
    7453};
    7554
    7655}
    7756
    78 #endif // ManagedTexture_h
     57#endif
  • trunk/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.cpp

    r95957 r96141  
    7979}
    8080
    81 void VideoLayerChromium::updateCompositorResources(GraphicsContext3D* context)
     81void VideoLayerChromium::updateCompositorResources(GraphicsContext3D* context, TextureAllocator* allocator)
    8282{
    8383    if (!m_delegate)
     
    131131        ASSERT(texture.m_texture);
    132132        ASSERT(frame->requiredTextureSize(plane) == texture.m_texture->size());
    133         updateTexture(context, texture, frame->data(plane));
     133        updateTexture(context, allocator, texture, frame->data(plane));
    134134    }
    135135
     
    248248}
    249249
    250 void VideoLayerChromium::updateTexture(GraphicsContext3D* context, Texture& texture, const void* data) const
     250void VideoLayerChromium::updateTexture(GraphicsContext3D* context, TextureAllocator* allocator, Texture& texture, const void* data) const
    251251{
    252252    ASSERT(context);
    253253    ASSERT(texture.m_texture);
    254254
    255     texture.m_texture->bindTexture(context);
     255    texture.m_texture->bindTexture(context, allocator);
    256256
    257257    GC3Denum format = texture.m_texture->format();
  • trunk/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.h

    r95957 r96141  
    5151    virtual PassRefPtr<CCLayerImpl> createCCLayerImpl();
    5252
    53     virtual void updateCompositorResources(GraphicsContext3D*);
     53    virtual void updateCompositorResources(GraphicsContext3D*, TextureAllocator*);
    5454    virtual bool drawsContent() const { return true; }
    5555
     
    7777    bool texturesValid();
    7878    bool reserveTextures(const VideoFrameChromium*, GC3Denum textureFormat);
    79     void updateTexture(GraphicsContext3D*, Texture&, const void*) const;
     79    void updateTexture(GraphicsContext3D*, TextureAllocator*, Texture&, const void*) const;
    8080
    8181    void resetFrameParameters();
  • trunk/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.cpp

    r95901 r96141  
    6666}
    6767
    68 void WebGLLayerChromium::updateCompositorResources(GraphicsContext3D* rendererContext)
     68void WebGLLayerChromium::updateCompositorResources(GraphicsContext3D* rendererContext, TextureAllocator*)
    6969{
    7070    if (!drawsContent())
  • trunk/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.h

    r95901 r96141  
    5151
    5252    virtual bool drawsContent() const;
    53     virtual void updateCompositorResources(GraphicsContext3D*);
     53    virtual void updateCompositorResources(GraphicsContext3D*, TextureAllocator*);
    5454    void setTextureUpdated();
    5555    bool paintRenderedResultsToCanvas(ImageBuffer*);
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp

    r96066 r96141  
    127127        PlatformCanvas::AutoLocker locker(&canvas);
    128128
    129         m_hudTexture->bindTexture(context);
     129        m_hudTexture->bindTexture(context, m_layerRenderer->renderSurfaceTextureAllocator());
    130130        bool uploadedViaMap = false;
    131131        if (m_useMapSubForUploads) {
     
    149149    ASSERT(program && program->initialized());
    150150    GLC(context, context->activeTexture(GraphicsContext3D::TEXTURE0));
    151     m_hudTexture->bindTexture(context);
     151    m_hudTexture->bindTexture(context, m_layerRenderer->renderSurfaceTextureAllocator());
    152152    GLC(context, context->useProgram(program->program()));
    153153    GLC(context, context->uniform1i(program->fragmentShader().samplerLocation(), 0));
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp

    r96066 r96141  
    9393    m_proxy.clear();
    9494    clearPendingUpdate();
    95     ASSERT(!m_contentsTextureManager || !m_contentsTextureManager->currentMemoryUseBytes());
    96     m_contentsTextureManager.clear();
    97 }
    98 
    99 void CCLayerTreeHost::deleteContentsTextures(GraphicsContext3D* context)
     95}
     96
     97void CCLayerTreeHost::deleteContentsTexturesOnCCThread(TextureAllocator* allocator)
    10098{
    10199    ASSERT(CCProxy::isImplThread());
    102100    if (m_contentsTextureManager)
    103         m_contentsTextureManager->evictAndDeleteAllTextures(context);
     101        m_contentsTextureManager->evictAndDeleteAllTextures(allocator);
    104102}
    105103
     
    116114// should be delayed until the CCLayerTreeHost::commitComplete, which will run
    117115// after the commit, but on the main thread.
    118 void CCLayerTreeHost::commitTo(CCLayerTreeHostImpl* hostImpl)
     116void CCLayerTreeHost::commitToOnCCThread(CCLayerTreeHostImpl* hostImpl)
    119117{
    120118    ASSERT(CCProxy::isImplThread());
     
    123121
    124122    contentsTextureManager()->reduceMemoryToLimit(TextureManager::reclaimLimitBytes());
    125     contentsTextureManager()->deleteEvictedTextures(hostImpl->context());
    126 
    127     updateCompositorResources(m_updateList, hostImpl->context());
     123    contentsTextureManager()->deleteEvictedTextures(hostImpl->contentsTextureAllocator());
     124
     125    updateCompositorResources(m_updateList, hostImpl->context(), hostImpl->contentsTextureAllocator());
    128126
    129127    hostImpl->setVisible(m_visible);
    130128    hostImpl->setZoomAnimatorTransform(m_zoomAnimatorTransform);
    131129    hostImpl->setViewport(viewportSize());
    132 
    133     hostImpl->layerRenderer()->setContentsTextureMemoryUseBytes(m_contentsTextureManager->currentMemoryUseBytes());
    134130
    135131    // Synchronize trees, if one exists at all...
     
    165161void CCLayerTreeHost::didRecreateGraphicsContext(bool success)
    166162{
    167     m_contentsTextureManager->evictAndDeleteAllTextures(0);
    168 
    169163    if (rootLayer())
    170164        rootLayer()->cleanupResourcesRecursive();
     
    378372}
    379373
    380 void CCLayerTreeHost::updateCompositorResources(const LayerList& renderSurfaceLayerList, GraphicsContext3D* context)
     374void CCLayerTreeHost::updateCompositorResources(const LayerList& renderSurfaceLayerList, GraphicsContext3D* context, TextureAllocator* allocator)
    381375{
    382376    for (int surfaceIndex = renderSurfaceLayerList.size() - 1; surfaceIndex >= 0 ; --surfaceIndex) {
     
    395389                continue;
    396390
    397             updateCompositorResources(layer, context);
     391            updateCompositorResources(layer, context, allocator);
    398392        }
    399393    }
    400394}
    401395
    402 void CCLayerTreeHost::updateCompositorResources(LayerChromium* layer, GraphicsContext3D* context)
     396void CCLayerTreeHost::updateCompositorResources(LayerChromium* layer, GraphicsContext3D* context, TextureAllocator* allocator)
    403397{
    404398    if (layer->bounds().isEmpty())
     
    409403
    410404    if (layer->maskLayer())
    411         updateCompositorResources(layer->maskLayer(), context);
     405        updateCompositorResources(layer->maskLayer(), context, allocator);
    412406    if (layer->replicaLayer())
    413         updateCompositorResources(layer->replicaLayer(), context);
     407        updateCompositorResources(layer->replicaLayer(), context, allocator);
    414408
    415409    if (layer->drawsContent())
    416         layer->updateCompositorResources(context);
     410        layer->updateCompositorResources(context, allocator);
    417411}
    418412
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h

    r96066 r96141  
    4646class LayerChromium;
    4747class LayerPainterChromium;
     48class TextureAllocator;
    4849class TextureManager;
    4950
     
    99100    void animateAndLayout(double frameBeginTime);
    100101    void commitComplete();
    101     void commitTo(CCLayerTreeHostImpl*);
     102    void commitToOnCCThread(CCLayerTreeHostImpl*);
    102103    PassOwnPtr<CCThread> createCompositorThread();
    103104    PassRefPtr<GraphicsContext3D> createLayerTreeHostContext3D();
     
    107108    void scheduleComposite();
    108109#endif
     110    void deleteContentsTexturesOnCCThread(TextureAllocator*);
    109111
    110112    // CCLayerTreeHost interface to WebView.
     
    153155    void updateLayers();
    154156
    155     void deleteContentsTextures(GraphicsContext3D*);
    156 
    157157protected:
    158158    CCLayerTreeHost(CCLayerTreeHostClient*, PassRefPtr<LayerChromium> rootLayer, const CCSettings&);
     
    164164    void paintLayerContents(const LayerList&);
    165165    void updateLayers(LayerChromium*);
    166     void updateCompositorResources(const LayerList&, GraphicsContext3D*);
    167     void updateCompositorResources(LayerChromium*, GraphicsContext3D*);
     166    void updateCompositorResources(const LayerList&, GraphicsContext3D*, TextureAllocator*);
     167    void updateCompositorResources(LayerChromium*, GraphicsContext3D*, TextureAllocator*);
    168168    void clearPendingUpdate();
    169169
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp

    r96066 r96141  
    9999}
    100100
     101TextureAllocator* CCLayerTreeHostImpl::contentsTextureAllocator() const
     102{
     103    return m_layerRenderer->contentsTextureAllocator();
     104}
     105
    101106void CCLayerTreeHostImpl::present()
    102107{
     
    135140    }
    136141
    137     // If we had a previous layer renderer, then its context must have been lost along with all of its resources.
    138     // Let the old layer renderer known its resources are gone.
    139     if (m_layerRenderer) {
    140         m_layerRenderer->setContentsTextureMemoryUseBytes(0);
     142    if (m_layerRenderer)
    141143        m_layerRenderer->close();
    142     }
    143144
    144145    m_layerRenderer = layerRenderer.release();
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h

    r95988 r96141  
    3838class CCLayerImpl;
    3939class LayerRendererChromium;
     40class TextureAllocator;
    4041struct LayerRendererCapabilities;
    4142class TransformationMatrix;
     
    6263    LayerRendererChromium* layerRenderer() { return m_layerRenderer.get(); }
    6364    const LayerRendererCapabilities& layerRendererCapabilities() const;
     65    TextureAllocator* contentsTextureAllocator() const;
    6466
    6567    void present();
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.cpp

    r95901 r96141  
    188188    GLC(context3D, context3D->activeTexture(GraphicsContext3D::TEXTURE0));
    189189    GLC(context3D, context3D->uniform1i(program->fragmentShader().samplerLocation(), 0));
    190     m_contentsTexture->bindTexture(context3D);
     190    m_contentsTexture->bindTexture(context3D, layerRenderer->renderSurfaceTextureAllocator());
    191191
    192192    if (shaderMaskSamplerLocation != -1) {
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp

    r96066 r96141  
    161161        ScopedSetImplThread impl;
    162162        m_layerTreeHostImpl->beginCommit();
    163         m_layerTreeHost->commitTo(m_layerTreeHostImpl.get());
     163        m_layerTreeHost->commitToOnCCThread(m_layerTreeHostImpl.get());
    164164        m_layerTreeHostImpl->commitComplete();
    165165    }
     
    191191    {
    192192        ScopedSetImplThread impl;
    193         m_layerTreeHost->deleteContentsTextures(m_layerTreeHostImpl->context());
     193        m_layerTreeHost->deleteContentsTexturesOnCCThread(m_layerTreeHostImpl->contentsTextureAllocator());
    194194        m_layerTreeHostImpl.clear();
    195195    }
     
    228228        {
    229229            ScopedSetImplThread impl;
     230            m_layerTreeHost->deleteContentsTexturesOnCCThread(m_layerTreeHostImpl->contentsTextureAllocator());
    230231            ok = m_layerTreeHostImpl->initializeLayerRenderer(context);
    231232            if (ok)
     
    264265        ScopedSetImplThread impl;
    265266        m_layerTreeHostImpl->beginCommit();
    266         m_layerTreeHost->commitTo(m_layerTreeHostImpl.get());
     267        m_layerTreeHost->commitToOnCCThread(m_layerTreeHostImpl.get());
    267268        m_layerTreeHostImpl->commitComplete();
    268269    }
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp

    r96066 r96141  
    346346    }
    347347    m_layerTreeHostImpl->beginCommit();
    348     m_layerTreeHost->commitTo(m_layerTreeHostImpl.get());
     348    m_layerTreeHost->commitToOnCCThread(m_layerTreeHostImpl.get());
    349349    m_layerTreeHostImpl->commitComplete();
    350350
     
    431431    TRACE_EVENT("CCThreadProxy::layerTreeHostClosedOnCCThread", this, 0);
    432432    ASSERT(isImplThread());
    433     m_layerTreeHost->deleteContentsTextures(m_layerTreeHostImpl->context());
     433    m_layerTreeHost->deleteContentsTexturesOnCCThread(m_layerTreeHostImpl->contentsTextureAllocator());
    434434    m_layerTreeHostImpl.clear();
    435435    completion->signal();
Note: See TracChangeset for help on using the changeset viewer.