Skip to content
  • vangelis@chromium.org's avatar
    2010-11-24 James Robinson <jamesr@chromium.org> · bb315268
    vangelis@chromium.org authored
            Reviewed by Kenneth Russell.
    
            [chromium] Compositor needs to manage its VRAM use
            https://bugs.webkit.org/show_bug.cgi?id=49629
    
            This adds a basic texture manager to the Chromium compositor to limit the amount of VRAM
            used by compositor textures and switches ContentLayerChromium, ImageLayerChromium, and
            RenderSurfaceChromium to use managed LayerTexture.  The other *LayerChromium classes (Canvas,
            Video, and WebGL) and the root layer are still unmanaged.
    
            The TextureManager works by providing tokens to callers that want to use a managed texture.
            The token can be used to request a texture, see if the previously requested texture is still
            available, and to protect/unprotect textures when they cannot be collected.  Whenever a
            texture is created the manager attempts to free up the least recently used textures until the
            total memory use is below the provided threshhold.  If the manager cannot satisfy the memory
            limit it will not return any new textures until some old textures are released.
    
            A LayerTexture wraps a TextureManager token, size, and format.  A LayerChromium can check if a
            previously requested texture is still available for use and reserve the LayerTexture's underlying
            storage between the updateContentsIfDirty() and the draw() call.
    
            Also changes LayerChromium from having separate contentsDirty()/updateContents() calls to a single
            updateContentsIfDirty().
    
            Tests: compositing/lots-of-img-layers-with-opacity.html
                   compositing/lots-of-img-layers.html
    
            * WebCore.gypi:
            * platform/graphics/chromium/Canvas2DLayerChromium.cpp:
            (WebCore::Canvas2DLayerChromium::updateContentsIfDirty):
            * platform/graphics/chromium/Canvas2DLayerChromium.h:
            * platform/graphics/chromium/ContentLayerChromium.cpp:
            (WebCore::ContentLayerChromium::cleanupResources):
            (WebCore::ContentLayerChromium::updateContentsIfDirty):
            (WebCore::ContentLayerChromium::updateTextureRect):
            (WebCore::ContentLayerChromium::draw):
            * platform/graphics/chromium/ContentLayerChromium.h:
            * platform/graphics/chromium/ImageLayerChromium.cpp:
            (WebCore::ImageLayerChromium::updateContentsIfDirty):
            * platform/graphics/chromium/ImageLayerChromium.h:
            * platform/graphics/chromium/LayerChromium.h:
            (WebCore::LayerChromium::updateContentsIfDirty):
            (WebCore::LayerChromium::draw):
            * platform/graphics/chromium/LayerRendererChromium.cpp:
            (WebCore::LayerRendererChromium::LayerRendererChromium):
            (WebCore::LayerRendererChromium::prepareToDrawLayers):
            (WebCore::LayerRendererChromium::drawLayers):
            (WebCore::LayerRendererChromium::updateLayersRecursive):
            (WebCore::LayerRendererChromium::useRenderSurface):
            (WebCore::LayerRendererChromium::drawLayer):
            (WebCore::LayerRendererChromium::initializeSharedObjects):
            (WebCore::LayerRendererChromium::cleanupSharedObjects):
            * platform/graphics/chromium/LayerRendererChromium.h:
            (WebCore::LayerRendererChromium::renderSurfaceSharedValues):
            (WebCore::LayerRendererChromium::textureManager):
            * platform/graphics/chromium/LayerTexture.cpp: Added.
            (WebCore::LayerTexture::LayerTexture):
            (WebCore::LayerTexture::~LayerTexture):
            (WebCore::LayerTexture::isValid):
            (WebCore::LayerTexture::reserve):
            (WebCore::LayerTexture::unreserve):
            (WebCore::LayerTexture::bindTexture):
            (WebCore::LayerTexture::framebufferTexture2D):
            * platform/graphics/chromium/LayerTexture.h: Added.
            (WebCore::LayerTexture::create):
            * platform/graphics/chromium/PluginLayerChromium.cpp:
            (WebCore::PluginLayerChromium::updateContentsIfDirty):
            * platform/graphics/chromium/PluginLayerChromium.h:
            * platform/graphics/chromium/RenderSurfaceChromium.cpp:
            (WebCore::RenderSurfaceChromium::SharedValues::SharedValues):
            (WebCore::RenderSurfaceChromium::SharedValues::~SharedValues):
            (WebCore::RenderSurfaceChromium::RenderSurfaceChromium):
            (WebCore::RenderSurfaceChromium::cleanupResources):
            (WebCore::RenderSurfaceChromium::prepareContentsTexture):
            (WebCore::RenderSurfaceChromium::draw):
            * platform/graphics/chromium/RenderSurfaceChromium.h:
            (WebCore::RenderSurfaceChromium::SharedValues::shaderProgram):
            (WebCore::RenderSurfaceChromium::SharedValues::shaderSamplerLocation):
            (WebCore::RenderSurfaceChromium::SharedValues::shaderMatrixLocation):
            (WebCore::RenderSurfaceChromium::SharedValues::shaderAlphaLocation):
            (WebCore::RenderSurfaceChromium::SharedValues::initialized):
            * platform/graphics/chromium/TextureManager.cpp: Added.
            (WebCore::memoryUseBytes):
            (WebCore::TextureManager::TextureManager):
            (WebCore::TextureManager::getToken):
            (WebCore::TextureManager::releaseToken):
            (WebCore::TextureManager::hasTexture):
            (WebCore::TextureManager::protectTexture):
            (WebCore::TextureManager::unprotectTexture):
            (WebCore::TextureManager::reduceMemoryToLimit):
            (WebCore::TextureManager::addTexture):
            (WebCore::TextureManager::removeTexture):
            (WebCore::TextureManager::requestTexture):
            * platform/graphics/chromium/TextureManager.h: Added.
            (WebCore::TextureManager::create):
            * platform/graphics/chromium/VideoLayerChromium.cpp:
            (WebCore::VideoLayerChromium::updateContentsIfDirty):
            * platform/graphics/chromium/VideoLayerChromium.h:
            * platform/graphics/chromium/WebGLLayerChromium.cpp:
            (WebCore::WebGLLayerChromium::updateContentsIfDirty):
            * platform/graphics/chromium/WebGLLayerChromium.h:
    2010-11-24  James Robinson  <jamesr@chromium.org>
    
            Reviewed by Kenneth Russell.
    
            [chromium] Compositor needs to manage its VRAM use
            https://bugs.webkit.org/show_bug.cgi?id=49629
    
            Adds a few tests involving lots of visible image layers.  The tests are designed
            to require slightly more than 64MB of VRAM.
    
            * compositing/lots-of-img-layers-with-opacity.html: Added.
            * compositing/lots-of-img-layers.html: Added.
            * platform/chromium-gpu-win/compositing/lots-of-img-layers-expected.checksum: Added.
            * platform/chromium-gpu-win/compositing/lots-of-img-layers-expected.png: Added.
            * platform/chromium-gpu-win/compositing/lots-of-img-layers-expected.txt: Added.
            * platform/chromium-gpu-win/compositing/lots-of-img-layers-with-opacity-expected.checksum: Added.
            * platform/chromium-gpu-win/compositing/lots-of-img-layers-with-opacity-expected.png: Added.
            * platform/chromium-gpu-win/compositing/lots-of-img-layers-with-opacity-expected.txt: Added.
            * platform/chromium-gpu/test_expectations.txt:
            * platform/mac/compositing/lots-of-img-layers-expected.checksum: Added.
            * platform/mac/compositing/lots-of-img-layers-expected.png: Added.
            * platform/mac/compositing/lots-of-img-layers-expected.txt: Added.
            * platform/mac/compositing/lots-of-img-layers-with-opacity-expected.checksum: Added.
            * platform/mac/compositing/lots-of-img-layers-with-opacity-expected.png: Added.
            * platform/mac/compositing/lots-of-img-layers-with-opacity-expected.txt: Added.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@72701 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    bb315268