Title: [118513] trunk/Source
Revision
118513
Author
[email protected]
Date
2012-05-25 05:05:41 -0700 (Fri, 25 May 2012)

Log Message

[chromium] add instrumentation for compositing
https://bugs.webkit.org/show_bug.cgi?id=83928

Reviewed by James Robinson.

Source/Platform:

- added willCommit() and didBeginFrame() methods for instrumentation of compositing.

* chromium/public/WebLayerTreeViewClient.h:
(WebLayerTreeViewClient):

Source/WebCore:

- plumb willCommit() and didBeginFrame() from CCSingleThreadProxy and CCThreadProxy to inspector instrumentation;
- note for threaded case, didBeginFrame() is invoked upon unblocking of main thread;

* platform/graphics/chromium/cc/CCLayerTreeHost.h:
(CCLayerTreeHostClient):
(WebCore::CCLayerTreeHost::didBeginFrame):
(WebCore::CCLayerTreeHost::willCommit):
* platform/graphics/chromium/cc/CCSingleThreadProxy.cpp:
(WebCore::CCSingleThreadProxy::commitAndComposite):
* platform/graphics/chromium/cc/CCThreadProxy.cpp:
(WebCore::CCThreadProxy::beginFrame):

Source/WebKit/chromium:

- plumb willCommit() and didComposite() to inspector instrumentation via WebViewImpl.

* WebKit.gypi: Added WebLayerTreeViewTest
* src/WebLayerTreeViewImpl.cpp:
(WebKit::WebLayerTreeViewImpl::didBeginFrame):
(WebKit):
(WebKit::WebLayerTreeViewImpl::willCommit):
* src/WebLayerTreeViewImpl.h:
(WebLayerTreeViewImpl):
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::didBeginFrame):
(WebKit):
(WebKit::WebViewImpl::willCommit):
* src/WebViewImpl.h:
(WebViewImpl):
* tests/CCLayerTreeHostTest.cpp:
* tests/FakeCCLayerTreeHostClient.h:
* tests/WebLayerTest.cpp:
* tests/WebLayerTreeViewTest.cpp: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/Platform/ChangeLog (118512 => 118513)


--- trunk/Source/Platform/ChangeLog	2012-05-25 11:20:20 UTC (rev 118512)
+++ trunk/Source/Platform/ChangeLog	2012-05-25 12:05:41 UTC (rev 118513)
@@ -1,3 +1,15 @@
+2012-05-17  Andrey Kosyakov  <[email protected]>
+
+        [chromium] add instrumentation for compositing
+        https://bugs.webkit.org/show_bug.cgi?id=83928
+
+        Reviewed by James Robinson.
+
+        - added willCommit() and didBeginFrame() methods for instrumentation of compositing.
+
+        * chromium/public/WebLayerTreeViewClient.h:
+        (WebLayerTreeViewClient):
+
 2012-05-21  Kinuko Yasuda  <[email protected]>
 
         Cleanup: add a file system call which captures the file metadata at once.

Modified: trunk/Source/Platform/chromium/public/WebLayerTreeViewClient.h (118512 => 118513)


--- trunk/Source/Platform/chromium/public/WebLayerTreeViewClient.h	2012-05-25 11:20:20 UTC (rev 118512)
+++ trunk/Source/Platform/chromium/public/WebLayerTreeViewClient.h	2012-05-25 12:05:41 UTC (rev 118513)
@@ -40,6 +40,10 @@
     // tasks.  FIXME: make pure virtual once upstream deps are satisfied.
     virtual void willBeginFrame() { }
 
+    // Indicates that main thread tasks associated with frame rendering have completed.
+    // Issued unconditionally, even if the context was lost in the process.
+    virtual void didBeginFrame() { }
+
     // Updates animation and layout. These are called before the compositing
     // pass so that layers can be updated at the given frame time.
     virtual void updateAnimations(double monotonicFrameBeginTime) = 0;
@@ -59,6 +63,10 @@
     // context event).
     virtual void didRebindGraphicsContext(bool success) = 0;
 
+    // Indicates that a frame will be committed to the impl side of the compositor
+    // for rendering.
+    virtual void willCommit() { }
+
     // Indicates that a frame was committed to the impl side of the compositor
     // for rendering.
     //

Modified: trunk/Source/WebCore/ChangeLog (118512 => 118513)


--- trunk/Source/WebCore/ChangeLog	2012-05-25 11:20:20 UTC (rev 118512)
+++ trunk/Source/WebCore/ChangeLog	2012-05-25 12:05:41 UTC (rev 118513)
@@ -1,3 +1,22 @@
+2012-05-17  Andrey Kosyakov  <[email protected]>
+
+        [chromium] add instrumentation for compositing
+        https://bugs.webkit.org/show_bug.cgi?id=83928
+
+        Reviewed by James Robinson.
+
+        - plumb willCommit() and didBeginFrame() from CCSingleThreadProxy and CCThreadProxy to inspector instrumentation;
+        - note for threaded case, didBeginFrame() is invoked upon unblocking of main thread;
+
+        * platform/graphics/chromium/cc/CCLayerTreeHost.h:
+        (CCLayerTreeHostClient):
+        (WebCore::CCLayerTreeHost::didBeginFrame):
+        (WebCore::CCLayerTreeHost::willCommit):
+        * platform/graphics/chromium/cc/CCSingleThreadProxy.cpp:
+        (WebCore::CCSingleThreadProxy::commitAndComposite):
+        * platform/graphics/chromium/cc/CCThreadProxy.cpp:
+        (WebCore::CCThreadProxy::beginFrame):
+
 2012-05-25  Taiju Tsuiki  <[email protected]>
 
         Web Inspector: Drop InspectorFileSystemInstrumentation

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h (118512 => 118513)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h	2012-05-25 11:20:20 UTC (rev 118512)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h	2012-05-25 12:05:41 UTC (rev 118513)
@@ -55,11 +55,14 @@
 class CCLayerTreeHostClient {
 public:
     virtual void willBeginFrame() = 0;
+    // Marks finishing compositing-related tasks on the main thread. In threaded mode, this corresponds to didCommit().
+    virtual void didBeginFrame() = 0;
     virtual void updateAnimations(double frameBeginTime) = 0;
     virtual void layout() = 0;
     virtual void applyScrollAndScale(const IntSize& scrollDelta, float pageScale) = 0;
     virtual PassRefPtr<GraphicsContext3D> createContext() = 0;
     virtual void didRecreateContext(bool success) = 0;
+    virtual void willCommit() = 0;
     virtual void didCommit() = 0;
     virtual void didCommitAndDrawFrame() = 0;
     virtual void didCompleteSwapBuffers() = 0;
@@ -151,6 +154,7 @@
 
     // CCLayerTreeHost interface to CCProxy.
     void willBeginFrame() { m_client->willBeginFrame(); }
+    void didBeginFrame() { m_client->didBeginFrame(); }
     void updateAnimations(double monotonicFrameBeginTime);
     void layout();
     void beginCommitOnImplThread(CCLayerTreeHostImpl*);
@@ -165,6 +169,7 @@
         RecreateFailedAndGaveUp,
     };
     RecreateResult recreateContext();
+    void willCommit() { m_client->willCommit(); }
     void didCommitAndDrawFrame() { m_client->didCommitAndDrawFrame(); }
     void didCompleteSwapBuffers() { m_client->didCompleteSwapBuffers(); }
     void deleteContentsTexturesOnImplThread(TextureAllocator*);

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp (118512 => 118513)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp	2012-05-25 11:20:20 UTC (rev 118512)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp	2012-05-25 12:05:41 UTC (rev 118513)
@@ -344,8 +344,11 @@
     if (!m_layerTreeHost->updateLayers(updater))
         return false;
 
+    m_layerTreeHost->willCommit();
     doCommit(updater);
-    return doComposite();
+    bool result = doComposite();
+    m_layerTreeHost->didBeginFrame();
+    return result;
 }
 
 bool CCSingleThreadProxy::doComposite()

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp (118512 => 118513)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp	2012-05-25 11:20:20 UTC (rev 118512)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp	2012-05-25 12:05:41 UTC (rev 118513)
@@ -516,6 +516,7 @@
     // they are drawn by the impl thread.
     m_texturesAcquired = false;
 
+    m_layerTreeHost->willCommit();
     // Before applying scrolls and calling animate, we set m_animateRequested to false.
     // If it is true now, it means setNeedAnimate was called again. Call setNeedsCommit
     // now so that we get begin frame when this one is done.
@@ -536,6 +537,7 @@
     }
 
     m_layerTreeHost->commitComplete();
+    m_layerTreeHost->didBeginFrame();
 }
 
 void CCThreadProxy::beginFrameCompleteOnImplThread(CCCompletionEvent* completion)

Modified: trunk/Source/WebKit/chromium/ChangeLog (118512 => 118513)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-05-25 11:20:20 UTC (rev 118512)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-05-25 12:05:41 UTC (rev 118513)
@@ -1,3 +1,30 @@
+2012-05-17  Andrey Kosyakov  <[email protected]>
+
+        [chromium] add instrumentation for compositing
+        https://bugs.webkit.org/show_bug.cgi?id=83928
+
+        Reviewed by James Robinson.
+
+        - plumb willCommit() and didComposite() to inspector instrumentation via WebViewImpl.
+
+        * WebKit.gypi: Added WebLayerTreeViewTest
+        * src/WebLayerTreeViewImpl.cpp:
+        (WebKit::WebLayerTreeViewImpl::didBeginFrame):
+        (WebKit):
+        (WebKit::WebLayerTreeViewImpl::willCommit):
+        * src/WebLayerTreeViewImpl.h:
+        (WebLayerTreeViewImpl):
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::didBeginFrame):
+        (WebKit):
+        (WebKit::WebViewImpl::willCommit):
+        * src/WebViewImpl.h:
+        (WebViewImpl):
+        * tests/CCLayerTreeHostTest.cpp:
+        * tests/FakeCCLayerTreeHostClient.h:
+        * tests/WebLayerTest.cpp:
+        * tests/WebLayerTreeViewTest.cpp: Added.
+
 2012-05-25  Peter Beverloo  <[email protected]>
 
         [Chromium] Pull in Android tools from Chromium's repo through the DEPS file

Modified: trunk/Source/WebKit/chromium/WebKit.gypi (118512 => 118513)


--- trunk/Source/WebKit/chromium/WebKit.gypi	2012-05-25 11:20:20 UTC (rev 118512)
+++ trunk/Source/WebKit/chromium/WebKit.gypi	2012-05-25 12:05:41 UTC (rev 118513)
@@ -145,6 +145,7 @@
             'tests/WebCompositorInputHandlerImplTest.cpp',
             'tests/WebFrameTest.cpp',
             'tests/WebLayerTest.cpp',
+            'tests/WebLayerTreeViewTest.cpp',
             'tests/WebMediaPlayerClientImplTest.cpp',
             'tests/WebPageNewSerializerTest.cpp',
             'tests/WebPageSerializerTest.cpp',

Modified: trunk/Source/WebKit/chromium/src/WebLayerTreeViewImpl.cpp (118512 => 118513)


--- trunk/Source/WebKit/chromium/src/WebLayerTreeViewImpl.cpp	2012-05-25 11:20:20 UTC (rev 118512)
+++ trunk/Source/WebKit/chromium/src/WebLayerTreeViewImpl.cpp	2012-05-25 12:05:41 UTC (rev 118513)
@@ -65,6 +65,11 @@
     m_client->willBeginFrame();
 }
 
+void WebLayerTreeViewImpl::didBeginFrame()
+{
+    m_client->didBeginFrame();
+}
+
 void WebLayerTreeViewImpl::updateAnimations(double monotonicFrameBeginTime)
 {
     m_client->updateAnimations(monotonicFrameBeginTime);
@@ -94,6 +99,11 @@
     m_client->didRebindGraphicsContext(success);
 }
 
+void WebLayerTreeViewImpl::willCommit()
+{
+    m_client->willCommit();
+}
+
 void WebLayerTreeViewImpl::didCommit()
 {
     m_client->didCommit();

Modified: trunk/Source/WebKit/chromium/src/WebLayerTreeViewImpl.h (118512 => 118513)


--- trunk/Source/WebKit/chromium/src/WebLayerTreeViewImpl.h	2012-05-25 11:20:20 UTC (rev 118512)
+++ trunk/Source/WebKit/chromium/src/WebLayerTreeViewImpl.h	2012-05-25 12:05:41 UTC (rev 118513)
@@ -40,11 +40,13 @@
     virtual ~WebLayerTreeViewImpl();
 
     virtual void willBeginFrame() OVERRIDE;
+    virtual void didBeginFrame() OVERRIDE;
     virtual void updateAnimations(double monotonicFrameBeginTime) OVERRIDE;
     virtual void layout() OVERRIDE;
     virtual void applyScrollAndScale(const WebCore::IntSize& scrollDelta, float pageScale) OVERRIDE;
     virtual PassRefPtr<WebCore::GraphicsContext3D> createContext() OVERRIDE;
     virtual void didRecreateContext(bool success) OVERRIDE;
+    virtual void willCommit() OVERRIDE;
     virtual void didCommit() OVERRIDE;
     virtual void didCommitAndDrawFrame() OVERRIDE;
     virtual void didCompleteSwapBuffers() OVERRIDE;

Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.cpp (118512 => 118513)


--- trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2012-05-25 11:20:20 UTC (rev 118512)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2012-05-25 12:05:41 UTC (rev 118513)
@@ -1467,6 +1467,11 @@
     m_client->willBeginCompositorFrame();
 }
 
+void WebViewImpl::didBeginFrame()
+{
+    InspectorInstrumentation::didComposite(m_page.get());
+}
+
 void WebViewImpl::updateAnimations(double monotonicFrameBeginTime)
 {
 #if ENABLE(REQUEST_ANIMATION_FRAME)
@@ -3546,6 +3551,11 @@
     }
 }
 
+void WebViewImpl::willCommit()
+{
+    InspectorInstrumentation::willComposite(m_page.get());
+}
+
 void WebViewImpl::didCommit()
 {
     if (m_client)

Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.h (118512 => 118513)


--- trunk/Source/WebKit/chromium/src/WebViewImpl.h	2012-05-25 11:20:20 UTC (rev 118512)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.h	2012-05-25 12:05:41 UTC (rev 118513)
@@ -291,10 +291,12 @@
 
     // WebLayerTreeViewClient
     virtual void willBeginFrame();
+    virtual void didBeginFrame();
     virtual void updateAnimations(double monotonicFrameBeginTime);
     virtual void applyScrollAndScale(const WebSize&, float);
     virtual WebGraphicsContext3D* createContext3D();
     virtual void didRebindGraphicsContext(bool);
+    virtual void willCommit();
     virtual void didCommit();
     virtual void didCommitAndDrawFrame();
     virtual void didCompleteSwapBuffers();

Modified: trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp (118512 => 118513)


--- trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp	2012-05-25 11:20:20 UTC (rev 118512)
+++ trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp	2012-05-25 12:05:41 UTC (rev 118513)
@@ -249,6 +249,10 @@
     {
     }
 
+    virtual void didBeginFrame() OVERRIDE
+    {
+    }
+
     virtual void updateAnimations(double monotonicTime) OVERRIDE
     {
         m_testHooks->updateAnimations(monotonicTime);
@@ -274,6 +278,10 @@
         return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(webContext.release(), GraphicsContext3D::RenderDirectlyToHostWindow);
     }
 
+    virtual void willCommit() OVERRIDE
+    {
+    }
+
     virtual void didCommit() OVERRIDE
     {
         m_testHooks->didCommit();

Modified: trunk/Source/WebKit/chromium/tests/FakeCCLayerTreeHostClient.h (118512 => 118513)


--- trunk/Source/WebKit/chromium/tests/FakeCCLayerTreeHostClient.h	2012-05-25 11:20:20 UTC (rev 118512)
+++ trunk/Source/WebKit/chromium/tests/FakeCCLayerTreeHostClient.h	2012-05-25 12:05:41 UTC (rev 118513)
@@ -35,6 +35,7 @@
 class FakeCCLayerTreeHostClient : public CCLayerTreeHostClient {
 public:
     virtual void willBeginFrame() OVERRIDE { }
+    virtual void didBeginFrame() OVERRIDE { }
     virtual void updateAnimations(double monotonicFrameBeginTime) OVERRIDE { }
     virtual void layout() OVERRIDE { }
     virtual void applyScrollAndScale(const IntSize& scrollDelta, float pageScale) OVERRIDE { }
@@ -44,6 +45,7 @@
         return createCompositorMockGraphicsContext3D(attrs);
     }
     virtual void didRecreateContext(bool success) OVERRIDE { }
+    virtual void willCommit() OVERRIDE { }
     virtual void didCommit() OVERRIDE { }
     virtual void didCommitAndDrawFrame() OVERRIDE { }
     virtual void didCompleteSwapBuffers() OVERRIDE { }

Modified: trunk/Source/WebKit/chromium/tests/WebLayerTest.cpp (118512 => 118513)


--- trunk/Source/WebKit/chromium/tests/WebLayerTest.cpp	2012-05-25 11:20:20 UTC (rev 118512)
+++ trunk/Source/WebKit/chromium/tests/WebLayerTest.cpp	2012-05-25 12:05:41 UTC (rev 118513)
@@ -53,10 +53,12 @@
     MOCK_METHOD0(scheduleComposite, void());
 
     virtual void updateAnimations(double frameBeginTime) { }
+    virtual void didBeginFrame() { }
     virtual void layout() { }
     virtual void applyScrollAndScale(const WebSize& scrollDelta, float scaleFactor) { }
     virtual WebGraphicsContext3D* createContext3D() { return CompositorFakeWebGraphicsContext3D::create(WebGraphicsContext3D::Attributes()).leakPtr(); }
     virtual void didRebindGraphicsContext(bool success) { }
+    virtual void willCommit() { }
     virtual void didCommitAndDrawFrame() { }
     virtual void didCompleteSwapBuffers() { }
 };

Added: trunk/Source/WebKit/chromium/tests/WebLayerTreeViewTest.cpp (0 => 118513)


--- trunk/Source/WebKit/chromium/tests/WebLayerTreeViewTest.cpp	                        (rev 0)
+++ trunk/Source/WebKit/chromium/tests/WebLayerTreeViewTest.cpp	2012-05-25 12:05:41 UTC (rev 118513)
@@ -0,0 +1,220 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include "platform/WebLayerTreeView.h"
+
+#include "CompositorFakeWebGraphicsContext3D.h"
+#include "WebCompositor.h"
+#include "public/WebLayer.h"
+#include "public/WebLayerTreeViewClient.h"
+#include "public/WebThread.h"
+#include <gmock/gmock.h>
+#include <public/Platform.h>
+
+using namespace WebKit;
+using testing::Mock;
+using testing::Test;
+
+namespace {
+
+class MockWebLayerTreeViewClient : public WebLayerTreeViewClient {
+public:
+    virtual void scheduleComposite() OVERRIDE { }
+    virtual void updateAnimations(double frameBeginTime) OVERRIDE { }
+    MOCK_METHOD0(willBeginFrame, void());
+    MOCK_METHOD0(didBeginFrame, void());
+    virtual void layout() OVERRIDE { }
+    virtual void applyScrollAndScale(const WebSize& scrollDelta, float scaleFactor) OVERRIDE { }
+    virtual WebGraphicsContext3D* createContext3D() OVERRIDE { return CompositorFakeWebGraphicsContext3D::create(WebGraphicsContext3D::Attributes()).leakPtr(); }
+    virtual void didRebindGraphicsContext(bool success) OVERRIDE { }
+    MOCK_METHOD0(willCommit, void());
+    MOCK_METHOD0(didCommit, void());
+    virtual void didCommitAndDrawFrame() OVERRIDE { }
+    virtual void didCompleteSwapBuffers() OVERRIDE { }
+};
+
+class MockWebLayerTreeViewClientForThreadedTests : public MockWebLayerTreeViewClient {
+public:
+    virtual void didBeginFrame() OVERRIDE
+    {
+        WebKit::Platform::current()->currentThread()->exitRunLoop();
+        MockWebLayerTreeViewClient::didBeginFrame();
+    }
+};
+
+class WebLayerTreeViewTestBase : public Test {
+protected:
+    virtual void initializeCompositor() = 0;
+    virtual WebLayerTreeViewClient* client() = 0;
+
+public:
+    virtual void SetUp()
+    {
+        initializeCompositor();
+        m_rootLayer = WebLayer::create();
+        EXPECT_TRUE(m_view.initialize(client(), m_rootLayer, WebLayerTreeView::Settings()));
+        m_view.setSurfaceReady();
+    }
+
+    virtual void TearDown()
+    {
+        Mock::VerifyAndClearExpectations(client());
+
+        m_view.setRootLayer(0);
+        m_rootLayer.reset();
+        m_view.reset();
+        WebKit::WebCompositor::shutdown();
+    }
+
+protected:
+    WebLayer m_rootLayer;
+    WebLayerTreeView m_view;
+};
+
+class WebLayerTreeViewSingleThreadTest : public WebLayerTreeViewTestBase {
+protected:
+    void composite()
+    {
+        m_view.composite();
+    }
+
+    virtual void initializeCompositor() OVERRIDE
+    {
+        WebKit::WebCompositor::initialize(0);
+    }
+
+    virtual WebLayerTreeViewClient* client() OVERRIDE
+    {
+        return &m_client;
+    }
+
+    MockWebLayerTreeViewClient m_client;
+};
+
+class CancelableTaskWrapper : public RefCounted<CancelableTaskWrapper> {
+    class Task : public WebThread::Task {
+    public:
+        Task(CancelableTaskWrapper* cancelableTask)
+            : m_cancelableTask(cancelableTask)
+        {
+        }
+
+    private:
+        virtual void run() OVERRIDE
+        {
+            m_cancelableTask->runIfNotCanceled();
+        }
+
+        RefPtr<CancelableTaskWrapper> m_cancelableTask;
+    };
+
+public:
+    CancelableTaskWrapper(PassOwnPtr<WebThread::Task> task)
+        : m_task(task)
+    {
+    }
+
+    void cancel()
+    {
+        m_task.clear();
+    }
+
+    WebThread::Task* createTask()
+    {
+        ASSERT(m_task);
+        return new Task(this);
+    }
+
+    void runIfNotCanceled()
+    {
+        if (!m_task)
+            return;
+        m_task->run();
+        m_task.clear();
+    }
+
+private:
+    OwnPtr<WebThread::Task> m_task;
+};
+
+class WebLayerTreeViewThreadedTest : public WebLayerTreeViewTestBase {
+protected:
+    class TimeoutTask : public WebThread::Task {
+        virtual void run() OVERRIDE
+        {
+            WebKit::Platform::current()->currentThread()->exitRunLoop();
+        }
+    };
+
+    void composite()
+    {
+        m_view.setNeedsRedraw();
+        RefPtr<CancelableTaskWrapper> timeoutTask = adoptRef(new CancelableTaskWrapper(adoptPtr(new TimeoutTask())));
+        WebKit::Platform::current()->currentThread()->postDelayedTask(timeoutTask->createTask(), 5000);
+        WebKit::Platform::current()->currentThread()->enterRunLoop();
+        timeoutTask->cancel();
+        m_view.finishAllRendering();
+    }
+
+    virtual void initializeCompositor() OVERRIDE
+    {
+        m_webThread = adoptPtr(WebKit::Platform::current()->createThread("WebLayerTreeViewTest"));
+        WebCompositor::initialize(m_webThread.get());
+    }
+
+    virtual WebLayerTreeViewClient* client() OVERRIDE
+    {
+        return &m_client;
+    }
+
+    MockWebLayerTreeViewClientForThreadedTests m_client;
+    OwnPtr<WebThread> m_webThread;
+};
+
+TEST_F(WebLayerTreeViewSingleThreadTest, InstrumentationCallbacks)
+{
+    ::testing::InSequence dummy;
+
+    EXPECT_CALL(m_client, willCommit());
+    EXPECT_CALL(m_client, didCommit());
+    EXPECT_CALL(m_client, didBeginFrame());
+
+    composite();
+}
+
+TEST_F(WebLayerTreeViewThreadedTest, InstrumentationCallbacks)
+{
+    ::testing::InSequence dummy;
+
+    EXPECT_CALL(m_client, willBeginFrame());
+    EXPECT_CALL(m_client, willCommit());
+    EXPECT_CALL(m_client, didCommit());
+    EXPECT_CALL(m_client, didBeginFrame());
+
+    composite();
+}
+
+} // namespace
Property changes on: trunk/Source/WebKit/chromium/tests/WebLayerTreeViewTest.cpp
___________________________________________________________________

Added: svn:eol-style

_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to