Add signalSyncPoint to the WebGraphicsContext3D command buffer impls.
[chromium-blink-merge.git] / cc / trees / proxy.cc
blob8d2d2b7eadc226c22c8d11697cd5f3b1651f78c2
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.
5 #include "cc/trees/proxy.h"
7 #include "cc/base/thread.h"
8 #include "cc/base/thread_impl.h"
10 namespace cc {
12 Thread* Proxy::MainThread() const { return main_thread_.get(); }
14 bool Proxy::HasImplThread() const { return impl_thread_; }
16 Thread* Proxy::ImplThread() const { return impl_thread_.get(); }
18 Thread* Proxy::CurrentThread() const {
19 if (MainThread() && MainThread()->BelongsToCurrentThread())
20 return MainThread();
21 if (ImplThread() && ImplThread()->BelongsToCurrentThread())
22 return ImplThread();
23 return NULL;
26 bool Proxy::IsMainThread() const {
27 #ifndef NDEBUG
28 DCHECK(MainThread());
29 if (impl_thread_is_overridden_)
30 return false;
31 return MainThread()->BelongsToCurrentThread();
32 #else
33 return true;
34 #endif
37 bool Proxy::IsImplThread() const {
38 #ifndef NDEBUG
39 if (impl_thread_is_overridden_)
40 return true;
41 return ImplThread() && ImplThread()->BelongsToCurrentThread();
42 #else
43 return true;
44 #endif
47 #ifndef NDEBUG
48 void Proxy::SetCurrentThreadIsImplThread(bool is_impl_thread) {
49 impl_thread_is_overridden_ = is_impl_thread;
51 #endif
53 bool Proxy::IsMainThreadBlocked() const {
54 #ifndef NDEBUG
55 return is_main_thread_blocked_;
56 #else
57 return true;
58 #endif
61 #ifndef NDEBUG
62 void Proxy::SetMainThreadBlocked(bool is_main_thread_blocked) {
63 is_main_thread_blocked_ = is_main_thread_blocked;
65 #endif
67 Proxy::Proxy(scoped_ptr<Thread> impl_thread)
68 : main_thread_(ThreadImpl::CreateForCurrentThread()),
69 #ifdef NDEBUG
70 impl_thread_(impl_thread.Pass()) {}
71 #else
72 impl_thread_(impl_thread.Pass()),
73 impl_thread_is_overridden_(false),
74 is_main_thread_blocked_(false) {}
75 #endif
77 Proxy::~Proxy() {
78 DCHECK(IsMainThread());
81 } // namespace cc