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 CC_PROXY_H_ | 5 #ifndef CC_PROXY_H_ |
6 #define CC_PROXY_H_ | 6 #define CC_PROXY_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/time.h" | 10 #include "base/time.h" |
| 11 #include "base/memory/scoped_ptr.h" |
11 #include <public/WebCompositorOutputSurface.h> | 12 #include <public/WebCompositorOutputSurface.h> |
12 #include "cc/cc_export.h" | 13 #include "cc/cc_export.h" |
13 | 14 |
14 namespace gfx { | 15 namespace gfx { |
15 class Rect; | 16 class Rect; |
16 class Vector2d; | 17 class Vector2d; |
17 } | 18 } |
18 | 19 |
19 namespace cc { | 20 namespace cc { |
20 | 21 |
21 class Thread; | 22 class Thread; |
22 struct RenderingStats; | 23 struct RenderingStats; |
23 struct RendererCapabilities; | 24 struct RendererCapabilities; |
24 | 25 |
25 // Abstract class responsible for proxying commands from the main-thread side of | 26 // Abstract class responsible for proxying commands from the main-thread side of |
26 // the compositor over to the compositor implementation. | 27 // the compositor over to the compositor implementation. |
27 class CC_EXPORT Proxy { | 28 class CC_EXPORT Proxy { |
28 public: | 29 public: |
29 static void setMainThread(Thread*); | 30 Thread* mainThread() const; |
30 static Thread* mainThread(); | 31 bool hasImplThread() const; |
31 | 32 Thread* implThread() const; |
32 static bool hasImplThread(); | |
33 static void setImplThread(Thread*); | |
34 static Thread* implThread(); | |
35 | 33 |
36 // Returns 0 if the current thread is neither the main thread nor the impl t
hread. | 34 // Returns 0 if the current thread is neither the main thread nor the impl t
hread. |
37 static Thread* currentThread(); | 35 Thread* currentThread() const; |
| 36 |
| 37 // Debug hooks |
| 38 bool isMainThread() const; |
| 39 bool isImplThread() const; |
| 40 bool isMainThreadBlocked() const; |
| 41 #ifndef NDEBUG |
| 42 void setMainThreadBlocked(bool); |
| 43 void setCurrentThreadIsImplThread(bool); |
| 44 #endif |
38 | 45 |
39 virtual ~Proxy(); | 46 virtual ~Proxy(); |
40 | 47 |
41 virtual bool compositeAndReadback(void *pixels, const gfx::Rect&) = 0; | 48 virtual bool compositeAndReadback(void *pixels, const gfx::Rect&) = 0; |
42 | 49 |
43 virtual void startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnc
hor, float scale, base::TimeDelta duration) = 0; | 50 virtual void startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnc
hor, float scale, base::TimeDelta duration) = 0; |
44 | 51 |
45 virtual void finishAllRendering() = 0; | 52 virtual void finishAllRendering() = 0; |
46 | 53 |
47 virtual bool isStarted() const = 0; | 54 virtual bool isStarted() const = 0; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 | 90 |
84 // Forces 3D commands on all contexts to wait for all previous SwapBuffers t
o finish before executing in the GPU | 91 // Forces 3D commands on all contexts to wait for all previous SwapBuffers t
o finish before executing in the GPU |
85 // process. | 92 // process. |
86 virtual void forceSerializeOnSwapBuffers() = 0; | 93 virtual void forceSerializeOnSwapBuffers() = 0; |
87 | 94 |
88 // Maximum number of sub-region texture updates supported for each commit. | 95 // Maximum number of sub-region texture updates supported for each commit. |
89 virtual size_t maxPartialTextureUpdates() const = 0; | 96 virtual size_t maxPartialTextureUpdates() const = 0; |
90 | 97 |
91 virtual void acquireLayerTextures() = 0; | 98 virtual void acquireLayerTextures() = 0; |
92 | 99 |
93 // Debug hooks | |
94 static bool isMainThread(); | |
95 static bool isImplThread(); | |
96 static bool isMainThreadBlocked(); | |
97 #ifndef NDEBUG | |
98 static void setMainThreadBlocked(bool); | |
99 #endif | |
100 | |
101 // Testing hooks | 100 // Testing hooks |
102 virtual void loseContext() = 0; | 101 virtual void loseContext() = 0; |
103 | 102 |
104 #ifndef NDEBUG | |
105 static void setCurrentThreadIsImplThread(bool); | |
106 #endif | |
107 | |
108 protected: | 103 protected: |
109 Proxy(); | 104 explicit Proxy(scoped_ptr<Thread> implThread); |
110 friend class DebugScopedSetImplThread; | 105 friend class DebugScopedSetImplThread; |
| 106 friend class DebugScopedSetMainThread; |
111 friend class DebugScopedSetMainThreadBlocked; | 107 friend class DebugScopedSetMainThreadBlocked; |
112 | 108 |
113 private: | 109 private: |
114 DISALLOW_COPY_AND_ASSIGN(Proxy); | 110 DISALLOW_COPY_AND_ASSIGN(Proxy); |
| 111 |
| 112 scoped_ptr<Thread> m_mainThread; |
| 113 scoped_ptr<Thread> m_implThread; |
| 114 #ifndef NDEBUG |
| 115 bool m_implThreadIsOverridden; |
| 116 bool m_isMainThreadBlocked; |
| 117 #endif |
115 }; | 118 }; |
116 | 119 |
117 class DebugScopedSetMainThreadBlocked { | 120 class DebugScopedSetMainThreadBlocked { |
118 public: | 121 public: |
119 DebugScopedSetMainThreadBlocked() | 122 explicit DebugScopedSetMainThreadBlocked(Proxy* proxy) |
| 123 : m_proxy(proxy) |
120 { | 124 { |
121 #ifndef NDEBUG | 125 #ifndef NDEBUG |
122 DCHECK(!Proxy::isMainThreadBlocked()); | 126 DCHECK(!m_proxy->isMainThreadBlocked()); |
123 Proxy::setMainThreadBlocked(true); | 127 m_proxy->setMainThreadBlocked(true); |
124 #endif | 128 #endif |
125 } | 129 } |
126 ~DebugScopedSetMainThreadBlocked() | 130 ~DebugScopedSetMainThreadBlocked() |
127 { | 131 { |
128 #ifndef NDEBUG | 132 #ifndef NDEBUG |
129 DCHECK(Proxy::isMainThreadBlocked()); | 133 DCHECK(m_proxy->isMainThreadBlocked()); |
130 Proxy::setMainThreadBlocked(false); | 134 m_proxy->setMainThreadBlocked(false); |
131 #endif | 135 #endif |
132 } | 136 } |
| 137 private: |
| 138 Proxy* m_proxy; |
133 }; | 139 }; |
134 | 140 |
135 } | 141 } |
136 | 142 |
137 #endif // CC_PROXY_H_ | 143 #endif // CC_PROXY_H_ |
OLD | NEW |