Changeset 96173 in webkit


Ignore:
Timestamp:
Sep 27, 2011 5:25:01 PM (13 years ago)
Author:
mihaip@chromium.org
Message:

Unreviewed, rolling out r96141.
http://trac.webkit.org/changeset/96141
https://bugs.webkit.org/show_bug.cgi?id=68190

Breaks PrerenderBrowserTest.PrerenderHTML5Video in
browser_tests

  • 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::createLayerTexture):
(WebCore::LayerRendererChromium::deleteLayerTexture):
(WebCore::LayerRendererChromium::useRenderSurface):
(WebCore::LayerRendererChromium::initializeSharedObjects):
(WebCore::LayerRendererChromium::cleanupSharedObjects):

  • platform/graphics/chromium/LayerRendererChromium.h:

(WebCore::LayerRendererChromium::setContentsTextureMemoryUseBytes):

  • 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::memoryUseBytes):
(WebCore::TextureManager::deleteEvictedTextures):
(WebCore::TextureManager::evictAndDeleteAllTextures):
(WebCore::TextureManager::removeTexture):
(WebCore::TextureManager::allocateTexture):
(WebCore::TextureManager::requestTexture):

  • platform/graphics/chromium/TextureManager.h:
  • platform/graphics/chromium/TiledLayerChromium.cpp:

(WebCore::TiledLayerChromium::updateCompositorResources):

  • platform/graphics/chromium/TiledLayerChromium.h:
  • platform/graphics/chromium/TrackingTextureAllocator.cpp: Removed.
  • platform/graphics/chromium/TrackingTextureAllocator.h: Removed.
  • 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::deleteContentsTextures):
(WebCore::CCLayerTreeHost::commitTo):
(WebCore::CCLayerTreeHost::didRecreateGraphicsContext):
(WebCore::CCLayerTreeHost::updateCompositorResources):

  • platform/graphics/chromium/cc/CCLayerTreeHost.cpp.rej: Removed.
  • platform/graphics/chromium/cc/CCLayerTreeHost.h:
  • platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:

(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:
3 deleted
29 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r96172 r96173  
     12011-09-27  Mihai Parparita  <mihaip@chromium.org>
     2
     3        Unreviewed, rolling out r96141.
     4        http://trac.webkit.org/changeset/96141
     5        https://bugs.webkit.org/show_bug.cgi?id=68190
     6
     7        Breaks PrerenderBrowserTest.PrerenderHTML5Video in
     8        browser_tests
     9
     10        * WebCore.gypi:
     11        * platform/graphics/chromium/Canvas2DLayerChromium.cpp:
     12        (WebCore::Canvas2DLayerChromium::updateCompositorResources):
     13        * platform/graphics/chromium/Canvas2DLayerChromium.h:
     14        * platform/graphics/chromium/ImageLayerChromium.cpp:
     15        (WebCore::ImageLayerTextureUpdater::updateTextureRect):
     16        * platform/graphics/chromium/LayerChromium.h:
     17        (WebCore::LayerChromium::updateCompositorResources):
     18        * platform/graphics/chromium/LayerRendererChromium.cpp:
     19        (WebCore::LayerRendererChromium::LayerRendererChromium):
     20        (WebCore::LayerRendererChromium::releaseRenderSurfaceTextures):
     21        (WebCore::LayerRendererChromium::drawLayers):
     22        (WebCore::LayerRendererChromium::createLayerTexture):
     23        (WebCore::LayerRendererChromium::deleteLayerTexture):
     24        (WebCore::LayerRendererChromium::useRenderSurface):
     25        (WebCore::LayerRendererChromium::initializeSharedObjects):
     26        (WebCore::LayerRendererChromium::cleanupSharedObjects):
     27        * platform/graphics/chromium/LayerRendererChromium.h:
     28        (WebCore::LayerRendererChromium::setContentsTextureMemoryUseBytes):
     29        * platform/graphics/chromium/LayerTextureUpdater.h:
     30        * platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp:
     31        (WebCore::LayerTextureUpdaterBitmap::updateTextureRect):
     32        (WebCore::LayerTextureUpdaterSkPicture::updateTextureRect):
     33        * platform/graphics/chromium/LayerTextureUpdaterCanvas.h:
     34        * platform/graphics/chromium/ManagedTexture.cpp:
     35        (WebCore::ManagedTexture::bindTexture):
     36        (WebCore::ManagedTexture::framebufferTexture2D):
     37        * platform/graphics/chromium/ManagedTexture.h:
     38        * platform/graphics/chromium/TextureManager.cpp:
     39        (WebCore::memoryUseBytes):
     40        (WebCore::TextureManager::deleteEvictedTextures):
     41        (WebCore::TextureManager::evictAndDeleteAllTextures):
     42        (WebCore::TextureManager::removeTexture):
     43        (WebCore::TextureManager::allocateTexture):
     44        (WebCore::TextureManager::requestTexture):
     45        * platform/graphics/chromium/TextureManager.h:
     46        * platform/graphics/chromium/TiledLayerChromium.cpp:
     47        (WebCore::TiledLayerChromium::updateCompositorResources):
     48        * platform/graphics/chromium/TiledLayerChromium.h:
     49        * platform/graphics/chromium/TrackingTextureAllocator.cpp: Removed.
     50        * platform/graphics/chromium/TrackingTextureAllocator.h: Removed.
     51        * platform/graphics/chromium/VideoLayerChromium.cpp:
     52        (WebCore::VideoLayerChromium::updateCompositorResources):
     53        (WebCore::VideoLayerChromium::updateTexture):
     54        * platform/graphics/chromium/VideoLayerChromium.h:
     55        * platform/graphics/chromium/WebGLLayerChromium.cpp:
     56        (WebCore::WebGLLayerChromium::updateCompositorResources):
     57        * platform/graphics/chromium/WebGLLayerChromium.h:
     58        * platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp:
     59        (WebCore::CCHeadsUpDisplay::draw):
     60        * platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
     61        (WebCore::CCLayerTreeHost::~CCLayerTreeHost):
     62        (WebCore::CCLayerTreeHost::deleteContentsTextures):
     63        (WebCore::CCLayerTreeHost::commitTo):
     64        (WebCore::CCLayerTreeHost::didRecreateGraphicsContext):
     65        (WebCore::CCLayerTreeHost::updateCompositorResources):
     66        * platform/graphics/chromium/cc/CCLayerTreeHost.cpp.rej: Removed.
     67        * platform/graphics/chromium/cc/CCLayerTreeHost.h:
     68        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
     69        (WebCore::CCLayerTreeHostImpl::initializeLayerRenderer):
     70        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.h:
     71        * platform/graphics/chromium/cc/CCRenderSurface.cpp:
     72        (WebCore::CCRenderSurface::drawSurface):
     73        * platform/graphics/chromium/cc/CCSingleThreadProxy.cpp:
     74        (WebCore::CCSingleThreadProxy::setNeedsCommit):
     75        (WebCore::CCSingleThreadProxy::stop):
     76        (WebCore::CCSingleThreadProxy::recreateContextIfNeeded):
     77        (WebCore::CCSingleThreadProxy::commitIfNeeded):
     78        * platform/graphics/chromium/cc/CCThreadProxy.cpp:
     79        (WebCore::CCThreadProxy::commitOnCCThread):
     80        (WebCore::CCThreadProxy::layerTreeHostClosedOnCCThread):
     81
    1822011-09-27  James Robinson  <jamesr@chromium.org>
    283
  • trunk/Source/WebCore/WebCore.gypi

    r96142 r96173  
    34673467            'platform/graphics/chromium/SimpleFontDataChromiumWin.cpp',
    34683468            'platform/graphics/chromium/SimpleFontDataLinux.cpp',
    3469             'platform/graphics/chromium/TrackingTextureAllocator.cpp',
    3470             'platform/graphics/chromium/TrackingTextureAllocator.h',
    34713469            'platform/graphics/chromium/TextureManager.cpp',
    34723470            'platform/graphics/chromium/TextureManager.h',
  • trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp

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

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

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

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

    r96141 r96173  
    5252#include "TreeSynchronizer.h"
    5353#include "TraceEvent.h"
    54 #include "TrackingTextureAllocator.h"
    5554#include "WebGLLayerChromium.h"
    5655#include "cc/CCLayerImpl.h"
     
    149148    , m_currentRenderSurface(0)
    150149    , m_offscreenFramebufferId(0)
     150    , m_contentsTextureMemoryUseBytes(0)
    151151    , m_context(context)
    152152    , m_defaultRenderSurface(0)
     
    215215void LayerRendererChromium::releaseRenderSurfaceTextures()
    216216{
    217     m_renderSurfaceTextureManager->evictAndDeleteAllTextures(m_renderSurfaceTextureAllocator.get());
     217    m_renderSurfaceTextureManager->evictAndDeleteAllTextures(m_context.get());
    218218}
    219219
     
    238238        return;
    239239
    240     size_t contentsMemoryUseBytes = m_contentsTextureAllocator->currentMemoryUseBytes();
    241     m_renderSurfaceTextureManager->setMemoryLimitBytes(TextureManager::highLimitBytes() - contentsMemoryUseBytes);
     240    m_renderSurfaceTextureManager->setMemoryLimitBytes(TextureManager::highLimitBytes() - m_contentsTextureMemoryUseBytes);
    242241    drawLayersInternal();
    243242
    244     if (TextureManager::reclaimLimitBytes() > contentsMemoryUseBytes)
    245         m_renderSurfaceTextureManager->reduceMemoryToLimit(TextureManager::reclaimLimitBytes() - contentsMemoryUseBytes);
     243    if (TextureManager::reclaimLimitBytes() > m_contentsTextureMemoryUseBytes)
     244        m_renderSurfaceTextureManager->reduceMemoryToLimit(TextureManager::reclaimLimitBytes() - m_contentsTextureMemoryUseBytes);
    246245    else
    247246        m_renderSurfaceTextureManager->reduceMemoryToLimit(0);
    248     m_renderSurfaceTextureManager->deleteEvictedTextures(m_renderSurfaceTextureAllocator.get());
     247    m_renderSurfaceTextureManager->deleteEvictedTextures(m_context.get());
    249248
    250249    if (settings().compositeOffscreen)
     
    438437}
    439438
     439// FIXME: This method should eventually be replaced by a proper texture manager.
     440unsigned 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
     454void LayerRendererChromium::deleteLayerTexture(unsigned textureId)
     455{
     456    if (!textureId)
     457        return;
     458
     459    GLC(m_context.get(), m_context->deleteTexture(textureId));
     460}
     461
    440462// Returns true if any part of the layer falls within the visibleRect
    441463bool LayerRendererChromium::isLayerVisible(LayerChromium* layer, const TransformationMatrix& matrix, const IntRect& visibleRect)
     
    495517        return false;
    496518
    497     renderSurface->contentsTexture()->framebufferTexture2D(m_context.get(), m_renderSurfaceTextureAllocator.get());
     519    renderSurface->contentsTexture()->framebufferTexture2D(m_context.get());
    498520
    499521#if !defined ( NDEBUG )
     
    614636
    615637    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());
    618638    return true;
    619639}
     
    824844        GLC(m_context.get(), m_context->deleteFramebuffer(m_offscreenFramebufferId));
    825845
     846    ASSERT(!m_contentsTextureMemoryUseBytes);
    826847    releaseRenderSurfaceTextures();
    827848}
  • trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h

    r96141 r96173  
    3939#include "IntRect.h"
    4040#include "LayerChromium.h"
    41 #include "TrackingTextureAllocator.h"
    4241#include "VideoLayerChromium.h"
    4342#include "cc/CCCanvasLayerImpl.h"
     
    7069class GraphicsContext3D;
    7170class NonCompositedContentHost;
    72 class TrackingTextureAllocator;
    7371
    7472// Class that handles drawing of composited render layers using GL.
     
    8179    void close();
    8280
    83     ~LayerRendererChromium();
     81    virtual ~LayerRendererChromium();
    8482
    8583    const CCSettings& settings() const { return m_owner->settings(); }
     
    107105
    108106    void setZoomAnimatorTransform(const TransformationMatrix& t) { m_zoomAnimatorTransform = t; }
     107
     108    unsigned createLayerTexture();
     109    void deleteLayerTexture(unsigned);
    109110
    110111    static void debugGLCall(GraphicsContext3D*, const char* command, const char* file, int line);
     
    133134
    134135    TextureManager* renderSurfaceTextureManager() const { return m_renderSurfaceTextureManager.get(); }
    135     TextureAllocator* renderSurfaceTextureAllocator() const { return m_renderSurfaceTextureAllocator.get(); }
    136     TextureAllocator* contentsTextureAllocator() const { return m_contentsTextureAllocator.get(); }
    137136
    138137    CCHeadsUpDisplay* headsUpDisplay() { return m_headsUpDisplay.get(); }
     
    149148
    150149    typedef Vector<RefPtr<CCLayerImpl> > CCLayerList;
     150
     151    void setContentsTextureMemoryUseBytes(size_t contentsTextureMemoryUseBytes) { m_contentsTextureMemoryUseBytes = contentsTextureMemoryUseBytes; }
    151152
    152153    static void toGLMatrix(float*, const TransformationMatrix&);
     
    213214    OwnPtr<CCVideoLayerImpl::YUVProgram> m_videoLayerYUVProgram;
    214215
     216    size_t m_contentsTextureMemoryUseBytes;
    215217    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

    r96141 r96173  
    3939class IntSize;
    4040class ManagedTexture;
    41 class TextureAllocator;
    4241
    4342class LayerTextureUpdater : public RefCounted<LayerTextureUpdater> {
     
    6362    virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat) = 0;
    6463    virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels) = 0;
    65     virtual void updateTextureRect(GraphicsContext3D*, TextureAllocator*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect) = 0;
     64    virtual void updateTextureRect(GraphicsContext3D*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect) = 0;
    6665};
    6766
  • trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp

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

    r96172 r96173  
    7272    virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat);
    7373    virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels);
    74     virtual void updateTextureRect(GraphicsContext3D*, TextureAllocator*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect);
     74    virtual void updateTextureRect(GraphicsContext3D*, 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*, TextureAllocator*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect);
     91    virtual void updateTextureRect(GraphicsContext3D*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect);
    9292
    9393private:
  • trunk/Source/WebCore/platform/graphics/chromium/ManagedTexture.cpp

    r96141 r96173  
    8181}
    8282
    83 void ManagedTexture::bindTexture(GraphicsContext3D* context, TextureAllocator* allocator)
     83void ManagedTexture::bindTexture(GraphicsContext3D* context)
    8484{
    8585    ASSERT(m_textureManager->hasTexture(m_token));
    8686    if (!m_textureId)
    87         m_textureId = m_textureManager->allocateTexture(allocator, m_token);
     87        m_textureId = m_textureManager->allocateTexture(context, m_token);
    8888    context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_textureId);
    8989}
    9090
    91 void ManagedTexture::framebufferTexture2D(GraphicsContext3D* context, TextureAllocator* allocator)
     91void ManagedTexture::framebufferTexture2D(GraphicsContext3D* context)
    9292{
    9393    ASSERT(m_textureManager->hasTexture(m_token));
    9494    if (!m_textureId)
    95         m_textureId = m_textureManager->allocateTexture(allocator, m_token);
     95        m_textureId = m_textureManager->allocateTexture(context, 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

    r96141 r96173  
    3737
    3838class GraphicsContext3D;
     39class TextureManager;
    3940
    4041class ManagedTexture {
     
    5657    }
    5758
    58     void bindTexture(GraphicsContext3D*, TextureAllocator*);
    59     void framebufferTexture2D(GraphicsContext3D*, TextureAllocator*);
     59    void bindTexture(GraphicsContext3D*);
     60    void framebufferTexture2D(GraphicsContext3D*);
    6061
    6162    IntSize size() const { return m_size; }
  • trunk/Source/WebCore/platform/graphics/chromium/TextureManager.cpp

    r96141 r96173  
    3333namespace WebCore {
    3434
    35 size_t TextureManager::highLimitBytes()
    36 {
    37     return 128 * 1024 * 1024;
    38 }
    39 
    40 size_t TextureManager::reclaimLimitBytes()
    41 {
    42     return 64 * 1024 * 1024;
    43 }
    44 
    45 size_t TextureManager::lowLimitBytes()
    46 {
    47     return 3 * 1024 * 1024;
    48 }
    49 
    50 size_t TextureManager::memoryUseBytes(const IntSize& size, GC3Denum textureFormat)
     35static size_t memoryUseBytes(IntSize size, GC3Denum textureFormat)
    5136{
    5237    // FIXME: This assumes all textures are 1 byte/component.
     
    6045}
    6146
     47size_t TextureManager::highLimitBytes()
     48{
     49    return 128 * 1024 * 1024;
     50}
     51
     52size_t TextureManager::reclaimLimitBytes()
     53{
     54    return 64 * 1024 * 1024;
     55}
     56
     57size_t TextureManager::lowLimitBytes()
     58{
     59    return 3 * 1024 * 1024;
     60}
    6261
    6362TextureManager::TextureManager(size_t memoryLimitBytes, int maxTextureSize)
     
    154153}
    155154
    156 void TextureManager::deleteEvictedTextures(TextureAllocator* allocator)
    157 {
    158     if (allocator) {
     155void TextureManager::deleteEvictedTextures(GraphicsContext3D* context)
     156{
     157    if (context) {
    159158        for (size_t i = 0; i < m_evictedTextures.size(); ++i) {
    160159            if (m_evictedTextures[i].textureId) {
    161160#ifndef NDEBUG
    162                 ASSERT(m_evictedTextures[i].allocator == allocator);
    163 #endif
    164                 allocator->deleteTexture(m_evictedTextures[i].textureId, m_evictedTextures[i].size, m_evictedTextures[i].format);
     161                ASSERT(m_evictedTextures[i].allocatingContext == context);
     162#endif
     163                GLC(context, context->deleteTexture(m_evictedTextures[i].textureId));
    165164            }
    166165        }
     
    169168}
    170169
    171 void TextureManager::evictAndDeleteAllTextures(TextureAllocator* allocator)
     170void TextureManager::evictAndDeleteAllTextures(GraphicsContext3D* context)
    172171{
    173172    unprotectAllTextures();
    174173    reduceMemoryToLimit(0);
    175     deleteEvictedTextures(allocator);
     174    deleteEvictedTextures(context);
    176175}
    177176
     
    186185    EvictionEntry entry;
    187186    entry.textureId = info.textureId;
    188     entry.size = info.size;
    189     entry.format = info.format;
    190 #ifndef NDEBUG
    191     entry.allocator = info.allocator;
     187#ifndef NDEBUG
     188    entry.allocatingContext = info.allocatingContext;
    192189#endif
    193190    m_evictedTextures.append(entry);
    194191}
    195192
    196 unsigned TextureManager::allocateTexture(TextureAllocator* allocator, TextureToken token)
     193unsigned TextureManager::allocateTexture(GraphicsContext3D* context, TextureToken token)
    197194{
    198195    TextureMap::iterator it = m_textures.find(token);
     
    201198    ASSERT(info->isProtected);
    202199
    203     unsigned textureId = allocator->createTexture(info->size, info->format);
     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));
    204210    info->textureId = textureId;
    205211#ifndef NDEBUG
    206     info->allocator = allocator;
     212    info->allocatingContext = context;
    207213#endif
    208214    return textureId;
     
    234240    info.isProtected = true;
    235241#ifndef NDEBUG
    236     info.allocator = 0;
     242    info.allocatingContext = 0;
    237243#endif
    238244    addTexture(token, info);
  • trunk/Source/WebCore/platform/graphics/chromium/TextureManager.h

    r96141 r96173  
    3838typedef int TextureToken;
    3939
    40 class TextureAllocator {
    41 public:
    42     virtual unsigned createTexture(const IntSize&, GC3Denum format) = 0;
    43     virtual void deleteTexture(unsigned texture, const IntSize&, GC3Denum) = 0;
    44 
    45 protected:
    46     virtual ~TextureAllocator() { }
    47 };
    48 
    4940class TextureManager {
    5041    WTF_MAKE_NONCOPYABLE(TextureManager);
     
    6253    static size_t lowLimitBytes();
    6354
    64     static size_t memoryUseBytes(const IntSize&, GC3Denum format);
    65 
    6655    void setMemoryLimitBytes(size_t);
    6756
     
    7766    bool isProtected(TextureToken);
    7867
    79     unsigned allocateTexture(TextureAllocator*, TextureToken);
    80     void deleteEvictedTextures(TextureAllocator*);
     68    unsigned allocateTexture(GraphicsContext3D*, TextureToken);
     69    void deleteEvictedTextures(GraphicsContext3D*);
    8170
    82     void evictAndDeleteAllTextures(TextureAllocator*);
     71    void evictAndDeleteAllTextures(GraphicsContext3D*);
    8372
    8473    void reduceMemoryToLimit(size_t);
     
    9483        bool isProtected;
    9584#ifndef NDEBUG
    96         TextureAllocator* allocator;
     85        GraphicsContext3D* allocatingContext;
    9786#endif
    9887    };
     
    112101    struct EvictionEntry {
    113102        unsigned textureId;
    114         IntSize size;
    115         GC3Denum format;
    116103#ifndef NDEBUG
    117         TextureAllocator* allocator;
     104        GraphicsContext3D* allocatingContext;
    118105#endif
    119106    };
  • trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp

    r96141 r96173  
    152152}
    153153
    154 void TiledLayerChromium::updateCompositorResources(GraphicsContext3D* context, TextureAllocator* allocator)
     154void TiledLayerChromium::updateCompositorResources(GraphicsContext3D* context)
    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, allocator);
     200            tile->texture()->bindTexture(context);
    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, allocator, tile->texture(), sourceRect, destRect);
     206            textureUpdater()->updateTextureRect(context, tile->texture(), sourceRect, destRect);
    207207            tile->clearDirty();
    208208        }
  • trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h

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

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

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

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

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

    r96141 r96173  
    127127        PlatformCanvas::AutoLocker locker(&canvas);
    128128
    129         m_hudTexture->bindTexture(context, m_layerRenderer->renderSurfaceTextureAllocator());
     129        m_hudTexture->bindTexture(context);
    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, m_layerRenderer->renderSurfaceTextureAllocator());
     151    m_hudTexture->bindTexture(context);
    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

    r96141 r96173  
    9393    m_proxy.clear();
    9494    clearPendingUpdate();
    95 }
    96 
    97 void CCLayerTreeHost::deleteContentsTexturesOnCCThread(TextureAllocator* allocator)
     95    ASSERT(!m_contentsTextureManager || !m_contentsTextureManager->currentMemoryUseBytes());
     96    m_contentsTextureManager.clear();
     97}
     98
     99void CCLayerTreeHost::deleteContentsTextures(GraphicsContext3D* context)
    98100{
    99101    ASSERT(CCProxy::isImplThread());
    100102    if (m_contentsTextureManager)
    101         m_contentsTextureManager->evictAndDeleteAllTextures(allocator);
     103        m_contentsTextureManager->evictAndDeleteAllTextures(context);
    102104}
    103105
     
    114116// should be delayed until the CCLayerTreeHost::commitComplete, which will run
    115117// after the commit, but on the main thread.
    116 void CCLayerTreeHost::commitToOnCCThread(CCLayerTreeHostImpl* hostImpl)
     118void CCLayerTreeHost::commitTo(CCLayerTreeHostImpl* hostImpl)
    117119{
    118120    ASSERT(CCProxy::isImplThread());
     
    121123
    122124    contentsTextureManager()->reduceMemoryToLimit(TextureManager::reclaimLimitBytes());
    123     contentsTextureManager()->deleteEvictedTextures(hostImpl->contentsTextureAllocator());
    124 
    125     updateCompositorResources(m_updateList, hostImpl->context(), hostImpl->contentsTextureAllocator());
     125    contentsTextureManager()->deleteEvictedTextures(hostImpl->context());
     126
     127    updateCompositorResources(m_updateList, hostImpl->context());
    126128
    127129    hostImpl->setVisible(m_visible);
    128130    hostImpl->setZoomAnimatorTransform(m_zoomAnimatorTransform);
    129131    hostImpl->setViewport(viewportSize());
     132
     133    hostImpl->layerRenderer()->setContentsTextureMemoryUseBytes(m_contentsTextureManager->currentMemoryUseBytes());
    130134
    131135    // Synchronize trees, if one exists at all...
     
    161165void CCLayerTreeHost::didRecreateGraphicsContext(bool success)
    162166{
     167    m_contentsTextureManager->evictAndDeleteAllTextures(0);
     168
    163169    if (rootLayer())
    164170        rootLayer()->cleanupResourcesRecursive();
     
    372378}
    373379
    374 void CCLayerTreeHost::updateCompositorResources(const LayerList& renderSurfaceLayerList, GraphicsContext3D* context, TextureAllocator* allocator)
     380void CCLayerTreeHost::updateCompositorResources(const LayerList& renderSurfaceLayerList, GraphicsContext3D* context)
    375381{
    376382    for (int surfaceIndex = renderSurfaceLayerList.size() - 1; surfaceIndex >= 0 ; --surfaceIndex) {
     
    389395                continue;
    390396
    391             updateCompositorResources(layer, context, allocator);
     397            updateCompositorResources(layer, context);
    392398        }
    393399    }
    394400}
    395401
    396 void CCLayerTreeHost::updateCompositorResources(LayerChromium* layer, GraphicsContext3D* context, TextureAllocator* allocator)
     402void CCLayerTreeHost::updateCompositorResources(LayerChromium* layer, GraphicsContext3D* context)
    397403{
    398404    if (layer->bounds().isEmpty())
     
    403409
    404410    if (layer->maskLayer())
    405         updateCompositorResources(layer->maskLayer(), context, allocator);
     411        updateCompositorResources(layer->maskLayer(), context);
    406412    if (layer->replicaLayer())
    407         updateCompositorResources(layer->replicaLayer(), context, allocator);
     413        updateCompositorResources(layer->replicaLayer(), context);
    408414
    409415    if (layer->drawsContent())
    410         layer->updateCompositorResources(context, allocator);
     416        layer->updateCompositorResources(context);
    411417}
    412418
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h

    r96141 r96173  
    4646class LayerChromium;
    4747class LayerPainterChromium;
    48 class TextureAllocator;
    4948class TextureManager;
    5049
     
    10099    void animateAndLayout(double frameBeginTime);
    101100    void commitComplete();
    102     void commitToOnCCThread(CCLayerTreeHostImpl*);
     101    void commitTo(CCLayerTreeHostImpl*);
    103102    PassOwnPtr<CCThread> createCompositorThread();
    104103    PassRefPtr<GraphicsContext3D> createLayerTreeHostContext3D();
     
    108107    void scheduleComposite();
    109108#endif
    110     void deleteContentsTexturesOnCCThread(TextureAllocator*);
    111109
    112110    // CCLayerTreeHost interface to WebView.
     
    155153    void updateLayers();
    156154
     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*, TextureAllocator*);
    167     void updateCompositorResources(LayerChromium*, GraphicsContext3D*, TextureAllocator*);
     166    void updateCompositorResources(const LayerList&, GraphicsContext3D*);
     167    void updateCompositorResources(LayerChromium*, GraphicsContext3D*);
    168168    void clearPendingUpdate();
    169169
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp

    r96141 r96173  
    9999}
    100100
    101 TextureAllocator* CCLayerTreeHostImpl::contentsTextureAllocator() const
    102 {
    103     return m_layerRenderer->contentsTextureAllocator();
    104 }
    105 
    106101void CCLayerTreeHostImpl::present()
    107102{
     
    140135    }
    141136
    142     if (m_layerRenderer)
     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);
    143141        m_layerRenderer->close();
     142    }
    144143
    145144    m_layerRenderer = layerRenderer.release();
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h

    r96141 r96173  
    3838class CCLayerImpl;
    3939class LayerRendererChromium;
    40 class TextureAllocator;
    4140struct LayerRendererCapabilities;
    4241class TransformationMatrix;
     
    6362    LayerRendererChromium* layerRenderer() { return m_layerRenderer.get(); }
    6463    const LayerRendererCapabilities& layerRendererCapabilities() const;
    65     TextureAllocator* contentsTextureAllocator() const;
    6664
    6765    void present();
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.cpp

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

    r96141 r96173  
    161161        ScopedSetImplThread impl;
    162162        m_layerTreeHostImpl->beginCommit();
    163         m_layerTreeHost->commitToOnCCThread(m_layerTreeHostImpl.get());
     163        m_layerTreeHost->commitTo(m_layerTreeHostImpl.get());
    164164        m_layerTreeHostImpl->commitComplete();
    165165    }
     
    191191    {
    192192        ScopedSetImplThread impl;
    193         m_layerTreeHost->deleteContentsTexturesOnCCThread(m_layerTreeHostImpl->contentsTextureAllocator());
     193        m_layerTreeHost->deleteContentsTextures(m_layerTreeHostImpl->context());
    194194        m_layerTreeHostImpl.clear();
    195195    }
     
    228228        {
    229229            ScopedSetImplThread impl;
    230             m_layerTreeHost->deleteContentsTexturesOnCCThread(m_layerTreeHostImpl->contentsTextureAllocator());
    231230            ok = m_layerTreeHostImpl->initializeLayerRenderer(context);
    232231            if (ok)
     
    265264        ScopedSetImplThread impl;
    266265        m_layerTreeHostImpl->beginCommit();
    267         m_layerTreeHost->commitToOnCCThread(m_layerTreeHostImpl.get());
     266        m_layerTreeHost->commitTo(m_layerTreeHostImpl.get());
    268267        m_layerTreeHostImpl->commitComplete();
    269268    }
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp

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