Changeset 96392 in webkit


Ignore:
Timestamp:
Sep 30, 2011 12:05:19 AM (13 years ago)
Author:
jamesr@google.com
Message:

[chromium] Add WebKit API for sending input events to the compositor thread
https://bugs.webkit.org/show_bug.cgi?id=69117

Reviewed by Darin Fisher.

Source/WebCore:

Convert to using an externally-provided thread instead of one managed by CCThreadProxy internally. Most changes
in these files are mechanically changing references from ccThread to s_ccThread to reflect the class-static
nature of this pointer, the rest are removing the old thread creation codepath.

These changes are covered by the CC* unit tests and by the gpu layout tests when run with the
use_threaded_compositing=1 gyp define.

  • platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
  • platform/graphics/chromium/cc/CCLayerTreeHost.h:
  • platform/graphics/chromium/cc/CCThreadProxy.cpp:

(WebCore::CCThreadProxy::setThread):
(WebCore::CCThreadProxy::CCThreadProxy):
(WebCore::CCThreadProxy::~CCThreadProxy):
(WebCore::CCThreadProxy::compositeAndReadback):
(WebCore::CCThreadProxy::finishAllRendering):
(WebCore::CCThreadProxy::initializeLayerRenderer):
(WebCore::CCThreadProxy::setNeedsCommit):
(WebCore::CCThreadProxy::setNeedsCommitAndRedraw):
(WebCore::CCThreadProxy::setNeedsRedraw):
(WebCore::CCThreadProxy::start):
(WebCore::CCThreadProxy::stop):
(WebCore::CCThreadProxy::beginFrameAndCommit):
(WebCore::CCThreadProxy::scheduleDrawTaskOnCCThread):

  • platform/graphics/chromium/cc/CCThreadProxy.h:

Source/WebKit/chromium:

Adds a new WebKit interface to allow the embedder to pass input events directly to the compositor thread.
Exposes the new WebCompositor interface and associated client. These interfaces are slightly different in that
they can only be interacted with from the compositor thread.

Changes the initialization path for the compositor thread to using an externally allocated and managed thread
instead of one internal to WebCore so that the embedder can interact with the thread more easily. This also
simplifies the startup and shutdown paths. The contract is that WebCompositor::setThread() must be called
before any compositor can be initialized and the passed-in thread must outlive all compositor instances.

Each WebCompositor instance is associated with a WebWidget. There isn't any way to get a WebCompositor for a
given WebWidget in this patch, that will be done in a follow-up.

  • WebKit.gyp:
  • public/WebCompositor.h:

(WebKit::WebCompositor::~WebCompositor):

  • public/WebCompositorClient.h:

(WebKit::WebCompositorClient::~WebCompositorClient):

  • src/CCThreadImpl.cpp:

(WebKit::CCThreadImpl::create):
(WebKit::CCThreadImpl::CCThreadImpl):

  • src/CCThreadImpl.h:
  • src/WebCompositorImpl.cpp: Added.

(WebKit::WebCompositor::setThread):
(WebKit::WebCompositorImpl::WebCompositorImpl):
(WebKit::WebCompositorImpl::~WebCompositorImpl):
(WebKit::WebCompositorImpl::setClient):
(WebKit::WebCompositorImpl::handleInputEvent):

  • src/WebCompositorImpl.h:

(WebKit::WebCompositorImpl::create):

  • src/WebViewImpl.cpp:
  • src/WebViewImpl.h:
  • tests/CCLayerTreeHostTest.cpp:

(WTF::CCLayerTreeHostTest::CCLayerTreeHostTest):

  • tests/CCThreadTest.cpp:

(WebKit::TEST):

Tools:

Adds support for creating and setting a compositor thread in DRT.

  • DumpRenderTree/chromium/WebViewHost.cpp:

(WebViewHost::WebViewHost):

  • DumpRenderTree/chromium/WebViewHost.h:
Location:
trunk
Files:
1 added
17 edited
3 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r96385 r96392  
     12011-09-30  James Robinson  <jamesr@chromium.org>
     2
     3        [chromium] Add WebKit API for sending input events to the compositor thread
     4        https://bugs.webkit.org/show_bug.cgi?id=69117
     5
     6        Reviewed by Darin Fisher.
     7
     8        Convert to using an externally-provided thread instead of one managed by CCThreadProxy internally. Most changes
     9        in these files are mechanically changing references from ccThread to s_ccThread to reflect the class-static
     10        nature of this pointer, the rest are removing the old thread creation codepath.
     11
     12        These changes are covered by the CC* unit tests and by the gpu layout tests when run with the
     13        use_threaded_compositing=1 gyp define.
     14
     15        * platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
     16        * platform/graphics/chromium/cc/CCLayerTreeHost.h:
     17        * platform/graphics/chromium/cc/CCThreadProxy.cpp:
     18        (WebCore::CCThreadProxy::setThread):
     19        (WebCore::CCThreadProxy::CCThreadProxy):
     20        (WebCore::CCThreadProxy::~CCThreadProxy):
     21        (WebCore::CCThreadProxy::compositeAndReadback):
     22        (WebCore::CCThreadProxy::finishAllRendering):
     23        (WebCore::CCThreadProxy::initializeLayerRenderer):
     24        (WebCore::CCThreadProxy::setNeedsCommit):
     25        (WebCore::CCThreadProxy::setNeedsCommitAndRedraw):
     26        (WebCore::CCThreadProxy::setNeedsRedraw):
     27        (WebCore::CCThreadProxy::start):
     28        (WebCore::CCThreadProxy::stop):
     29        (WebCore::CCThreadProxy::beginFrameAndCommit):
     30        (WebCore::CCThreadProxy::scheduleDrawTaskOnCCThread):
     31        * platform/graphics/chromium/cc/CCThreadProxy.h:
     32
    1332011-09-29  Fady Samuel  <fsamuel@chromium.org>
    234
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp

    r96186 r96392  
    144144}
    145145
    146 PassOwnPtr<CCThread> CCLayerTreeHost::createCompositorThread()
    147 {
    148     return m_client->createCompositorThread();
    149 }
    150 
    151146PassRefPtr<GraphicsContext3D> CCLayerTreeHost::createLayerTreeHostContext3D()
    152147{
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h

    r96283 r96392  
    4242
    4343class CCLayerTreeHostImpl;
    44 class CCThread;
    4544class GraphicsContext3D;
    4645class LayerChromium;
     
    5251public:
    5352    virtual void animateAndLayout(double frameBeginTime) = 0;
    54     virtual PassOwnPtr<CCThread> createCompositorThread() = 0;
    5553    virtual PassRefPtr<GraphicsContext3D> createLayerTreeHostContext3D() = 0;
    5654    virtual void didRecreateGraphicsContext(bool success) = 0;
     
    10098    void commitComplete();
    10199    void commitToOnCCThread(CCLayerTreeHostImpl*);
    102     PassOwnPtr<CCThread> createCompositorThread();
    103100    PassRefPtr<GraphicsContext3D> createLayerTreeHostContext3D();
    104101    virtual PassOwnPtr<CCLayerTreeHostImpl> createLayerTreeHostImpl();
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp

    r96186 r96392  
    3939namespace WebCore {
    4040
    41 namespace {
    42 CCThread* ccThread;
    43 int numProxies = 0;
     41CCThread* CCThreadProxy::s_ccThread = 0;
     42
     43void CCThreadProxy::setThread(CCThread* ccThread)
     44{
     45    s_ccThread = ccThread;
     46#ifndef NDEBUG
     47    CCProxy::setImplThread(s_ccThread->threadID());
     48#endif
    4449}
    4550
     
    6166    TRACE_EVENT("CCThreadProxy::CCThreadProxy", this, 0);
    6267    ASSERT(isMainThread());
    63     numProxies++;
    64     if (!ccThread) {
    65         ccThread = m_layerTreeHost->createCompositorThread().leakPtr();
    66 #ifndef NDEBUG
    67         CCProxy::setImplThread(ccThread->threadID());
    68 #endif
    69     }
    7068}
    7169
     
    7573    ASSERT(isMainThread());
    7674    ASSERT(!m_started);
    77 
    78     numProxies--;
    79     if (!numProxies) {
    80         delete ccThread;
    81         ccThread = 0;
    82     }
    8375}
    8476
     
    9890            CCMainThread::Task* taskPtr = 0;
    9991            CCCompletionEvent completion;
    100             ccThread->postTask(createCCThreadTask(this, &CCThreadProxy::obtainBeginFrameAndCommitTaskFromCCThread, AllowCrossThreadAccess(&completion), AllowCrossThreadAccess(&taskPtr)));
     92            s_ccThread->postTask(createCCThreadTask(this, &CCThreadProxy::obtainBeginFrameAndCommitTaskFromCCThread, AllowCrossThreadAccess(&completion), AllowCrossThreadAccess(&taskPtr)));
    10193            completion.wait();
    10294            beginFrameAndCommitTask = adoptPtr(taskPtr);
     
    109101    bool success = false;
    110102    CCCompletionEvent completion;
    111     ccThread->postTask(createCCThreadTask(this, &CCThreadProxy::drawLayersAndReadbackOnCCThread, AllowCrossThreadAccess(&completion), AllowCrossThreadAccess(&success), AllowCrossThreadAccess(pixels), rect));
     103    s_ccThread->postTask(createCCThreadTask(this, &CCThreadProxy::drawLayersAndReadbackOnCCThread, AllowCrossThreadAccess(&completion), AllowCrossThreadAccess(&success), AllowCrossThreadAccess(pixels), rect));
    112104    completion.wait();
    113105    return success;
     
    139131    // Make sure all GL drawing is finished on the impl thread.
    140132    CCCompletionEvent completion;
    141     ccThread->postTask(createCCThreadTask(this, &CCThreadProxy::finishAllRenderingOnCCThread, AllowCrossThreadAccess(&completion)));
     133    s_ccThread->postTask(createCCThreadTask(this, &CCThreadProxy::finishAllRenderingOnCCThread, AllowCrossThreadAccess(&completion)));
    142134    completion.wait();
    143135}
     
    165157    bool initializeSucceeded = false;
    166158    LayerRendererCapabilities capabilities;
    167     ccThread->postTask(createCCThreadTask(this, &CCThreadProxy::initializeLayerRendererOnCCThread,
     159    s_ccThread->postTask(createCCThreadTask(this, &CCThreadProxy::initializeLayerRendererOnCCThread,
    168160                                          AllowCrossThreadAccess(contextPtr), AllowCrossThreadAccess(&completion), AllowCrossThreadAccess(&initializeSucceeded), AllowCrossThreadAccess(&capabilities)));
    169161    completion.wait();
     
    192184    TRACE_EVENT("CCThreadProxy::setNeedsCommit", this, 0);
    193185    m_commitRequested = true;
    194     ccThread->postTask(createCCThreadTask(this, &CCThreadProxy::updateSchedulerStateOnCCThread, m_commitRequested, true));
     186    s_ccThread->postTask(createCCThreadTask(this, &CCThreadProxy::updateSchedulerStateOnCCThread, m_commitRequested, true));
    195187}
    196188
     
    203195
    204196    TRACE_EVENT("CCThreadProxy::setNeedsCommitAndRedraw", this, 0);
    205     ccThread->postTask(createCCThreadTask(this, &CCThreadProxy::updateSchedulerStateOnCCThread, m_commitRequested, true));
     197    s_ccThread->postTask(createCCThreadTask(this, &CCThreadProxy::updateSchedulerStateOnCCThread, m_commitRequested, true));
    206198}
    207199
     
    218210    // compared to setNeedsCommitAndRedraw messages.
    219211    TRACE_EVENT("CCThreadProxy::setNeedsRedraw", this, 0);
    220     ccThread->postTask(createCCThreadTask(this, &CCThreadProxy::updateSchedulerStateOnCCThread, false, true));
     212    s_ccThread->postTask(createCCThreadTask(this, &CCThreadProxy::updateSchedulerStateOnCCThread, false, true));
    221213}
    222214
     
    224216{
    225217    ASSERT(isMainThread());
     218    ASSERT(s_ccThread);
    226219    // Create LayerTreeHostImpl.
    227220    CCCompletionEvent completion;
    228     ccThread->postTask(createCCThreadTask(this, &CCThreadProxy::initializeImplOnCCThread, AllowCrossThreadAccess(&completion)));
     221    s_ccThread->postTask(createCCThreadTask(this, &CCThreadProxy::initializeImplOnCCThread, AllowCrossThreadAccess(&completion)));
    229222    completion.wait();
    230223
     
    240233    // Synchronously deletes the impl.
    241234    CCCompletionEvent completion;
    242     ccThread->postTask(createCCThreadTask(this, &CCThreadProxy::layerTreeHostClosedOnCCThread, AllowCrossThreadAccess(&completion)));
     235    s_ccThread->postTask(createCCThreadTask(this, &CCThreadProxy::layerTreeHostClosedOnCCThread, AllowCrossThreadAccess(&completion)));
    243236    completion.wait();
    244237
     
    326319        TRACE_EVENT("commit", this, 0);
    327320        CCCompletionEvent completion;
    328         ccThread->postTask(createCCThreadTask(this, &CCThreadProxy::commitOnCCThread, AllowCrossThreadAccess(&completion)));
     321        s_ccThread->postTask(createCCThreadTask(this, &CCThreadProxy::commitOnCCThread, AllowCrossThreadAccess(&completion)));
    329322        completion.wait();
    330323    }
     
    363356    ASSERT(m_layerTreeHostImpl);
    364357    m_drawTaskPostedOnCCThread = true;
    365     ccThread->postTask(createCCThreadTask(this, &CCThreadProxy::drawLayersAndPresentOnCCThread));
     358    s_ccThread->postTask(createCCThreadTask(this, &CCThreadProxy::drawLayersAndPresentOnCCThread));
    366359}
    367360
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.h

    r96066 r96392  
    3535
    3636class CCLayerTreeHost;
     37class CCThread;
    3738
    3839class CCThreadProxy : public CCProxy {
    3940public:
     41    static void setThread(CCThread*);
     42
    4043    static PassOwnPtr<CCProxy> create(CCLayerTreeHost*);
    4144
     
    9093    bool m_drawTaskPostedOnCCThread;
    9194    bool m_redrawRequestedOnCCThread;
     95
     96    static CCThread* s_ccThread;
    9297};
    9398
  • trunk/Source/WebKit/chromium/ChangeLog

    r96337 r96392  
     12011-09-30  James Robinson  <jamesr@chromium.org>
     2
     3        [chromium] Add WebKit API for sending input events to the compositor thread
     4        https://bugs.webkit.org/show_bug.cgi?id=69117
     5
     6        Reviewed by Darin Fisher.
     7
     8        Adds a new WebKit interface to allow the embedder to pass input events directly to the compositor thread.
     9        Exposes the new WebCompositor interface and associated client. These interfaces are slightly different in that
     10        they can only be interacted with from the compositor thread.
     11
     12        Changes the initialization path for the compositor thread to using an externally allocated and managed thread
     13        instead of one internal to WebCore so that the embedder can interact with the thread more easily. This also
     14        simplifies the startup and shutdown paths.  The contract is that WebCompositor::setThread() must be called
     15        before any compositor can be initialized and the passed-in thread must outlive all compositor instances.
     16
     17        Each WebCompositor instance is associated with a WebWidget.  There isn't any way to get a WebCompositor for a
     18        given WebWidget in this patch, that will be done in a follow-up.
     19
     20        * WebKit.gyp:
     21        * public/WebCompositor.h:
     22        (WebKit::WebCompositor::~WebCompositor):
     23        * public/WebCompositorClient.h:
     24        (WebKit::WebCompositorClient::~WebCompositorClient):
     25        * src/CCThreadImpl.cpp:
     26        (WebKit::CCThreadImpl::create):
     27        (WebKit::CCThreadImpl::CCThreadImpl):
     28        * src/CCThreadImpl.h:
     29        * src/WebCompositorImpl.cpp: Added.
     30        (WebKit::WebCompositor::setThread):
     31        (WebKit::WebCompositorImpl::WebCompositorImpl):
     32        (WebKit::WebCompositorImpl::~WebCompositorImpl):
     33        (WebKit::WebCompositorImpl::setClient):
     34        (WebKit::WebCompositorImpl::handleInputEvent):
     35        * src/WebCompositorImpl.h:
     36        (WebKit::WebCompositorImpl::create):
     37        * src/WebViewImpl.cpp:
     38        * src/WebViewImpl.h:
     39        * tests/CCLayerTreeHostTest.cpp:
     40        (WTF::CCLayerTreeHostTest::CCLayerTreeHostTest):
     41        * tests/CCThreadTest.cpp:
     42        (WebKit::TEST):
     43
    1442011-09-29  Iain Merrick  <husky@google.com>
    245
  • trunk/Source/WebKit/chromium/WebKit.gyp

    r96233 r96392  
    128128                'public/WebCommonWorkerClient.h',
    129129                'public/WebCompositionUnderline.h',
     130                'public/WebCompositorClient.h',
     131                'public/WebCompositor.h',
    130132                'public/WebConsoleMessage.h',
    131133                'public/WebContextMenuData.h',
     
    446448                'src/WebColor.cpp',
    447449                'src/WebCommon.cpp',
     450                'src/WebCompositorImpl.cpp',
     451                'src/WebCompositorImpl.h',
    448452                'src/WebCrossOriginPreflightResultCache.cpp',
    449453                'src/WebCString.cpp',
  • trunk/Source/WebKit/chromium/public/WebCompositor.h

    r96391 r96392  
    55 * modification, are permitted provided that the following conditions
    66 * are met:
     7 *
    78 * 1.  Redistributions of source code must retain the above copyright
    89 *     notice, this list of conditions and the following disclaimer.
     
    1112 *     documentation and/or other materials provided with the distribution.
    1213 *
    13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
     14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
    1415 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    1516 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    16  * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
     17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
    1718 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    1819 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
    19  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
    20  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    21  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    22  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
     21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2324 */
    2425
    25 #include "cc/CCThread.h"
    26 #include <wtf/OwnPtr.h>
    27 #include <wtf/Threading.h>
     26#ifndef WebCompositor_h
     27#define WebCompositor_h
    2828
    29 
    30 #ifndef CCThreadImpl_h
    31 #define CCThreadImpl_h
     29#include "WebCommon.h"
    3230
    3331namespace WebKit {
    3432
     33class WebCompositorClient;
     34class WebInputEvent;
    3535class WebThread;
    3636
    37 // Implements CCThread in terms of WebThread.
    38 class CCThreadImpl : public WebCore::CCThread {
     37// This represents the compositor associated with a WebWidget. All calls to the WebCompositor must
     38// be made from the compositor thread.
     39class WebCompositor {
    3940public:
    40     static PassOwnPtr<WebCore::CCThread> create();
    41     virtual ~CCThreadImpl();
    42     void postTask(PassOwnPtr<WebCore::CCThread::Task>);
    43     WTF::ThreadIdentifier threadID() const;
     41    // This must be called once with a non-null WebThread before any compositors attempt to initialize.
     42    WEBKIT_EXPORT static void setThread(WebThread*);
    4443
    45 private:
    46     CCThreadImpl();
     44    virtual void setClient(WebCompositorClient*) = 0;
     45    virtual void handleInputEvent(const WebInputEvent&) = 0;
    4746
    48     OwnPtr<WebThread> m_thread;
    49     WTF::ThreadIdentifier m_threadID;
     47protected:
     48    virtual ~WebCompositor() { }
    5049};
    5150
  • trunk/Source/WebKit/chromium/public/WebCompositorClient.h

    r96391 r96392  
    55 * modification, are permitted provided that the following conditions
    66 * are met:
     7 *
    78 * 1.  Redistributions of source code must retain the above copyright
    89 *     notice, this list of conditions and the following disclaimer.
     
    1112 *     documentation and/or other materials provided with the distribution.
    1213 *
    13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
     14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
    1415 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    1516 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    16  * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
     17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
    1718 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    1819 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
    19  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
    20  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    21  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    22  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
     21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2324 */
    2425
    25 #include "cc/CCThread.h"
    26 #include <wtf/OwnPtr.h>
    27 #include <wtf/Threading.h>
    28 
    29 
    30 #ifndef CCThreadImpl_h
    31 #define CCThreadImpl_h
     26#ifndef WebCompositorClient_h
     27#define WebCompositorClient_h
    3228
    3329namespace WebKit {
    3430
    35 class WebThread;
     31class WebCompositorClient {
     32public:
     33    // Callbacks invoked from the compositor thread.
     34    virtual void willShutdown() = 0;
     35    virtual void didHandleInputEvent() = 0;
    3636
    37 // Implements CCThread in terms of WebThread.
    38 class CCThreadImpl : public WebCore::CCThread {
    39 public:
    40     static PassOwnPtr<WebCore::CCThread> create();
    41     virtual ~CCThreadImpl();
    42     void postTask(PassOwnPtr<WebCore::CCThread::Task>);
    43     WTF::ThreadIdentifier threadID() const;
    44 
    45 private:
    46     CCThreadImpl();
    47 
    48     OwnPtr<WebThread> m_thread;
    49     WTF::ThreadIdentifier m_threadID;
     37protected:
     38    virtual ~WebCompositorClient() { }
    5039};
    5140
  • trunk/Source/WebKit/chromium/public/WebKit.h

    r95901 r96392  
    3333
    3434#include "WebCommon.h"
     35
     36#define HAVE_WEBCOMPOSITOR
    3537
    3638namespace WebKit {
  • trunk/Source/WebKit/chromium/src/CCThreadImpl.cpp

    r95901 r96392  
    7777};
    7878
    79 PassOwnPtr<CCThread> CCThreadImpl::create()
     79PassOwnPtr<CCThread> CCThreadImpl::create(WebThread* thread)
    8080{
    81     return adoptPtr(new CCThreadImpl());
     81    return adoptPtr(new CCThreadImpl(thread));
    8282}
    8383
     
    9696}
    9797
    98 CCThreadImpl::CCThreadImpl()
    99     : m_thread(adoptPtr(webKitPlatformSupport()->createThread("CCThread")))
     98CCThreadImpl::CCThreadImpl(WebThread* thread)
     99    : m_thread(thread)
    100100{
    101101    // Get the threadId for the newly-created thread by running a task
  • trunk/Source/WebKit/chromium/src/CCThreadImpl.h

    r95901 r96392  
    3838class CCThreadImpl : public WebCore::CCThread {
    3939public:
    40     static PassOwnPtr<WebCore::CCThread> create();
     40    static PassOwnPtr<WebCore::CCThread> create(WebThread*);
    4141    virtual ~CCThreadImpl();
    4242    void postTask(PassOwnPtr<WebCore::CCThread::Task>);
     
    4444
    4545private:
    46     CCThreadImpl();
     46    explicit CCThreadImpl(WebThread*);
    4747
    48     OwnPtr<WebThread> m_thread;
     48    WebThread* m_thread;
    4949    WTF::ThreadIdentifier m_threadID;
    5050};
  • trunk/Source/WebKit/chromium/src/WebCompositorImpl.h

    r96391 r96392  
    55 * modification, are permitted provided that the following conditions
    66 * are met:
     7 *
    78 * 1.  Redistributions of source code must retain the above copyright
    89 *     notice, this list of conditions and the following disclaimer.
     
    1112 *     documentation and/or other materials provided with the distribution.
    1213 *
    13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
     14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
    1415 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    1516 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    16  * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
     17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
    1718 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    1819 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
    19  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
    20  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    21  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    22  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
     21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2324 */
    2425
    25 #include "cc/CCThread.h"
    26 #include <wtf/OwnPtr.h>
    27 #include <wtf/Threading.h>
     26#ifndef WebCompositorImpl_h
     27#define WebCompositorImpl_h
    2828
    29 
    30 #ifndef CCThreadImpl_h
    31 #define CCThreadImpl_h
     29#include "WebCompositor.h"
     30#include <wtf/Noncopyable.h>
     31#include <wtf/PassOwnPtr.h>
    3232
    3333namespace WebKit {
    3434
    35 class WebThread;
     35class WebCompositorClient;
    3636
    37 // Implements CCThread in terms of WebThread.
    38 class CCThreadImpl : public WebCore::CCThread {
     37class WebCompositorImpl : public WebCompositor {
     38    WTF_MAKE_NONCOPYABLE(WebCompositorImpl);
    3939public:
    40     static PassOwnPtr<WebCore::CCThread> create();
    41     virtual ~CCThreadImpl();
    42     void postTask(PassOwnPtr<WebCore::CCThread::Task>);
    43     WTF::ThreadIdentifier threadID() const;
     40    static PassOwnPtr<WebCompositorImpl> create()
     41    {
     42        return adoptPtr(new WebCompositorImpl);
     43    }
     44
     45    virtual ~WebCompositorImpl();
     46
     47    virtual void setClient(WebCompositorClient*);
     48    virtual void handleInputEvent(const WebInputEvent&);
    4449
    4550private:
    46     CCThreadImpl();
     51    WebCompositorImpl();
    4752
    48     OwnPtr<WebThread> m_thread;
    49     WTF::ThreadIdentifier m_threadID;
     53    WebCompositorClient* m_client;
    5054};
    5155
    52 } // namespace WebKit
     56}
    5357
    54 #endif
     58#endif // WebCompositorImpl_h
  • trunk/Source/WebKit/chromium/src/WebViewImpl.cpp

    r96283 r96392  
    3535#include "AXObjectCache.h"
    3636#include "BackForwardListChromium.h"
    37 #include "CCThreadImpl.h"
    3837#include "CSSStyleSelector.h"
    3938#include "CSSValueKeywords.h"
     
    26872686#endif
    26882687
    2689 PassOwnPtr<CCThread> WebViewImpl::createCompositorThread()
    2690 {
    2691     return CCThreadImpl::create();
    2692 }
    2693 
    26942688PassRefPtr<GraphicsContext3D> WebViewImpl::createLayerTreeHostContext3D()
    26952689{
  • trunk/Source/WebKit/chromium/src/WebViewImpl.h

    r96283 r96392  
    220220    // CCLayerTreeHostClient
    221221    virtual void animateAndLayout(double frameBeginTime);
    222     virtual PassOwnPtr<WebCore::CCThread> createCompositorThread();
    223222    virtual PassRefPtr<WebCore::GraphicsContext3D> createLayerTreeHostContext3D();
    224223    virtual void didRecreateGraphicsContext(bool success);
  • trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp

    r96283 r96392  
    2929#include "cc/CCLayerTreeHost.h"
    3030
     31#include "cc/CCLayerTreeHostImpl.h"
     32#include "cc/CCMainThreadTask.h"
     33#include "cc/CCThreadTask.h"
    3134#include "CCThreadImpl.h"
    3235#include "GraphicsContext3DPrivate.h"
     36#include <gtest/gtest.h>
    3337#include "LayerChromium.h"
    3438#include "MockWebGraphicsContext3D.h"
    3539#include "TextureManager.h"
    36 #include "cc/CCLayerTreeHostImpl.h"
    37 #include "cc/CCMainThreadTask.h"
    38 #include "cc/CCThreadTask.h"
    39 #include <gtest/gtest.h>
     40#include "WebCompositor.h"
     41#include "WebKit.h"
     42#include "WebKitPlatformSupport.h"
     43#include "WebThread.h"
    4044#include <webkit/support/webkit_support.h>
    4145#include <wtf/MainThread.h>
     
    146150    virtual void animateAndLayout(double frameBeginTime)
    147151    {
    148     }
    149 
    150     virtual PassOwnPtr<CCThread> createCompositorThread()
    151     {
    152         return CCThreadImpl::create();
    153152    }
    154153
     
    209208        , m_timedOut(false)
    210209    {
     210        m_webThread = adoptPtr(webKitPlatformSupport()->createThread("CCLayerTreeHostTest"));
     211        WebCompositor::setThread(m_webThread.get());
    211212#if USE(THREADED_COMPOSITING)
    212213        m_settings.enableCompositorThread = true;
     
    285286    bool m_running;
    286287    bool m_timedOut;
     288
     289    OwnPtr<WebThread> m_webThread;
    287290};
    288291
  • trunk/Source/WebKit/chromium/tests/CCThreadTest.cpp

    r95901 r96392  
    2828
    2929#include "CCThreadImpl.h"
     30#include "WebKit.h"
     31#include "WebKitPlatformSupport.h"
     32#include "WebThread.h"
    3033#include "cc/CCCompletionEvent.h"
    3134#include "cc/CCMainThreadTask.h"
    3235#include "cc/CCThreadTask.h"
     36
    3337#include <gtest/gtest.h>
    34 
    3538#include <webkit/support/webkit_support.h>
    3639#include <wtf/MainThread.h>
    3740
    3841using namespace WebCore;
     42using namespace WebKit;
    3943
    4044namespace {
     
    5458TEST(CCThreadTest, pingPongUsingCondition)
    5559{
    56     OwnPtr<CCThread> thread = WebKit::CCThreadImpl::create();
     60    OwnPtr<WebThread> webThread = adoptPtr(webKitPlatformSupport()->createThread("test"));
     61
     62    OwnPtr<CCThread> thread = WebKit::CCThreadImpl::create(webThread.get());
    5763    PingPongUsingCondition target;
    5864    CCCompletionEvent completion;
     
    8187};
    8288
    83 TEST(CCThreadTest, DISABLED_startPostAndWaitOnCondition)
     89TEST(CCThreadTest, startPostAndWaitOnCondition)
    8490{
    85     OwnPtr<CCThread> thread = WebKit::CCThreadImpl::create();
     91    OwnPtr<WebThread> webThread = adoptPtr(webKitPlatformSupport()->createThread("test"));
     92
     93    OwnPtr<CCThread> thread = WebKit::CCThreadImpl::create(webThread.get());
    8694
    8795    PingPongTestUsingTasks target;
  • trunk/Tools/ChangeLog

    r96390 r96392  
     12011-09-30  James Robinson  <jamesr@chromium.org>
     2
     3        [chromium] Add WebKit API for sending input events to the compositor thread
     4        https://bugs.webkit.org/show_bug.cgi?id=69117
     5
     6        Reviewed by Darin Fisher.
     7
     8        Adds support for creating and setting a compositor thread in DRT.
     9
     10        * DumpRenderTree/chromium/WebViewHost.cpp:
     11        (WebViewHost::WebViewHost):
     12        * DumpRenderTree/chromium/WebViewHost.h:
     13
    1142011-09-29  David Levin  <levin@chromium.org>
    215
  • trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp

    r96258 r96392  
    3737#include "TestWebWorker.h"
    3838#include "WebCString.h"
     39#include "WebCompositor.h"
    3940#include "WebConsoleMessage.h"
    4041#include "WebContextMenuData.h"
     
    4647#include "WebGeolocationClientMock.h"
    4748#include "WebHistoryItem.h"
     49#include "WebKit.h"
     50#include "WebKitPlatformSupport.h"
    4851#include "WebNode.h"
    4952#include "WebPopupMenu.h"
     
    5760#include "WebTextCheckingCompletion.h"
    5861#include "WebTextCheckingResult.h"
     62#include "WebThread.h"
    5963#include "WebURLRequest.h"
    6064#include "WebURLResponse.h"
     
    11681172{
    11691173    WTF::initializeThreading();
     1174
     1175    m_compositorThread = adoptPtr(WebKit::webKitPlatformSupport()->createThread("Compositor"));
     1176    WebCompositor::setThread(m_compositorThread.get());
     1177
    11701178    reset();
    11711179}
  • trunk/Tools/DumpRenderTree/chromium/WebViewHost.h

    r96258 r96392  
    5959class WebSpeechInputControllerMock;
    6060class WebSpeechInputListener;
     61class WebThread;
    6162class WebURL;
    6263struct WebRect;
     
    349350    WebKit::WebTextCheckingCompletion* m_lastRequestedTextCheckingCompletion;
    350351
     352    OwnPtr<WebKit::WebThread> m_compositorThread;
     353
    351354    TaskList m_taskList;
    352355    Vector<WebKit::WebWidget*> m_popupmenus;
Note: See TracChangeset for help on using the changeset viewer.