[Chromium] Refactor CCTextureUpdater into CCTextureUpdater and CCTextureUpdateController.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 Aug 2012 17:59:04 +0000 (17:59 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 Aug 2012 17:59:04 +0000 (17:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=92596

Patch by David Reveman <reveman@chromium.org> on 2012-08-06
Reviewed by Adrienne Walker.

Source/WebCore:

The CCTextureUpdater interface is used by the main thread to queue
texture updates. The CCTextureUpdateController constructor takes a
CCTextureUpdater and contains the logic required to perform texture
uploads and texture copies. This class is only used by the impl thread.

No new tests.

* WebCore.gypi:
* platform/graphics/chromium/LayerRendererChromium.cpp:
* platform/graphics/chromium/ScrollbarLayerChromium.cpp:
(WebCore::ScrollbarLayerChromium::updatePart):
* platform/graphics/chromium/TextureCopier.cpp:
(WebCore::AcceleratedTextureCopier::copyTexture):
* platform/graphics/chromium/TextureCopier.h:
(Parameters):
(TextureCopier):
(AcceleratedTextureCopier):
* platform/graphics/chromium/TextureUploader.h:
(Parameters):
(TextureUploader):
* platform/graphics/chromium/ThrottledTextureUploader.cpp:
(WebCore::ThrottledTextureUploader::uploadTexture):
* platform/graphics/chromium/ThrottledTextureUploader.h:
(ThrottledTextureUploader):
* platform/graphics/chromium/TiledLayerChromium.cpp:
(WebCore::TiledLayerChromium::updateTiles):
* platform/graphics/chromium/cc/CCSingleThreadProxy.cpp:
(WebCore::CCSingleThreadProxy::doCommit):
* platform/graphics/chromium/cc/CCTextureUpdateController.cpp: Added.
(WebCore):
(WebCore::CCTextureUpdateController::maxPartialTextureUpdates):
(WebCore::CCTextureUpdateController::updateTextures):
(WebCore::CCTextureUpdateController::CCTextureUpdateController):
(WebCore::CCTextureUpdateController::~CCTextureUpdateController):
(WebCore::CCTextureUpdateController::hasMoreUpdates):
(WebCore::CCTextureUpdateController::updateMoreTextures):
(WebCore::CCTextureUpdateController::updateMoreTexturesSize):
* platform/graphics/chromium/cc/CCTextureUpdateController.h: Copied from Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.h.
(WebCore):
(CCTextureUpdateController):
(WebCore::CCTextureUpdateController::create):
* platform/graphics/chromium/cc/CCTextureUpdater.cpp:
(WebCore::CCTextureUpdater::appendFullUpload):
(WebCore::CCTextureUpdater::appendPartialUpload):
(WebCore::CCTextureUpdater::appendCopy):
(WebCore::CCTextureUpdater::takeFirstFullUpload):
(WebCore::CCTextureUpdater::takeFirstPartialUpload):
(WebCore::CCTextureUpdater::takeFirstCopy):
(WebCore::CCTextureUpdater::hasMoreUpdates):
* platform/graphics/chromium/cc/CCTextureUpdater.h:
(CCTextureUpdater):
(WebCore::CCTextureUpdater::fullUploadSize):
(WebCore::CCTextureUpdater::partialUploadSize):
(WebCore::CCTextureUpdater::copySize):
* platform/graphics/chromium/cc/CCThreadProxy.cpp:
(WebCore::CCThreadProxy::scheduledActionBeginFrame):
(WebCore::CCThreadProxy::beginFrame):
(WebCore::CCThreadProxy::beginFrameCompleteOnImplThread):
(WebCore::CCThreadProxy::hasMoreResourceUpdates):
(WebCore::CCThreadProxy::scheduledActionUpdateMoreResources):
(WebCore::CCThreadProxy::scheduledActionCommit):
(WebCore::CCThreadProxy::maxPartialTextureUpdates):
* platform/graphics/chromium/cc/CCThreadProxy.h:
(WebCore):
(WebCore::CCThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState):
(BeginFrameAndCommitState):
(CCThreadProxy):

Source/WebKit/chromium:

* WebKit.gypi:
* src/WebExternalTextureLayer.cpp:
* tests/CCTextureUpdateControllerTest.cpp: Renamed from Source/WebKit/chromium/tests/CCTextureUpdaterTest.cpp.
* tests/CCTiledLayerTestCommon.h:
(WebKitTests::FakeTextureCopier::copyTexture):
(WebKitTests::FakeTextureUploader::uploadTexture):
* tests/TextureCopierTest.cpp:
(TEST):
* tests/TiledLayerChromiumTest.cpp:

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

24 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.gypi
Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
Source/WebCore/platform/graphics/chromium/ScrollbarLayerChromium.cpp
Source/WebCore/platform/graphics/chromium/TextureCopier.cpp
Source/WebCore/platform/graphics/chromium/TextureCopier.h
Source/WebCore/platform/graphics/chromium/TextureUploader.h
Source/WebCore/platform/graphics/chromium/ThrottledTextureUploader.cpp
Source/WebCore/platform/graphics/chromium/ThrottledTextureUploader.h
Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp
Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp
Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdateController.cpp [new file with mode: 0644]
Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdateController.h [new file with mode: 0644]
Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.cpp
Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.h
Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp
Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/WebKit.gypi
Source/WebKit/chromium/src/WebExternalTextureLayer.cpp
Source/WebKit/chromium/tests/CCTextureUpdateControllerTest.cpp [moved from Source/WebKit/chromium/tests/CCTextureUpdaterTest.cpp with 78% similarity]
Source/WebKit/chromium/tests/CCTiledLayerTestCommon.h
Source/WebKit/chromium/tests/TextureCopierTest.cpp
Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp

index 8fb7af9..a844ce9 100644 (file)
@@ -1,3 +1,78 @@
+2012-08-06  David Reveman  <reveman@chromium.org>
+
+        [Chromium] Refactor CCTextureUpdater into CCTextureUpdater and CCTextureUpdateController.
+        https://bugs.webkit.org/show_bug.cgi?id=92596
+
+        Reviewed by Adrienne Walker.
+
+        The CCTextureUpdater interface is used by the main thread to queue
+        texture updates. The CCTextureUpdateController constructor takes a
+        CCTextureUpdater and contains the logic required to perform texture
+        uploads and texture copies. This class is only used by the impl thread.
+
+        No new tests.
+
+        * WebCore.gypi:
+        * platform/graphics/chromium/LayerRendererChromium.cpp:
+        * platform/graphics/chromium/ScrollbarLayerChromium.cpp:
+        (WebCore::ScrollbarLayerChromium::updatePart):
+        * platform/graphics/chromium/TextureCopier.cpp:
+        (WebCore::AcceleratedTextureCopier::copyTexture):
+        * platform/graphics/chromium/TextureCopier.h:
+        (Parameters):
+        (TextureCopier):
+        (AcceleratedTextureCopier):
+        * platform/graphics/chromium/TextureUploader.h:
+        (Parameters):
+        (TextureUploader):
+        * platform/graphics/chromium/ThrottledTextureUploader.cpp:
+        (WebCore::ThrottledTextureUploader::uploadTexture):
+        * platform/graphics/chromium/ThrottledTextureUploader.h:
+        (ThrottledTextureUploader):
+        * platform/graphics/chromium/TiledLayerChromium.cpp:
+        (WebCore::TiledLayerChromium::updateTiles):
+        * platform/graphics/chromium/cc/CCSingleThreadProxy.cpp:
+        (WebCore::CCSingleThreadProxy::doCommit):
+        * platform/graphics/chromium/cc/CCTextureUpdateController.cpp: Added.
+        (WebCore):
+        (WebCore::CCTextureUpdateController::maxPartialTextureUpdates):
+        (WebCore::CCTextureUpdateController::updateTextures):
+        (WebCore::CCTextureUpdateController::CCTextureUpdateController):
+        (WebCore::CCTextureUpdateController::~CCTextureUpdateController):
+        (WebCore::CCTextureUpdateController::hasMoreUpdates):
+        (WebCore::CCTextureUpdateController::updateMoreTextures):
+        (WebCore::CCTextureUpdateController::updateMoreTexturesSize):
+        * platform/graphics/chromium/cc/CCTextureUpdateController.h: Copied from Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.h.
+        (WebCore):
+        (CCTextureUpdateController):
+        (WebCore::CCTextureUpdateController::create):
+        * platform/graphics/chromium/cc/CCTextureUpdater.cpp:
+        (WebCore::CCTextureUpdater::appendFullUpload):
+        (WebCore::CCTextureUpdater::appendPartialUpload):
+        (WebCore::CCTextureUpdater::appendCopy):
+        (WebCore::CCTextureUpdater::takeFirstFullUpload):
+        (WebCore::CCTextureUpdater::takeFirstPartialUpload):
+        (WebCore::CCTextureUpdater::takeFirstCopy):
+        (WebCore::CCTextureUpdater::hasMoreUpdates):
+        * platform/graphics/chromium/cc/CCTextureUpdater.h:
+        (CCTextureUpdater):
+        (WebCore::CCTextureUpdater::fullUploadSize):
+        (WebCore::CCTextureUpdater::partialUploadSize):
+        (WebCore::CCTextureUpdater::copySize):
+        * platform/graphics/chromium/cc/CCThreadProxy.cpp:
+        (WebCore::CCThreadProxy::scheduledActionBeginFrame):
+        (WebCore::CCThreadProxy::beginFrame):
+        (WebCore::CCThreadProxy::beginFrameCompleteOnImplThread):
+        (WebCore::CCThreadProxy::hasMoreResourceUpdates):
+        (WebCore::CCThreadProxy::scheduledActionUpdateMoreResources):
+        (WebCore::CCThreadProxy::scheduledActionCommit):
+        (WebCore::CCThreadProxy::maxPartialTextureUpdates):
+        * platform/graphics/chromium/cc/CCThreadProxy.h:
+        (WebCore):
+        (WebCore::CCThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState):
+        (BeginFrameAndCommitState):
+        (CCThreadProxy):
+
 2012-08-06  Douglas Stockwell  <dstockwell@chromium.org>
 
         Crash in WebCore::RenderListItem::updateMarkerLocation
index 1e188ad..b46e571 100644 (file)
             'platform/graphics/chromium/cc/CCTextureDrawQuad.h',
             'platform/graphics/chromium/cc/CCTextureLayerImpl.cpp',
             'platform/graphics/chromium/cc/CCTextureLayerImpl.h',
+            'platform/graphics/chromium/cc/CCTextureUpdateController.cpp',
+            'platform/graphics/chromium/cc/CCTextureUpdateController.h',
             'platform/graphics/chromium/cc/CCTextureUpdater.cpp',
             'platform/graphics/chromium/cc/CCTextureUpdater.h',
             'platform/graphics/chromium/cc/CCThread.h',
index 0296b77..649e610 100644 (file)
@@ -126,7 +126,7 @@ public:
     virtual bool isBusy() OVERRIDE { return false; }
     virtual void beginUploads() OVERRIDE { }
     virtual void endUploads() OVERRIDE { }
-    virtual void uploadTexture(LayerTextureUpdater::Texture* texture, CCResourceProvider* resourceProvider, const IntRect sourceRect, const IntRect destRect) OVERRIDE { texture->updateRect(resourceProvider, sourceRect, destRect); }
+    virtual void uploadTexture(CCResourceProvider* resourceProvider, Parameters upload) OVERRIDE { upload.texture->updateRect(resourceProvider, upload.sourceRect, upload.destRect); }
 
 protected:
     UnthrottledTextureUploader() { }
index 652d744..5a9fbf5 100644 (file)
@@ -226,7 +226,8 @@ void ScrollbarLayerChromium::updatePart(LayerTextureUpdater* painter, LayerTextu
     texture->prepareRect(rect, stats);
 
     IntRect destRect(IntPoint(), rect.size());
-    updater.appendFullUpdate(texture, rect, destRect);
+    TextureUploader::Parameters upload = { texture, rect, destRect };
+    updater.appendFullUpload(upload);
 }
 
 
index 0b59597..fbb7cff 100644 (file)
@@ -66,13 +66,13 @@ AcceleratedTextureCopier::~AcceleratedTextureCopier()
         GLC(m_context, m_context->deleteFramebuffer(m_fbo));
 }
 
-void AcceleratedTextureCopier::copyTexture(unsigned sourceTextureId, unsigned destTextureId, const IntSize& size)
+void AcceleratedTextureCopier::copyTexture(Parameters parameters)
 {
     TRACE_EVENT0("cc", "TextureCopier::copyTexture");
 
     // Note: this code does not restore the viewport, bound program, 2D texture, framebuffer, buffer or blend enable.
     GLC(m_context, m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo));
-    GLC(m_context, m_context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, destTextureId, 0));
+    GLC(m_context, m_context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, parameters.destTexture, 0));
 
 #if OS(ANDROID)
     // Clear destination to improve performance on tiling GPUs.
@@ -80,7 +80,7 @@ void AcceleratedTextureCopier::copyTexture(unsigned sourceTextureId, unsigned de
     GLC(m_context, m_context->clear(GraphicsContext3D::COLOR_BUFFER_BIT));
 #endif
 
-    GLC(m_context, m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, sourceTextureId));
+    GLC(m_context, m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, parameters.sourceTexture));
     GLC(m_context, m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::NEAREST));
     GLC(m_context, m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::NEAREST));
 
@@ -96,7 +96,7 @@ void AcceleratedTextureCopier::copyTexture(unsigned sourceTextureId, unsigned de
     GLC(m_context, m_context->enableVertexAttribArray(kPositionAttribute));
     GLC(m_context, m_context->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, 0));
 
-    GLC(m_context, m_context->viewport(0, 0, size.width(), size.height()));
+    GLC(m_context, m_context->viewport(0, 0, parameters.size.width(), parameters.size.height()));
     GLC(m_context, m_context->disable(GraphicsContext3D::BLEND));
     GLC(m_context, m_context->drawArrays(GraphicsContext3D::TRIANGLE_FAN, 0, 4));
 
index 31250bc..afe2ec0 100644 (file)
@@ -40,10 +40,15 @@ class IntSize;
 
 class TextureCopier {
 public:
-    // Copy the base level contents of |sourceTextureId| to |destTextureId|. Both texture objects
+    struct Parameters {
+        unsigned sourceTexture;
+        unsigned destTexture;
+        IntSize size;
+    };
+    // Copy the base level contents of |sourceTexture| to |destTexture|. Both texture objects
     // must be complete and have a base level of |size| dimensions. The color formats do not need
-    // to match, but |destTextureId| must have a renderable format.
-    virtual void copyTexture(unsigned sourceTextureId, unsigned destTextureId, const IntSize&) = 0;
+    // to match, but |destTexture| must have a renderable format.
+    virtual void copyTexture(Parameters) = 0;
     virtual void flush() = 0;
 
 protected:
@@ -61,7 +66,7 @@ public:
     }
     virtual ~AcceleratedTextureCopier();
 
-    virtual void copyTexture(unsigned sourceTextureId, unsigned destTextureId, const IntSize&) OVERRIDE;
+    virtual void copyTexture(Parameters) OVERRIDE;
     virtual void flush() OVERRIDE;
 
 protected:
index 92870cb..7a51653 100644 (file)
@@ -31,12 +31,18 @@ namespace WebCore {
 
 class TextureUploader {
 public:
+    struct Parameters {
+        LayerTextureUpdater::Texture* texture;
+        IntRect sourceRect;
+        IntRect destRect;
+    };
+
     virtual ~TextureUploader() { }
 
     virtual bool isBusy() = 0;
     virtual void beginUploads() = 0;
     virtual void endUploads() = 0;
-    virtual void uploadTexture(LayerTextureUpdater::Texture*, CCResourceProvider*, const IntRect sourceRect, const IntRect destRect) = 0;
+    virtual void uploadTexture(CCResourceProvider*, Parameters) = 0;
 };
 
 }
index 281e08f..93da189 100644 (file)
@@ -120,9 +120,9 @@ void ThrottledTextureUploader::endUploads()
     m_pendingQueries.append(m_availableQueries.takeFirst());
 }
 
-void ThrottledTextureUploader::uploadTexture(LayerTextureUpdater::Texture* texture, CCResourceProvider* resourceProvider, const IntRect sourceRect, const IntRect destRect)
+void ThrottledTextureUploader::uploadTexture(CCResourceProvider* resourceProvider, Parameters upload)
 {
-    texture->updateRect(resourceProvider, sourceRect, destRect);
+    upload.texture->updateRect(resourceProvider, upload.sourceRect, upload.destRect);
 }
 
 void ThrottledTextureUploader::processQueries()
index f8c43dc..361468f 100644 (file)
@@ -51,7 +51,7 @@ public:
     virtual bool isBusy() OVERRIDE;
     virtual void beginUploads() OVERRIDE;
     virtual void endUploads() OVERRIDE;
-    virtual void uploadTexture(LayerTextureUpdater::Texture*, CCResourceProvider*, const IntRect sourceRect, const IntRect destRect) OVERRIDE;
+    virtual void uploadTexture(CCResourceProvider*, Parameters) OVERRIDE;
 
 private:
     class Query {
index 68740ef..683a45a 100644 (file)
@@ -506,10 +506,11 @@ void TiledLayerChromium::updateTiles(bool idle, int left, int top, int right, in
             if (paintOffset.y() + destRect.height() > paintRect.height())
                 CRASH();
 
+            TextureUploader::Parameters upload = { tile->texture(), sourceRect, destRect };
             if (tile->partialUpdate)
-                updater.appendPartialUpdate(tile->texture(), sourceRect, destRect);
+                updater.appendPartialUpload(upload);
             else
-                updater.appendFullUpdate(tile->texture(), sourceRect, destRect);
+                updater.appendFullUpload(upload);
         }
     }
 }
index 26b0a71..16425ff 100644 (file)
@@ -30,7 +30,7 @@
 #include "cc/CCDrawQuad.h"
 #include "cc/CCGraphicsContext.h"
 #include "cc/CCLayerTreeHost.h"
-#include "cc/CCTextureUpdater.h"
+#include "cc/CCTextureUpdateController.h"
 #include "cc/CCTimer.h"
 #include <wtf/CurrentTime.h>
 
@@ -206,12 +206,13 @@ void CCSingleThreadProxy::doCommit(CCTextureUpdater& updater)
 
         m_layerTreeHost->beginCommitOnImplThread(m_layerTreeHostImpl.get());
 
-        // CCTextureUpdater is non-blocking and will return without updating
-        // any textures if the uploader is busy. This shouldn't be a problem
-        // here as the throttled uploader isn't used in single thread mode.
-        // For correctness, loop until no more updates are pending.
+        // CCTextureUpdateController::updateTextures is non-blocking and will
+        // return without updating any textures if the uploader is busy. This
+        // shouldn't be a problem here as the throttled uploader isn't used in
+        // single thread mode. For correctness, loop until no more updates are
+        // pending.
         while (updater.hasMoreUpdates())
-            updater.update(m_layerTreeHostImpl->resourceProvider(), m_layerTreeHostImpl->layerRenderer()->textureCopier(), m_layerTreeHostImpl->layerRenderer()->textureUploader(), maxPartialTextureUpdates());
+            CCTextureUpdateController::updateTextures(m_layerTreeHostImpl->resourceProvider(), m_layerTreeHostImpl->layerRenderer()->textureCopier(), m_layerTreeHostImpl->layerRenderer()->textureUploader(), &updater, maxPartialTextureUpdates());
 
         m_layerTreeHost->finishCommitOnImplThread(m_layerTreeHostImpl.get());
 
diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdateController.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdateController.cpp
new file mode 100644 (file)
index 0000000..fbb0f36
--- /dev/null
@@ -0,0 +1,143 @@
+/*
+ * 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 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 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 "cc/CCTextureUpdateController.h"
+
+#include "GraphicsContext3D.h"
+#include "TextureCopier.h"
+#include "TextureUploader.h"
+#include <wtf/CurrentTime.h>
+
+namespace {
+
+// Number of textures to update with each call to updateMoreTextures().
+static const size_t textureUpdatesPerFrame = 48;
+
+// Flush interval when performing texture uploads.
+static const int textureUploadFlushPeriod = 4;
+
+} // anonymous namespace
+
+namespace WebCore {
+
+size_t CCTextureUpdateController::maxPartialTextureUpdates()
+{
+    return textureUpdatesPerFrame;
+}
+
+void CCTextureUpdateController::updateTextures(CCResourceProvider* resourceProvider, TextureCopier* copier, TextureUploader* uploader, CCTextureUpdater* updater, size_t count)
+{
+    if (updater->fullUploadSize() || updater->partialUploadSize()) {
+        if (uploader->isBusy())
+            return;
+
+        uploader->beginUploads();
+
+        size_t fullUploadCount = 0;
+        while (updater->fullUploadSize() && fullUploadCount < count) {
+            uploader->uploadTexture(resourceProvider, updater->takeFirstFullUpload());
+            fullUploadCount++;
+            if (!(fullUploadCount % textureUploadFlushPeriod))
+                resourceProvider->shallowFlushIfSupported();
+        }
+
+        // Make sure there are no dangling uploads without a flush.
+        if (fullUploadCount % textureUploadFlushPeriod)
+            resourceProvider->shallowFlushIfSupported();
+
+        bool moreUploads = updater->fullUploadSize();
+
+        ASSERT(updater->partialUploadSize() <= count);
+        // We need another update batch if the number of updates remaining
+        // in |count| is greater than the remaining partial entries.
+        if ((count - fullUploadCount) < updater->partialUploadSize())
+            moreUploads = true;
+
+        if (moreUploads) {
+            uploader->endUploads();
+            return;
+        }
+
+        size_t partialUploadCount = 0;
+        while (updater->partialUploadSize()) {
+            uploader->uploadTexture(resourceProvider, updater->takeFirstPartialUpload());
+            partialUploadCount++;
+            if (!(partialUploadCount % textureUploadFlushPeriod))
+                resourceProvider->shallowFlushIfSupported();
+        }
+
+        // Make sure there are no dangling partial uploads without a flush.
+        if (partialUploadCount % textureUploadFlushPeriod)
+            resourceProvider->shallowFlushIfSupported();
+
+        uploader->endUploads();
+    }
+
+    size_t copyCount = 0;
+    while (updater->copySize()) {
+        copier->copyTexture(updater->takeFirstCopy());
+        copyCount++;
+    }
+
+    // If we've performed any texture copies, we need to insert a flush here into the compositor context
+    // before letting the main thread proceed as it may make draw calls to the source texture of one of
+    // our copy operations.
+    if (copyCount)
+        copier->flush();
+}
+
+CCTextureUpdateController::CCTextureUpdateController(PassOwnPtr<CCTextureUpdater> updater, CCResourceProvider* resourceProvider, TextureCopier* copier, TextureUploader* uploader)
+    : m_updater(updater)
+    , m_resourceProvider(resourceProvider)
+    , m_copier(copier)
+    , m_uploader(uploader)
+{
+}
+
+CCTextureUpdateController::~CCTextureUpdateController()
+{
+}
+
+bool CCTextureUpdateController::hasMoreUpdates() const
+{
+    return m_updater->hasMoreUpdates();
+}
+
+void CCTextureUpdateController::updateMoreTextures()
+{
+    if (!m_updater->hasMoreUpdates())
+        return;
+
+    updateTextures(m_resourceProvider, m_copier, m_uploader, m_updater.get(), updateMoreTexturesSize());
+}
+
+size_t CCTextureUpdateController::updateMoreTexturesSize() const
+{
+    return textureUpdatesPerFrame;
+}
+
+}
diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdateController.h b/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdateController.h
new file mode 100644 (file)
index 0000000..81a1a7e
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * 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 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 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 CCTextureUpdateController_h
+#define CCTextureUpdateController_h
+
+#include "cc/CCTextureUpdater.h"
+#include <wtf/Noncopyable.h>
+#include <wtf/OwnPtr.h>
+
+namespace WebCore {
+
+class TextureCopier;
+class TextureUploader;
+
+class CCTextureUpdateController {
+    WTF_MAKE_NONCOPYABLE(CCTextureUpdateController);
+public:
+    static PassOwnPtr<CCTextureUpdateController> create(PassOwnPtr<CCTextureUpdater> updater, CCResourceProvider* resourceProvider, TextureCopier* copier, TextureUploader* uploader)
+    {
+        return adoptPtr(new CCTextureUpdateController(updater, resourceProvider, copier, uploader));
+    }
+    static size_t maxPartialTextureUpdates();
+    static void updateTextures(CCResourceProvider*, TextureCopier*, TextureUploader*, CCTextureUpdater*, size_t count);
+
+    virtual ~CCTextureUpdateController();
+
+    bool hasMoreUpdates() const;
+    void updateMoreTextures();
+
+    // Virtual for testing.
+    virtual size_t updateMoreTexturesSize() const;
+
+protected:
+    CCTextureUpdateController(PassOwnPtr<CCTextureUpdater>, CCResourceProvider*, TextureCopier*, TextureUploader*);
+
+    OwnPtr<CCTextureUpdater> m_updater;
+    CCResourceProvider* m_resourceProvider;
+    TextureCopier* m_copier;
+    TextureUploader* m_uploader;
+};
+
+}
+
+#endif // CCTextureUpdateController_h
index c6f4929..c5203d7 100644 (file)
 
 #include "cc/CCTextureUpdater.h"
 
-#include "CCPrioritizedTexture.h"
-#include "GraphicsContext3D.h"
-#include "LayerTextureUpdater.h"
-#include "TextureCopier.h"
-#include "TextureUploader.h"
-
-using namespace std;
-
 namespace WebCore {
 
-static const int kUploadFlushPeriod = 4;
-
 CCTextureUpdater::CCTextureUpdater()
-    : m_entryIndex(0)
 {
 }
 
@@ -50,116 +39,39 @@ CCTextureUpdater::~CCTextureUpdater()
 {
 }
 
-void CCTextureUpdater::appendUpdate(LayerTextureUpdater::Texture* texture, const IntRect& sourceRect, const IntRect& destRect, Vector<UpdateEntry>& entries)
+void CCTextureUpdater::appendFullUpload(TextureUploader::Parameters upload)
 {
-    ASSERT(texture);
-
-    UpdateEntry entry;
-    entry.texture = texture;
-    entry.sourceRect = sourceRect;
-    entry.destRect = destRect;
-    entries.append(entry);
+    m_fullEntries.append(upload);
 }
 
-void CCTextureUpdater::appendFullUpdate(LayerTextureUpdater::Texture* texture, const IntRect& sourceRect, const IntRect& destRect)
+void CCTextureUpdater::appendPartialUpload(TextureUploader::Parameters upload)
 {
-    appendUpdate(texture, sourceRect, destRect, m_fullEntries);
+    m_partialEntries.append(upload);
 }
 
-void CCTextureUpdater::appendPartialUpdate(LayerTextureUpdater::Texture* texture, const IntRect& sourceRect, const IntRect& destRect)
+void CCTextureUpdater::appendCopy(TextureCopier::Parameters copy)
 {
-    appendUpdate(texture, sourceRect, destRect, m_partialEntries);
+    m_copyEntries.append(copy);
 }
 
-void CCTextureUpdater::appendCopy(unsigned sourceTexture, unsigned destTexture, const IntSize& size)
+TextureUploader::Parameters CCTextureUpdater::takeFirstFullUpload()
 {
-    CopyEntry copy;
-    copy.sourceTexture = sourceTexture;
-    copy.destTexture = destTexture;
-    copy.size = size;
-    m_copyEntries.append(copy);
+    return m_fullEntries.takeFirst();
 }
 
-bool CCTextureUpdater::hasMoreUpdates() const
+TextureUploader::Parameters CCTextureUpdater::takeFirstPartialUpload()
 {
-    return m_fullEntries.size() || m_partialEntries.size() || m_copyEntries.size();
+    return m_partialEntries.takeFirst();
 }
 
-void CCTextureUpdater::update(CCResourceProvider* resourceProvider, TextureCopier* copier, TextureUploader* uploader, size_t count)
+TextureCopier::Parameters CCTextureUpdater::takeFirstCopy()
 {
-    size_t index;
-
-    if (m_fullEntries.size() || m_partialEntries.size()) {
-        if (uploader->isBusy())
-            return;
-
-        uploader->beginUploads();
-
-        int fullUploadCount = 0;
-        size_t maxIndex = min(m_entryIndex + count, m_fullEntries.size());
-        for (index = m_entryIndex; index < maxIndex; ++index) {
-            UpdateEntry& entry = m_fullEntries[index];
-            uploader->uploadTexture(entry.texture, resourceProvider, entry.sourceRect, entry.destRect);
-            fullUploadCount++;
-            if (!(fullUploadCount % kUploadFlushPeriod))
-                resourceProvider->shallowFlushIfSupported();
-        }
-
-        // Make sure there are no dangling uploads without a flush.
-        if (fullUploadCount % kUploadFlushPeriod)
-            resourceProvider->shallowFlushIfSupported();
-
-        bool moreUploads = maxIndex < m_fullEntries.size();
-
-        ASSERT(m_partialEntries.size() <= count);
-        // We need another update batch if the number of updates remaining
-        // in |count| is greater than the remaining partial entries.
-        if ((count - (index - m_entryIndex)) < m_partialEntries.size())
-            moreUploads = true;
-
-        if (moreUploads) {
-            m_entryIndex = index;
-            uploader->endUploads();
-            return;
-        }
-
-        for (index = 0; index < m_partialEntries.size(); ++index) {
-            UpdateEntry& entry = m_partialEntries[index];
-            uploader->uploadTexture(entry.texture, resourceProvider, entry.sourceRect, entry.destRect);
-            if (!((index+1) % kUploadFlushPeriod))
-                resourceProvider->shallowFlushIfSupported();
-        }
-
-        // Make sure there are no dangling partial uploads without a flush.
-        // Note: We don't need to use (index+1) in this case because index was
-        // incremented at the end of the for loop.
-        if (index % kUploadFlushPeriod)
-            resourceProvider->shallowFlushIfSupported();
-
-        uploader->endUploads();
-    }
-
-    for (index = 0; index < m_copyEntries.size(); ++index) {
-        CopyEntry& copyEntry = m_copyEntries[index];
-        copier->copyTexture(copyEntry.sourceTexture, copyEntry.destTexture, copyEntry.size);
-    }
-
-    // If we've performed any texture copies, we need to insert a flush here into the compositor context
-    // before letting the main thread proceed as it may make draw calls to the source texture of one of
-    // our copy operations.
-    if (m_copyEntries.size())
-        copier->flush();
-
-    // If no entries left to process, auto-clear.
-    clear();
+    return m_copyEntries.takeFirst();
 }
 
-void CCTextureUpdater::clear()
+bool CCTextureUpdater::hasMoreUpdates() const
 {
-    m_entryIndex = 0;
-    m_fullEntries.clear();
-    m_partialEntries.clear();
-    m_copyEntries.clear();
+    return m_fullEntries.size() || m_partialEntries.size() || m_copyEntries.size();
 }
 
 }
index 972a1c0..5225f7c 100644 (file)
 #ifndef CCTextureUpdater_h
 #define CCTextureUpdater_h
 
-#include "IntRect.h"
-#include "LayerTextureUpdater.h"
-#include <wtf/Vector.h>
+#include "TextureCopier.h"
+#include "TextureUploader.h"
+#include <wtf/Deque.h>
+#include <wtf/Noncopyable.h>
 
 namespace WebCore {
 
-class CCResourceProvider;
-class TextureCopier;
-class TextureUploader;
-
 class CCTextureUpdater {
+    WTF_MAKE_NONCOPYABLE(CCTextureUpdater);
 public:
     CCTextureUpdater();
-    ~CCTextureUpdater();
+    virtual ~CCTextureUpdater();
 
-    void appendFullUpdate(LayerTextureUpdater::Texture*, const IntRect& sourceRect, const IntRect& destRect);
-    void appendPartialUpdate(LayerTextureUpdater::Texture*, const IntRect& sourceRect, const IntRect& destRect);
-    void appendCopy(unsigned sourceTexture, unsigned destTexture, const IntSize&);
+    void appendFullUpload(TextureUploader::Parameters);
+    void appendPartialUpload(TextureUploader::Parameters);
+    void appendCopy(TextureCopier::Parameters);
 
-    bool hasMoreUpdates() const;
+    TextureUploader::Parameters takeFirstFullUpload();
+    TextureUploader::Parameters takeFirstPartialUpload();
+    TextureCopier::Parameters takeFirstCopy();
 
-    // Update some textures.
-    void update(CCResourceProvider*, TextureCopier*, TextureUploader*, size_t count);
+    size_t fullUploadSize() const { return m_fullEntries.size(); }
+    size_t partialUploadSize() const { return m_partialEntries.size(); }
+    size_t copySize() const { return m_copyEntries.size(); }
 
-    void clear();
+    bool hasMoreUpdates() const;
 
 private:
-    struct UpdateEntry {
-        LayerTextureUpdater::Texture* texture;
-        IntRect sourceRect;
-        IntRect destRect;
-    };
-
-    struct CopyEntry {
-        IntSize size;
-        unsigned sourceTexture;
-        unsigned destTexture;
-    };
-
-    static void appendUpdate(LayerTextureUpdater::Texture*, const IntRect& sourceRect, const IntRect& destRect, Vector<UpdateEntry>&);
-
-    size_t m_entryIndex;
-    Vector<UpdateEntry> m_fullEntries;
-    Vector<UpdateEntry> m_partialEntries;
-    Vector<CopyEntry> m_copyEntries;
+    Deque<TextureUploader::Parameters> m_fullEntries;
+    Deque<TextureUploader::Parameters> m_partialEntries;
+    Deque<TextureCopier::Parameters> m_copyEntries;
 };
 
 }
index 4824ffb..51b7b69 100644 (file)
@@ -35,7 +35,7 @@
 #include "cc/CCLayerTreeHost.h"
 #include "cc/CCScheduler.h"
 #include "cc/CCScopedThreadProxy.h"
-#include "cc/CCTextureUpdater.h"
+#include "cc/CCTextureUpdateController.h"
 #include "cc/CCThreadTask.h"
 #include <public/WebSharedGraphicsContext3D.h>
 #include <wtf/CurrentTime.h>
@@ -46,10 +46,6 @@ using namespace WTF;
 using WebKit::WebSharedGraphicsContext3D;
 namespace {
 
-// Number of textures to update with each call to
-// scheduledActionUpdateMoreResources().
-static const size_t textureUpdatesPerFrame = 48;
-
 // Measured in seconds.
 static const double contextRecreationTickRate = 0.03;
 
@@ -449,8 +445,6 @@ void CCThreadProxy::scheduledActionBeginFrame()
     m_pendingBeginFrameRequest = adoptPtr(new BeginFrameAndCommitState());
     m_pendingBeginFrameRequest->monotonicFrameBeginTime = monotonicallyIncreasingTime();
     m_pendingBeginFrameRequest->scrollInfo = m_layerTreeHostImpl->processScrollDeltas();
-    m_currentTextureUpdaterOnImplThread = adoptPtr(new CCTextureUpdater);
-    m_pendingBeginFrameRequest->updater = m_currentTextureUpdaterOnImplThread.get();
     m_pendingBeginFrameRequest->contentsTexturesWereDeleted = m_layerTreeHostImpl->contentsTexturesWerePurgedSinceLastCommit();
     m_pendingBeginFrameRequest->memoryAllocationLimitBytes = m_layerTreeHostImpl->memoryAllocationLimitBytes();
 
@@ -521,7 +515,8 @@ void CCThreadProxy::beginFrame()
     if (request->contentsTexturesWereDeleted)
         m_layerTreeHost->evictAllContentTextures();
 
-    m_layerTreeHost->updateLayers(*request->updater, request->memoryAllocationLimitBytes);
+    OwnPtr<CCTextureUpdater> updater = adoptPtr(new CCTextureUpdater);
+    m_layerTreeHost->updateLayers(*(updater.get()), request->memoryAllocationLimitBytes);
 
     // Once single buffered layers are committed, they cannot be modified until
     // they are drawn by the impl thread.
@@ -543,7 +538,7 @@ void CCThreadProxy::beginFrame()
         DebugScopedSetMainThreadBlocked mainThreadBlocked;
 
         CCCompletionEvent completion;
-        CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::beginFrameCompleteOnImplThread, &completion));
+        CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::beginFrameCompleteOnImplThread, &completion, updater.release()));
         completion.wait();
     }
 
@@ -551,7 +546,7 @@ void CCThreadProxy::beginFrame()
     m_layerTreeHost->didBeginFrame();
 }
 
-void CCThreadProxy::beginFrameCompleteOnImplThread(CCCompletionEvent* completion)
+void CCThreadProxy::beginFrameCompleteOnImplThread(CCCompletionEvent* completion, PassOwnPtr<CCTextureUpdater> updater)
 {
     TRACE_EVENT0("cc", "CCThreadProxy::beginFrameCompleteOnImplThread");
     ASSERT(!m_commitCompletionEventOnImplThread);
@@ -564,6 +559,7 @@ void CCThreadProxy::beginFrameCompleteOnImplThread(CCCompletionEvent* completion
         return;
     }
 
+    m_currentTextureUpdateControllerOnImplThread = CCTextureUpdateController::create(updater, m_layerTreeHostImpl->resourceProvider(), m_layerTreeHostImpl->layerRenderer()->textureCopier(), m_layerTreeHostImpl->layerRenderer()->textureUploader());
     m_commitCompletionEventOnImplThread = completion;
 
     m_schedulerOnImplThread->beginFrameComplete();
@@ -581,9 +577,9 @@ void CCThreadProxy::beginFrameAbortedOnImplThread()
 
 bool CCThreadProxy::hasMoreResourceUpdates() const
 {
-    if (!m_currentTextureUpdaterOnImplThread)
+    if (!m_currentTextureUpdateControllerOnImplThread)
         return false;
-    return m_currentTextureUpdaterOnImplThread->hasMoreUpdates();
+    return m_currentTextureUpdateControllerOnImplThread->hasMoreUpdates();
 }
 
 bool CCThreadProxy::canDraw()
@@ -597,19 +593,19 @@ bool CCThreadProxy::canDraw()
 void CCThreadProxy::scheduledActionUpdateMoreResources()
 {
     TRACE_EVENT0("cc", "CCThreadProxy::scheduledActionUpdateMoreResources");
-    ASSERT(m_currentTextureUpdaterOnImplThread);
-    m_currentTextureUpdaterOnImplThread->update(m_layerTreeHostImpl->resourceProvider(), m_layerTreeHostImpl->layerRenderer()->textureCopier(), m_layerTreeHostImpl->layerRenderer()->textureUploader(), textureUpdatesPerFrame);
+    ASSERT(m_currentTextureUpdateControllerOnImplThread);
+    m_currentTextureUpdateControllerOnImplThread->updateMoreTextures();
 }
 
 void CCThreadProxy::scheduledActionCommit()
 {
     TRACE_EVENT0("cc", "CCThreadProxy::scheduledActionCommit");
     ASSERT(isImplThread());
-    ASSERT(m_currentTextureUpdaterOnImplThread);
-    ASSERT(!m_currentTextureUpdaterOnImplThread->hasMoreUpdates());
+    ASSERT(m_currentTextureUpdateControllerOnImplThread);
+    ASSERT(!m_currentTextureUpdateControllerOnImplThread->hasMoreUpdates());
     ASSERT(m_commitCompletionEventOnImplThread);
 
-    m_currentTextureUpdaterOnImplThread.clear();
+    m_currentTextureUpdateControllerOnImplThread.clear();
 
     m_layerTreeHostImpl->beginCommit();
 
@@ -866,7 +862,7 @@ void CCThreadProxy::setFullRootLayerDamageOnImplThread()
 
 size_t CCThreadProxy::maxPartialTextureUpdates() const
 {
-    return textureUpdatesPerFrame;
+    return CCTextureUpdateController::maxPartialTextureUpdates();
 }
 
 void CCThreadProxy::recreateContextOnImplThread(CCCompletionEvent* completion, CCGraphicsContext* contextPtr, bool* recreateSucceeded, LayerRendererCapabilities* capabilities)
index 6c03685..f3212e6 100644 (file)
@@ -38,6 +38,7 @@ class CCInputHandler;
 class CCLayerTreeHost;
 class CCScheduler;
 class CCScopedThreadProxy;
+class CCTextureUpdateController;
 class CCTextureUpdater;
 class CCThread;
 class CCThreadProxyContextRecreationTimer;
@@ -99,13 +100,11 @@ private:
     struct BeginFrameAndCommitState {
         BeginFrameAndCommitState()
             : monotonicFrameBeginTime(0)
-            , updater(0)
         {
         }
 
         double monotonicFrameBeginTime;
         OwnPtr<CCScrollAndScaleSet> scrollInfo;
-        CCTextureUpdater* updater;
         bool contentsTexturesWereDeleted;
         size_t memoryAllocationLimitBytes;
     };
@@ -127,7 +126,7 @@ private:
         IntRect rect;
     };
     void forceBeginFrameOnImplThread(CCCompletionEvent*);
-    void beginFrameCompleteOnImplThread(CCCompletionEvent*);
+    void beginFrameCompleteOnImplThread(CCCompletionEvent*, PassOwnPtr<CCTextureUpdater>);
     void beginFrameAbortedOnImplThread();
     void requestReadbackOnImplThread(ReadbackRequest*);
     void requestStartPageScaleAnimationOnImplThread(IntSize targetPosition, bool useAnchor, float scale, double durationSec);
@@ -183,7 +182,7 @@ private:
     // Set when the main thread is waiting on layers to be drawn.
     CCCompletionEvent* m_textureAcquisitionCompletionEventOnImplThread;
 
-    OwnPtr<CCTextureUpdater> m_currentTextureUpdaterOnImplThread;
+    OwnPtr<CCTextureUpdateController> m_currentTextureUpdateControllerOnImplThread;
 
     // Set when the next draw should post didCommitAndDrawFrame to the main thread.
     bool m_nextFrameIsNewlyCommittedFrameOnImplThread;
index 94d5564..4ae3f29 100644 (file)
@@ -1,3 +1,20 @@
+2012-08-06  David Reveman  <reveman@chromium.org>
+
+        [Chromium] Refactor CCTextureUpdater into CCTextureUpdater and CCTextureUpdateController.
+        https://bugs.webkit.org/show_bug.cgi?id=92596
+
+        Reviewed by Adrienne Walker.
+
+        * WebKit.gypi:
+        * src/WebExternalTextureLayer.cpp:
+        * tests/CCTextureUpdateControllerTest.cpp: Renamed from Source/WebKit/chromium/tests/CCTextureUpdaterTest.cpp.
+        * tests/CCTiledLayerTestCommon.h:
+        (WebKitTests::FakeTextureCopier::copyTexture):
+        (WebKitTests::FakeTextureUploader::uploadTexture):
+        * tests/TextureCopierTest.cpp:
+        (TEST):
+        * tests/TiledLayerChromiumTest.cpp:
+
 2012-08-06  Shawn Singh  <shawnsingh@chromium.org>
 
         [chromium] Non-preserves-3d requires explicit flattening of screen-space transform.
index 5edefd2..2a838d4 100644 (file)
@@ -87,7 +87,7 @@
             'tests/CCScrollbarAnimationControllerLinearFadeTest.cpp',
             'tests/CCSolidColorLayerImplTest.cpp',
             'tests/CCTestCommon.h',
-            'tests/CCTextureUpdaterTest.cpp',
+            'tests/CCTextureUpdateControllerTest.cpp',
             'tests/CCTiledLayerImplTest.cpp',
             'tests/CCTiledLayerTestCommon.h',
             'tests/CCTiledLayerTestCommon.cpp',
index d9cea3b..68649b3 100644 (file)
@@ -45,7 +45,8 @@ public:
 
     virtual void appendCopy(unsigned sourceTexture, unsigned destinationTexture, WebSize size) OVERRIDE
     {
-        m_updater.appendCopy(sourceTexture, destinationTexture, size);
+        TextureCopier::Parameters copy = { sourceTexture, destinationTexture, size };
+        m_updater.appendCopy(copy);
     }
 
 private:
@@ -24,8 +24,9 @@
 
 #include "config.h"
 
-#include "cc/CCTextureUpdater.h"
+#include "cc/CCTextureUpdateController.h"
 
+#include "CCSchedulerTestCommon.h"
 #include "CCTiledLayerTestCommon.h"
 #include "FakeWebGraphicsContext3D.h"
 #include "GraphicsContext3DPrivate.h"
@@ -47,11 +48,11 @@ namespace {
 const int kFlushPeriodFull = 4;
 const int kFlushPeriodPartial = kFlushPeriodFull;
 
-class CCTextureUpdaterTest;
+class CCTextureUpdateControllerTest;
 
 class WebGraphicsContext3DForUploadTest : public FakeWebGraphicsContext3D {
 public:
-    WebGraphicsContext3DForUploadTest(CCTextureUpdaterTest *test)
+    WebGraphicsContext3DForUploadTest(CCTextureUpdateControllerTest *test)
         : m_test(test)
         , m_supportShallowFlush(true)
     { }
@@ -68,27 +69,23 @@ public:
     }
 
 private:
-    CCTextureUpdaterTest* m_test;
+    CCTextureUpdateControllerTest* m_test;
     bool m_supportShallowFlush;
 };
 
 
 class TextureUploaderForUploadTest : public FakeTextureUploader {
 public:
-    TextureUploaderForUploadTest(CCTextureUpdaterTest *test) : m_test(test) { }
+    TextureUploaderForUploadTest(CCTextureUpdateControllerTest *test) : m_test(test) { }
 
     virtual void beginUploads() OVERRIDE;
     virtual void endUploads() OVERRIDE;
-    virtual void uploadTexture(WebCore::LayerTextureUpdater::Texture*,
-                               WebCore::CCResourceProvider*,
-                               const WebCore::IntRect sourceRect,
-                               const WebCore::IntRect destRect) OVERRIDE;
+    virtual void uploadTexture(WebCore::CCResourceProvider*, Parameters) OVERRIDE;
 
 private:
-    CCTextureUpdaterTest* m_test;
+    CCTextureUpdateControllerTest* m_test;
 };
 
-
 class TextureForUploadTest : public LayerTextureUpdater::Texture {
 public:
     TextureForUploadTest() : LayerTextureUpdater::Texture(adoptPtr<CCPrioritizedTexture>(0)) { }
@@ -96,10 +93,11 @@ public:
 };
 
 
-class CCTextureUpdaterTest : public Test {
+class CCTextureUpdateControllerTest : public Test {
 public:
-    CCTextureUpdaterTest()
-    : m_uploader(this)
+    CCTextureUpdateControllerTest()
+    : m_updater(adoptPtr(new CCTextureUpdater))
+    , m_uploader(this)
     , m_fullUploadCountExpected(0)
     , m_partialCountExpected(0)
     , m_totalUploadCountExpected(0)
@@ -193,8 +191,9 @@ protected:
         m_totalUploadCountExpected += count;
 
         const IntRect rect(0, 0, 300, 150);
+        const TextureUploader::Parameters upload = { &m_texture, rect, rect };
         for (int i = 0; i < count; i++)
-            m_updater.appendFullUpdate(&m_texture, rect, rect);
+            m_updater->appendFullUpload(upload);
     }
 
     void appendPartialUploadsToUpdater(int count)
@@ -203,8 +202,9 @@ protected:
         m_totalUploadCountExpected += count;
 
         const IntRect rect(0, 0, 100, 100);
+        const TextureUploader::Parameters upload = { &m_texture, rect, rect };
         for (int i = 0; i < count; i++)
-            m_updater.appendPartialUpdate(&m_texture, rect, rect);
+            m_updater->appendPartialUpload(upload);
     }
 
     void setMaxUploadCountPerUpdate(int count)
@@ -213,10 +213,10 @@ protected:
     }
 
 protected:
-    // Classes required to interact and test the CCTextureUpdater
+    // Classes required to interact and test the CCTextureUpdateController
     OwnPtr<CCGraphicsContext> m_context;
     OwnPtr<CCResourceProvider> m_resourceProvider;
-    CCTextureUpdater m_updater;
+    OwnPtr<CCTextureUpdater> m_updater;
     TextureForUploadTest m_texture;
     FakeTextureCopier m_copier;
     TextureUploaderForUploadTest m_uploader;
@@ -238,7 +238,6 @@ protected:
     int m_numPreviousFlushes;
 };
 
-
 void WebGraphicsContext3DForUploadTest::flush(void)
 {
     m_test->onFlush();
@@ -259,21 +258,18 @@ void TextureUploaderForUploadTest::endUploads()
     m_test->onEndUploads();
 }
 
-void TextureUploaderForUploadTest::uploadTexture(WebCore::LayerTextureUpdater::Texture* texture,
-                                                 WebCore::CCResourceProvider*,
-                                                 const WebCore::IntRect sourceRect,
-                                                 const WebCore::IntRect destRect)
+void TextureUploaderForUploadTest::uploadTexture(WebCore::CCResourceProvider*, Parameters)
 {
     m_test->onUpload();
 }
 
 
 // ZERO UPLOADS TESTS
-TEST_F(CCTextureUpdaterTest, ZeroUploads)
+TEST_F(CCTextureUpdateControllerTest, ZeroUploads)
 {
     appendFullUploadsToUpdater(0);
     appendPartialUploadsToUpdater(0);
-    m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, m_totalUploadCountExpected);
+    CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_copier, &m_uploader, m_updater.get(), m_totalUploadCountExpected);
 
     EXPECT_EQ(0, m_numBeginUploads);
     EXPECT_EQ(0, m_numEndUploads);
@@ -283,12 +279,12 @@ TEST_F(CCTextureUpdaterTest, ZeroUploads)
 
 
 // ONE UPLOAD TESTS
-TEST_F(CCTextureUpdaterTest, OneFullUpload)
+TEST_F(CCTextureUpdateControllerTest, OneFullUpload)
 {
     appendFullUploadsToUpdater(1);
     appendPartialUploadsToUpdater(0);
     DebugScopedSetImplThread implThread;
-    m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, m_totalUploadCountExpected);
+    CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_copier, &m_uploader, m_updater.get(), m_totalUploadCountExpected);
 
     EXPECT_EQ(1, m_numBeginUploads);
     EXPECT_EQ(1, m_numEndUploads);
@@ -296,12 +292,12 @@ TEST_F(CCTextureUpdaterTest, OneFullUpload)
     EXPECT_EQ(1, m_numPreviousUploads);
 }
 
-TEST_F(CCTextureUpdaterTest, OnePartialUpload)
+TEST_F(CCTextureUpdateControllerTest, OnePartialUpload)
 {
     appendFullUploadsToUpdater(0);
     appendPartialUploadsToUpdater(1);
     DebugScopedSetImplThread implThread;
-    m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, m_totalUploadCountExpected);
+    CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_copier, &m_uploader, m_updater.get(), m_totalUploadCountExpected);
 
     EXPECT_EQ(1, m_numBeginUploads);
     EXPECT_EQ(1, m_numEndUploads);
@@ -309,12 +305,12 @@ TEST_F(CCTextureUpdaterTest, OnePartialUpload)
     EXPECT_EQ(1, m_numPreviousUploads);
 }
 
-TEST_F(CCTextureUpdaterTest, OneFullOnePartialUpload)
+TEST_F(CCTextureUpdateControllerTest, OneFullOnePartialUpload)
 {
     appendFullUploadsToUpdater(1);
     appendPartialUploadsToUpdater(1);
     DebugScopedSetImplThread implThread;
-    m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, m_totalUploadCountExpected);
+    CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_copier, &m_uploader, m_updater.get(), m_totalUploadCountExpected);
 
     // We expect the full uploads to be followed by a flush
     // before the partial uploads begin.
@@ -333,12 +329,12 @@ const int fullNoRemainderCount = fullUploadFlushMultipler * kFlushPeriodFull;
 const int partialUploadFlushMultipler = 11;
 const int partialNoRemainderCount = partialUploadFlushMultipler * kFlushPeriodPartial;
 
-TEST_F(CCTextureUpdaterTest, ManyFullUploadsNoRemainder)
+TEST_F(CCTextureUpdateControllerTest, ManyFullUploadsNoRemainder)
 {
     appendFullUploadsToUpdater(fullNoRemainderCount);
     appendPartialUploadsToUpdater(0);
     DebugScopedSetImplThread implThread;
-    m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, m_totalUploadCountExpected);
+    CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_copier, &m_uploader, m_updater.get(), m_totalUploadCountExpected);
 
     EXPECT_EQ(1, m_numBeginUploads);
     EXPECT_EQ(1, m_numEndUploads);
@@ -346,12 +342,12 @@ TEST_F(CCTextureUpdaterTest, ManyFullUploadsNoRemainder)
     EXPECT_EQ(fullNoRemainderCount, m_numPreviousUploads);
 }
 
-TEST_F(CCTextureUpdaterTest, ManyPartialUploadsNoRemainder)
+TEST_F(CCTextureUpdateControllerTest, ManyPartialUploadsNoRemainder)
 {
     appendFullUploadsToUpdater(0);
     appendPartialUploadsToUpdater(partialNoRemainderCount);
     DebugScopedSetImplThread implThread;
-    m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, m_totalUploadCountExpected);
+    CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_copier, &m_uploader, m_updater.get(), m_totalUploadCountExpected);
 
     EXPECT_EQ(1, m_numBeginUploads);
     EXPECT_EQ(1, m_numEndUploads);
@@ -359,12 +355,12 @@ TEST_F(CCTextureUpdaterTest, ManyPartialUploadsNoRemainder)
     EXPECT_EQ(partialNoRemainderCount, m_numPreviousUploads);
 }
 
-TEST_F(CCTextureUpdaterTest, ManyFullManyPartialUploadsNoRemainder)
+TEST_F(CCTextureUpdateControllerTest, ManyFullManyPartialUploadsNoRemainder)
 {
     appendFullUploadsToUpdater(fullNoRemainderCount);
     appendPartialUploadsToUpdater(partialNoRemainderCount);
     DebugScopedSetImplThread implThread;
-    m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, m_totalUploadCountExpected);
+    CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_copier, &m_uploader, m_updater.get(), m_totalUploadCountExpected);
 
     EXPECT_EQ(1, m_numBeginUploads);
     EXPECT_EQ(1, m_numEndUploads);
@@ -382,12 +378,12 @@ const int fullMaxRemainderCount = fullNoRemainderCount - 1;
 const int partialMinRemainderCount = partialNoRemainderCount + 1;
 const int partialMaxRemainderCount = partialNoRemainderCount - 1;
 
-TEST_F(CCTextureUpdaterTest, ManyFullAndPartialMinRemainder)
+TEST_F(CCTextureUpdateControllerTest, ManyFullAndPartialMinRemainder)
 {
     appendFullUploadsToUpdater(fullMinRemainderCount);
     appendPartialUploadsToUpdater(partialMinRemainderCount);
     DebugScopedSetImplThread implThread;
-    m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, m_totalUploadCountExpected);
+    CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_copier, &m_uploader, m_updater.get(), m_totalUploadCountExpected);
 
     EXPECT_EQ(1, m_numBeginUploads);
     EXPECT_EQ(1, m_numEndUploads);
@@ -395,12 +391,12 @@ TEST_F(CCTextureUpdaterTest, ManyFullAndPartialMinRemainder)
     EXPECT_EQ(fullMinRemainderCount + partialMinRemainderCount, m_numPreviousUploads);
 }
 
-TEST_F(CCTextureUpdaterTest, ManyFullAndPartialUploadsMaxRemainder)
+TEST_F(CCTextureUpdateControllerTest, ManyFullAndPartialUploadsMaxRemainder)
 {
     appendFullUploadsToUpdater(fullMaxRemainderCount);
     appendPartialUploadsToUpdater(partialMaxRemainderCount);
     DebugScopedSetImplThread implThread;
-    m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, m_totalUploadCountExpected);
+    CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_copier, &m_uploader, m_updater.get(), m_totalUploadCountExpected);
 
     EXPECT_EQ(1, m_numBeginUploads);
     EXPECT_EQ(1, m_numEndUploads);
@@ -408,12 +404,12 @@ TEST_F(CCTextureUpdaterTest, ManyFullAndPartialUploadsMaxRemainder)
     EXPECT_EQ(fullMaxRemainderCount + partialMaxRemainderCount, m_numPreviousUploads);
 }
 
-TEST_F(CCTextureUpdaterTest, ManyFullMinRemainderManyPartialMaxRemainder)
+TEST_F(CCTextureUpdateControllerTest, ManyFullMinRemainderManyPartialMaxRemainder)
 {
     appendFullUploadsToUpdater(fullMinRemainderCount);
     appendPartialUploadsToUpdater(partialMaxRemainderCount);
     DebugScopedSetImplThread implThread;
-    m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, m_totalUploadCountExpected);
+    CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_copier, &m_uploader, m_updater.get(), m_totalUploadCountExpected);
 
     EXPECT_EQ(1, m_numBeginUploads);
     EXPECT_EQ(1, m_numEndUploads);
@@ -421,12 +417,12 @@ TEST_F(CCTextureUpdaterTest, ManyFullMinRemainderManyPartialMaxRemainder)
     EXPECT_EQ(fullMinRemainderCount + partialMaxRemainderCount, m_numPreviousUploads);
 }
 
-TEST_F(CCTextureUpdaterTest, ManyFullMaxRemainderManyPartialMinRemainder)
+TEST_F(CCTextureUpdateControllerTest, ManyFullMaxRemainderManyPartialMinRemainder)
 {
     appendFullUploadsToUpdater(fullMaxRemainderCount);
     appendPartialUploadsToUpdater(partialMinRemainderCount);
     DebugScopedSetImplThread implThread;
-    m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, m_totalUploadCountExpected);
+    CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_copier, &m_uploader, m_updater.get(), m_totalUploadCountExpected);
 
     EXPECT_EQ(1, m_numBeginUploads);
     EXPECT_EQ(1, m_numEndUploads);
@@ -444,7 +440,7 @@ int expectedFlushes(int uploads, int flushPeriod)
     return (uploads + flushPeriod - 1) / flushPeriod;
 }
 
-TEST_F(CCTextureUpdaterTest, TripleUpdateFinalUpdateFullAndPartial)
+TEST_F(CCTextureUpdateControllerTest, TripleUpdateFinalUpdateFullAndPartial)
 {
     const int kMaxUploadsPerUpdate = 40;
     const int kFullUploads = 100;
@@ -459,7 +455,7 @@ TEST_F(CCTextureUpdaterTest, TripleUpdateFinalUpdateFullAndPartial)
 
     // First update (40 full)
     DebugScopedSetImplThread implThread;
-    m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, kMaxUploadsPerUpdate);
+    CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_copier, &m_uploader, m_updater.get(), kMaxUploadsPerUpdate);
 
     EXPECT_EQ(1, m_numBeginUploads);
     EXPECT_EQ(1, m_numEndUploads);
@@ -471,7 +467,7 @@ TEST_F(CCTextureUpdaterTest, TripleUpdateFinalUpdateFullAndPartial)
     EXPECT_EQ(expectedPreviousUploads, m_numPreviousUploads);
 
     // Second update (40 full)
-    m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, kMaxUploadsPerUpdate);
+    CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_copier, &m_uploader, m_updater.get(), kMaxUploadsPerUpdate);
 
     EXPECT_EQ(2, m_numBeginUploads);
     EXPECT_EQ(2, m_numEndUploads);
@@ -483,7 +479,7 @@ TEST_F(CCTextureUpdaterTest, TripleUpdateFinalUpdateFullAndPartial)
     EXPECT_EQ(expectedPreviousUploads, m_numPreviousUploads);
 
     // Third update (20 full, 20 partial)
-    m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, kMaxUploadsPerUpdate);
+    CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_copier, &m_uploader, m_updater.get(), kMaxUploadsPerUpdate);
 
     EXPECT_EQ(3, m_numBeginUploads);
     EXPECT_EQ(3, m_numEndUploads);
@@ -499,7 +495,7 @@ TEST_F(CCTextureUpdaterTest, TripleUpdateFinalUpdateFullAndPartial)
     EXPECT_EQ(kFullUploads + kPartialUploads, m_numTotalUploads);
 }
 
-TEST_F(CCTextureUpdaterTest, TripleUpdateFinalUpdateAllPartial)
+TEST_F(CCTextureUpdateControllerTest, TripleUpdateFinalUpdateAllPartial)
 {
     const int kMaxUploadsPerUpdate = 40;
     const int kFullUploads = 70;
@@ -514,7 +510,7 @@ TEST_F(CCTextureUpdaterTest, TripleUpdateFinalUpdateAllPartial)
 
     // First update (40 full)
     DebugScopedSetImplThread implThread;
-    m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, kMaxUploadsPerUpdate);
+    CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_copier, &m_uploader, m_updater.get(), kMaxUploadsPerUpdate);
 
     EXPECT_EQ(1, m_numBeginUploads);
     EXPECT_EQ(1, m_numEndUploads);
@@ -526,7 +522,7 @@ TEST_F(CCTextureUpdaterTest, TripleUpdateFinalUpdateAllPartial)
     EXPECT_EQ(expectedPreviousUploads, m_numPreviousUploads);
 
     // Second update (30 full, optionally 10 partial)
-    m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, kMaxUploadsPerUpdate);
+    CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_copier, &m_uploader, m_updater.get(), kMaxUploadsPerUpdate);
 
     EXPECT_EQ(2, m_numBeginUploads);
     EXPECT_EQ(2, m_numEndUploads);
@@ -536,7 +532,7 @@ TEST_F(CCTextureUpdaterTest, TripleUpdateFinalUpdateAllPartial)
     // onFlush(), onUpload(), and onEndUpload() will do basic flush checks for us anyway.
 
     // Third update (30 partial OR 20 partial if 10 partial uploaded in second update)
-    m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, kMaxUploadsPerUpdate);
+    CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_copier, &m_uploader, m_updater.get(), kMaxUploadsPerUpdate);
 
     EXPECT_EQ(3, m_numBeginUploads);
     EXPECT_EQ(3, m_numEndUploads);
@@ -547,5 +543,4 @@ TEST_F(CCTextureUpdaterTest, TripleUpdateFinalUpdateAllPartial)
     EXPECT_EQ(kFullUploads + kPartialUploads, m_numTotalUploads);
 }
 
-
 } // namespace
index de1eb66..6cd228b 100644 (file)
@@ -153,7 +153,7 @@ protected:
 
 class FakeTextureCopier : public WebCore::TextureCopier {
 public:
-    virtual void copyTexture(unsigned, unsigned, const WebCore::IntSize&) { }
+    virtual void copyTexture(Parameters) { }
     virtual void flush() { }
 };
 
@@ -162,7 +162,7 @@ public:
     virtual bool isBusy() { return false; }
     virtual void beginUploads() { }
     virtual void endUploads() { }
-    virtual void uploadTexture(WebCore::LayerTextureUpdater::Texture* texture, WebCore::CCResourceProvider* resourceProvider, const WebCore::IntRect sourceRect, const WebCore::IntRect destRect) { texture->updateRect(resourceProvider, sourceRect, destRect); }
+    virtual void uploadTexture(WebCore::CCResourceProvider* resourceProvider, Parameters upload) { upload.texture->updateRect(resourceProvider, upload.sourceRect, upload.destRect); }
 };
 
 }
index 776e23b..c9af60f 100644 (file)
@@ -76,5 +76,6 @@ TEST(TextureCopierTest, testDrawArraysCopy)
     int destTextureId = 2;
     IntSize size(256, 128);
     OwnPtr<AcceleratedTextureCopier> copier(AcceleratedTextureCopier::create(mockContext.get(), false));
-    copier->copyTexture(sourceTextureId, destTextureId, size);
+    TextureCopier::Parameters copy = { sourceTextureId, destTextureId, size };
+    copier->copyTexture(copy);
 }
index 8d6b789..0b44b86 100644 (file)
@@ -37,6 +37,7 @@
 #include "cc/CCOverdrawMetrics.h"
 #include "cc/CCRenderingStats.h"
 #include "cc/CCSingleThreadProxy.h" // For DebugScopedSetImplThread
+#include "cc/CCTextureUpdateController.h"
 #include <gtest/gtest.h>
 #include <public/WebTransformationMatrix.h>
 
@@ -89,7 +90,7 @@ public:
 
     void updateTextures(int count = 500)
     {
-        m_updater.update(m_resourceProvider.get(), &m_copier, &m_uploader, count);
+        CCTextureUpdateController::updateTextures(m_resourceProvider.get(), &m_copier, &m_uploader, &m_updater, count);
     }
 public:
     OwnPtr<CCGraphicsContext> m_context;