Changeset 93680 in webkit


Ignore:
Timestamp:
Aug 23, 2011 6:22:22 PM (13 years ago)
Author:
nduca@chromium.org
Message:

[chromium] Implement CCThread in terms of WebThread
https://bugs.webkit.org/show_bug.cgi?id=66610

Reviewed by Darin Fisher.

Source/WebCore:

  • WebCore.gypi:
  • platform/graphics/chromium/cc/CCCompletionEvent.h:
  • platform/graphics/chromium/cc/CCLayerTreeHost.h:

(WebCore::CCLayerTreeHost::client):

  • platform/graphics/chromium/cc/CCLayerTreeHostImplProxy.cpp:

(WebCore::CCLayerTreeHostImplProxy::CCLayerTreeHostImplProxy):

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

(WebCore::CCThread::~CCThread):

Source/WebKit/chromium:

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

(WebKit::WebThread::~WebThread):

  • src/CCThreadImpl.cpp: Added.

(WebKit::GetThreadIDTask::GetThreadIDTask):
(WebKit::GetThreadIDTask::~GetThreadIDTask):
(WebKit::GetThreadIDTask::run):
(WebKit::CCThreadTaskAdapter::CCThreadTaskAdapter):
(WebKit::CCThreadTaskAdapter::~CCThreadTaskAdapter):
(WebKit::CCThreadTaskAdapter::run):
(WebKit::CCThreadImpl::create):
(WebKit::CCThreadImpl::~CCThreadImpl):
(WebKit::CCThreadImpl::postTask):
(WebKit::CCThreadImpl::threadID):
(WebKit::CCThreadImpl::CCThreadImpl):

  • src/CCThreadImpl.h: Renamed from Source/WebCore/platform/graphics/chromium/cc/CCThread.cpp.
  • src/WebViewImpl.cpp:

(WebKit::WebViewImpl::createCompositorThread):

  • src/WebViewImpl.h:
  • tests/CCThreadTest.cpp:
Location:
trunk/Source
Files:
1 added
12 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r93679 r93680  
     12011-08-23  Nat Duca  <nduca@chromium.org>
     2
     3        [chromium] Implement CCThread in terms of WebThread
     4        https://bugs.webkit.org/show_bug.cgi?id=66610
     5
     6        Reviewed by Darin Fisher.
     7
     8        * WebCore.gypi:
     9        * platform/graphics/chromium/cc/CCCompletionEvent.h:
     10        * platform/graphics/chromium/cc/CCLayerTreeHost.h:
     11        (WebCore::CCLayerTreeHost::client):
     12        * platform/graphics/chromium/cc/CCLayerTreeHostImplProxy.cpp:
     13        (WebCore::CCLayerTreeHostImplProxy::CCLayerTreeHostImplProxy):
     14        * platform/graphics/chromium/cc/CCThread.h:
     15        (WebCore::CCThread::~CCThread):
     16
    1172011-08-23  Iain Merrick  <husky@google.com>
    218
  • trunk/Source/WebCore/WebCore.gypi

    r93594 r93680  
    35433543            'platform/graphics/chromium/cc/CCRenderSurface.cpp',
    35443544            'platform/graphics/chromium/cc/CCRenderSurface.h',
    3545             'platform/graphics/chromium/cc/CCThread.cpp',
    35463545            'platform/graphics/chromium/cc/CCThread.h',
    35473546            'platform/graphics/chromium/cc/CCThreadTask.h',
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCCompletionEvent.h

    r85165 r93680  
    1 
    21/*
    32 * Copyright (C) 2011 Google Inc. All rights reserved.
     
    3130namespace WebCore {
    3231
     32// Used for making blocking calls from one thread to another. Use only when
     33// absolutely certain that doing-so will not lead to a livelock.
     34//
     35// It is safe to destroy this object as soon as wait() returns.
    3336class CCCompletionEvent {
    3437public:
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h

    r93615 r93680  
    3939class CCLayerTreeHostImpl;
    4040class CCLayerTreeHostImplClient;
     41class CCThread;
    4142class GraphicsContext3D;
    4243class LayerChromium;
     
    4950public:
    5051    virtual void animateAndLayout(double frameBeginTime) = 0;
     52    virtual PassOwnPtr<CCThread> createCompositorThread() = 0;
    5153    virtual PassRefPtr<GraphicsContext3D> createLayerTreeHostContext3D() = 0;
    5254    virtual PassOwnPtr<LayerPainterChromium> createRootLayerPainter() = 0;
     
    8688    bool animating() const { return m_animating; }
    8789    void setAnimating(bool animating) { m_animating = animating; } // Can be removed when non-threaded scheduling moves inside.
     90
     91    CCLayerTreeHostClient* client() { return m_client; }
    8892
    8993    GraphicsContext3D* context();
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImplProxy.cpp

    r93346 r93680  
    5050    numProxies++;
    5151    if (!ccThread)
    52         ccThread = CCThread::create().leakPtr();
     52        ccThread = layerTreeHost->client()->createCompositorThread().leakPtr();
    5353}
    5454
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCThread.h

    r83249 r93680  
    2626#define CCThread_h
    2727
    28 #include <wtf/MessageQueue.h>
    2928#include <wtf/PassOwnPtr.h>
    30 #include <wtf/RefCounted.h>
    3129#include <wtf/Threading.h>
    3230
    3331namespace WebCore {
    3432
    35 // The CCThread singleton owns the compositor thread and provides
    36 // basic infrastructure for messaging between the two threads.
     33// CCThread provides basic infrastructure for messaging with the compositor in a
     34// platform-neutral way.
    3735class CCThread {
    3836public:
    39     static PassOwnPtr<CCThread> create()
    40     {
    41         return adoptPtr(new CCThread());
    42     }
    43 
    44     virtual ~CCThread();
     37    virtual ~CCThread() { }
    4538
    4639    class Task {
     
    5548    };
    5649
    57     void postTask(PassOwnPtr<Task>); // Executes the task on context's thread asynchronously.
     50    virtual void postTask(PassOwnPtr<Task>) = 0; // Executes the task on context's thread asynchronously.
    5851
    59     WTF::ThreadIdentifier threadID() const { return m_threadID; }
    60 
    61 protected:
    62     explicit CCThread();
    63 
    64     static void* compositorThreadStart(void*);
    65     void* runLoop();
    66 
    67     WTF::ThreadIdentifier m_threadID;
    68     MessageQueue<Task> m_queue;
    69 
    70     Mutex m_threadCreationMutex;
     52    virtual WTF::ThreadIdentifier threadID() const = 0;
    7153};
    7254
  • trunk/Source/WebKit/chromium/ChangeLog

    r93679 r93680  
     12011-08-23  Nat Duca  <nduca@chromium.org>
     2
     3        [chromium] Implement CCThread in terms of WebThread
     4        https://bugs.webkit.org/show_bug.cgi?id=66610
     5
     6        Reviewed by Darin Fisher.
     7
     8        * WebKit.gyp:
     9        * public/WebThread.h:
     10        (WebKit::WebThread::~WebThread):
     11        * src/CCThreadImpl.cpp: Added.
     12        (WebKit::GetThreadIDTask::GetThreadIDTask):
     13        (WebKit::GetThreadIDTask::~GetThreadIDTask):
     14        (WebKit::GetThreadIDTask::run):
     15        (WebKit::CCThreadTaskAdapter::CCThreadTaskAdapter):
     16        (WebKit::CCThreadTaskAdapter::~CCThreadTaskAdapter):
     17        (WebKit::CCThreadTaskAdapter::run):
     18        (WebKit::CCThreadImpl::create):
     19        (WebKit::CCThreadImpl::~CCThreadImpl):
     20        (WebKit::CCThreadImpl::postTask):
     21        (WebKit::CCThreadImpl::threadID):
     22        (WebKit::CCThreadImpl::CCThreadImpl):
     23        * src/CCThreadImpl.h: Renamed from Source/WebCore/platform/graphics/chromium/cc/CCThread.cpp.
     24        * src/WebViewImpl.cpp:
     25        (WebKit::WebViewImpl::createCompositorThread):
     26        * src/WebViewImpl.h:
     27        * tests/CCThreadTest.cpp:
     28
    1292011-08-23  Iain Merrick  <husky@google.com>
    230
  • trunk/Source/WebKit/chromium/WebKit.gyp

    r93618 r93680  
    327327                'src/BoundObject.cpp',
    328328                'src/BoundObject.h',
     329                'src/CCThreadImpl.cpp',
     330                'src/CCThreadImpl.h',
    329331                'src/ChromeClientImpl.cpp',
    330332                'src/ChromeClientImpl.h',
  • trunk/Source/WebKit/chromium/public/WebThread.h

    r92965 r93680  
    3030namespace WebKit {
    3131
     32#define WEBTHREAD_HAS_LONGLONG_CHANGE
     33
    3234// Provides an interface to an embedder-defined thread implementation.
    3335//
     
    4345
    4446    virtual void postTask(Task*) = 0;
    45     virtual void postDelayedTask(Task*, int64 delayMs) = 0;
     47    virtual void postDelayedTask(Task*, long long delayMs) = 0;
    4648
    47 protected:
    48     ~WebThread() { }
     49    virtual ~WebThread() { }
    4950};
    5051
  • trunk/Source/WebKit/chromium/src/CCThreadImpl.h

    r93679 r93680  
    2323 */
    2424
    25 #include "config.h"
     25#include "cc/CCThread.h"
     26#include <wtf/OwnPtr.h>
     27#include <wtf/Threading.h>
    2628
    27 #include "CCThread.h"
    2829
    29 #include "LayerRendererChromium.h"
    30 #include "TraceEvent.h"
    31 #include <wtf/CurrentTime.h>
    32 #include <wtf/PassOwnPtr.h>
    33 #include <wtf/ThreadingPrimitives.h>
     30#ifndef CCThreadImpl_h
     31#define CCThreadImpl_h
    3432
    35 namespace WebCore {
     33namespace WebKit {
    3634
    37 using namespace WTF;
     35class WebThread;
    3836
    39 CCThread::CCThread()
    40 {
    41     MutexLocker lock(m_threadCreationMutex);
    42     m_threadID = createThread(CCThread::compositorThreadStart, this, "Chromium Compositor");
    43 }
     37// Implements CCThread in terms of WebThread.
     38class CCThreadImpl : public WebCore::CCThread {
     39public:
     40    static PassOwnPtr<WebCore::CCThread> create();
     41    virtual ~CCThreadImpl();
     42    void postTask(PassOwnPtr<WebCore::CCThread::Task>);
     43    WTF::ThreadIdentifier threadID() const;
    4444
    45 CCThread::~CCThread()
    46 {
    47     m_queue.kill();
     45private:
     46    CCThreadImpl();
    4847
    49     // Stop thread.
    50     void* exitCode;
    51     waitForThreadCompletion(m_threadID, &exitCode);
    52     m_threadID = 0;
    53 }
     48    OwnPtr<WebThread> m_thread;
     49    WTF::ThreadIdentifier m_threadID;
     50};
    5451
    55 void CCThread::postTask(PassOwnPtr<Task> task)
    56 {
    57     m_queue.append(task);
    58 }
     52} // namespace WebKit
    5953
    60 void* CCThread::compositorThreadStart(void* userdata)
    61 {
    62     CCThread* ccThread = static_cast<CCThread*>(userdata);
    63     return ccThread->runLoop();
    64 }
    65 
    66 void* CCThread::runLoop()
    67 {
    68     TRACE_EVENT("CCThread::runLoop", this, 0);
    69     {
    70         // Wait for CCThread::start() to complete to have m_threadID
    71         // established before starting the main loop.
    72         MutexLocker lock(m_threadCreationMutex);
    73     }
    74 
    75     while (OwnPtr<Task> task = m_queue.waitForMessage())
    76         task->performTask();
    77 
    78     return 0;
    79 }
    80 
    81 }
     54#endif
  • trunk/Source/WebKit/chromium/src/WebViewImpl.cpp

    r93679 r93680  
    3535#include "AXObjectCache.h"
    3636#include "BackForwardListChromium.h"
     37#include "CCThreadImpl.h"
    3738#include "CSSStyleSelector.h"
    3839#include "CSSValueKeywords.h"
     
    26402641#endif
    26412642
     2643PassOwnPtr<CCThread> WebViewImpl::createCompositorThread()
     2644{
     2645    return CCThreadImpl::create();
     2646}
     2647
    26422648PassRefPtr<GraphicsContext3D> WebViewImpl::createLayerTreeHostContext3D()
    26432649{
  • trunk/Source/WebKit/chromium/src/WebViewImpl.h

    r93434 r93680  
    217217    // CCLayerTreeHostClient
    218218    virtual void animateAndLayout(double frameBeginTime);
     219    virtual PassOwnPtr<WebCore::CCThread> createCompositorThread();
    219220    virtual PassRefPtr<WebCore::GraphicsContext3D> createLayerTreeHostContext3D();
    220221    virtual PassOwnPtr<WebCore::LayerPainterChromium> createRootLayerPainter();
  • trunk/Source/WebKit/chromium/tests/CCThreadTest.cpp

    r92068 r93680  
    2727#include "cc/CCThread.h"
    2828
     29#include "CCThreadImpl.h"
    2930#include "cc/CCCompletionEvent.h"
    3031#include "cc/CCMainThreadTask.h"
    3132#include "cc/CCThreadTask.h"
    3233#include <gtest/gtest.h>
     34
    3335#include <webkit/support/webkit_support.h>
    3436#include <wtf/MainThread.h>
     
    5254TEST(CCThreadTest, pingPongUsingCondition)
    5355{
    54     OwnPtr<CCThread> thread = CCThread::create();
     56    OwnPtr<CCThread> thread = WebKit::CCThreadImpl::create();
    5557    PingPongUsingCondition target;
    5658    CCCompletionEvent completion;
     
    8183TEST(CCThreadTest, DISABLED_startPostAndWaitOnCondition)
    8284{
    83     OwnPtr<CCThread> thread = CCThread::create();
     85    OwnPtr<CCThread> thread = WebKit::CCThreadImpl::create();
    8486
    8587    PingPongTestUsingTasks target;
Note: See TracChangeset for help on using the changeset viewer.