2010-12-09 James Robinson <jamesr@chromium.org>
authorjamesr@google.com <jamesr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Dec 2010 01:45:18 +0000 (01:45 +0000)
committerjamesr@google.com <jamesr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Dec 2010 01:45:18 +0000 (01:45 +0000)
commit0b08057d4d8f8c0e1e96f341b9cf165c5e499514
tree8b4b38a6a03e67d21d5e297a3b7efe58e0c6efe3
parent5d63bc25d220ad6be0315dce020adc6926fe26a3
2010-12-09  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.

        * 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/chromium/compositing/lots-of-img-layers-with-opacity.html: Added.
        * platform/chromium/compositing/lots-of-img-layers.html: Added.
        * platform/chromium/test_expectations.txt:
2010-12-09  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

        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: platform/chromium/compositing/lots-of-img-layers-with-opacity.html
               platform/chromium/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::useShader):
        (WebCore::LayerRendererChromium::prepareToDrawLayers):
        (WebCore::LayerRendererChromium::updateRootLayerTextureRect):
        (WebCore::LayerRendererChromium::drawLayers):
        (WebCore::LayerRendererChromium::getFramebufferPixels):
        (WebCore::LayerRendererChromium::createLayerTexture):
        (WebCore::LayerRendererChromium::deleteLayerTexture):
        (WebCore::LayerRendererChromium::updateLayersRecursive):
        (WebCore::LayerRendererChromium::useRenderSurface):
        (WebCore::LayerRendererChromium::drawLayer):
        (WebCore::LayerRendererChromium::setScissorToRect):
        (WebCore::LayerRendererChromium::setDrawViewportRect):
        (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:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73663 268f45cc-cd09-0410-ab3c-d52691b4dbfc
34 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/chromium-gpu-win/compositing/lots-of-img-layers-expected.checksum [new file with mode: 0644]
LayoutTests/platform/chromium-gpu-win/compositing/lots-of-img-layers-expected.png [new file with mode: 0644]
LayoutTests/platform/chromium-gpu-win/compositing/lots-of-img-layers-expected.txt [new file with mode: 0644]
LayoutTests/platform/chromium-gpu-win/compositing/lots-of-img-layers-with-opacity-expected.checksum [new file with mode: 0644]
LayoutTests/platform/chromium-gpu-win/compositing/lots-of-img-layers-with-opacity-expected.png [new file with mode: 0644]
LayoutTests/platform/chromium-gpu-win/compositing/lots-of-img-layers-with-opacity-expected.txt [new file with mode: 0644]
LayoutTests/platform/chromium-gpu/test_expectations.txt
LayoutTests/platform/chromium/compositing/lots-of-img-layers-with-opacity.html [new file with mode: 0644]
LayoutTests/platform/chromium/compositing/lots-of-img-layers.html [new file with mode: 0644]
LayoutTests/platform/chromium/test_expectations.txt
WebCore/ChangeLog
WebCore/WebCore.gypi
WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp
WebCore/platform/graphics/chromium/Canvas2DLayerChromium.h
WebCore/platform/graphics/chromium/ContentLayerChromium.cpp
WebCore/platform/graphics/chromium/ContentLayerChromium.h
WebCore/platform/graphics/chromium/ImageLayerChromium.cpp
WebCore/platform/graphics/chromium/ImageLayerChromium.h
WebCore/platform/graphics/chromium/LayerChromium.h
WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
WebCore/platform/graphics/chromium/LayerRendererChromium.h
WebCore/platform/graphics/chromium/LayerTexture.cpp [new file with mode: 0644]
WebCore/platform/graphics/chromium/LayerTexture.h [new file with mode: 0644]
WebCore/platform/graphics/chromium/PluginLayerChromium.cpp
WebCore/platform/graphics/chromium/PluginLayerChromium.h
WebCore/platform/graphics/chromium/RenderSurfaceChromium.cpp
WebCore/platform/graphics/chromium/RenderSurfaceChromium.h
WebCore/platform/graphics/chromium/TextureManager.cpp [new file with mode: 0644]
WebCore/platform/graphics/chromium/TextureManager.h [new file with mode: 0644]
WebCore/platform/graphics/chromium/VideoLayerChromium.cpp
WebCore/platform/graphics/chromium/VideoLayerChromium.h
WebCore/platform/graphics/chromium/WebGLLayerChromium.cpp
WebCore/platform/graphics/chromium/WebGLLayerChromium.h