[chromium] Use CCTexture/TextureAllocator and remove TextureManager
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Jul 2012 21:35:34 +0000 (21:35 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Jul 2012 21:35:34 +0000 (21:35 +0000)
https://bugs.webkit.org/show_bug.cgi?id=91001

Patch by Eric Penner <epenner@google.com> on 2012-07-12
Reviewed by Adrienne Walker.

Source/WebCore:

Use CCTexture to clean up CCPrioritizedTexture::Backing.
Add TextureAllocator.h and remove remainder of TextureManager.h/cpp.
Minor move/refactoring of link/unlink in CCPrioritizedTexture.
Remove double initialization of the default memory limit.

Covered by existing tests (refactoring).

* WebCore.gypi:
* platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.cpp:
* platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.h:
(WebCore):
* platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.cpp:
* platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.h:
(WebCore):
* platform/graphics/chromium/ImageLayerChromium.cpp:
* platform/graphics/chromium/LayerRendererChromium.cpp:
(WebCore::LayerRendererChromium::initialize):
* platform/graphics/chromium/ManagedTexture.cpp: Removed.
* platform/graphics/chromium/ManagedTexture.h: Removed.
* platform/graphics/chromium/RenderSurfaceChromium.h:
(WebCore):
* platform/graphics/chromium/TextureAllocator.h: Copied from Source/WebCore/platform/graphics/chromium/cc/CCPriorityCalculator.h.
(WebCore):
(TextureAllocator):
(WebCore::TextureAllocator::~TextureAllocator):
* platform/graphics/chromium/TextureManager.cpp: Removed.
* platform/graphics/chromium/TextureManager.h: Removed.
* platform/graphics/chromium/TiledLayerChromium.cpp:
* platform/graphics/chromium/TrackingTextureAllocator.cpp:
(WebCore::TrackingTextureAllocator::createTexture):
(WebCore::TrackingTextureAllocator::deleteTexture):
* platform/graphics/chromium/TrackingTextureAllocator.h:
* platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp:
* platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
(WebCore::CCLayerTreeHost::prioritizeTextures):
* platform/graphics/chromium/cc/CCLayerTreeHost.h:
(WebCore):
* platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
(WebCore::CCLayerTreeHostImpl::CCLayerTreeHostImpl):
* platform/graphics/chromium/cc/CCPrioritizedTexture.cpp:
(WebCore::CCPrioritizedTexture::CCPrioritizedTexture):
(WebCore::CCPrioritizedTexture::setDimensions):
(WebCore::CCPrioritizedTexture::textureId):
(WebCore::CCPrioritizedTexture::bindTexture):
(WebCore::CCPrioritizedTexture::framebufferTexture2D):
(WebCore::CCPrioritizedTexture::link):
(WebCore):
(WebCore::CCPrioritizedTexture::unlink):
* platform/graphics/chromium/cc/CCPrioritizedTexture.h:
(WebCore):
(WebCore::CCPrioritizedTexture::bytes):
(CCPrioritizedTexture):
(WebCore::CCPrioritizedTexture::haveBackingTexture):
(WebCore::CCPrioritizedTexture::Backing::Backing):
(WebCore::CCPrioritizedTexture::Backing::~Backing):
(WebCore::CCPrioritizedTexture::Backing::owner):
(Backing):
(WebCore::CCPrioritizedTexture::backing):
* platform/graphics/chromium/cc/CCPrioritizedTextureManager.cpp:
(WebCore::CCPrioritizedTextureManager::prioritizeTextures):
(WebCore::CCPrioritizedTextureManager::requestLate):
(WebCore::CCPrioritizedTextureManager::acquireBackingTextureIfNeeded):
(WebCore::CCPrioritizedTextureManager::reduceMemory):
(WebCore::CCPrioritizedTextureManager::clearAllMemory):
(WebCore::CCPrioritizedTextureManager::registerTexture):
(WebCore::CCPrioritizedTextureManager::returnBackingTexture):
(WebCore::CCPrioritizedTextureManager::createBacking):
(WebCore::CCPrioritizedTextureManager::destroyBacking):
(WebCore::CCPrioritizedTextureManager::assertInvariants):
* platform/graphics/chromium/cc/CCPrioritizedTextureManager.h:
(CCPrioritizedTextureManager):
(WebCore::CCPrioritizedTextureManager::defaultMemoryAllocationLimit):
(WebCore::CCPrioritizedTextureManager::compareBackings):
* platform/graphics/chromium/cc/CCPriorityCalculator.h:
* platform/graphics/chromium/cc/CCScopedTexture.cpp:
* platform/graphics/chromium/cc/CCScopedTexture.h:
* platform/graphics/chromium/cc/CCTexture.h:
(WebCore::CCTexture::CCTexture):
* platform/graphics/chromium/cc/CCTiledLayerImpl.cpp:
(WebCore):
* platform/graphics/chromium/cc/CCVideoLayerImpl.cpp:

Source/WebKit/chromium:

Deleting old texture manager tests.

* WebKit.gypi:
* tests/CCLayerTreeHostImplTest.cpp:
* tests/CCPrioritizedTextureTest.cpp:
(WTF::CCPrioritizedTextureTest::texturesMemorySize):
* tests/CCThreadedTest.cpp:
* tests/CCTiledLayerTestCommon.h:
* tests/Canvas2DLayerBridgeTest.cpp:
* tests/TextureManagerTest.cpp: Removed.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@122506 268f45cc-cd09-0410-ab3c-d52691b4dbfc

40 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.gypi
Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.cpp
Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.h
Source/WebCore/platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.cpp
Source/WebCore/platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.h
Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp
Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
Source/WebCore/platform/graphics/chromium/ManagedTexture.cpp [deleted file]
Source/WebCore/platform/graphics/chromium/ManagedTexture.h [deleted file]
Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.h
Source/WebCore/platform/graphics/chromium/TextureAllocator.h [new file with mode: 0644]
Source/WebCore/platform/graphics/chromium/TextureManager.cpp [deleted file]
Source/WebCore/platform/graphics/chromium/TextureManager.h [deleted file]
Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp
Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.cpp
Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.h
Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp
Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp
Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h
Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp
Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTexture.cpp
Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTexture.h
Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTextureManager.cpp
Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTextureManager.h
Source/WebCore/platform/graphics/chromium/cc/CCPriorityCalculator.h
Source/WebCore/platform/graphics/chromium/cc/CCScopedTexture.cpp
Source/WebCore/platform/graphics/chromium/cc/CCScopedTexture.h
Source/WebCore/platform/graphics/chromium/cc/CCTexture.h
Source/WebCore/platform/graphics/chromium/cc/CCTiledLayerImpl.cpp
Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/WebKit.gypi
Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp
Source/WebKit/chromium/tests/CCPrioritizedTextureTest.cpp
Source/WebKit/chromium/tests/CCThreadedTest.cpp
Source/WebKit/chromium/tests/CCTiledLayerTestCommon.h
Source/WebKit/chromium/tests/Canvas2DLayerBridgeTest.cpp
Source/WebKit/chromium/tests/LayerRendererChromiumTest.cpp
Source/WebKit/chromium/tests/TextureManagerTest.cpp [deleted file]

index 9a7ef49..a519e76 100644 (file)
@@ -1,3 +1,92 @@
+2012-07-12  Eric Penner  <epenner@google.com>
+
+        [chromium] Use CCTexture/TextureAllocator and remove TextureManager
+        https://bugs.webkit.org/show_bug.cgi?id=91001
+
+        Reviewed by Adrienne Walker.
+
+        Use CCTexture to clean up CCPrioritizedTexture::Backing.
+        Add TextureAllocator.h and remove remainder of TextureManager.h/cpp.
+        Minor move/refactoring of link/unlink in CCPrioritizedTexture.
+        Remove double initialization of the default memory limit.
+
+        Covered by existing tests (refactoring).
+
+        * WebCore.gypi:
+        * platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.cpp:
+        * platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.h:
+        (WebCore):
+        * platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.cpp:
+        * platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.h:
+        (WebCore):
+        * platform/graphics/chromium/ImageLayerChromium.cpp:
+        * platform/graphics/chromium/LayerRendererChromium.cpp:
+        (WebCore::LayerRendererChromium::initialize):
+        * platform/graphics/chromium/ManagedTexture.cpp: Removed.
+        * platform/graphics/chromium/ManagedTexture.h: Removed.
+        * platform/graphics/chromium/RenderSurfaceChromium.h:
+        (WebCore):
+        * platform/graphics/chromium/TextureAllocator.h: Copied from Source/WebCore/platform/graphics/chromium/cc/CCPriorityCalculator.h.
+        (WebCore):
+        (TextureAllocator):
+        (WebCore::TextureAllocator::~TextureAllocator):
+        * platform/graphics/chromium/TextureManager.cpp: Removed.
+        * platform/graphics/chromium/TextureManager.h: Removed.
+        * platform/graphics/chromium/TiledLayerChromium.cpp:
+        * platform/graphics/chromium/TrackingTextureAllocator.cpp:
+        (WebCore::TrackingTextureAllocator::createTexture):
+        (WebCore::TrackingTextureAllocator::deleteTexture):
+        * platform/graphics/chromium/TrackingTextureAllocator.h:
+        * platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp:
+        * platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
+        (WebCore::CCLayerTreeHost::prioritizeTextures):
+        * platform/graphics/chromium/cc/CCLayerTreeHost.h:
+        (WebCore):
+        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
+        (WebCore::CCLayerTreeHostImpl::CCLayerTreeHostImpl):
+        * platform/graphics/chromium/cc/CCPrioritizedTexture.cpp:
+        (WebCore::CCPrioritizedTexture::CCPrioritizedTexture):
+        (WebCore::CCPrioritizedTexture::setDimensions):
+        (WebCore::CCPrioritizedTexture::textureId):
+        (WebCore::CCPrioritizedTexture::bindTexture):
+        (WebCore::CCPrioritizedTexture::framebufferTexture2D):
+        (WebCore::CCPrioritizedTexture::link):
+        (WebCore):
+        (WebCore::CCPrioritizedTexture::unlink):
+        * platform/graphics/chromium/cc/CCPrioritizedTexture.h:
+        (WebCore):
+        (WebCore::CCPrioritizedTexture::bytes):
+        (CCPrioritizedTexture):
+        (WebCore::CCPrioritizedTexture::haveBackingTexture):
+        (WebCore::CCPrioritizedTexture::Backing::Backing):
+        (WebCore::CCPrioritizedTexture::Backing::~Backing):
+        (WebCore::CCPrioritizedTexture::Backing::owner):
+        (Backing):
+        (WebCore::CCPrioritizedTexture::backing):
+        * platform/graphics/chromium/cc/CCPrioritizedTextureManager.cpp:
+        (WebCore::CCPrioritizedTextureManager::prioritizeTextures):
+        (WebCore::CCPrioritizedTextureManager::requestLate):
+        (WebCore::CCPrioritizedTextureManager::acquireBackingTextureIfNeeded):
+        (WebCore::CCPrioritizedTextureManager::reduceMemory):
+        (WebCore::CCPrioritizedTextureManager::clearAllMemory):
+        (WebCore::CCPrioritizedTextureManager::registerTexture):
+        (WebCore::CCPrioritizedTextureManager::returnBackingTexture):
+        (WebCore::CCPrioritizedTextureManager::createBacking):
+        (WebCore::CCPrioritizedTextureManager::destroyBacking):
+        (WebCore::CCPrioritizedTextureManager::assertInvariants):
+        * platform/graphics/chromium/cc/CCPrioritizedTextureManager.h:
+        (CCPrioritizedTextureManager):
+        (WebCore::CCPrioritizedTextureManager::defaultMemoryAllocationLimit):
+        (WebCore::CCPrioritizedTextureManager::compareBackings):
+        * platform/graphics/chromium/cc/CCPriorityCalculator.h:
+        * platform/graphics/chromium/cc/CCScopedTexture.cpp:
+        * platform/graphics/chromium/cc/CCScopedTexture.h:
+        * platform/graphics/chromium/cc/CCTexture.h:
+        (WebCore::CCTexture::CCTexture):
+        * platform/graphics/chromium/cc/CCTiledLayerImpl.cpp:
+        (WebCore):
+        * platform/graphics/chromium/cc/CCVideoLayerImpl.cpp:
+
 2012-07-12  Ryosuke Niwa  <rniwa@webkit.org>
 
         Let XCode have its own way.
index 608dbba..e1b0204 100644 (file)
             'platform/graphics/chromium/LayerTextureSubImage.cpp',
             'platform/graphics/chromium/LayerTextureSubImage.h',
             'platform/graphics/chromium/LayerTextureUpdater.h',
-            'platform/graphics/chromium/ManagedTexture.cpp',
-            'platform/graphics/chromium/ManagedTexture.h',
             'platform/graphics/chromium/PlatformCanvas.cpp',
             'platform/graphics/chromium/PlatformCanvas.h',
             'platform/graphics/chromium/PlatformColor.h',
             'platform/graphics/chromium/TextureCopier.h',
             'platform/graphics/chromium/TextureLayerChromium.cpp',
             'platform/graphics/chromium/TextureLayerChromium.h',
-            'platform/graphics/chromium/TextureManager.cpp',
-            'platform/graphics/chromium/TextureManager.h',
+            'platform/graphics/chromium/TextureAllocator.h',
             'platform/graphics/chromium/TextureUploader.h',
             'platform/graphics/chromium/ThrottledTextureUploader.cpp',
             'platform/graphics/chromium/ThrottledTextureUploader.h',
index f869c58..d75cf05 100644 (file)
@@ -33,6 +33,7 @@
 #include "LayerPainterChromium.h"
 #include "PlatformColor.h"
 #include "PlatformContextSkia.h"
+#include "TextureAllocator.h"
 #include "cc/CCGraphicsContext.h"
 #include "skia/ext/platform_canvas.h"
 
index d97968c..276e2b3 100644 (file)
@@ -38,6 +38,7 @@ namespace WebCore {
 
 class LayerPainterChromium;
 class CCGraphicsContext;
+class TextureAllocator;
 
 // This class rasterizes the contentRect into a skia bitmap canvas. It then updates
 // textures by copying from the canvas into the texture, using MapSubImage if
index 787b399..9f13888 100644 (file)
@@ -34,6 +34,8 @@
 
 namespace WebCore {
 
+class TextureAllocator;
+
 // This class records the contentRect into an SkPicture, then software rasterizes
 // the SkPicture into bitmaps for each tile. This implements CCSettings::perTilePainting.
 class BitmapSkPictureCanvasLayerTextureUpdater : public SkPictureCanvasLayerTextureUpdater {
index 3769365..696563a 100644 (file)
@@ -36,7 +36,6 @@
 
 #include "LayerTextureSubImage.h"
 #include "LayerTextureUpdater.h"
-#include "ManagedTexture.h"
 #include "PlatformColor.h"
 #include "cc/CCLayerTreeHost.h"
 
index e759f5c..4c82cfa 100644 (file)
@@ -43,7 +43,6 @@
 #include "SharedGraphicsContext3D.h"
 #include "SkBitmap.h"
 #include "SkColor.h"
-#include "TextureManager.h"
 #include "ThrottledTextureUploader.h"
 #include "TraceEvent.h"
 #include "TrackingTextureAllocator.h"
@@ -209,8 +208,6 @@ bool LayerRendererChromium::initialize()
     m_capabilities.usingGpuMemoryManager = extensions.contains("GL_CHROMIUM_gpu_memory_manager");
     if (m_capabilities.usingGpuMemoryManager)
         m_context->setMemoryAllocationChangedCallbackCHROMIUM(this);
-    else
-        m_client->setMemoryAllocationLimitBytes(TextureManager::highLimitBytes(viewportSize()));
 
     m_capabilities.usingDiscardFramebuffer = extensions.contains("GL_CHROMIUM_discard_framebuffer");
 
diff --git a/Source/WebCore/platform/graphics/chromium/ManagedTexture.cpp b/Source/WebCore/platform/graphics/chromium/ManagedTexture.cpp
deleted file mode 100644 (file)
index 4dabf1b..0000000
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright (C) 2010, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1.  Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- * 2.  Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if USE(ACCELERATED_COMPOSITING)
-
-#include "ManagedTexture.h"
-
-#include "GraphicsContext3D.h"
-#include "cc/CCGraphicsContext.h"
-#include <public/WebGraphicsContext3D.h>
-
-using WebKit::WebGraphicsContext3D;
-
-namespace WebCore {
-
-ManagedTexture::ManagedTexture(TextureManager* manager)
-    : m_textureManager(manager)
-    , m_token(0)
-    , m_format(0)
-    , m_textureId(0)
-{
-    m_textureManager->registerTexture(this);
-}
-
-ManagedTexture::ManagedTexture(TextureManager* manager, TextureToken token, IntSize size, unsigned format, unsigned textureId)
-    : m_textureManager(manager)
-    , m_token(token)
-    , m_size(size)
-    , m_format(format)
-    , m_textureId(textureId)
-{
-    m_textureManager->registerTexture(this);
-}
-
-ManagedTexture::~ManagedTexture()
-{
-    if (!m_textureManager)
-        return;
-    m_textureManager->unregisterTexture(this);
-    if (m_token)
-        m_textureManager->releaseToken(m_token);
-}
-
-void ManagedTexture::setTextureManager(TextureManager* manager)
-{
-    if (manager == m_textureManager)
-        return;
-
-    if (m_textureManager)
-        m_textureManager->unregisterTexture(this);
-    m_textureManager = manager;
-    clear();
-    if (m_textureManager)
-        m_textureManager->registerTexture(this);
-}
-
-bool ManagedTexture::isValid(const IntSize& size, unsigned format)
-{
-    return m_token && size == m_size && format == m_format && m_textureManager && m_textureManager->hasTexture(m_token);
-}
-
-bool ManagedTexture::reserve(const IntSize& size, unsigned format)
-{
-    if (!m_textureManager)
-        return false;
-
-    if (!m_token)
-        m_token = m_textureManager->getToken();
-
-    bool reserved = true;
-    if (size == m_size && format == m_format && m_textureManager->hasTexture(m_token))
-        m_textureManager->protectTexture(m_token);
-    else {
-        m_textureId = 0;
-        reserved = m_textureManager->requestTexture(m_token, size, format);
-        if (reserved) {
-            m_size = size;
-            m_format = format;
-        }
-    }
-
-    return reserved;
-}
-
-void ManagedTexture::unreserve()
-{
-    if (!m_token || !m_textureManager)
-        return;
-
-    m_textureManager->unprotectTexture(m_token);
-}
-
-void ManagedTexture::allocate(TextureAllocator* allocator)
-{
-    ASSERT(m_textureManager->hasTexture(m_token));
-    if (!m_textureId)
-        m_textureId = m_textureManager->allocateTexture(allocator, m_token);
-}
-
-void ManagedTexture::bindTexture(CCGraphicsContext* context, TextureAllocator* allocator)
-{
-    allocate(allocator);
-    WebGraphicsContext3D* context3d = context->context3D();
-    if (!context3d) {
-        // FIXME: Implement this path for software compositing.
-        return;
-    }
-    context3d->bindTexture(GraphicsContext3D::TEXTURE_2D, m_textureId);
-}
-
-PassOwnPtr<ManagedTexture> ManagedTexture::steal()
-{
-    OwnPtr<ManagedTexture> texture = adoptPtr(new ManagedTexture(m_textureManager, m_token, m_size, m_format, m_textureId));
-    clear();
-    return texture.release();
-}
-
-void ManagedTexture::clear()
-{
-    m_token = 0;
-    m_size = IntSize();
-    m_format = 0;
-    m_textureId = 0;
-}
-
-}
-
-#endif // USE(ACCELERATED_COMPOSITING)
diff --git a/Source/WebCore/platform/graphics/chromium/ManagedTexture.h b/Source/WebCore/platform/graphics/chromium/ManagedTexture.h
deleted file mode 100644 (file)
index 6e67ebf..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2010, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1.  Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- * 2.  Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ManagedTexture_h
-#define ManagedTexture_h
-
-#include "IntSize.h"
-#include "TextureManager.h"
-
-#include <wtf/FastAllocBase.h>
-#include <wtf/Noncopyable.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/RefPtr.h>
-
-namespace WebCore {
-
-class CCGraphicsContext;
-
-class ManagedTexture {
-    WTF_MAKE_NONCOPYABLE(ManagedTexture);
-public:
-    static PassOwnPtr<ManagedTexture> create(TextureManager* manager)
-    {
-        return adoptPtr(new ManagedTexture(manager));
-    }
-    ~ManagedTexture();
-
-    void setTextureManager(TextureManager*);
-    void clearManager() { m_textureManager = 0; }
-
-    bool isValid(const IntSize&, unsigned format);
-    bool reserve(const IntSize&, unsigned format);
-    void unreserve();
-    bool isReserved()
-    {
-        return m_textureManager && m_textureManager->isProtected(m_token);
-    }
-
-    void allocate(TextureAllocator*);
-    void bindTexture(CCGraphicsContext*, TextureAllocator*);
-
-    IntSize size() const { return m_size; }
-    unsigned format() const { return m_format; }
-    unsigned textureId() const { return m_textureId; }
-
-    // Steal token and textureId by instantiates a new texture using existing
-    // member variables.
-    PassOwnPtr<ManagedTexture> steal();
-
-private:
-    explicit ManagedTexture(TextureManager*);
-    ManagedTexture(TextureManager*, TextureToken, IntSize, unsigned format, unsigned textureId);
-
-    void clear();
-
-    TextureManager* m_textureManager;
-    TextureToken m_token;
-    IntSize m_size;
-    unsigned m_format;
-    unsigned m_textureId;
-};
-
-}
-
-#endif // ManagedTexture_h
index 0e7d4e3..2b608f4 100644 (file)
@@ -40,7 +40,6 @@ namespace WebCore {
 class FilterOperations;
 class LayerChromium;
 class LayerRendererChromium;
-class ManagedTexture;
 
 class RenderSurfaceChromium {
     WTF_MAKE_NONCOPYABLE(RenderSurfaceChromium);
diff --git a/Source/WebCore/platform/graphics/chromium/TextureAllocator.h b/Source/WebCore/platform/graphics/chromium/TextureAllocator.h
new file mode 100644 (file)
index 0000000..58de115
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2012, Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#ifndef TextureAllocator_h
+#define TextureAllocator_h
+
+#include "GraphicsContext3D.h"
+#include "IntRect.h"
+#include "IntSize.h"
+
+namespace WebCore {
+
+class TextureAllocator {
+public:
+    virtual unsigned createTexture(const IntSize&, GC3Denum format) = 0;
+    virtual void deleteTexture(unsigned texture, const IntSize&, GC3Denum) = 0;
+    virtual void deleteAllTextures() = 0;
+
+protected:
+    virtual ~TextureAllocator() { }
+};
+
+}
+
+#endif
+
+
diff --git a/Source/WebCore/platform/graphics/chromium/TextureManager.cpp b/Source/WebCore/platform/graphics/chromium/TextureManager.cpp
deleted file mode 100644 (file)
index 485c722..0000000
+++ /dev/null
@@ -1,325 +0,0 @@
-/*
- * Copyright (C) 2010, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1.  Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- * 2.  Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if USE(ACCELERATED_COMPOSITING)
-
-#include "TextureManager.h"
-
-#include "ManagedTexture.h"
-#include "TraceEvent.h"
-
-using namespace std;
-
-namespace WebCore {
-
-
-namespace {
-size_t memoryLimitBytes(size_t viewportMultiplier, const IntSize& viewportSize, size_t minMegabytes, size_t maxMegabytes)
-{
-    if (!viewportMultiplier)
-        return maxMegabytes * 1024 * 1024;
-    if (viewportSize.isEmpty())
-        return minMegabytes * 1024 * 1024;
-    return max(minMegabytes * 1024 * 1024, min(maxMegabytes * 1024 * 1024, viewportMultiplier * TextureManager::memoryUseBytes(viewportSize, GraphicsContext3D::RGBA)));
-}
-}
-
-size_t TextureManager::highLimitBytes(const IntSize& viewportSize)
-{
-    size_t viewportMultiplier, minMegabytes, maxMegabytes;
-#if OS(ANDROID)
-    viewportMultiplier = 16;
-    minMegabytes = 32;
-    maxMegabytes = 64;
-#else
-    viewportMultiplier = 0;
-    minMegabytes = 0;
-    maxMegabytes = 128;
-#endif
-    return memoryLimitBytes(viewportMultiplier, viewportSize, minMegabytes, maxMegabytes);
-}
-
-size_t TextureManager::reclaimLimitBytes(const IntSize& viewportSize)
-{
-    size_t viewportMultiplier, minMegabytes, maxMegabytes;
-#if OS(ANDROID)
-    viewportMultiplier = 8;
-    minMegabytes = 16;
-    maxMegabytes = 32;
-#else
-    viewportMultiplier = 0;
-    minMegabytes = 0;
-    maxMegabytes = 64;
-#endif
-    return memoryLimitBytes(viewportMultiplier, viewportSize, minMegabytes, maxMegabytes);
-}
-
-size_t TextureManager::memoryUseBytes(const IntSize& size, GC3Denum textureFormat)
-{
-    // FIXME: This assumes all textures are 1 byte/component.
-    const GC3Denum type = GraphicsContext3D::UNSIGNED_BYTE;
-    unsigned int componentsPerPixel = 4;
-    unsigned int bytesPerComponent = 1;
-    if (!GraphicsContext3D::computeFormatAndTypeParameters(textureFormat, type, &componentsPerPixel, &bytesPerComponent))
-        ASSERT_NOT_REACHED();
-
-    return size.width() * size.height() * componentsPerPixel * bytesPerComponent;
-}
-
-
-TextureManager::TextureManager(size_t maxMemoryLimitBytes, size_t preferredMemoryLimitBytes, int maxTextureSize)
-    : m_maxMemoryLimitBytes(maxMemoryLimitBytes)
-    , m_preferredMemoryLimitBytes(preferredMemoryLimitBytes)
-    , m_memoryUseBytes(0)
-    , m_maxTextureSize(maxTextureSize)
-    , m_nextToken(1)
-{
-}
-
-TextureManager::~TextureManager()
-{
-    for (HashSet<ManagedTexture*>::iterator it = m_registeredTextures.begin(); it != m_registeredTextures.end(); ++it)
-        (*it)->clearManager();
-}
-
-void TextureManager::setMemoryAllocationLimitBytes(size_t memoryLimitBytes)
-{
-    setMaxMemoryLimitBytes(memoryLimitBytes);
-#if defined(OS_ANDROID)
-    // On android, we are setting the preferred memory limit to half of our
-    // maximum allocation, because we would like to stay significantly below
-    // the absolute memory limit whenever we can. Specifically, by limitting
-    // prepainting only to the halfway memory mark.
-    setPreferredMemoryLimitBytes(memoryLimitBytes / 2);
-#else
-    setPreferredMemoryLimitBytes(memoryLimitBytes);
-#endif
-}
-
-void TextureManager::setMaxMemoryLimitBytes(size_t memoryLimitBytes)
-{
-    reduceMemoryToLimit(memoryLimitBytes);
-    ASSERT(currentMemoryUseBytes() <= memoryLimitBytes);
-    m_maxMemoryLimitBytes = memoryLimitBytes;
-}
-
-void TextureManager::setPreferredMemoryLimitBytes(size_t memoryLimitBytes)
-{
-    m_preferredMemoryLimitBytes = memoryLimitBytes;
-}
-
-void TextureManager::registerTexture(ManagedTexture* texture)
-{
-    ASSERT(texture);
-    ASSERT(!m_registeredTextures.contains(texture));
-
-    m_registeredTextures.add(texture);
-}
-
-void TextureManager::unregisterTexture(ManagedTexture* texture)
-{
-    ASSERT(texture);
-    ASSERT(m_registeredTextures.contains(texture));
-
-    m_registeredTextures.remove(texture);
-}
-
-TextureToken TextureManager::getToken()
-{
-    return m_nextToken++;
-}
-
-void TextureManager::releaseToken(TextureToken token)
-{
-    TextureMap::iterator it = m_textures.find(token);
-    if (it != m_textures.end())
-        removeTexture(token, it->second);
-}
-
-bool TextureManager::hasTexture(TextureToken token)
-{
-    return m_textures.contains(token);
-}
-
-bool TextureManager::isProtected(TextureToken token)
-{
-    return token && hasTexture(token) && m_textures.get(token).isProtected;
-}
-
-void TextureManager::protectTexture(TextureToken token)
-{
-    ASSERT(hasTexture(token));
-    TextureInfo info = m_textures.take(token);
-    info.isProtected = true;
-    m_textures.add(token, info);
-    // If someone protects a texture, put it at the end of the LRU list.
-    m_textureLRUSet.remove(token);
-    m_textureLRUSet.add(token);
-}
-
-void TextureManager::unprotectTexture(TextureToken token)
-{
-    TextureMap::iterator it = m_textures.find(token);
-    if (it != m_textures.end())
-        it->second.isProtected = false;
-}
-
-void TextureManager::unprotectAllTextures()
-{
-    for (TextureMap::iterator it = m_textures.begin(); it != m_textures.end(); ++it)
-        it->second.isProtected = false;
-}
-
-void TextureManager::evictTexture(TextureToken token, TextureInfo info)
-{
-    TRACE_EVENT0("cc", "TextureManager::evictTexture");
-    removeTexture(token, info);
-}
-
-void TextureManager::reduceMemoryToLimit(size_t limit)
-{
-    while (m_memoryUseBytes > limit) {
-        ASSERT(!m_textureLRUSet.isEmpty());
-        bool foundCandidate = false;
-        for (ListHashSet<TextureToken>::iterator lruIt = m_textureLRUSet.begin(); lruIt != m_textureLRUSet.end(); ++lruIt) {
-            TextureToken token = *lruIt;
-            TextureInfo info = m_textures.get(token);
-            if (info.isProtected)
-                continue;
-            evictTexture(token, info);
-            foundCandidate = true;
-            break;
-        }
-        if (!foundCandidate)
-            return;
-    }
-}
-
-void TextureManager::addTexture(TextureToken token, TextureInfo info)
-{
-    ASSERT(!m_textureLRUSet.contains(token));
-    ASSERT(!m_textures.contains(token));
-    m_memoryUseBytes += memoryUseBytes(info.size, info.format);
-    m_textures.set(token, info);
-    m_textureLRUSet.add(token);
-}
-
-void TextureManager::deleteEvictedTextures(TextureAllocator* allocator)
-{
-    if (allocator) {
-        for (size_t i = 0; i < m_evictedTextures.size(); ++i) {
-            if (m_evictedTextures[i].textureId) {
-#ifndef NDEBUG
-                ASSERT(m_evictedTextures[i].allocator == allocator);
-#endif
-                allocator->deleteTexture(m_evictedTextures[i].textureId, m_evictedTextures[i].size, m_evictedTextures[i].format);
-            }
-        }
-    }
-    m_evictedTextures.clear();
-}
-
-void TextureManager::evictAndRemoveAllDeletedTextures()
-{
-    unprotectAllTextures();
-    reduceMemoryToLimit(0);
-    m_evictedTextures.clear();
-}
-
-void TextureManager::evictAndDeleteAllTextures(TextureAllocator* allocator)
-{
-    unprotectAllTextures();
-    reduceMemoryToLimit(0);
-    deleteEvictedTextures(allocator);
-}
-
-void TextureManager::removeTexture(TextureToken token, TextureInfo info)
-{
-    ASSERT(m_textureLRUSet.contains(token));
-    ASSERT(m_textures.contains(token));
-    m_memoryUseBytes -= memoryUseBytes(info.size, info.format);
-    m_textures.remove(token);
-    ASSERT(m_textureLRUSet.contains(token));
-    m_textureLRUSet.remove(token);
-    EvictionEntry entry;
-    entry.textureId = info.textureId;
-    entry.size = info.size;
-    entry.format = info.format;
-#ifndef NDEBUG
-    entry.allocator = info.allocator;
-#endif
-    m_evictedTextures.append(entry);
-}
-
-unsigned TextureManager::allocateTexture(TextureAllocator* allocator, TextureToken token)
-{
-    TextureMap::iterator it = m_textures.find(token);
-    ASSERT(it != m_textures.end());
-    TextureInfo* info = &it.get()->second;
-    ASSERT(info->isProtected);
-
-    unsigned textureId = allocator->createTexture(info->size, info->format);
-    info->textureId = textureId;
-#ifndef NDEBUG
-    info->allocator = allocator;
-#endif
-    return textureId;
-}
-
-bool TextureManager::requestTexture(TextureToken token, IntSize size, unsigned format)
-{
-    if (size.width() > m_maxTextureSize || size.height() > m_maxTextureSize)
-        return false;
-
-    TextureMap::iterator it = m_textures.find(token);
-    if (it != m_textures.end()) {
-        ASSERT(it->second.size != size || it->second.format != format);
-        removeTexture(token, it->second);
-    }
-
-    size_t memoryRequiredBytes = memoryUseBytes(size, format);
-    if (memoryRequiredBytes > m_maxMemoryLimitBytes)
-        return false;
-
-    reduceMemoryToLimit(m_maxMemoryLimitBytes - memoryRequiredBytes);
-    if (m_memoryUseBytes + memoryRequiredBytes > m_maxMemoryLimitBytes)
-        return false;
-
-    TextureInfo info;
-    info.size = size;
-    info.format = format;
-    info.textureId = 0;
-    info.isProtected = true;
-#ifndef NDEBUG
-    info.allocator = 0;
-#endif
-    addTexture(token, info);
-    return true;
-}
-
-}
-
-#endif // USE(ACCELERATED_COMPOSITING)
diff --git a/Source/WebCore/platform/graphics/chromium/TextureManager.h b/Source/WebCore/platform/graphics/chromium/TextureManager.h
deleted file mode 100644 (file)
index 47a189b..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright (C) 2010, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1.  Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- * 2.  Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef TextureManager_h
-#define TextureManager_h
-
-#include "GraphicsContext3D.h"
-#include "IntRect.h"
-#include "IntSize.h"
-#include <wtf/FastAllocBase.h>
-#include <wtf/HashMap.h>
-#include <wtf/HashSet.h>
-#include <wtf/ListHashSet.h>
-#include <wtf/Vector.h>
-
-namespace WebCore {
-
-class ManagedTexture;
-typedef int TextureToken;
-
-class TextureAllocator {
-public:
-    virtual unsigned createTexture(const IntSize&, GC3Denum format) = 0;
-    virtual void deleteTexture(unsigned texture, const IntSize&, GC3Denum) = 0;
-    virtual void deleteAllTextures() = 0;
-
-protected:
-    virtual ~TextureAllocator() { }
-};
-
-class TextureManager {
-    WTF_MAKE_NONCOPYABLE(TextureManager);
-public:
-    static PassOwnPtr<TextureManager> create(size_t maxMemoryLimitBytes, size_t preferredMemoryLimitBytes, int maxTextureSize)
-    {
-        return adoptPtr(new TextureManager(maxMemoryLimitBytes, preferredMemoryLimitBytes, maxTextureSize));
-    }
-    ~TextureManager();
-
-    // Absolute maximum limit for texture allocations for this instance.
-    static size_t highLimitBytes(const IntSize& viewportSize);
-    // Preferred texture size limit given the viewport size.
-    static size_t reclaimLimitBytes(const IntSize& viewportSize);
-
-    static size_t memoryUseBytes(const IntSize&, GC3Denum format);
-
-    void setMemoryAllocationLimitBytes(size_t);
-    void setMaxMemoryLimitBytes(size_t);
-    size_t maxMemoryLimitBytes() { return m_maxMemoryLimitBytes; }
-    void setPreferredMemoryLimitBytes(size_t);
-    size_t preferredMemoryLimitBytes() { return m_preferredMemoryLimitBytes; }
-
-    void registerTexture(ManagedTexture*);
-    void unregisterTexture(ManagedTexture*);
-
-    TextureToken getToken();
-    void releaseToken(TextureToken);
-    bool hasTexture(TextureToken);
-
-    bool requestTexture(TextureToken, IntSize, GC3Denum textureFormat);
-
-    void protectTexture(TextureToken);
-    void unprotectTexture(TextureToken);
-    void unprotectAllTextures();
-    bool isProtected(TextureToken);
-
-    unsigned allocateTexture(TextureAllocator*, TextureToken);
-    void deleteEvictedTextures(TextureAllocator*);
-
-    void evictAndRemoveAllDeletedTextures();
-    void evictAndDeleteAllTextures(TextureAllocator*);
-
-    void reduceMemoryToLimit(size_t);
-    size_t currentMemoryUseBytes() const { return m_memoryUseBytes; }
-
-private:
-    TextureManager(size_t maxMemoryLimitBytes, size_t preferredMemoryLimitBytes, int maxTextureSize);
-
-    struct TextureInfo {
-        IntSize size;
-        GC3Denum format;
-        unsigned textureId;
-        bool isProtected;
-#ifndef NDEBUG
-        TextureAllocator* allocator;
-#endif
-    };
-
-    void addTexture(TextureToken, TextureInfo);
-    void removeTexture(TextureToken, TextureInfo);
-    void evictTexture(TextureToken, TextureInfo);
-
-    HashSet<ManagedTexture*> m_registeredTextures;
-
-    typedef HashMap<TextureToken, TextureInfo> TextureMap;
-    TextureMap m_textures;
-    ListHashSet<TextureToken> m_textureLRUSet;
-
-    size_t m_maxMemoryLimitBytes;
-    size_t m_preferredMemoryLimitBytes;
-    size_t m_memoryUseBytes;
-    int m_maxTextureSize;
-    TextureToken m_nextToken;
-
-    struct EvictionEntry {
-        unsigned textureId;
-        IntSize size;
-        GC3Denum format;
-#ifndef NDEBUG
-        TextureAllocator* allocator;
-#endif
-    };
-
-    Vector<EvictionEntry> m_evictedTextures;
-};
-
-}
-
-#endif
index e75dd40..d085c9d 100644 (file)
@@ -30,7 +30,6 @@
 #include "TiledLayerChromium.h"
 
 #include "GraphicsContext3D.h"
-#include "ManagedTexture.h"
 #include "Region.h"
 #include "TextStream.h"
 
index c589a3c..7ae29f9 100644 (file)
@@ -75,7 +75,7 @@ unsigned TrackingTextureAllocator::createTexture(const IntSize& size, GC3Denum f
     if (size.width() > m_maxTextureSize || size.height() > m_maxTextureSize)
         return 0;
 
-    m_currentMemoryUseBytes += TextureManager::memoryUseBytes(size, format);
+    m_currentMemoryUseBytes += CCTexture::memorySizeBytes(size, format);
 
     unsigned textureId = 0;
     GLC(m_context, textureId = m_context->createTexture());
@@ -100,7 +100,7 @@ unsigned TrackingTextureAllocator::createTexture(const IntSize& size, GC3Denum f
 
 void TrackingTextureAllocator::deleteTexture(unsigned textureId, const IntSize& size, GC3Denum format)
 {
-    m_currentMemoryUseBytes -= TextureManager::memoryUseBytes(size, format);
+    m_currentMemoryUseBytes -= CCTexture::memorySizeBytes(size, format);
     GLC(m_context, m_context->deleteTexture(textureId));
     GLC(m_context, m_context->deleteTexture(textureId));
     ASSERT(m_allocatedTextureIds.contains(textureId));
index 78ef40d..38f7ca0 100644 (file)
@@ -25,7 +25,7 @@
 #ifndef TrackingTextureAllocator_h
 #define TrackingTextureAllocator_h
 
-#include "TextureManager.h"
+#include "TextureAllocator.h"
 #include <wtf/HashSet.h>
 #include <wtf/PassRefPtr.h>
 
index 731f770..be19983 100644 (file)
@@ -31,7 +31,6 @@
 #include "GraphicsContext3D.h"
 #include "LayerRendererChromium.h"
 #include "PlatformCanvas.h"
-#include "TextureManager.h"
 #include "cc/CCDebugRectHistory.h"
 #include "cc/CCFrameRateCounter.h"
 #include "cc/CCLayerTreeHostImpl.h"
index d65397e..1a4359e 100644 (file)
@@ -27,7 +27,6 @@
 #include "cc/CCLayerTreeHost.h"
 
 #include "LayerChromium.h"
-#include "ManagedTexture.h"
 #include "Region.h"
 #include "TraceEvent.h"
 #include "TreeSynchronizer.h"
@@ -529,7 +528,7 @@ void CCLayerTreeHost::prioritizeTextures(const LayerList& updateList)
         LayerChromium* renderSurfaceLayer = updateList[i].get();
         RenderSurfaceChromium* renderSurface = renderSurfaceLayer->renderSurface();
 
-        size_t bytes = TextureManager::memoryUseBytes(renderSurface->contentRect().size(), GraphicsContext3D::RGBA);
+        size_t bytes = CCTexture::memorySizeBytes(renderSurface->contentRect().size(), GraphicsContext3D::RGBA);
         contentsTextureBytes += bytes;
 
         if (renderSurface->backgroundFilters().isEmpty())
@@ -538,7 +537,7 @@ void CCLayerTreeHost::prioritizeTextures(const LayerList& updateList)
         if (bytes > maxBackgroundTextureBytes)
             maxBackgroundTextureBytes = bytes;
         if (!readbackBytes)
-            readbackBytes = TextureManager::memoryUseBytes(m_deviceViewportSize, GraphicsContext3D::RGBA);
+            readbackBytes = CCTexture::memorySizeBytes(m_deviceViewportSize, GraphicsContext3D::RGBA);
     }
     size_t renderSurfacesBytes = readbackBytes + maxBackgroundTextureBytes + contentsTextureBytes;
 
index 97060f7..7bb0f68 100644 (file)
@@ -51,7 +51,6 @@ class CCLayerChromium;
 class CCLayerTreeHostImpl;
 class CCLayerTreeHostImplClient;
 class CCTextureUpdater;
-class ManagedTexture;
 class Region;
 class TextureAllocator;
 class CCPrioritizedTextureManager;
index 78e7091..a86530c 100644 (file)
@@ -42,6 +42,7 @@
 #include "cc/CCLayerTreeHostCommon.h"
 #include "cc/CCOverdrawMetrics.h"
 #include "cc/CCPageScaleAnimation.h"
+#include "cc/CCPrioritizedTextureManager.h"
 #include "cc/CCRenderPassDrawQuad.h"
 #include "cc/CCSettings.h"
 #include "cc/CCSingleThreadProxy.h"
@@ -122,7 +123,7 @@ CCLayerTreeHostImpl::CCLayerTreeHostImpl(const CCLayerTreeSettings& settings, CC
     , m_deviceScaleFactor(1)
     , m_visible(true)
     , m_contentsTexturesWerePurgedSinceLastCommit(false)
-    , m_memoryAllocationLimitBytes(TextureManager::highLimitBytes(viewportSize()))
+    , m_memoryAllocationLimitBytes(CCPrioritizedTextureManager::defaultMemoryAllocationLimit())
     , m_headsUpDisplay(CCHeadsUpDisplay::create())
     , m_pageScale(1)
     , m_pageScaleDelta(1)
index d8cc174..a6a3081 100644 (file)
@@ -29,6 +29,7 @@
 #include "CCPrioritizedTextureManager.h"
 #include "CCPriorityCalculator.h"
 #include "LayerRendererChromium.h"
+#include "TextureAllocator.h"
 #include <algorithm>
 
 using namespace std;
@@ -38,16 +39,16 @@ namespace WebCore {
 CCPrioritizedTexture::CCPrioritizedTexture(CCPrioritizedTextureManager* manager, IntSize size, GC3Denum format)
     : m_size(size)
     , m_format(format)
-    , m_memorySizeBytes(0)
+    , m_bytes(0)
     , m_priority(CCPriorityCalculator::lowestPriority())
     , m_isAbovePriorityCutoff(false)
-    , m_currentBacking(0)
+    , m_backing(0)
     , m_manager(0)
 {
     // m_manager is set in registerTexture() so validity can be checked.
     ASSERT(format || size.isEmpty());
     if (format)
-        m_memorySizeBytes = TextureManager::memoryUseBytes(size, format);
+        m_bytes = CCTexture::memorySizeBytes(size, format);
     if (manager)
         manager->registerTexture(this);
 }
@@ -74,8 +75,8 @@ void CCPrioritizedTexture::setDimensions(IntSize size, GC3Denum format)
         m_isAbovePriorityCutoff = false;
         m_format = format;
         m_size = size;
-        m_memorySizeBytes = TextureManager::memoryUseBytes(size, format);
-        ASSERT(m_manager || !m_currentBacking);
+        m_bytes = CCTexture::memorySizeBytes(size, format);
+        ASSERT(m_manager || !m_backing);
         if (m_manager)
             m_manager->returnBackingTexture(this);
     }
@@ -97,8 +98,8 @@ void CCPrioritizedTexture::acquireBackingTexture(TextureAllocator* allocator)
 
 unsigned CCPrioritizedTexture::textureId()
 {
-    if (m_currentBacking)
-        return m_currentBacking->textureId();
+    if (m_backing)
+        return m_backing->id();
     return 0;
 }
 
@@ -107,7 +108,7 @@ void CCPrioritizedTexture::bindTexture(CCGraphicsContext* context, TextureAlloca
     ASSERT(m_isAbovePriorityCutoff);
     if (m_isAbovePriorityCutoff)
         acquireBackingTexture(allocator);
-    ASSERT(m_currentBacking);
+    ASSERT(m_backing);
     WebKit::WebGraphicsContext3D* context3d = context->context3D();
     if (!context3d) {
         // FIXME: Implement this path for software compositing.
@@ -121,7 +122,7 @@ void CCPrioritizedTexture::framebufferTexture2D(CCGraphicsContext* context, Text
     ASSERT(m_isAbovePriorityCutoff);
     if (m_isAbovePriorityCutoff)
         acquireBackingTexture(allocator);
-    ASSERT(m_currentBacking);
+    ASSERT(m_backing);
     WebKit::WebGraphicsContext3D* context3d = context->context3D();
     if (!context3d) {
         // FIXME: Implement this path for software compositing.
@@ -130,12 +131,26 @@ void CCPrioritizedTexture::framebufferTexture2D(CCGraphicsContext* context, Text
     context3d->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, textureId(), 0);
 }
 
-void CCPrioritizedTexture::setCurrentBacking(CCPrioritizedTexture::Backing* backing)
+void CCPrioritizedTexture::link(Backing* backing)
 {
-    if (m_currentBacking == backing)
-        return;
-    m_currentBacking = backing;
+    ASSERT(backing);
+    ASSERT(!backing->m_owner);
+    ASSERT(!m_backing);
+
+    m_backing = backing;
+    m_backing->m_owner = this;
+}
+
+void CCPrioritizedTexture::unlink()
+{
+    ASSERT(m_backing);
+    ASSERT(m_backing->m_owner == this);
+
+    m_backing->m_owner = 0;
+    m_backing = 0;
 }
 
+
+
 } // namespace WebCore
 
index 9ea2fb1..dc85793 100644 (file)
 #define CCPrioritizedTexture_h
 
 #include "CCPriorityCalculator.h"
+#include "CCTexture.h"
 #include "GraphicsContext3D.h"
 #include "IntRect.h"
 #include "IntSize.h"
-#include "TextureManager.h"
 
 namespace WebCore {
 
 class CCPrioritizedTextureManager;
 class CCPriorityCalculator;
 class CCGraphicsContext;
+class TextureAllocator;
 
 class CCPrioritizedTexture {
     WTF_MAKE_NONCOPYABLE(CCPrioritizedTexture);
@@ -57,7 +58,7 @@ public:
     void setDimensions(IntSize, GC3Denum format);
     GC3Denum format() const { return m_format; }
     IntSize size() const { return m_size; }
-    size_t memorySizeBytes() const { return m_memorySizeBytes; }
+    size_t bytes() const { return m_bytes; }
 
     // Set priority for the requested texture. 
     void setRequestPriority(int priority) { m_priority = priority; }
@@ -68,12 +69,12 @@ public:
     bool canAcquireBackingTexture() const { return m_isAbovePriorityCutoff; }
 
     // This returns whether we still have a backing texture. This can continue
-    // to be true even after canAquireBackingTexture() becomes false. In this
+    // to be true even after canAcquireBackingTexture() becomes false. In this
     // case the texture can be used but shouldn't be updated since it will get
     // taken away "soon".
-    bool haveBackingTexture() const { return !!currentBacking(); }
+    bool haveBackingTexture() const { return !!backing(); }
 
-    // If canAquireBackingTexture() is true acquireBackingTexture() will acquire
+    // If canAcquireBackingTexture() is true acquireBackingTexture() will acquire
     // a backing texture for use. Call this whenever the texture is actually needed.
     void acquireBackingTexture(TextureAllocator*);
 
@@ -81,13 +82,13 @@ public:
     //        (all textures are visible) but we can still squeeze into the limit
     //        by not painting occluded textures. In this case the manager
     //        refuses all visible textures and requestLate() will enable
-    //        canAquireBackingTexture() on a call-order basis. We might want to
+    //        canAcquireBackingTexture() on a call-order basis. We might want to
     //        just remove this in the future (carefully) and just make sure we don't
     //        regress OOMs situations.
     bool requestLate();
 
-    // These functions will aquire the texture if possible. If neither haveBackingTexture()
-    // nor canAquireBackingTexture() is true, an ID of zero will be used/returned.
+    // These functions will acquire the texture if possible. If neither haveBackingTexture()
+    // nor canAcquireBackingTexture() is true, an ID of zero will be used/returned.
     void bindTexture(CCGraphicsContext*, TextureAllocator*);
     void framebufferTexture2D(CCGraphicsContext*, TextureAllocator*);
     unsigned textureId();
@@ -95,34 +96,17 @@ public:
 private:
     friend class CCPrioritizedTextureManager;
 
-    class Backing {
+    class Backing : public CCTexture {
         WTF_MAKE_NONCOPYABLE(Backing);
     public:
-        IntSize size() const { return m_size; }
-        GC3Denum format() const { return m_format; }
-        size_t memorySizeBytes() const { return m_memorySizeBytes; }
-        unsigned textureId() const { return m_textureId; }
-        CCPrioritizedTexture* currentTexture() const { return m_currentTexture; }
-        void setCurrentTexture(CCPrioritizedTexture* current) { m_currentTexture = current; }
+        Backing(unsigned id, IntSize size, GC3Denum format)
+            : CCTexture(id, size, format), m_owner(0) { }
+        ~Backing() { ASSERT(!m_owner); }
 
+        CCPrioritizedTexture* owner() { return m_owner; }
     private:
-        friend class CCPrioritizedTextureManager;
-
-        Backing(IntSize size, GC3Denum format, unsigned textureId)
-            : m_size(size)
-            , m_format(format)
-            , m_memorySizeBytes(TextureManager::memoryUseBytes(size, format))
-            , m_textureId(textureId)
-            , m_priority(CCPriorityCalculator::lowestPriority())
-            , m_currentTexture(0) { }
-        ~Backing() { ASSERT(!m_currentTexture); }
-
-        IntSize m_size;
-        GC3Denum m_format;
-        size_t m_memorySizeBytes;
-        unsigned m_textureId;
-        int m_priority;
-        CCPrioritizedTexture* m_currentTexture;
+        friend class CCPrioritizedTexture;
+        CCPrioritizedTexture* m_owner;
     };
 
     CCPrioritizedTexture(CCPrioritizedTextureManager*, IntSize, GC3Denum format);
@@ -131,17 +115,18 @@ private:
     void setAbovePriorityCutoff(bool isAbovePriorityCutoff) { m_isAbovePriorityCutoff = isAbovePriorityCutoff; }
     void setManagerInternal(CCPrioritizedTextureManager* manager) { m_manager = manager; }
 
-    Backing* currentBacking() const { return m_currentBacking; }
-    void setCurrentBacking(Backing*);
+    Backing* backing() const { return m_backing; }
+    void link(Backing*);
+    void unlink();
 
     IntSize m_size;
     GC3Denum m_format;
-    size_t m_memorySizeBytes;
+    size_t m_bytes;
 
     size_t m_priority;
     bool m_isAbovePriorityCutoff;
 
-    Backing* m_currentBacking;
+    Backing* m_backing;
     CCPrioritizedTextureManager* m_manager;
 };
 
index 5af53df..0195b6f 100644 (file)
@@ -97,7 +97,7 @@ void CCPrioritizedTextureManager::prioritizeTextures(size_t renderSurfacesMemory
             reservedRenderSurfaces = true;
         }
 
-        size_t newMemoryBytes = memoryBytes + (*it)->memorySizeBytes();
+        size_t newMemoryBytes = memoryBytes + (*it)->bytes();
         if (newMemoryBytes > m_memoryAvailableBytes) {
             m_priorityCutoff = (*it)->requestPriority();
             break;
@@ -114,7 +114,7 @@ void CCPrioritizedTextureManager::prioritizeTextures(size_t renderSurfacesMemory
         bool isAbovePriorityCutoff = CCPriorityCalculator::priorityIsHigher((*it)->requestPriority(), m_priorityCutoff);
         (*it)->setAbovePriorityCutoff(isAbovePriorityCutoff);
         if (isAbovePriorityCutoff)
-            m_memoryAboveCutoffBytes += (*it)->memorySizeBytes();
+            m_memoryAboveCutoffBytes += (*it)->bytes();
     }
     ASSERT(m_memoryAboveCutoffBytes <= m_memoryAvailableBytes);
 
@@ -157,15 +157,15 @@ bool CCPrioritizedTextureManager::requestLate(CCPrioritizedTexture* texture)
     if (CCPriorityCalculator::priorityIsLower(texture->requestPriority(), m_priorityCutoff))
         return false;
 
-    size_t newMemoryBytes = m_memoryAboveCutoffBytes + texture->memorySizeBytes();
+    size_t newMemoryBytes = m_memoryAboveCutoffBytes + texture->bytes();
     if (newMemoryBytes > m_memoryAvailableBytes)
         return false;
 
     m_memoryAboveCutoffBytes = newMemoryBytes;
     texture->setAbovePriorityCutoff(true);
-    if (texture->currentBacking()) {
-        m_backings.remove(texture->currentBacking());
-        m_backings.add(texture->currentBacking());
+    if (texture->backing()) {
+        m_backings.remove(texture->backing());
+        m_backings.add(texture->backing());
     }
     return true;
 }
@@ -173,7 +173,7 @@ bool CCPrioritizedTextureManager::requestLate(CCPrioritizedTexture* texture)
 void CCPrioritizedTextureManager::acquireBackingTextureIfNeeded(CCPrioritizedTexture* texture, TextureAllocator* allocator)
 {
     ASSERT(texture->isAbovePriorityCutoff());
-    if (texture->currentBacking() || !texture->isAbovePriorityCutoff())
+    if (texture->backing() || !texture->isAbovePriorityCutoff())
         return;
 
     // Find a backing below, by either recycling or allocating.
@@ -181,7 +181,7 @@ void CCPrioritizedTextureManager::acquireBackingTextureIfNeeded(CCPrioritizedTex
 
     // First try to recycle
     for (BackingSet::iterator it = m_backings.begin(); it != m_backings.end(); ++it) {
-        if ((*it)->currentTexture() && (*it)->currentTexture()->isAbovePriorityCutoff())
+        if ((*it)->owner() && (*it)->owner()->isAbovePriorityCutoff())
             break;
         if ((*it)->size() == texture->size() && (*it)->format() == texture->format()) {
             backing = (*it);
@@ -191,14 +191,14 @@ void CCPrioritizedTextureManager::acquireBackingTextureIfNeeded(CCPrioritizedTex
 
     // Otherwise reduce memory and just allocate a new backing texures.
     if (!backing) {
-        reduceMemory(m_memoryAvailableBytes - texture->memorySizeBytes(), allocator);
+        reduceMemory(m_memoryAvailableBytes - texture->bytes(), allocator);
         backing = createBacking(texture->size(), texture->format(), allocator);
     }
 
     // Move the used backing texture to the end of the eviction list.
-    if (backing->currentTexture())
-        unlink(backing->currentTexture(), backing);
-    link(texture, backing);
+    if (backing->owner())
+        backing->owner()->unlink();
+    texture->link(backing);
     m_backings.remove(backing);
     m_backings.add(backing);
 }
@@ -211,7 +211,7 @@ void CCPrioritizedTextureManager::reduceMemory(size_t limitBytes, TextureAllocat
     // or until all backings remaining are above the cutoff.
     while (memoryUseBytes() > limitBytes && m_backings.size() > 0) {
         BackingSet::iterator it = m_backings.begin();
-        if ((*it)->currentTexture() && (*it)->currentTexture()->isAbovePriorityCutoff())
+        if ((*it)->owner() && (*it)->owner()->isAbovePriorityCutoff())
             break;
         destroyBacking((*it), allocator);
     }
@@ -229,9 +229,9 @@ void CCPrioritizedTextureManager::reduceMemory(TextureAllocator* allocator)
     // backing textures (any more than 10%).
     size_t wastedMemory = 0;
     for (BackingSet::iterator it = m_backings.begin(); it != m_backings.end(); ++it) {
-        if ((*it)->currentTexture())
+        if ((*it)->owner())
             break;
-        wastedMemory += (*it)->memorySizeBytes();
+        wastedMemory += (*it)->bytes();
     }
     size_t tenPercentOfMemory = m_memoryAvailableBytes / 10;
     if (wastedMemory <= tenPercentOfMemory)
@@ -244,8 +244,8 @@ void CCPrioritizedTextureManager::clearAllMemory(TextureAllocator* allocator)
     // Unlink and destroy all backing textures.
     while (m_backings.size() > 0) {
         BackingSet::iterator it = m_backings.begin();
-        if ((*it)->currentTexture())
-            unlink((*it)->currentTexture(), (*it));
+        if ((*it)->owner())
+            (*it)->owner()->unlink();
         destroyBacking((*it), allocator);
     }
 }
@@ -258,32 +258,11 @@ void CCPrioritizedTextureManager::allBackingTexturesWereDeleted()
     clearAllMemory(0);
 }
 
-void CCPrioritizedTextureManager::unlink(CCPrioritizedTexture* texture, CCPrioritizedTexture::Backing* backing)
-{
-    ASSERT(texture && backing);
-    ASSERT(texture->currentBacking() == backing);
-    ASSERT(backing->currentTexture() == texture);
-
-    texture->setCurrentBacking(0);
-    backing->setCurrentTexture(0);
-}
-
-void CCPrioritizedTextureManager::link(CCPrioritizedTexture* texture, CCPrioritizedTexture::Backing* backing)
-{
-    ASSERT(texture && backing);
-    ASSERT(!texture->currentBacking());
-    ASSERT(!backing->currentTexture());
-
-    texture->setCurrentBacking(backing);
-    backing->setCurrentTexture(texture);
-}
-
-
 void CCPrioritizedTextureManager::registerTexture(CCPrioritizedTexture* texture)
 {
     ASSERT(texture);
     ASSERT(!texture->textureManager());
-    ASSERT(!texture->currentBacking());
+    ASSERT(!texture->backing());
     ASSERT(m_textures.find(texture) == m_textures.end());
 
     texture->setManagerInternal(this);
@@ -305,11 +284,11 @@ void CCPrioritizedTextureManager::unregisterTexture(CCPrioritizedTexture* textur
 
 void CCPrioritizedTextureManager::returnBackingTexture(CCPrioritizedTexture* texture)
 {
-    if (texture->currentBacking()) {
+    if (texture->backing()) {
         // Move the backing texture to the front for eviction/recycling and unlink it.
-        m_backings.remove(texture->currentBacking());
-        m_backings.insertBefore(m_backings.begin(), texture->currentBacking());
-        unlink(texture, texture->currentBacking());
+        m_backings.remove(texture->backing());
+        m_backings.insertBefore(m_backings.begin(), texture->backing());
+        texture->unlink();
     }
 }
 
@@ -317,9 +296,8 @@ CCPrioritizedTexture::Backing* CCPrioritizedTextureManager::createBacking(IntSiz
 {
     ASSERT(allocator);
 
-    unsigned textureId = allocator->createTexture(size, format);
-    CCPrioritizedTexture::Backing* backing = new CCPrioritizedTexture::Backing(size, format, textureId);
-    m_memoryUseBytes += backing->memorySizeBytes();
+    CCPrioritizedTexture::Backing* backing = new CCPrioritizedTexture::Backing(allocator->createTexture(size, format), size, format);
+    m_memoryUseBytes += backing->bytes();
     // Put backing texture at the front for eviction, since it isn't in use yet.
     m_backings.insertBefore(m_backings.begin(), backing);
     return backing;
@@ -328,14 +306,14 @@ CCPrioritizedTexture::Backing* CCPrioritizedTextureManager::createBacking(IntSiz
 void CCPrioritizedTextureManager::destroyBacking(CCPrioritizedTexture::Backing* backing, TextureAllocator* allocator)
 {
     ASSERT(backing);
-    ASSERT(!backing->currentTexture() || !backing->currentTexture()->isAbovePriorityCutoff());
+    ASSERT(!backing->owner() || !backing->owner()->isAbovePriorityCutoff());
     ASSERT(m_backings.find(backing) != m_backings.end());
 
     if (allocator)
-        allocator->deleteTexture(backing->textureId(), backing->size(), backing->format());
-    if (backing->currentTexture())
-        unlink(backing->currentTexture(), backing);
-    m_memoryUseBytes -= backing->memorySizeBytes();
+        allocator->deleteTexture(backing->id(), backing->size(), backing->format());
+    if (backing->owner())
+        backing->owner()->unlink();
+    m_memoryUseBytes -= backing->bytes();
     m_backings.remove(backing);
 
     delete backing;
@@ -351,15 +329,15 @@ void CCPrioritizedTextureManager::assertInvariants()
 
     // Backings/textures must be doubly-linked and only to other backings/textures in this manager.
     for (BackingSet::iterator it = m_backings.begin(); it != m_backings.end(); ++it) {
-        if ((*it)->currentTexture()) {
-            ASSERT(m_textures.find((*it)->currentTexture()) != m_textures.end());
-            ASSERT((*it)->currentTexture()->currentBacking() == (*it));
+        if ((*it)->owner()) {
+            ASSERT(m_textures.find((*it)->owner()) != m_textures.end());
+            ASSERT((*it)->owner()->backing() == (*it));
         }
     }
     for (TextureSet::iterator it = m_textures.begin(); it != m_textures.end(); ++it) {
-        if ((*it)->currentBacking()) {
-            ASSERT(m_backings.find((*it)->currentBacking()) != m_backings.end());
-            ASSERT((*it)->currentBacking()->currentTexture() == (*it));
+        if ((*it)->backing()) {
+            ASSERT(m_backings.find((*it)->backing()) != m_backings.end());
+            ASSERT((*it)->backing()->owner() == (*it));
         }
     }
 
@@ -368,10 +346,10 @@ void CCPrioritizedTextureManager::assertInvariants()
     // reduceMemory will not find all textures available for eviction/recycling).
     bool reachedProtected = false;
     for (BackingSet::iterator it = m_backings.begin(); it != m_backings.end(); ++it) {
-        if ((*it)->currentTexture() && (*it)->currentTexture()->isAbovePriorityCutoff())
+        if ((*it)->owner() && (*it)->owner()->isAbovePriorityCutoff())
             reachedProtected = true;
         if (reachedProtected)
-            ASSERT((*it)->currentTexture() && (*it)->currentTexture()->isAbovePriorityCutoff());
+            ASSERT((*it)->owner() && (*it)->owner()->isAbovePriorityCutoff());
     }
 }
 #endif
index 3c70b2b..980291a 100644 (file)
 
 #include "CCPrioritizedTexture.h"
 #include "CCPriorityCalculator.h"
+#include "CCTexture.h"
 #include "GraphicsContext3D.h"
 #include "IntRect.h"
 #include "IntSize.h"
-#include "TextureManager.h"
 
 namespace WebCore {
 
@@ -50,6 +50,13 @@ public:
     }
     ~CCPrioritizedTextureManager();
 
+    // FIXME (http://crbug.com/137094): This 64MB default is a straggler from the
+    // old texture manager and is just to give us a default memory allocation before
+    // we get a callback from the GPU memory manager. We should probaby either:
+    // - wait for the callback before rendering anything instead
+    // - push this into the GPU memory manager somehow.
+    static size_t defaultMemoryAllocationLimit() { return 64 * 1024 * 1024; }
+
     // memoryUseBytes() describes the number of bytes used by existing allocated textures.
     // memoryAboveCutoffBytes() describes the number of bytes that would be used if all
     // textures that are above the cutoff were allocated.
@@ -91,8 +98,8 @@ private:
     // Compare backings. Lowest priority first.
     static inline bool compareBackings(CCPrioritizedTexture::Backing* a, CCPrioritizedTexture::Backing* b)
     {
-        int priorityA = a->currentTexture() ? a->currentTexture()->requestPriority() : CCPriorityCalculator::lowestPriority();
-        int priorityB = b->currentTexture() ? b->currentTexture()->requestPriority() : CCPriorityCalculator::lowestPriority();
+        int priorityA = a->owner() ? a->owner()->requestPriority() : CCPriorityCalculator::lowestPriority();
+        int priorityB = b->owner() ? b->owner()->requestPriority() : CCPriorityCalculator::lowestPriority();
         if (priorityA == priorityB)
             return a < b;
         return CCPriorityCalculator::priorityIsLower(priorityA, priorityB);
@@ -102,9 +109,6 @@ private:
 
     void reduceMemory(size_t limit, TextureAllocator*);
 
-    void link(CCPrioritizedTexture*, CCPrioritizedTexture::Backing*);
-    void unlink(CCPrioritizedTexture*, CCPrioritizedTexture::Backing*);
-
     CCPrioritizedTexture::Backing* createBacking(IntSize, GC3Denum format, TextureAllocator*);
     void destroyBacking(CCPrioritizedTexture::Backing*, TextureAllocator*);
 
index 68a225b..a90a073 100644 (file)
@@ -28,7 +28,6 @@
 #include "GraphicsContext3D.h"
 #include "IntRect.h"
 #include "IntSize.h"
-#include "TextureManager.h"
 
 namespace WebCore {
 
index 80f8315..b9f75d1 100644 (file)
  */
 
 #include "config.h"
-
 #include "cc/CCScopedTexture.h"
 
-#include "TextureManager.h" // For TextureAllocator
+#include "TextureAllocator.h"
 
 namespace WebCore {
 
index 5a3c4e9..9f7241f 100644 (file)
@@ -26,6 +26,7 @@
 #ifndef CCScopedTexture_h
 #define CCScopedTexture_h
 
+#include "TextureAllocator.h"
 #include "cc/CCTexture.h"
 
 #if !ASSERT_DISABLED
@@ -34,7 +35,6 @@
 
 namespace WebCore {
 
-class TextureAllocator;
 
 class CCScopedTexture : protected CCTexture {
     WTF_MAKE_NONCOPYABLE(CCScopedTexture);
index a296104..0d5d9f7 100644 (file)
@@ -35,6 +35,10 @@ namespace WebCore {
 class CCTexture {
 public:
     CCTexture() : m_id(0) { }
+    CCTexture(unsigned id, IntSize size, GC3Denum format)
+        : m_id(id)
+        , m_size(size)
+        , m_format(format) { }
 
     unsigned id() const { return m_id; }
     const IntSize& size() const { return m_size; }
index cc790e5..1b21089 100644 (file)
@@ -54,8 +54,6 @@ static const int debugTileBorderMissingTileColorRed = 255;
 static const int debugTileBorderMissingTileColorGreen = 0;
 static const int debugTileBorderMissingTileColorBlue = 0;
 
-class ManagedTexture;
-
 class DrawableTile : public CCLayerTilingData::Tile {
     WTF_MAKE_NONCOPYABLE(DrawableTile);
 public:
index 3e1f581..cc349c8 100644 (file)
@@ -35,7 +35,7 @@
 #include "LayerTextureSubImage.h"
 #include "NotImplemented.h"
 #include "TextStream.h"
-#include "TextureManager.h" // For TextureAllocator
+#include "TextureAllocator.h"
 #include "cc/CCGraphicsContext.h"
 #include "cc/CCLayerTreeHostImpl.h"
 #include "cc/CCProxy.h"
index e5c5546..e700b7a 100644 (file)
@@ -1,3 +1,21 @@
+2012-07-12  Eric Penner  <epenner@google.com>
+
+        [chromium] Use CCTexture/TextureAllocator and remove TextureManager
+        https://bugs.webkit.org/show_bug.cgi?id=91001
+
+        Reviewed by Adrienne Walker.
+
+        Deleting old texture manager tests.
+
+        * WebKit.gypi:
+        * tests/CCLayerTreeHostImplTest.cpp:
+        * tests/CCPrioritizedTextureTest.cpp:
+        (WTF::CCPrioritizedTextureTest::texturesMemorySize):
+        * tests/CCThreadedTest.cpp:
+        * tests/CCTiledLayerTestCommon.h:
+        * tests/Canvas2DLayerBridgeTest.cpp:
+        * tests/TextureManagerTest.cpp: Removed.
+
 2012-07-12  Robert Sesek  <rsesek@chromium.org>
 
         [chromium][Mac] r122400 broke 10.6 build
index bede2b1..3f905a7 100644 (file)
             'tests/ScrollbarLayerChromiumTest.cpp',
             'tests/TextureCopierTest.cpp',
             'tests/TextureLayerChromiumTest.cpp',
-            'tests/TextureManagerTest.cpp',
             'tests/ThrottledTextureUploaderTest.cpp',
             'tests/TiledLayerChromiumTest.cpp',
             'tests/TilingDataTest.cpp',
index abf1eff..1184b22 100644 (file)
@@ -31,7 +31,6 @@
 #include "CCTestCommon.h"
 #include "FakeWebGraphicsContext3D.h"
 #include "LayerRendererChromium.h"
-#include "ManagedTexture.h"
 #include "cc/CCIOSurfaceLayerImpl.h"
 #include "cc/CCLayerImpl.h"
 #include "cc/CCLayerTilingData.h"
index 468af36..a8b9627 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "CCTiledLayerTestCommon.h"
 #include "cc/CCPrioritizedTextureManager.h"
+#include "cc/CCTexture.h"
 #include <gtest/gtest.h>
 
 using namespace WebCore;
@@ -50,7 +51,7 @@ public:
 
     size_t texturesMemorySize(size_t textureCount)
     {
-        return TextureManager::memoryUseBytes(m_textureSize, m_textureFormat) * textureCount;
+        return CCTexture::memorySizeBytes(m_textureSize, m_textureFormat) * textureCount;
     }
 
     PassOwnPtr<CCPrioritizedTextureManager> createManager(size_t maxTextures)
index 40d3ce5..2e2c1a0 100644 (file)
@@ -34,7 +34,6 @@
 #include "FakeWebGraphicsContext3D.h"
 #include "GraphicsContext3DPrivate.h"
 #include "LayerChromium.h"
-#include "TextureManager.h"
 #include "WebCompositor.h"
 #include "WebKit.h"
 #include "cc/CCActiveAnimation.h"
index dfd46d9..9501cab 100644 (file)
@@ -29,6 +29,7 @@
 #include "IntSize.h"
 #include "LayerTextureUpdater.h"
 #include "Region.h"
+#include "TextureAllocator.h"
 #include "TextureCopier.h"
 #include "TextureUploader.h"
 #include "TiledLayerChromium.h"
index 435907c..c206dda 100644 (file)
@@ -30,7 +30,6 @@
 #include "GraphicsContext3DPrivate.h"
 #include "ImageBuffer.h"
 #include "LayerChromium.h"
-#include "TextureManager.h"
 #include "WebCompositor.h"
 #include "WebKit.h"
 #include "cc/CCGraphicsContext.h"
index 9c9ec25..7cdba80 100644 (file)
@@ -30,6 +30,7 @@
 #include "GraphicsContext3D.h"
 #include "WebCompositor.h"
 #include "cc/CCDrawQuad.h"
+#include "cc/CCPrioritizedTextureManager.h"
 #include "cc/CCSettings.h"
 #include "cc/CCSingleThreadProxy.h"
 
@@ -76,7 +77,7 @@ public:
     FakeCCRendererClient()
         : m_setFullRootLayerDamageCount(0)
         , m_rootLayer(CCLayerImpl::create(1))
-        , m_memoryAllocationLimitBytes(0)
+        , m_memoryAllocationLimitBytes(CCPrioritizedTextureManager::defaultMemoryAllocationLimit())
     {
         m_rootLayer->createRenderSurface();
         m_rootRenderPass = CCRenderPass::create(m_rootLayer->renderSurface(), m_rootLayer->id());
diff --git a/Source/WebKit/chromium/tests/TextureManagerTest.cpp b/Source/WebKit/chromium/tests/TextureManagerTest.cpp
deleted file mode 100644 (file)
index d5313f5..0000000
+++ /dev/null
@@ -1,295 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1.  Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- * 2.  Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "CCTiledLayerTestCommon.h"
-#include "ManagedTexture.h"
-#include "TextureManager.h"
-
-#include <gtest/gtest.h>
-
-using namespace WebCore;
-using namespace WebKitTests;
-using namespace WTF;
-
-namespace {
-
-class TextureManagerTest : public testing::Test {
-public:
-    TextureManagerTest()
-        : m_textureSize(256, 256)
-        , m_textureFormat(GraphicsContext3D::RGBA)
-    {
-    }
-
-    virtual ~TextureManagerTest()
-    {
-    }
-
-    size_t texturesMemorySize(size_t textureCount)
-    {
-        return TextureManager::memoryUseBytes(m_textureSize, m_textureFormat) * textureCount;
-    }
-
-    PassOwnPtr<TextureManager> createTextureManager(size_t maxTextures, size_t preferredTextures)
-    {
-        return TextureManager::create(texturesMemorySize(maxTextures), texturesMemorySize(preferredTextures), 1024);
-    }
-
-    bool requestTexture(TextureManager* manager, TextureToken token)
-    {
-        bool result = manager->requestTexture(token, m_textureSize, m_textureFormat);
-        if (result)
-            manager->allocateTexture(&m_fakeTextureAllocator, token);
-        return result;
-    }
-
-private:
-    FakeTextureAllocator m_fakeTextureAllocator;
-    const IntSize m_textureSize;
-    const GC3Denum m_textureFormat;
-};
-
-TEST_F(TextureManagerTest, requestTextureInPreferredLimit)
-{
-    const size_t preferredTextures = 8;
-    OwnPtr<TextureManager> textureManager = createTextureManager(preferredTextures * 2, preferredTextures);
-    TextureToken tokens[preferredTextures];
-    for (size_t i = 0; i < preferredTextures; ++i) {
-        tokens[i] = textureManager->getToken();
-        if (i)
-            EXPECT_GT(tokens[i], tokens[i - 1]);
-        EXPECT_TRUE(requestTexture(textureManager.get(), tokens[i]));
-        EXPECT_TRUE(textureManager->hasTexture(tokens[i]));
-        EXPECT_TRUE(textureManager->isProtected(tokens[i]));
-    }
-
-    for (size_t i = 0; i < preferredTextures; ++i)
-        EXPECT_TRUE(textureManager->hasTexture(tokens[i]));
-
-    EXPECT_EQ(texturesMemorySize(preferredTextures), textureManager->currentMemoryUseBytes());
-}
-
-TEST_F(TextureManagerTest, requestTextureExceedingPreferredLimit)
-{
-    const size_t maxTextures = 8;
-    const size_t preferredTextures = 4;
-    OwnPtr<TextureManager> textureManager = createTextureManager(maxTextures, preferredTextures);
-    TextureToken tokens[maxTextures];
-    for (size_t i = 0; i < preferredTextures; ++i) {
-        tokens[i] = textureManager->getToken();
-        EXPECT_TRUE(requestTexture(textureManager.get(), tokens[i]));
-        EXPECT_TRUE(textureManager->hasTexture(tokens[i]));
-    }
-
-    textureManager->unprotectTexture(tokens[0]);
-    textureManager->unprotectTexture(tokens[2]);
-
-    for (size_t i = preferredTextures; i < maxTextures; ++i) {
-        tokens[i] = textureManager->getToken();
-        EXPECT_TRUE(requestTexture(textureManager.get(), tokens[i]));
-        EXPECT_TRUE(textureManager->hasTexture(tokens[i]));
-    }
-
-    textureManager->unprotectTexture(tokens[4]);
-    textureManager->unprotectTexture(tokens[5]);
-
-    // These textures should be valid before the reduceMemoryToLimit call.
-    EXPECT_TRUE(textureManager->hasTexture(tokens[0]));
-    EXPECT_TRUE(textureManager->hasTexture(tokens[2]));
-
-    textureManager->reduceMemoryToLimit(texturesMemorySize(preferredTextures));
-
-    EXPECT_FALSE(textureManager->hasTexture(tokens[0]));
-    EXPECT_TRUE(textureManager->hasTexture(tokens[1]));
-    EXPECT_TRUE(textureManager->isProtected(tokens[1]));
-    EXPECT_FALSE(textureManager->hasTexture(tokens[2]));
-    EXPECT_TRUE(textureManager->hasTexture(tokens[3]));
-    EXPECT_TRUE(textureManager->isProtected(tokens[3]));
-
-    EXPECT_EQ(texturesMemorySize(preferredTextures), textureManager->currentMemoryUseBytes());
-}
-
-TEST_F(TextureManagerTest, requestTextureExceedingMaxLimit)
-{
-    const size_t maxTextures = 8;
-    const size_t preferredTextures = 4;
-    OwnPtr<TextureManager> textureManager = createTextureManager(maxTextures, preferredTextures);
-    TextureToken tokens[maxTextures];
-    for (size_t i = 0; i < maxTextures; ++i) {
-        tokens[i] = textureManager->getToken();
-        EXPECT_TRUE(requestTexture(textureManager.get(), tokens[i]));
-        EXPECT_TRUE(textureManager->hasTexture(tokens[i]));
-    }
-
-    EXPECT_EQ(texturesMemorySize(maxTextures), textureManager->currentMemoryUseBytes());
-
-    for (size_t i = 0; i < maxTextures; ++i) {
-        TextureToken token = textureManager->getToken();
-        EXPECT_FALSE(requestTexture(textureManager.get(), token));
-        EXPECT_FALSE(textureManager->hasTexture(token));
-    }
-
-    EXPECT_EQ(textureManager->currentMemoryUseBytes(), texturesMemorySize(maxTextures));
-
-    textureManager->unprotectTexture(tokens[1]);
-    textureManager->unprotectTexture(tokens[3]);
-    EXPECT_TRUE(requestTexture(textureManager.get(), textureManager->getToken()));
-    EXPECT_TRUE(requestTexture(textureManager.get(), textureManager->getToken()));
-    EXPECT_FALSE(requestTexture(textureManager.get(), textureManager->getToken()));
-    EXPECT_EQ(texturesMemorySize(maxTextures), textureManager->currentMemoryUseBytes());
-    EXPECT_FALSE(textureManager->hasTexture(tokens[1]));
-    EXPECT_FALSE(textureManager->hasTexture(tokens[3]));
-}
-
-TEST_F(TextureManagerTest, reduceMemoryToLimit)
-{
-    const size_t maxTextures = 8;
-    const size_t preferredTextures = 4;
-    OwnPtr<TextureManager> textureManager = createTextureManager(maxTextures, preferredTextures);
-    TextureToken tokens[maxTextures];
-    for (size_t i = 0; i < maxTextures; ++i) {
-        tokens[i] = textureManager->getToken();
-        EXPECT_TRUE(requestTexture(textureManager.get(), tokens[i]));
-    }
-
-    EXPECT_EQ(texturesMemorySize(maxTextures), textureManager->currentMemoryUseBytes());
-    textureManager->reduceMemoryToLimit(texturesMemorySize(maxTextures));
-    EXPECT_EQ(texturesMemorySize(maxTextures), textureManager->currentMemoryUseBytes());
-    textureManager->reduceMemoryToLimit(texturesMemorySize(preferredTextures));
-    EXPECT_EQ(texturesMemorySize(maxTextures), textureManager->currentMemoryUseBytes());
-
-    const size_t unprotectedTextures = preferredTextures + 1;
-    for (size_t i = 0; i < preferredTextures + 1; ++i)
-        textureManager->unprotectTexture(tokens[i]);
-
-    textureManager->reduceMemoryToLimit(texturesMemorySize(maxTextures));
-    EXPECT_EQ(texturesMemorySize(maxTextures), textureManager->currentMemoryUseBytes());
-    textureManager->reduceMemoryToLimit(texturesMemorySize(preferredTextures));
-    EXPECT_EQ(texturesMemorySize(preferredTextures), textureManager->currentMemoryUseBytes());
-    textureManager->reduceMemoryToLimit(texturesMemorySize(1));
-    EXPECT_EQ(texturesMemorySize(maxTextures - unprotectedTextures), textureManager->currentMemoryUseBytes());
-
-    // reduceMemoryToLimit doesn't change the current memory limits.
-    EXPECT_EQ(texturesMemorySize(maxTextures), textureManager->maxMemoryLimitBytes());
-    EXPECT_EQ(texturesMemorySize(preferredTextures), textureManager->preferredMemoryLimitBytes());
-}
-
-TEST_F(TextureManagerTest, setMaxMemoryLimitBytes)
-{
-    const size_t maxTextures = 8;
-    const size_t preferredTextures = 4;
-    OwnPtr<TextureManager> textureManager = createTextureManager(maxTextures, preferredTextures);
-    TextureToken tokens[maxTextures];
-    for (size_t i = 0; i < maxTextures; ++i) {
-        tokens[i] = textureManager->getToken();
-        EXPECT_TRUE(requestTexture(textureManager.get(), tokens[i]));
-    }
-
-    EXPECT_EQ(texturesMemorySize(maxTextures), textureManager->currentMemoryUseBytes());
-
-    const size_t unprotectedTextures = preferredTextures + 1;
-    for (size_t i = 0; i < unprotectedTextures; ++i)
-        textureManager->unprotectTexture(tokens[i]);
-
-    textureManager->setMaxMemoryLimitBytes(texturesMemorySize(maxTextures));
-    EXPECT_EQ(texturesMemorySize(maxTextures), textureManager->currentMemoryUseBytes());
-    textureManager->setMaxMemoryLimitBytes(texturesMemorySize(preferredTextures));
-    EXPECT_EQ(texturesMemorySize(preferredTextures), textureManager->currentMemoryUseBytes());
-    EXPECT_EQ(texturesMemorySize(preferredTextures), textureManager->maxMemoryLimitBytes());
-}
-
-TEST_F(TextureManagerTest, setPreferredMemoryLimitBytes)
-{
-    const size_t maxTextures = 8;
-    const size_t preferredTextures = 4;
-    OwnPtr<TextureManager> textureManager = createTextureManager(maxTextures, preferredTextures);
-    TextureToken tokens[maxTextures];
-    for (size_t i = 0; i < maxTextures; ++i) {
-        tokens[i] = textureManager->getToken();
-        EXPECT_TRUE(requestTexture(textureManager.get(), tokens[i]));
-    }
-
-    const size_t unprotectedTextures = preferredTextures + 1;
-    for (size_t i = 0; i < unprotectedTextures; ++i)
-        textureManager->unprotectTexture(tokens[i]);
-
-    EXPECT_EQ(texturesMemorySize(maxTextures), textureManager->currentMemoryUseBytes());
-    EXPECT_EQ(texturesMemorySize(maxTextures), textureManager->maxMemoryLimitBytes());
-
-    // Setting preferred memory limit only won't force reduceMemoryToLimit.
-    textureManager->setPreferredMemoryLimitBytes(texturesMemorySize(preferredTextures));
-    EXPECT_EQ(texturesMemorySize(maxTextures), textureManager->currentMemoryUseBytes());
-    EXPECT_EQ(texturesMemorySize(maxTextures), textureManager->maxMemoryLimitBytes());
-    EXPECT_EQ(texturesMemorySize(preferredTextures), textureManager->preferredMemoryLimitBytes());
-}
-
-TEST_F(TextureManagerTest, textureManagerDestroyedBeforeManagedTexture)
-{
-    OwnPtr<TextureManager> textureManager = createTextureManager(1, 1);
-    OwnPtr<ManagedTexture> managedTexture = ManagedTexture::create(textureManager.get());
-
-    IntSize size(50, 50);
-    unsigned format = GraphicsContext3D::RGBA;
-
-    // Texture is initially invalid, but we should be able to reserve.
-    EXPECT_FALSE(managedTexture->isValid(size, format));
-    EXPECT_TRUE(managedTexture->reserve(size, format));
-    EXPECT_TRUE(managedTexture->isValid(size, format));
-
-    textureManager.clear();
-
-    // Deleting the manager should invalidate the texture and reservation attempts should fail.
-    EXPECT_FALSE(managedTexture->isValid(size, format));
-    EXPECT_FALSE(managedTexture->reserve(size, format));
-}
-
-TEST_F(TextureManagerTest, textureMovedToNewManager)
-{
-    OwnPtr<TextureManager> textureManagerOne = createTextureManager(1, 1);
-    OwnPtr<TextureManager> textureManagerTwo = createTextureManager(1, 1);
-    OwnPtr<ManagedTexture> managedTexture = ManagedTexture::create(textureManagerOne.get());
-
-    IntSize size(50, 50);
-    unsigned format = GraphicsContext3D::RGBA;
-
-    // Texture is initially invalid, but we should be able to reserve.
-    EXPECT_FALSE(managedTexture->isValid(size, format));
-    EXPECT_TRUE(managedTexture->reserve(size, format));
-    EXPECT_TRUE(managedTexture->isValid(size, format));
-
-    // Setting to the same manager should be a no-op.
-    managedTexture->setTextureManager(textureManagerOne.get());
-    EXPECT_TRUE(managedTexture->isValid(size, format));
-
-    // Setting to a different manager should invalidate the texture.
-    managedTexture->setTextureManager(textureManagerTwo.get());
-
-    EXPECT_FALSE(managedTexture->isValid(size, format));
-    EXPECT_TRUE(managedTexture->reserve(size, format));
-    EXPECT_TRUE(managedTexture->isValid(size, format));
-}
-
-} // namespace