OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CCProxy_h | 5 #ifndef CCProxy_h |
6 #define CCProxy_h | 6 #define CCProxy_h |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/threading/platform_thread.h" |
10 #include <public/WebCompositorOutputSurface.h> | 12 #include <public/WebCompositorOutputSurface.h> |
11 | 13 |
12 namespace cc { | 14 namespace cc { |
13 | 15 |
14 class Thread; | 16 class Thread; |
15 class IntRect; | 17 class IntRect; |
16 class IntSize; | 18 class IntSize; |
17 struct RenderingStats; | 19 struct RenderingStats; |
18 struct RendererCapabilities; | 20 struct RendererCapabilities; |
19 | 21 |
20 // Abstract class responsible for proxying commands from the main-thread side of | 22 // Abstract class responsible for proxying commands from the main-thread side of |
21 // the compositor over to the compositor implementation. | 23 // the compositor over to the compositor implementation. |
22 class Proxy { | 24 class Proxy { |
23 public: | 25 public: |
24 static void setMainThread(Thread*); | 26 Thread* mainThread() const; |
25 static Thread* mainThread(); | 27 bool hasImplThread() const; |
26 | 28 Thread* implThread() const; |
27 static bool hasImplThread(); | |
28 static void setImplThread(Thread*); | |
29 static Thread* implThread(); | |
30 | 29 |
31 // Returns 0 if the current thread is neither the main thread nor the impl t
hread. | 30 // Returns 0 if the current thread is neither the main thread nor the impl t
hread. |
32 static Thread* currentThread(); | 31 Thread* currentThread() const; |
| 32 |
| 33 // Debug hooks |
| 34 bool isMainThread() const; |
| 35 bool isImplThread() const; |
| 36 bool isMainThreadBlocked() const; |
| 37 void setMainThread(Thread*); |
| 38 void setImplThread(Thread*); |
| 39 #ifndef NDEBUG |
| 40 void setMainThreadBlocked(bool); |
| 41 void setCurrentThreadIsImplThread(bool); |
| 42 #endif |
| 43 |
33 | 44 |
34 virtual ~Proxy(); | 45 virtual ~Proxy(); |
35 | 46 |
36 virtual bool compositeAndReadback(void *pixels, const IntRect&) = 0; | 47 virtual bool compositeAndReadback(void *pixels, const IntRect&) = 0; |
37 | 48 |
38 virtual void startPageScaleAnimation(const IntSize& targetPosition, bool use
Anchor, float scale, double durationSec) = 0; | 49 virtual void startPageScaleAnimation(const IntSize& targetPosition, bool use
Anchor, float scale, double durationSec) = 0; |
39 | 50 |
40 virtual void finishAllRendering() = 0; | 51 virtual void finishAllRendering() = 0; |
41 | 52 |
42 virtual bool isStarted() const = 0; | 53 virtual bool isStarted() const = 0; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 | 85 |
75 // Forces 3D commands on all contexts to wait for all previous SwapBuffers t
o finish before executing in the GPU | 86 // Forces 3D commands on all contexts to wait for all previous SwapBuffers t
o finish before executing in the GPU |
76 // process. | 87 // process. |
77 virtual void forceSerializeOnSwapBuffers() = 0; | 88 virtual void forceSerializeOnSwapBuffers() = 0; |
78 | 89 |
79 // Maximum number of sub-region texture updates supported for each commit. | 90 // Maximum number of sub-region texture updates supported for each commit. |
80 virtual size_t maxPartialTextureUpdates() const = 0; | 91 virtual size_t maxPartialTextureUpdates() const = 0; |
81 | 92 |
82 virtual void acquireLayerTextures() = 0; | 93 virtual void acquireLayerTextures() = 0; |
83 | 94 |
84 // Debug hooks | |
85 static bool isMainThread(); | |
86 static bool isImplThread(); | |
87 static bool isMainThreadBlocked(); | |
88 #ifndef NDEBUG | |
89 static void setMainThreadBlocked(bool); | |
90 #endif | |
91 | |
92 // Testing hooks | 95 // Testing hooks |
93 virtual void loseContext() = 0; | 96 virtual void loseContext() = 0; |
94 | 97 |
95 #ifndef NDEBUG | |
96 static void setCurrentThreadIsImplThread(bool); | |
97 #endif | |
98 | |
99 protected: | 98 protected: |
100 Proxy(); | 99 explicit Proxy(Thread* implThread); |
101 friend class DebugScopedSetImplThread; | 100 friend class DebugScopedSetImplThread; |
| 101 friend class DebugScopedSetMainThread; |
102 friend class DebugScopedSetMainThreadBlocked; | 102 friend class DebugScopedSetMainThreadBlocked; |
103 | 103 |
104 private: | 104 private: |
105 DISALLOW_COPY_AND_ASSIGN(Proxy); | 105 DISALLOW_COPY_AND_ASSIGN(Proxy); |
| 106 |
| 107 scoped_ptr<Thread> m_mainThread; |
| 108 scoped_ptr<Thread> m_implThread; |
| 109 #ifndef NDEBUG |
| 110 bool m_implThreadIsOverridden; |
| 111 bool m_isMainThreadBlocked; |
| 112 base::PlatformThreadId m_threadIDOverridenToBeImplThread; |
| 113 #endif |
106 }; | 114 }; |
107 | 115 |
108 class DebugScopedSetMainThreadBlocked { | 116 class DebugScopedSetMainThreadBlocked { |
109 public: | 117 public: |
110 DebugScopedSetMainThreadBlocked() | 118 DebugScopedSetMainThreadBlocked(Proxy* proxy) |
| 119 : m_proxy(proxy) |
111 { | 120 { |
112 #ifndef NDEBUG | 121 #ifndef NDEBUG |
113 DCHECK(!Proxy::isMainThreadBlocked()); | 122 DCHECK(!m_proxy->isMainThreadBlocked()); |
114 Proxy::setMainThreadBlocked(true); | 123 m_proxy->setMainThreadBlocked(true); |
115 #endif | 124 #endif |
116 } | 125 } |
117 ~DebugScopedSetMainThreadBlocked() | 126 ~DebugScopedSetMainThreadBlocked() |
118 { | 127 { |
119 #ifndef NDEBUG | 128 #ifndef NDEBUG |
120 DCHECK(Proxy::isMainThreadBlocked()); | 129 DCHECK(m_proxy->isMainThreadBlocked()); |
121 Proxy::setMainThreadBlocked(false); | 130 m_proxy->setMainThreadBlocked(false); |
122 #endif | 131 #endif |
123 } | 132 } |
| 133 private: |
| 134 Proxy* m_proxy; |
124 }; | 135 }; |
125 | 136 |
126 } | 137 } |
127 | 138 |
128 #endif | 139 #endif |
OLD | NEW |