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