summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authoraelias@chromium.org <aelias@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-08 07:03:44 +0000
committeraelias@chromium.org <aelias@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-08 07:03:44 +0000
commit61de581375ce3d76628772a78719cad63f0aabae (patch)
tree90e5818095cfa31182ceca09224c42d999644e4d /webkit
parentde8686ed05a28324b0978b2bb81cf3407f13762b (diff)
downloadchromium_src-61de581375ce3d76628772a78719cad63f0aabae.zip
chromium_src-61de581375ce3d76628772a78719cad63f0aabae.tar.gz
chromium_src-61de581375ce3d76628772a78719cad63f0aabae.tar.bz2
Remove static thread pointers from CC, attempt 3
BUG=152904 Review URL: https://chromiumcodereview.appspot.com/11232051 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@166627 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/compositor_bindings/compositor_bindings.gyp2
-rw-r--r--webkit/compositor_bindings/test/run_all_unittests.cc7
-rw-r--r--webkit/compositor_bindings/web_compositor_impl.cc85
-rw-r--r--webkit/compositor_bindings/web_compositor_impl.h34
-rw-r--r--webkit/compositor_bindings/web_compositor_support_impl.cc34
-rw-r--r--webkit/compositor_bindings/web_compositor_support_impl.h11
-rw-r--r--webkit/compositor_bindings/web_layer_tree_view_impl.cc19
-rw-r--r--webkit/compositor_bindings/web_layer_tree_view_impl.h3
-rw-r--r--webkit/compositor_bindings/web_layer_tree_view_unittest.cc13
-rw-r--r--webkit/compositor_bindings/web_layer_unittest.cc8
10 files changed, 54 insertions, 162 deletions
diff --git a/webkit/compositor_bindings/compositor_bindings.gyp b/webkit/compositor_bindings/compositor_bindings.gyp
index abcbaee..2b421fc 100644
--- a/webkit/compositor_bindings/compositor_bindings.gyp
+++ b/webkit/compositor_bindings/compositor_bindings.gyp
@@ -9,8 +9,6 @@
'web_animation_curve_common.h',
'web_animation_impl.cc',
'web_animation_impl.h',
- 'web_compositor_impl.cc',
- 'web_compositor_impl.h',
'web_content_layer_impl.cc',
'web_content_layer_impl.h',
'web_delegated_renderer_layer_impl.cc',
diff --git a/webkit/compositor_bindings/test/run_all_unittests.cc b/webkit/compositor_bindings/test/run_all_unittests.cc
index 818c008..19945d7 100644
--- a/webkit/compositor_bindings/test/run_all_unittests.cc
+++ b/webkit/compositor_bindings/test/run_all_unittests.cc
@@ -4,18 +4,13 @@
#include "base/message_loop.h"
#include "base/test/test_suite.h"
-#include "cc/proxy.h"
-#include "cc/thread_impl.h"
-#include <gmock/gmock.h>
+#include "testing/gmock/include/gmock/gmock.h"
int main(int argc, char** argv) {
::testing::InitGoogleMock(&argc, argv);
TestSuite testSuite(argc, argv);
MessageLoop message_loop;
- scoped_ptr<cc::Thread> mainCCThread = cc::ThreadImpl::createForCurrentThread();
- cc::Proxy::setMainThread(mainCCThread.get());
int result = testSuite.Run();
return result;
}
-
diff --git a/webkit/compositor_bindings/web_compositor_impl.cc b/webkit/compositor_bindings/web_compositor_impl.cc
deleted file mode 100644
index dcf5ec3..0000000
--- a/webkit/compositor_bindings/web_compositor_impl.cc
+++ /dev/null
@@ -1,85 +0,0 @@
-// Copyright 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "config.h"
-
-#include "web_compositor_impl.h"
-
-#ifdef LOG
-#undef LOG
-#endif
-#include "base/message_loop_proxy.h"
-#include "cc/layer_tree_host.h"
-#include "cc/proxy.h"
-#include "cc/settings.h"
-#include "cc/thread_impl.h"
-#include "third_party/WebKit/Source/Platform/chromium/public/Platform.h"
-#include "webkit/glue/webthread_impl.h"
-
-using namespace cc;
-
-namespace WebKit {
-
-bool WebCompositorImpl::s_initialized = false;
-Thread* WebCompositorImpl::s_mainThread = 0;
-Thread* WebCompositorImpl::s_implThread = 0;
-
-void WebCompositor::initialize(WebThread* implThread)
-{
- WebCompositorImpl::initialize(implThread);
-}
-
-bool WebCompositor::isThreadingEnabled()
-{
- return WebCompositorImpl::isThreadingEnabled();
-}
-
-void WebCompositor::shutdown()
-{
- WebCompositorImpl::shutdown();
-}
-
-void WebCompositorImpl::initialize(WebThread* implThread)
-{
- ASSERT(!s_initialized);
- s_initialized = true;
-
- s_mainThread = cc::ThreadImpl::createForCurrentThread().release();
- Proxy::setMainThread(s_mainThread);
- if (implThread) {
- webkit_glue::WebThreadImpl* webThreadImpl = static_cast<webkit_glue::WebThreadImpl*>(implThread);
- MessageLoop* implMessageLoop = webThreadImpl->message_loop();
- s_implThread = cc::ThreadImpl::createForDifferentThread(implMessageLoop->message_loop_proxy()).release();
- Proxy::setImplThread(s_implThread);
- } else
- Proxy::setImplThread(0);
-}
-
-bool WebCompositorImpl::isThreadingEnabled()
-{
- return s_implThread;
-}
-
-bool WebCompositorImpl::initialized()
-{
- return s_initialized;
-}
-
-void WebCompositorImpl::shutdown()
-{
- ASSERT(s_initialized);
- ASSERT(!LayerTreeHost::anyLayerTreeHostInstanceExists());
-
- if (s_implThread) {
- delete s_implThread;
- s_implThread = 0;
- }
- delete s_mainThread;
- s_mainThread = 0;
- Proxy::setImplThread(0);
- Proxy::setMainThread(0);
- s_initialized = false;
-}
-
-}
diff --git a/webkit/compositor_bindings/web_compositor_impl.h b/webkit/compositor_bindings/web_compositor_impl.h
deleted file mode 100644
index fe63b27..0000000
--- a/webkit/compositor_bindings/web_compositor_impl.h
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef WebCompositorImpl_h
-#define WebCompositorImpl_h
-
-#include "third_party/WebKit/Source/Platform/chromium/public/WebCompositor.h"
-
-namespace cc {
-class Thread;
-}
-
-namespace WebKit {
-
-class WebThread;
-
-class WebCompositorImpl : public WebCompositor {
-public:
- static bool initialized();
-
- static void initialize(WebThread* implThread);
- static bool isThreadingEnabled();
- static void shutdown();
-
-private:
- static bool s_initialized;
- static cc::Thread* s_mainThread;
- static cc::Thread* s_implThread;
-};
-
-}
-
-#endif // WebCompositorImpl_h
diff --git a/webkit/compositor_bindings/web_compositor_support_impl.cc b/webkit/compositor_bindings/web_compositor_support_impl.cc
index 6d237be..5e5a4d4 100644
--- a/webkit/compositor_bindings/web_compositor_support_impl.cc
+++ b/webkit/compositor_bindings/web_compositor_support_impl.cc
@@ -7,9 +7,10 @@
#include "base/debug/trace_event.h"
#include "base/memory/scoped_ptr.h"
+#include "base/message_loop_proxy.h"
#include "cc/settings.h"
+#include "cc/thread_impl.h"
#include "webkit/compositor_bindings/web_animation_impl.h"
-#include "webkit/compositor_bindings/web_compositor_impl.h"
#include "webkit/compositor_bindings/web_content_layer_impl.h"
#include "webkit/compositor_bindings/web_delegated_renderer_layer_impl.h"
#include "webkit/compositor_bindings/web_external_texture_layer_impl.h"
@@ -22,6 +23,7 @@
#include "webkit/compositor_bindings/web_solid_color_layer_impl.h"
#include "webkit/compositor_bindings/web_transform_animation_curve_impl.h"
#include "webkit/compositor_bindings/web_video_layer_impl.h"
+#include "webkit/glue/webthread_impl.h"
using WebKit::WebAnimation;
using WebKit::WebAnimationCurve;
@@ -46,29 +48,36 @@ using WebKit::WebTransformAnimationCurve;
using WebKit::WebVideoFrameProvider;
using WebKit::WebVideoLayer;
-using WebKit::WebCompositorImpl;
-
namespace webkit {
-WebCompositorSupportImpl::WebCompositorSupportImpl() {
+WebCompositorSupportImpl::WebCompositorSupportImpl()
+ : initialized_(false) {
}
WebCompositorSupportImpl::~WebCompositorSupportImpl() {
}
-void WebCompositorSupportImpl::initialize(WebKit::WebThread* thread) {
- if (thread) {
+void WebCompositorSupportImpl::initialize(WebKit::WebThread* impl_thread) {
+ DCHECK(!initialized_);
+ initialized_ = true;
+ if (impl_thread) {
TRACE_EVENT_INSTANT0("test_gpu", "ThreadedCompositingInitialization");
+ impl_thread_message_loop_proxy_ =
+ static_cast<webkit_glue::WebThreadImpl*>(impl_thread)->
+ message_loop()->message_loop_proxy();
+ } else {
+ impl_thread_message_loop_proxy_ = NULL;
}
- WebCompositorImpl::initialize(thread);
}
bool WebCompositorSupportImpl::isThreadingEnabled() {
- return WebCompositorImpl::isThreadingEnabled();
+ return impl_thread_message_loop_proxy_;
}
void WebCompositorSupportImpl::shutdown() {
- WebCompositorImpl::shutdown();
+ DCHECK(initialized_);
+ initialized_ = false;
+ impl_thread_message_loop_proxy_ = NULL;
}
void WebCompositorSupportImpl::setPerTilePaintingEnabled(bool enabled) {
@@ -90,9 +99,14 @@ void WebCompositorSupportImpl::setPageScalePinchZoomEnabled(bool enabled) {
WebLayerTreeView* WebCompositorSupportImpl::createLayerTreeView(
WebLayerTreeViewClient* client, const WebLayer& root,
const WebLayerTreeView::Settings& settings) {
+ DCHECK(initialized_);
scoped_ptr<WebKit::WebLayerTreeViewImpl> layerTreeViewImpl(
new WebKit::WebLayerTreeViewImpl(client));
- if (!layerTreeViewImpl->initialize(settings))
+ scoped_ptr<cc::Thread> impl_thread;
+ if (impl_thread_message_loop_proxy_)
+ impl_thread = cc::ThreadImpl::createForDifferentThread(
+ impl_thread_message_loop_proxy_);
+ if (!layerTreeViewImpl->initialize(settings, impl_thread.Pass()))
return NULL;
layerTreeViewImpl->setRootLayer(root);
return layerTreeViewImpl.release();
diff --git a/webkit/compositor_bindings/web_compositor_support_impl.h b/webkit/compositor_bindings/web_compositor_support_impl.h
index ac7e276..311f6fb 100644
--- a/webkit/compositor_bindings/web_compositor_support_impl.h
+++ b/webkit/compositor_bindings/web_compositor_support_impl.h
@@ -5,9 +5,14 @@
#ifndef WEBKIT_COMPOSITOR_BINDINGS_WEB_COMPOSITOR_SUPPORT_IMPL_H_
#define WEBKIT_COMPOSITOR_BINDINGS_WEB_COMPOSITOR_SUPPORT_IMPL_H_
+#include "base/memory/ref_counted.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebLayer.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebCompositorSupport.h"
+namespace base {
+class MessageLoopProxy;
+}
+
namespace webkit {
class WebCompositorSupportImpl : public WebKit::WebCompositorSupport {
@@ -15,7 +20,7 @@ class WebCompositorSupportImpl : public WebKit::WebCompositorSupport {
WebCompositorSupportImpl();
virtual ~WebCompositorSupportImpl();
- virtual void initialize(WebKit::WebThread* thread);
+ virtual void initialize(WebKit::WebThread* implThread);
virtual bool isThreadingEnabled();
virtual void shutdown();
virtual void setPerTilePaintingEnabled(bool enabled);
@@ -50,6 +55,10 @@ class WebCompositorSupportImpl : public WebKit::WebCompositorSupport {
createFloatAnimationCurve();
virtual WebKit::WebTransformAnimationCurve*
createTransformAnimationCurve();
+
+ private:
+ scoped_refptr<base::MessageLoopProxy> impl_thread_message_loop_proxy_;
+ bool initialized_;
};
} // namespace webkit
diff --git a/webkit/compositor_bindings/web_layer_tree_view_impl.cc b/webkit/compositor_bindings/web_layer_tree_view_impl.cc
index 731001f..ab0a953 100644
--- a/webkit/compositor_bindings/web_layer_tree_view_impl.cc
+++ b/webkit/compositor_bindings/web_layer_tree_view_impl.cc
@@ -9,6 +9,7 @@
#include "cc/input_handler.h"
#include "cc/layer.h"
#include "cc/layer_tree_host.h"
+#include "cc/thread.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebInputHandler.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebLayer.h"
@@ -23,15 +24,6 @@ using namespace cc;
namespace WebKit {
-WebLayerTreeView* WebLayerTreeView::create(WebLayerTreeViewClient* client, const WebLayer& root, const WebLayerTreeView::Settings& settings)
-{
- scoped_ptr<WebLayerTreeViewImpl> layerTreeViewImpl(new WebLayerTreeViewImpl(client));
- if (!layerTreeViewImpl->initialize(settings))
- return 0;
- layerTreeViewImpl->setRootLayer(root);
- return layerTreeViewImpl.release();
-}
-
WebLayerTreeViewImpl::WebLayerTreeViewImpl(WebLayerTreeViewClient* client)
: m_client(client)
{
@@ -41,7 +33,7 @@ WebLayerTreeViewImpl::~WebLayerTreeViewImpl()
{
}
-bool WebLayerTreeViewImpl::initialize(const WebLayerTreeView::Settings& webSettings)
+bool WebLayerTreeViewImpl::initialize(const WebLayerTreeView::Settings& webSettings, scoped_ptr<Thread> implThread)
{
LayerTreeSettings settings;
settings.acceleratePainting = webSettings.acceleratePainting;
@@ -51,7 +43,7 @@ bool WebLayerTreeViewImpl::initialize(const WebLayerTreeView::Settings& webSetti
settings.refreshRate = webSettings.refreshRate;
settings.defaultTileSize = webSettings.defaultTileSize;
settings.maxUntiledLayerSize = webSettings.maxUntiledLayerSize;
- m_layerTreeHost = LayerTreeHost::create(this, settings);
+ m_layerTreeHost = LayerTreeHost::create(this, settings, implThread.Pass());
if (!m_layerTreeHost.get())
return false;
@@ -151,10 +143,7 @@ bool WebLayerTreeViewImpl::commitRequested() const
void WebLayerTreeViewImpl::composite()
{
- if (Proxy::hasImplThread())
- m_layerTreeHost->setNeedsCommit();
- else
- m_layerTreeHost->composite();
+ m_layerTreeHost->composite();
}
void WebLayerTreeViewImpl::updateAnimations(double frameBeginTimeSeconds)
diff --git a/webkit/compositor_bindings/web_layer_tree_view_impl.h b/webkit/compositor_bindings/web_layer_tree_view_impl.h
index b89cb45..33c6eef 100644
--- a/webkit/compositor_bindings/web_layer_tree_view_impl.h
+++ b/webkit/compositor_bindings/web_layer_tree_view_impl.h
@@ -11,6 +11,7 @@
namespace cc {
class LayerTreeHost;
+class Thread;
}
namespace WebKit {
@@ -23,7 +24,7 @@ public:
explicit WebLayerTreeViewImpl(WebLayerTreeViewClient*);
virtual ~WebLayerTreeViewImpl();
- bool initialize(const Settings&);
+ bool initialize(const Settings&, scoped_ptr<cc::Thread> implThread);
// WebLayerTreeView implementation.
virtual void setSurfaceReady() OVERRIDE;
diff --git a/webkit/compositor_bindings/web_layer_tree_view_unittest.cc b/webkit/compositor_bindings/web_layer_tree_view_unittest.cc
index 3d40bde..06b6499 100644
--- a/webkit/compositor_bindings/web_layer_tree_view_unittest.cc
+++ b/webkit/compositor_bindings/web_layer_tree_view_unittest.cc
@@ -46,7 +46,12 @@ public:
initializeCompositor();
m_rootLayer.reset(new WebLayerImpl);
m_view.reset(new WebLayerTreeViewImpl(client()));
- ASSERT_TRUE(m_view->initialize(WebLayerTreeView::Settings()));
+ scoped_ptr<cc::Thread> implCCThread(NULL);
+ if (m_implThread)
+ implCCThread = cc::ThreadImpl::createForDifferentThread(
+ m_implThread->message_loop_proxy());
+ ASSERT_TRUE(m_view->initialize(WebLayerTreeView::Settings(),
+ implCCThread.Pass()));
m_view->setRootLayer(*m_rootLayer);
m_view->setSurfaceReady();
}
@@ -62,6 +67,7 @@ public:
protected:
scoped_ptr<WebLayer> m_rootLayer;
scoped_ptr<WebLayerTreeViewImpl> m_view;
+ scoped_ptr<base::Thread> m_implThread;
};
class WebLayerTreeViewSingleThreadTest : public WebLayerTreeViewTestBase {
@@ -87,7 +93,6 @@ class WebLayerTreeViewThreadedTest : public WebLayerTreeViewTestBase {
protected:
virtual ~WebLayerTreeViewThreadedTest()
{
- cc::Proxy::setImplThread(0);
}
void composite()
@@ -105,8 +110,6 @@ protected:
{
m_implThread.reset(new base::Thread("ThreadedTest"));
ASSERT_TRUE(m_implThread->Start());
- m_implCCThread = cc::ThreadImpl::createForDifferentThread(m_implThread->message_loop_proxy());
- cc::Proxy::setImplThread(m_implCCThread.get());
}
virtual WebLayerTreeViewClient* client() OVERRIDE
@@ -115,8 +118,6 @@ protected:
}
MockWebLayerTreeViewClientForThreadedTests m_client;
- scoped_ptr<base::Thread> m_implThread;
- scoped_ptr<cc::Thread> m_implCCThread;
base::CancelableClosure m_timeout;
};
diff --git a/webkit/compositor_bindings/web_layer_unittest.cc b/webkit/compositor_bindings/web_layer_unittest.cc
index 762be3c..dc70d69 100644
--- a/webkit/compositor_bindings/web_layer_unittest.cc
+++ b/webkit/compositor_bindings/web_layer_unittest.cc
@@ -5,8 +5,10 @@
#include "config.h"
#include <public/WebLayer.h>
+#include "cc/thread.h"
#include "cc/test/compositor_fake_web_graphics_context_3d.h"
#include "web_layer_impl.h"
+#include "web_layer_tree_view_impl.h"
#include "web_layer_tree_view_test_common.h"
#include <public/WebContentLayer.h>
#include <public/WebContentLayerClient.h>
@@ -50,7 +52,9 @@ public:
{
m_rootLayer.reset(WebLayer::create());
EXPECT_CALL(m_client, scheduleComposite()).Times(AnyNumber());
- m_view.reset(WebLayerTreeView::create(&m_client, *m_rootLayer, WebLayerTreeView::Settings()));
+ m_view.reset(new WebLayerTreeViewImpl(&m_client));
+ EXPECT_TRUE(m_view->initialize(WebLayerTreeView::Settings(), scoped_ptr<cc::Thread>(NULL)));
+ m_view->setRootLayer(*m_rootLayer);
EXPECT_TRUE(m_view);
Mock::VerifyAndClearExpectations(&m_client);
}
@@ -66,7 +70,7 @@ public:
protected:
MockWebLayerTreeViewClient m_client;
scoped_ptr<WebLayer> m_rootLayer;
- scoped_ptr<WebLayerTreeView> m_view;
+ scoped_ptr<WebLayerTreeViewImpl> m_view;
};
// Tests that the client gets called to ask for a composite if we change the