| OLD | NEW |
| (Empty) |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "config.h" | |
| 6 | |
| 7 #include "web_compositor_impl.h" | |
| 8 | |
| 9 #ifdef LOG | |
| 10 #undef LOG | |
| 11 #endif | |
| 12 #include "base/message_loop_proxy.h" | |
| 13 #include "cc/layer_tree_host.h" | |
| 14 #include "cc/proxy.h" | |
| 15 #include "cc/settings.h" | |
| 16 #include "cc/thread_impl.h" | |
| 17 #include "third_party/WebKit/Source/Platform/chromium/public/Platform.h" | |
| 18 #include "webkit/glue/webthread_impl.h" | |
| 19 | |
| 20 using namespace cc; | |
| 21 | |
| 22 namespace WebKit { | |
| 23 | |
| 24 bool WebCompositorImpl::s_initialized = false; | |
| 25 Thread* WebCompositorImpl::s_mainThread = 0; | |
| 26 Thread* WebCompositorImpl::s_implThread = 0; | |
| 27 | |
| 28 void WebCompositor::initialize(WebThread* implThread) | |
| 29 { | |
| 30 WebCompositorImpl::initialize(implThread); | |
| 31 } | |
| 32 | |
| 33 bool WebCompositor::isThreadingEnabled() | |
| 34 { | |
| 35 return WebCompositorImpl::isThreadingEnabled(); | |
| 36 } | |
| 37 | |
| 38 void WebCompositor::shutdown() | |
| 39 { | |
| 40 WebCompositorImpl::shutdown(); | |
| 41 } | |
| 42 | |
| 43 void WebCompositorImpl::initialize(WebThread* implThread) | |
| 44 { | |
| 45 ASSERT(!s_initialized); | |
| 46 s_initialized = true; | |
| 47 | |
| 48 s_mainThread = cc::ThreadImpl::createForCurrentThread().release(); | |
| 49 Proxy::setMainThread(s_mainThread); | |
| 50 if (implThread) { | |
| 51 webkit_glue::WebThreadImpl* webThreadImpl = static_cast<webkit_glue::Web
ThreadImpl*>(implThread); | |
| 52 MessageLoop* implMessageLoop = webThreadImpl->message_loop(); | |
| 53 s_implThread = cc::ThreadImpl::createForDifferentThread(implMessageLoop-
>message_loop_proxy()).release(); | |
| 54 Proxy::setImplThread(s_implThread); | |
| 55 } else | |
| 56 Proxy::setImplThread(0); | |
| 57 } | |
| 58 | |
| 59 bool WebCompositorImpl::isThreadingEnabled() | |
| 60 { | |
| 61 return s_implThread; | |
| 62 } | |
| 63 | |
| 64 bool WebCompositorImpl::initialized() | |
| 65 { | |
| 66 return s_initialized; | |
| 67 } | |
| 68 | |
| 69 void WebCompositorImpl::shutdown() | |
| 70 { | |
| 71 ASSERT(s_initialized); | |
| 72 ASSERT(!LayerTreeHost::anyLayerTreeHostInstanceExists()); | |
| 73 | |
| 74 if (s_implThread) { | |
| 75 delete s_implThread; | |
| 76 s_implThread = 0; | |
| 77 } | |
| 78 delete s_mainThread; | |
| 79 s_mainThread = 0; | |
| 80 Proxy::setImplThread(0); | |
| 81 Proxy::setMainThread(0); | |
| 82 s_initialized = false; | |
| 83 } | |
| 84 | |
| 85 } | |
| OLD | NEW |