Unreviewed, rolling out r95309.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Sep 2011 20:05:01 +0000 (20:05 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Sep 2011 20:05:01 +0000 (20:05 +0000)
http://trac.webkit.org/changeset/95309
https://bugs.webkit.org/show_bug.cgi?id=68271

Broke many chromium gpu tests. (Requested by dave_levin on
#webkit).

Patch by Sheriff Bot <webkit.review.bot@gmail.com> on 2011-09-16

Source/WebCore:

* platform/graphics/chromium/ContentLayerChromium.cpp:
(WebCore::ContentLayerChromium::createTextureUpdater):
* platform/graphics/chromium/LayerRendererChromium.cpp:
(WebCore::LayerRendererChromium::LayerRendererChromium):
* platform/graphics/chromium/cc/CCLayerTreeHost.h:
* platform/graphics/chromium/cc/CCLayerTreeHostImpl.h:
* platform/graphics/chromium/cc/CCThreadProxy.cpp:
(WebCore::CCThreadProxy::context):
(WebCore::CCThreadProxy::beginFrameAndCommitOnCCThread):
(WebCore::CCThreadProxy::setNeedsCommitAndRedrawOnCCThread):
(WebCore::CCThreadProxy::setNeedsRedrawOnCCThread):

Source/WebKit/chromium:

* tests/CCLayerTreeHostTest.cpp:
(WTF::CCLayerTreeHostTest::CCLayerTreeHostTest):
(WTF::CCLayerTreeHostTest::animateAndLayout):
(WTF::CCLayerTreeHostTest::beginCommitOnCCThread):
(WTF::CCLayerTreeHostTest::beginCommitOnMainThread):
(WTF::CCLayerTreeHostTest::commitOnCCThread):
(WTF::CCLayerTreeHostTest::commitCompleteOnCCThread):
(WTF::CCLayerTreeHostTest::commitCompleteOnMainThread):
(WTF::CCLayerTreeHostTest::drawLayersAndPresentOnCCThread):
(WTF::CCLayerTreeHostTest::updateLayers):
(WTF::CCLayerTreeHostTest::onBeginTest):
(WTF::CCLayerTreeHostTest::doEndTest):
(WTF::CCLayerTreeHostTest::onEndTest):
(WTF::CCLayerTreeHostTest::runTest):
(WTF::CCLayerTreeHostTest::testTimeout):
(WTF::MockLayerTreeHostClient::MockLayerTreeHostClient):
(WTF::MockLayerTreeHostClient::createLayerTreeHostContext3D):
(WTF::MockLayerTreeHostClient::animateAndLayout):
(WTF::MockLayerTreeHostClient::updateLayers):
(WTF::MockLayerTreeHostCommitter::create):
(WTF::MockLayerTreeHostCommitter::commit):
(WTF::MockLayerTreeHostCommitter::MockLayerTreeHostCommitter):
(WTF::MockLayerTreeHostImpl::create):
(WTF::MockLayerTreeHostImpl::beginCommit):
(WTF::MockLayerTreeHostImpl::commitComplete):
(WTF::MockLayerTreeHostImpl::drawLayersAndPresent):
(WTF::MockLayerTreeHostImpl::MockLayerTreeHostImpl):
(WTF::MockLayerTreeHostImplProxy::create):
(WTF::MockLayerTreeHostImplProxy::createLayerTreeHostImpl):
(WTF::MockLayerTreeHostImplProxy::MockLayerTreeHostImplProxy):
(WTF::MockLayerTreeHost::MockLayerTreeHost):
(WTF::MockLayerTreeHost::createLayerTreeHostImplProxy):
(WTF::MockLayerTreeHost::updateLayers):
(WTF::MockLayerTreeHost::createLayerTreeHostCommitter):
(WTF::MockLayerTreeHost::beginCommit):
(WTF::MockLayerTreeHost::commitComplete):
(WTF::CCLayerTreeHostTest::doBeginTest):
(WTF::CCLayerTreeHostTestShortlived2::beginTest):
(WTF::CCLayerTreeHostTestShortlived3::beginTest):
(WTF::CCLayerTreeHostTestCommitingWithContinuousRedraw::beginTest):
(WTF::CCLayerTreeHostTestCommitingWithContinuousRedraw::commitCompleteOnCCThread):
(WTF::CCLayerTreeHostTestCommitingWithContinuousRedraw::drawLayersAndPresentOnCCThread):
(WTF::CCLayerTreeHostTestSetNeedsCommit1::beginTest):
(WTF::CCLayerTreeHostTestSetNeedsCommit1::drawLayersAndPresentOnCCThread):
(WTF::CCLayerTreeHostTestSetNeedsCommit1::commitOnCCThread):
(WTF::CCLayerTreeHostTestSetNeedsCommit2::beginTest):
(WTF::CCLayerTreeHostTestSetNeedsCommit2::drawLayersAndPresentOnCCThread):
(WTF::CCLayerTreeHostTestSetNeedsCommit2::commitOnCCThread):
(WTF::CCLayerTreeHostTestSetNeedsRedraw::beginTest):
(WTF::CCLayerTreeHostTestSetNeedsRedraw::drawLayersAndPresentOnCCThread):
(WTF::CCLayerTreeHostTestSetNeedsRedraw::commitOnCCThread):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp
Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h
Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h
Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp

index aecd332..9956761 100644 (file)
@@ -1,3 +1,24 @@
+2011-09-16  Sheriff Bot  <webkit.review.bot@gmail.com>
+
+        Unreviewed, rolling out r95309.
+        http://trac.webkit.org/changeset/95309
+        https://bugs.webkit.org/show_bug.cgi?id=68271
+
+        Broke many chromium gpu tests. (Requested by dave_levin on
+        #webkit).
+
+        * platform/graphics/chromium/ContentLayerChromium.cpp:
+        (WebCore::ContentLayerChromium::createTextureUpdater):
+        * platform/graphics/chromium/LayerRendererChromium.cpp:
+        (WebCore::LayerRendererChromium::LayerRendererChromium):
+        * platform/graphics/chromium/cc/CCLayerTreeHost.h:
+        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.h:
+        * platform/graphics/chromium/cc/CCThreadProxy.cpp:
+        (WebCore::CCThreadProxy::context):
+        (WebCore::CCThreadProxy::beginFrameAndCommitOnCCThread):
+        (WebCore::CCThreadProxy::setNeedsCommitAndRedrawOnCCThread):
+        (WebCore::CCThreadProxy::setNeedsRedrawOnCCThread):
+
 2011-09-16  Filip Pizlo  <fpizlo@apple.com>
 
         DFG JIT should inline Math.abs
index 0f42aa9..05e3166 100644 (file)
@@ -120,7 +120,6 @@ bool ContentLayerChromium::drawsContent() const
 
 void ContentLayerChromium::createTextureUpdater(const CCLayerTreeHost* host)
 {
-#if !USE(THREADED_COMPOSITING)
 #if USE(SKIA)
     // Note that host->skiaContext() will crash if called while in threaded
     // mode. This thus depends on CCLayerTreeHost::initialize turning off
@@ -130,7 +129,6 @@ void ContentLayerChromium::createTextureUpdater(const CCLayerTreeHost* host)
         return;
     }
 #endif // SKIA
-#endif // !THREADED_COMPOSITING
 
     m_textureUpdater = LayerTextureUpdaterBitmap::create(ContentLayerPainter::create(m_delegate), host->layerRendererCapabilities().usingMapSub);
 }
index 7afcb73..f3ba0c5 100644 (file)
@@ -148,7 +148,6 @@ LayerRendererChromium::LayerRendererChromium(CCLayerTreeHostImpl* owner,
     , m_currentRenderSurface(0)
     , m_offscreenFramebufferId(0)
     , m_zoomAnimatorScale(1)
-    , m_contentsTextureMemoryUseBytes(0)
     , m_context(context)
     , m_defaultRenderSurface(0)
     , m_sharedGeometryQuad(FloatRect(-0.5f, -0.5f, 1.0f, 1.0f))
index fee2956..b523f77 100644 (file)
@@ -99,7 +99,7 @@ public:
     void commitTo(CCLayerTreeHostImpl*);
     PassOwnPtr<CCThread> createCompositorThread();
     PassRefPtr<GraphicsContext3D> createLayerTreeHostContext3D();
-    virtual PassOwnPtr<CCLayerTreeHostImpl> createLayerTreeHostImpl();
+    PassOwnPtr<CCLayerTreeHostImpl> createLayerTreeHostImpl();
     void didRecreateGraphicsContext(bool success);
 #if !USE(THREADED_COMPOSITING)
     void scheduleComposite();
@@ -154,7 +154,6 @@ public:
 
 protected:
     CCLayerTreeHost(CCLayerTreeHostClient*, PassRefPtr<LayerChromium> rootLayer, const CCSettings&);
-    bool initialize();
 
 private:
     typedef Vector<RefPtr<LayerChromium> > LayerList;
@@ -165,6 +164,8 @@ private:
     void updateCompositorResources(LayerChromium*, GraphicsContext3D*);
     void clearPendingUpdate();
 
+    bool initialize();
+
     bool m_animating;
 
     CCLayerTreeHostClient* m_client;
index a37e9f3..c752e00 100644 (file)
@@ -46,13 +46,13 @@ public:
     static PassOwnPtr<CCLayerTreeHostImpl> create(const CCSettings&);
     virtual ~CCLayerTreeHostImpl();
 
-    // Virtual for testing
     virtual void beginCommit();
     virtual void commitComplete();
-    virtual void drawLayers();
 
     GraphicsContext3D* context();
 
+    void drawLayers();
+
     void finishAllRendering();
     int frameNumber() const { return m_frameNumber; }
 
index 9a84da6..12b5b36 100644 (file)
@@ -84,6 +84,7 @@ bool CCThreadProxy::compositeAndReadback(void *pixels, const IntRect& rect)
 
 GraphicsContext3D* CCThreadProxy::context()
 {
+    ASSERT_NOT_REACHED();
     return 0;
 }
 
@@ -185,8 +186,8 @@ void CCThreadProxy::beginFrameAndCommitOnCCThread()
 {
     TRACE_EVENT("CCThreadProxy::beginFrameAndCommitOnCCThread", this, 0);
     ASSERT(isImplThread());
-    // TEMP HACK so we can exercise this code in unit tests.
-    CCMainThread::postTask(createMainThreadTask(this, &CCThreadProxy::beginFrameAndCommit, 0.0));
+    ASSERT_NOT_REACHED();
+    // FIXME: call beginFrameAndCommit on main thread
 }
 
 void CCThreadProxy::beginFrameAndCommit(double frameBeginTime)
@@ -246,15 +247,13 @@ void CCThreadProxy::setNeedsCommitAndRedrawOnCCThread()
     TRACE_EVENT("CCThreadProxy::setNeedsCommitAndRedrawOnCCThread", this, 0);
     ASSERT(isImplThread());
     ASSERT(m_layerTreeHostImpl);
-    // TEMP HACK so we can exercise this code in unit tests.
-    CCMainThread::postTask(createMainThreadTask(this, &CCThreadProxy::beginFrameAndCommit, 0.0));
+    ASSERT_NOT_REACHED();
 }
 
 void CCThreadProxy::setNeedsRedrawOnCCThread()
 {
     TRACE_EVENT("CCThreadProxy::setNeedsRedrawOnCCThread", this, 0);
-    // TEMP HACK so we can exercise this code in unit tests.
-    drawLayersOnCCThread();
+    ASSERT_NOT_REACHED();
 }
 
 void CCThreadProxy::initializeImplOnCCThread(CCCompletionEvent* completion)
@@ -285,4 +284,4 @@ void CCThreadProxy::layerTreeHostClosedOnCCThread(CCCompletionEvent* completion)
     completion->signal();
 }
 
-} // namespace WebCore
+}
index a1208e6..42df9cc 100644 (file)
@@ -1,3 +1,64 @@
+2011-09-16  Sheriff Bot  <webkit.review.bot@gmail.com>
+
+        Unreviewed, rolling out r95309.
+        http://trac.webkit.org/changeset/95309
+        https://bugs.webkit.org/show_bug.cgi?id=68271
+
+        Broke many chromium gpu tests. (Requested by dave_levin on
+        #webkit).
+
+        * tests/CCLayerTreeHostTest.cpp:
+        (WTF::CCLayerTreeHostTest::CCLayerTreeHostTest):
+        (WTF::CCLayerTreeHostTest::animateAndLayout):
+        (WTF::CCLayerTreeHostTest::beginCommitOnCCThread):
+        (WTF::CCLayerTreeHostTest::beginCommitOnMainThread):
+        (WTF::CCLayerTreeHostTest::commitOnCCThread):
+        (WTF::CCLayerTreeHostTest::commitCompleteOnCCThread):
+        (WTF::CCLayerTreeHostTest::commitCompleteOnMainThread):
+        (WTF::CCLayerTreeHostTest::drawLayersAndPresentOnCCThread):
+        (WTF::CCLayerTreeHostTest::updateLayers):
+        (WTF::CCLayerTreeHostTest::onBeginTest):
+        (WTF::CCLayerTreeHostTest::doEndTest):
+        (WTF::CCLayerTreeHostTest::onEndTest):
+        (WTF::CCLayerTreeHostTest::runTest):
+        (WTF::CCLayerTreeHostTest::testTimeout):
+        (WTF::MockLayerTreeHostClient::MockLayerTreeHostClient):
+        (WTF::MockLayerTreeHostClient::createLayerTreeHostContext3D):
+        (WTF::MockLayerTreeHostClient::animateAndLayout):
+        (WTF::MockLayerTreeHostClient::updateLayers):
+        (WTF::MockLayerTreeHostCommitter::create):
+        (WTF::MockLayerTreeHostCommitter::commit):
+        (WTF::MockLayerTreeHostCommitter::MockLayerTreeHostCommitter):
+        (WTF::MockLayerTreeHostImpl::create):
+        (WTF::MockLayerTreeHostImpl::beginCommit):
+        (WTF::MockLayerTreeHostImpl::commitComplete):
+        (WTF::MockLayerTreeHostImpl::drawLayersAndPresent):
+        (WTF::MockLayerTreeHostImpl::MockLayerTreeHostImpl):
+        (WTF::MockLayerTreeHostImplProxy::create):
+        (WTF::MockLayerTreeHostImplProxy::createLayerTreeHostImpl):
+        (WTF::MockLayerTreeHostImplProxy::MockLayerTreeHostImplProxy):
+        (WTF::MockLayerTreeHost::MockLayerTreeHost):
+        (WTF::MockLayerTreeHost::createLayerTreeHostImplProxy):
+        (WTF::MockLayerTreeHost::updateLayers):
+        (WTF::MockLayerTreeHost::createLayerTreeHostCommitter):
+        (WTF::MockLayerTreeHost::beginCommit):
+        (WTF::MockLayerTreeHost::commitComplete):
+        (WTF::CCLayerTreeHostTest::doBeginTest):
+        (WTF::CCLayerTreeHostTestShortlived2::beginTest):
+        (WTF::CCLayerTreeHostTestShortlived3::beginTest):
+        (WTF::CCLayerTreeHostTestCommitingWithContinuousRedraw::beginTest):
+        (WTF::CCLayerTreeHostTestCommitingWithContinuousRedraw::commitCompleteOnCCThread):
+        (WTF::CCLayerTreeHostTestCommitingWithContinuousRedraw::drawLayersAndPresentOnCCThread):
+        (WTF::CCLayerTreeHostTestSetNeedsCommit1::beginTest):
+        (WTF::CCLayerTreeHostTestSetNeedsCommit1::drawLayersAndPresentOnCCThread):
+        (WTF::CCLayerTreeHostTestSetNeedsCommit1::commitOnCCThread):
+        (WTF::CCLayerTreeHostTestSetNeedsCommit2::beginTest):
+        (WTF::CCLayerTreeHostTestSetNeedsCommit2::drawLayersAndPresentOnCCThread):
+        (WTF::CCLayerTreeHostTestSetNeedsCommit2::commitOnCCThread):
+        (WTF::CCLayerTreeHostTestSetNeedsRedraw::beginTest):
+        (WTF::CCLayerTreeHostTestSetNeedsRedraw::drawLayersAndPresentOnCCThread):
+        (WTF::CCLayerTreeHostTestSetNeedsRedraw::commitOnCCThread):
+
 2011-09-16  Iain Merrick  <husky@google.com>
 
         [chromium] Fix CCLayerTreeHostTest
index ff4ffbe..d854806 100644 (file)
 
 #include "cc/CCLayerTreeHost.h"
 
-#include "CCThreadImpl.h"
-#include "GraphicsContext3DPrivate.h"
-#include "LayerChromium.h"
-#include "LayerPainterChromium.h"
-#include "MockWebGraphicsContext3D.h"
-#include "TextureManager.h"
+#include "GraphicsContext3D.h"
 #include "cc/CCLayerTreeHostImpl.h"
 #include "cc/CCMainThreadTask.h"
 #include "cc/CCThreadTask.h"
 #include <wtf/PassRefPtr.h>
 #include <wtf/Vector.h>
 
+
 using namespace WebCore;
-using namespace WebKit;
 using namespace WTF;
 
 namespace {
 
-// Used by test stubs to notify the test when something interesting happens.
-class TestHooks {
-public:
-    virtual void beginCommitOnCCThread(CCLayerTreeHostImpl*) { }
-    virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl*) { }
-    virtual void drawLayersOnCCThread(CCLayerTreeHostImpl*) { }
-};
+class MockLayerTreeHost;
+class MockLayerTreeHostClient;
+class MockLayerTreeHostImpl;
 
-// Adapts CCLayerTreeHostImpl for test. Runs real code, then invokes test hooks.
-class MockLayerTreeHostImpl : public CCLayerTreeHostImpl {
+// The CCLayerTreeHostTest runs with the main loop running. It instantiates a single MockLayerTreeHost and associated
+// MockLayerTreeHostImpl/MockLayerTreeHostClient.
+//
+// beginTest() is called once the main message loop is running and the layer tree host is initialized.
+//
+// Key stages of the drawing loop, e.g. drawing or commiting, redirect to CCLayerTreeHostTest methods of similar names.
+// To track the commit process, override these functions.
+//
+// The test continues until someone calls endTest. endTest can be called on any thread, but be aware that
+// ending the test is an asynchronous process.
+class CCLayerTreeHostTest : public testing::Test {
 public:
-    static PassOwnPtr<MockLayerTreeHostImpl> create(TestHooks* testHooks, const CCSettings& settings)
+    CCLayerTreeHostTest()
+        : m_beginning(false)
+        , m_endWhenBeginReturns(false)
+        , m_running(false)
+        , m_timedOut(false) { }
+
+    virtual void afterTest() = 0;
+
+    virtual void beginTest() = 0;
+    virtual void animateAndLayout(MockLayerTreeHostClient* layerTreeHost, double frameBeginTime) { }
+    virtual void beginCommitOnCCThread(MockLayerTreeHostImpl* layerTreeHostImpl) { }
+    virtual void beginCommitOnMainThread(MockLayerTreeHost* layerTreeHost) { }
+    virtual void commitOnCCThread(MockLayerTreeHost* layerTreeHost, MockLayerTreeHostImpl* layerTreeHostImpl) { }
+    virtual void commitCompleteOnCCThread(MockLayerTreeHostImpl* layerTreeHostImpl) { }
+    virtual void commitCompleteOnMainThread(MockLayerTreeHost* layerTreeHost) { }
+    virtual void drawLayersAndPresentOnCCThread(MockLayerTreeHostImpl* layerTreeHostImpl) { }
+    virtual void updateLayers(MockLayerTreeHost* layerTreeHost) { }
+
+    void endTest();
+
+protected:
+    void doBeginTest();
+
+    static void onBeginTest(void* self)
     {
-        return adoptPtr(new MockLayerTreeHostImpl(testHooks, settings));
+        static_cast<CCLayerTreeHostTest*>(self)->doBeginTest();
     }
 
-    virtual void beginCommit()
+    void doEndTest()
     {
-        CCLayerTreeHostImpl::beginCommit();
-        m_testHooks->beginCommitOnCCThread(this);
     }
 
-    virtual void commitComplete()
+    static void onEndTest(void* self)
     {
-        CCLayerTreeHostImpl::commitComplete();
-        m_testHooks->commitCompleteOnCCThread(this);
+        ASSERT(isMainThread());
+        CCLayerTreeHostTest* test = static_cast<CCLayerTreeHostTest*>(self);
+        test->m_layerTreeHost.clear();
+        test->m_client.clear();
+        webkit_support::QuitMessageLoop();
     }
 
-    virtual void drawLayers()
+    void runTest()
     {
-        CCLayerTreeHostImpl::drawLayers();
-        m_testHooks->drawLayersOnCCThread(this);
+        webkit_support::PostDelayedTask(CCLayerTreeHostTest::onBeginTest, static_cast<void*>(this), 0);
+        webkit_support::PostDelayedTask(CCLayerTreeHostTest::testTimeout, static_cast<void*>(this), 5000);
+        webkit_support::RunMessageLoop();
+        m_running = false;
+        bool timedOut = m_timedOut; // Save whether we're timed out in case RunAllPendingMessages has the timeout.
+        webkit_support::RunAllPendingMessages();
+        if (timedOut) {
+            printf("Test timed out");
+            FAIL() << "Test timed out";
+            return;
+        }
+        afterTest();
     }
 
-private:
-    MockLayerTreeHostImpl(TestHooks* testHooks, const CCSettings& settings)
-        : CCLayerTreeHostImpl(settings)
-        , m_testHooks(testHooks)
+    static void testTimeout(void* self)
     {
+        CCLayerTreeHostTest* test = static_cast<CCLayerTreeHostTest*>(self);
+        if (!test->m_running)
+            return;
+        test->m_timedOut = true;
+        test->endTest();
     }
 
-    TestHooks* m_testHooks;
+    Mutex m_tracesLock;
+    Vector<std::string> m_traces;
+
+    OwnPtr<MockLayerTreeHostClient> m_client;
+    RefPtr<MockLayerTreeHost> m_layerTreeHost;
+
+private:
+    bool m_beginning;
+    bool m_endWhenBeginReturns;
+    bool m_running;
+    bool m_timedOut;
 };
 
-// Adapts CCLayerTreeHost for test. Injects MockLayerTreeHostImpl.
-class MockLayerTreeHost : public CCLayerTreeHost {
+class MockLayerTreeHostClient : public CCLayerTreeHostClient {
 public:
-    static PassRefPtr<MockLayerTreeHost> create(TestHooks* testHooks, CCLayerTreeHostClient* client, PassRefPtr<LayerChromium> rootLayer, const CCSettings& settings)
+    MockLayerTreeHostClient(CCLayerTreeHostTest* test) : m_test(test) { }
+
+    virtual PassRefPtr<GraphicsContext3D> createLayerTreeHostContext3D()
     {
-        return adoptRef(new MockLayerTreeHost(testHooks, client, rootLayer, settings));
+        return adoptRef<GraphicsContext3D>(0);
     }
 
-    virtual PassOwnPtr<CCLayerTreeHostImpl> createLayerTreeHostImpl()
+    virtual void animateAndLayout(double frameBeginTime)
     {
-        return MockLayerTreeHostImpl::create(m_testHooks, settings());
+        m_test->animateAndLayout(this, frameBeginTime);
     }
 
-private:
-    MockLayerTreeHost(TestHooks* testHooks, CCLayerTreeHostClient* client, PassRefPtr<LayerChromium> rootLayer, const CCSettings& settings)
-        : CCLayerTreeHost(client, rootLayer, settings)
-        , m_testHooks(testHooks)
+    virtual void updateLayers()
     {
-        bool success = initialize();
-        ASSERT(success);
     }
 
-    TestHooks* m_testHooks;
+private:
+    CCLayerTreeHostTest* m_test;
 };
 
-// Test stub for WebGraphicsContext3D. Returns canned values needed for compositor initialization.
-class CompositorMockWebGraphicsContext3D : public MockWebGraphicsContext3D {
+class MockLayerTreeHostCommitter : public CCLayerTreeHostCommitter {
 public:
-    static PassOwnPtr<CompositorMockWebGraphicsContext3D> create()
+    static PassOwnPtr<MockLayerTreeHostCommitter> create(CCLayerTreeHostTest* test)
     {
-        return adoptPtr(new CompositorMockWebGraphicsContext3D());
+        return adoptPtr(new MockLayerTreeHostCommitter(test));
     }
 
-    virtual bool makeContextCurrent() { return true; }
-    virtual WebGLId createProgram() { return 1; }
-    virtual WebGLId createShader(WGC3Denum) { return 1; }
-    virtual void getShaderiv(WebGLId, WGC3Denum, WGC3Dint* value) { *value = 1; }
-    virtual void getProgramiv(WebGLId, WGC3Denum, WGC3Dint* value) { *value = 1; }
+    virtual void commit(CCLayerTreeHost* host, CCLayerTreeHostImpl* hostImpl)
+    {
+        CCLayerTreeHostCommitter::commit(host, hostImpl);
+        m_test->commitOnCCThread(reinterpret_cast<MockLayerTreeHost*>(host), reinterpret_cast<MockLayerTreeHostImpl*>(hostImpl));
+    }
 
 private:
-    CompositorMockWebGraphicsContext3D() { }
+    MockLayerTreeHostCommitter(CCLayerTreeHostTest* test) : m_test(test) { }
+    CCLayerTreeHostTest* m_test;
 };
 
-// Implementation of CCLayerTreeHost callback interface.
-class MockLayerTreeHostClient : public CCLayerTreeHostClient {
+class MockLayerTreeHostImpl : public CCLayerTreeHostImpl {
 public:
-    static PassOwnPtr<MockLayerTreeHostClient> create(TestHooks* testHooks)
-    {
-        return adoptPtr(new MockLayerTreeHostClient(testHooks));
-    }
-
-    virtual void animateAndLayout(double frameBeginTime)
+    static PassOwnPtr<MockLayerTreeHostImpl> create(CCLayerTreeHostImplClient* client, CCLayerTreeHostTest* test)
     {
+        return adoptPtr(new MockLayerTreeHostImpl(client, test));
     }
 
-    virtual PassOwnPtr<CCThread> createCompositorThread()
+    virtual void beginCommit()
     {
-        return CCThreadImpl::create();
+        CCLayerTreeHostImpl::beginCommit();
+        m_test->beginCommitOnCCThread(this);
     }
 
-    virtual PassRefPtr<GraphicsContext3D> createLayerTreeHostContext3D()
+    virtual void commitComplete()
     {
-        OwnPtr<WebGraphicsContext3D> mock = CompositorMockWebGraphicsContext3D::create();
-        GraphicsContext3D::Attributes attrs;
-        RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(mock.release(), attrs, 0, GraphicsContext3D::RenderDirectlyToHostWindow, GraphicsContext3DPrivate::ForUseOnAnotherThread);
-        return context;
+        CCLayerTreeHostImpl::commitComplete();
+        m_test->commitCompleteOnCCThread(this);
     }
 
-    virtual PassOwnPtr<LayerPainterChromium> createRootLayerPainter()
+    virtual void drawLayersAndPresent()
     {
-        return nullptr;
+        m_test->drawLayersAndPresentOnCCThread(this);
     }
 
-    virtual void didRecreateGraphicsContext(bool)
+private:
+    MockLayerTreeHostImpl(CCLayerTreeHostImplClient* client, CCLayerTreeHostTest* test)
+            : CCLayerTreeHostImpl(client)
+            , m_test(test)
     {
     }
 
-private:
-    explicit MockLayerTreeHostClient(TestHooks* testHooks) : m_testHooks(testHooks) { }
-
-    TestHooks* m_testHooks;
+    CCLayerTreeHostTest* m_test;
 };
 
-// The CCLayerTreeHostTest runs with the main loop running. It instantiates a single MockLayerTreeHost and associated
-// MockLayerTreeHostImpl/MockLayerTreeHostClient.
-//
-// beginTest() is called once the main message loop is running and the layer tree host is initialized.
-//
-// Key stages of the drawing loop, e.g. drawing or commiting, redirect to CCLayerTreeHostTest methods of similar names.
-// To track the commit process, override these functions.
-//
-// The test continues until someone calls endTest. endTest can be called on any thread, but be aware that
-// ending the test is an asynchronous process.
-class CCLayerTreeHostTest : public testing::Test, TestHooks {
+class MockLayerTreeHostImplProxy : public CCLayerTreeHostImplProxy {
 public:
-    virtual void afterTest() = 0;
-    virtual void beginTest() = 0;
-
-    void endTest();
-
-    void postSetNeedsCommitToMainThread()
+    static PassOwnPtr<MockLayerTreeHostImplProxy> create(CCLayerTreeHost* host, CCLayerTreeHostTest* test)
     {
-        callOnMainThread(CCLayerTreeHostTest::dispatchSetNeedsCommit, this);
+        return adoptPtr(new MockLayerTreeHostImplProxy(host, test));
     }
 
-    void postSetNeedsRedrawToMainThread()
+    PassOwnPtr<CCLayerTreeHostImpl> createLayerTreeHostImpl()
     {
-        callOnMainThread(CCLayerTreeHostTest::dispatchSetNeedsRedraw, this);
+        return MockLayerTreeHostImpl::create(this, m_test);
     }
 
-protected:
-    CCLayerTreeHostTest()
-        : m_beginning(false)
-        , m_endWhenBeginReturns(false)
-        , m_running(false)
-        , m_timedOut(false) { }
+private:
+    MockLayerTreeHostImplProxy(CCLayerTreeHost* host, CCLayerTreeHostTest* test)
+        : CCLayerTreeHostImplProxy(host)
+        , m_test(test) { }
 
-    void doBeginTest();
+    CCLayerTreeHostTest* m_test;
+};
 
-    static void onBeginTest(void* self)
-    {
-        static_cast<CCLayerTreeHostTest*>(self)->doBeginTest();
-    }
+class MockLayerTreeHost : public CCLayerTreeHost {
+public:
+    MockLayerTreeHost(CCLayerTreeHostClient* client, CCLayerTreeHostTest* test)
+        : CCLayerTreeHost(client)
+        , m_test(test) { }
 
-    static void onEndTest(void* self)
+    virtual PassOwnPtr<CCLayerTreeHostImplProxy> createLayerTreeHostImplProxy()
     {
-        ASSERT(isMainThread());
-        webkit_support::QuitMessageLoop();
-        CCLayerTreeHostTest* test = static_cast<CCLayerTreeHostTest*>(self);
-        ASSERT(test);
-        test->m_layerTreeHost.clear();
+        OwnPtr<CCLayerTreeHostImplProxy> proxy = MockLayerTreeHostImplProxy::create(this, m_test);
+        proxy->start();
+        return proxy.release();
     }
 
-    static void dispatchSetNeedsCommit(void* self)
+    virtual void updateLayers()
     {
-      ASSERT(isMainThread());
-      CCLayerTreeHostTest* test = static_cast<CCLayerTreeHostTest*>(self);
-      ASSERT(test);
-      if (test->m_layerTreeHost)
-          test->m_layerTreeHost->setNeedsCommitAndRedraw();
+        m_test->updateLayers(this);
     }
 
-    static void dispatchSetNeedsRedraw(void* self)
+    virtual PassOwnPtr<CCLayerTreeHostCommitter> createLayerTreeHostCommitter()
     {
-      ASSERT(isMainThread());
-      CCLayerTreeHostTest* test = static_cast<CCLayerTreeHostTest*>(self);
-      ASSERT(test);
-      if (test->m_layerTreeHost)
-          test->m_layerTreeHost->setNeedsRedraw();
+        return MockLayerTreeHostCommitter::create(m_test);
     }
 
-    void runTest()
+    virtual void beginCommit()
     {
-        webkit_support::PostDelayedTask(CCLayerTreeHostTest::onBeginTest, static_cast<void*>(this), 0);
-        webkit_support::PostDelayedTask(CCLayerTreeHostTest::testTimeout, static_cast<void*>(this), 5000);
-        webkit_support::RunMessageLoop();
-        m_running = false;
-        bool timedOut = m_timedOut; // Save whether we're timed out in case RunAllPendingMessages has the timeout.
-        webkit_support::RunAllPendingMessages();
-        ASSERT(!m_layerTreeHost.get());
-        m_client.clear();
-        if (timedOut) {
-            FAIL() << "Test timed out";
-            return;
-        }
-        afterTest();
+        CCLayerTreeHost::beginCommit();
+        m_test->beginCommitOnMainThread(this);
     }
 
-    static void testTimeout(void* self)
+    virtual void commitComplete()
     {
-        CCLayerTreeHostTest* test = static_cast<CCLayerTreeHostTest*>(self);
-        if (!test->m_running)
-            return;
-        test->m_timedOut = true;
-        test->endTest();
+        m_test->commitCompleteOnMainThread(this);
+        CCLayerTreeHost::commitComplete();
     }
 
-    OwnPtr<MockLayerTreeHostClient> m_client;
-    RefPtr<CCLayerTreeHost> m_layerTreeHost;
-
 private:
-    bool m_beginning;
-    bool m_endWhenBeginReturns;
-    bool m_running;
-    bool m_timedOut;
+    CCLayerTreeHostTest* m_test;
 };
 
 void CCLayerTreeHostTest::doBeginTest()
 {
-    ASSERT(isMainThread());
     ASSERT(!m_running);
     m_running = true;
-    m_client = MockLayerTreeHostClient::create(this);
-
-    CCSettings settings;
-    settings.enableCompositorThread = true;
-    RefPtr<LayerChromium> rootLayer;
-    m_layerTreeHost = MockLayerTreeHost::create(this, m_client.get(), rootLayer, settings);
-    ASSERT(m_layerTreeHost);
-
+    m_client = adoptPtr(new MockLayerTreeHostClient(this));
+    m_layerTreeHost = adoptRef(new MockLayerTreeHost(m_client.get(), this));
+    m_layerTreeHost->init();
     m_beginning = true;
     beginTest();
     m_beginning = false;
@@ -341,7 +327,7 @@ public:
 
     virtual void beginTest()
     {
-        postSetNeedsCommitToMainThread();
+        m_layerTreeHost->setNeedsCommitAndRedraw();
         endTest();
     }
 
@@ -361,7 +347,7 @@ public:
 
     virtual void beginTest()
     {
-        postSetNeedsRedrawToMainThread();
+        m_layerTreeHost->setNeedsRedraw();
         endTest();
     }
 
@@ -385,23 +371,23 @@ public:
 
     virtual void beginTest()
     {
-        postSetNeedsCommitToMainThread();
+        m_layerTreeHost->setNeedsCommitAndRedraw();
         endTest();
     }
 
-    virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl*)
+    virtual void commitCompleteOnCCThread(MockLayerTreeHostImpl* layerTreeHostImpl)
     {
         m_numCompleteCommits++;
         if (m_numCompleteCommits == 2)
             endTest();
     }
 
-    virtual void drawLayersOnCCThread(CCLayerTreeHostImpl*)
+    virtual void drawLayersAndPresentOnCCThread(MockLayerTreeHostImpl* layerTreeHostImpl)
     {
         if (m_numDraws == 1)
-          postSetNeedsCommitToMainThread();
+            layerTreeHostImpl->setNeedsCommitAndRedraw();
         m_numDraws++;
-        postSetNeedsRedrawToMainThread();
+        layerTreeHostImpl->setNeedsRedraw();
     }
 
     virtual void afterTest()
@@ -429,18 +415,18 @@ public:
 
     virtual void beginTest()
     {
-        postSetNeedsCommitToMainThread();
-        postSetNeedsCommitToMainThread();
+        m_layerTreeHost->setNeedsCommitAndRedraw();
+        m_layerTreeHost->setNeedsCommitAndRedraw();
     }
 
-    virtual void drawLayersOnCCThread(CCLayerTreeHostImpl* impl)
+    virtual void drawLayersAndPresentOnCCThread(MockLayerTreeHostImpl* layerTreeHostImpl)
     {
         m_numDraws++;
-        if (!impl->sourceFrameNumber())
+        if (!layerTreeHostImpl->sourceFrameNumber())
             endTest();
     }
 
-    virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl*)
+    virtual void commitOnCCThread(MockLayerTreeHost* layerTreeHost, MockLayerTreeHostImpl* impl)
     {
         m_numCommits++;
     }
@@ -472,18 +458,18 @@ public:
 
     virtual void beginTest()
     {
-        postSetNeedsCommitToMainThread();
+        m_layerTreeHost->setNeedsCommitAndRedraw();
     }
 
-    virtual void drawLayersOnCCThread(CCLayerTreeHostImpl* impl)
+    virtual void drawLayersAndPresentOnCCThread(MockLayerTreeHostImpl* layerTreeHostImpl)
     {
-        if (!impl->sourceFrameNumber())
-            postSetNeedsCommitToMainThread();
-        else if (impl->sourceFrameNumber() == 1)
+        if (!layerTreeHostImpl->sourceFrameNumber())
+            layerTreeHostImpl->setNeedsCommitAndRedraw();
+        else if (layerTreeHostImpl->sourceFrameNumber() == 1)
             endTest();
     }
 
-    virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl*)
+    virtual void commitOnCCThread(MockLayerTreeHost* layerTreeHost, MockLayerTreeHostImpl* impl)
     {
         m_numCommits++;
     }
@@ -515,20 +501,19 @@ public:
 
     virtual void beginTest()
     {
-        postSetNeedsCommitToMainThread();
     }
 
-    virtual void drawLayersOnCCThread(CCLayerTreeHostImpl* impl)
+    virtual void drawLayersAndPresentOnCCThread(MockLayerTreeHostImpl* impl)
     {
         EXPECT_EQ(0, impl->sourceFrameNumber());
         if (!m_numDraws)
-            postSetNeedsRedrawToMainThread(); // Redraw again to verify that the second redraw doesn't commit.
+            impl->setNeedsRedraw(); // redraw again to verify that the second redraw doesnt commit.
         else
             endTest();
         m_numDraws++;
     }
 
-    virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl*)
+    virtual void commitOnCCThread(MockLayerTreeHost* layerTreeHost, MockLayerTreeHostImpl* impl)
     {
         m_numCommits++;
     }