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/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 | 13 |
13 namespace cc { | 14 namespace cc { |
14 | 15 |
15 class Thread; | 16 class Thread; |
16 class IntRect; | 17 class IntRect; |
17 class IntSize; | 18 class IntSize; |
18 struct RenderingStats; | 19 struct RenderingStats; |
19 struct RendererCapabilities; | 20 struct RendererCapabilities; |
20 | 21 |
21 // 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 |
22 // the compositor over to the compositor implementation. | 23 // the compositor over to the compositor implementation. |
23 class Proxy { | 24 class Proxy { |
24 public: | 25 public: |
25 static void setMainThread(Thread*); | 26 Thread* mainThread() const; |
26 static Thread* mainThread(); | 27 bool hasImplThread() const; |
27 | 28 Thread* implThread() const; |
28 static bool hasImplThread(); | |
29 static void setImplThread(Thread*); | |
30 static Thread* implThread(); | |
31 | 29 |
32 // 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. |
33 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*); | |
jamesr
2012/10/31 04:42:13
hmm, why do we need a setter for the main thread?
| |
38 void setImplThread(Thread*); | |
jamesr
2012/10/31 04:42:13
since these setters transfer ownership, they shoul
aelias_OOO_until_Jul13
2012/10/31 06:15:30
The setters were unused residue. I deleted both o
| |
39 #ifndef NDEBUG | |
40 void setMainThreadBlocked(bool); | |
41 void setCurrentThreadIsImplThread(bool); | |
42 #endif | |
34 | 43 |
35 virtual ~Proxy(); | 44 virtual ~Proxy(); |
36 | 45 |
37 virtual bool compositeAndReadback(void *pixels, const IntRect&) = 0; | 46 virtual bool compositeAndReadback(void *pixels, const IntRect&) = 0; |
38 | 47 |
39 virtual void startPageScaleAnimation(const IntSize& targetPosition, bool use Anchor, float scale, base::TimeDelta duration) = 0; | 48 virtual void startPageScaleAnimation(const IntSize& targetPosition, bool use Anchor, float scale, base::TimeDelta duration) = 0; |
40 | 49 |
41 virtual void finishAllRendering() = 0; | 50 virtual void finishAllRendering() = 0; |
42 | 51 |
43 virtual bool isStarted() const = 0; | 52 virtual bool isStarted() const = 0; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 | 88 |
80 // Forces 3D commands on all contexts to wait for all previous SwapBuffers t o finish before executing in the GPU | 89 // Forces 3D commands on all contexts to wait for all previous SwapBuffers t o finish before executing in the GPU |
81 // process. | 90 // process. |
82 virtual void forceSerializeOnSwapBuffers() = 0; | 91 virtual void forceSerializeOnSwapBuffers() = 0; |
83 | 92 |
84 // Maximum number of sub-region texture updates supported for each commit. | 93 // Maximum number of sub-region texture updates supported for each commit. |
85 virtual size_t maxPartialTextureUpdates() const = 0; | 94 virtual size_t maxPartialTextureUpdates() const = 0; |
86 | 95 |
87 virtual void acquireLayerTextures() = 0; | 96 virtual void acquireLayerTextures() = 0; |
88 | 97 |
89 // Debug hooks | |
90 static bool isMainThread(); | |
91 static bool isImplThread(); | |
92 static bool isMainThreadBlocked(); | |
93 #ifndef NDEBUG | |
94 static void setMainThreadBlocked(bool); | |
95 #endif | |
96 | |
97 // Testing hooks | 98 // Testing hooks |
98 virtual void loseContext() = 0; | 99 virtual void loseContext() = 0; |
99 | 100 |
100 #ifndef NDEBUG | |
101 static void setCurrentThreadIsImplThread(bool); | |
102 #endif | |
103 | |
104 protected: | 101 protected: |
105 Proxy(); | 102 explicit Proxy(Thread* implThread); |
106 friend class DebugScopedSetImplThread; | 103 friend class DebugScopedSetImplThread; |
104 friend class DebugScopedSetMainThread; | |
107 friend class DebugScopedSetMainThreadBlocked; | 105 friend class DebugScopedSetMainThreadBlocked; |
108 | 106 |
109 private: | 107 private: |
110 DISALLOW_COPY_AND_ASSIGN(Proxy); | 108 DISALLOW_COPY_AND_ASSIGN(Proxy); |
109 | |
110 scoped_ptr<Thread> m_mainThread; | |
111 scoped_ptr<Thread> m_implThread; | |
112 #ifndef NDEBUG | |
113 bool m_implThreadIsOverridden; | |
114 bool m_isMainThreadBlocked; | |
115 #endif | |
111 }; | 116 }; |
112 | 117 |
113 class DebugScopedSetMainThreadBlocked { | 118 class DebugScopedSetMainThreadBlocked { |
114 public: | 119 public: |
115 DebugScopedSetMainThreadBlocked() | 120 DebugScopedSetMainThreadBlocked(Proxy* proxy) |
121 : m_proxy(proxy) | |
116 { | 122 { |
117 #ifndef NDEBUG | 123 #ifndef NDEBUG |
118 DCHECK(!Proxy::isMainThreadBlocked()); | 124 DCHECK(!m_proxy->isMainThreadBlocked()); |
119 Proxy::setMainThreadBlocked(true); | 125 m_proxy->setMainThreadBlocked(true); |
120 #endif | 126 #endif |
121 } | 127 } |
122 ~DebugScopedSetMainThreadBlocked() | 128 ~DebugScopedSetMainThreadBlocked() |
123 { | 129 { |
124 #ifndef NDEBUG | 130 #ifndef NDEBUG |
125 DCHECK(Proxy::isMainThreadBlocked()); | 131 DCHECK(m_proxy->isMainThreadBlocked()); |
126 Proxy::setMainThreadBlocked(false); | 132 m_proxy->setMainThreadBlocked(false); |
127 #endif | 133 #endif |
128 } | 134 } |
135 private: | |
136 Proxy* m_proxy; | |
129 }; | 137 }; |
130 | 138 |
131 } | 139 } |
132 | 140 |
133 #endif | 141 #endif |
OLD | NEW |