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 CCSingleThreadProxy_h | 5 #ifndef CCSingleThreadProxy_h |
6 #define CCSingleThreadProxy_h | 6 #define CCSingleThreadProxy_h |
7 | 7 |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "CCAnimationEvents.h" | 10 #include "CCAnimationEvents.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 bool m_nextFrameIsNewlyCommittedFrame; | 82 bool m_nextFrameIsNewlyCommittedFrame; |
83 | 83 |
84 base::TimeDelta m_totalCommitTime; | 84 base::TimeDelta m_totalCommitTime; |
85 size_t m_totalCommitCount; | 85 size_t m_totalCommitCount; |
86 }; | 86 }; |
87 | 87 |
88 // For use in the single-threaded case. In debug builds, it pretends that the | 88 // For use in the single-threaded case. In debug builds, it pretends that the |
89 // code is running on the impl thread to satisfy assertion checks. | 89 // code is running on the impl thread to satisfy assertion checks. |
90 class DebugScopedSetImplThread { | 90 class DebugScopedSetImplThread { |
91 public: | 91 public: |
92 DebugScopedSetImplThread() | 92 DebugScopedSetImplThread(Proxy* proxy) |
| 93 : m_proxy(proxy) |
93 { | 94 { |
94 #ifndef NDEBUG | 95 #ifndef NDEBUG |
95 Proxy::setCurrentThreadIsImplThread(true); | 96 m_previousValue = m_proxy->m_implThreadIsOverridden; |
| 97 m_proxy->setCurrentThreadIsImplThread(true); |
96 #endif | 98 #endif |
97 } | 99 } |
98 ~DebugScopedSetImplThread() | 100 ~DebugScopedSetImplThread() |
99 { | 101 { |
100 #ifndef NDEBUG | 102 #ifndef NDEBUG |
101 Proxy::setCurrentThreadIsImplThread(false); | 103 m_proxy->setCurrentThreadIsImplThread(m_previousValue); |
102 #endif | 104 #endif |
103 } | 105 } |
| 106 private: |
| 107 bool m_previousValue; |
| 108 Proxy* m_proxy; |
104 }; | 109 }; |
105 | 110 |
106 // For use in the single-threaded case. In debug builds, it pretends that the | 111 // For use in the single-threaded case. In debug builds, it pretends that the |
107 // code is running on the main thread to satisfy assertion checks. | 112 // code is running on the main thread to satisfy assertion checks. |
108 class DebugScopedSetMainThread { | 113 class DebugScopedSetMainThread { |
109 public: | 114 public: |
110 DebugScopedSetMainThread() | 115 DebugScopedSetMainThread(Proxy* proxy) |
| 116 : m_proxy(proxy) |
111 { | 117 { |
112 #ifndef NDEBUG | 118 #ifndef NDEBUG |
113 Proxy::setCurrentThreadIsImplThread(false); | 119 m_previousValue = m_proxy->m_implThreadIsOverridden; |
| 120 m_proxy->setCurrentThreadIsImplThread(false); |
114 #endif | 121 #endif |
115 } | 122 } |
116 ~DebugScopedSetMainThread() | 123 ~DebugScopedSetMainThread() |
117 { | 124 { |
118 #ifndef NDEBUG | 125 #ifndef NDEBUG |
119 Proxy::setCurrentThreadIsImplThread(true); | 126 m_proxy->setCurrentThreadIsImplThread(m_previousValue); |
120 #endif | 127 #endif |
121 } | 128 } |
| 129 private: |
| 130 bool m_previousValue; |
| 131 Proxy* m_proxy; |
122 }; | 132 }; |
123 | 133 |
124 // For use in the single-threaded case. In debug builds, it pretends that the | 134 // For use in the single-threaded case. In debug builds, it pretends that the |
125 // code is running on the impl thread and that the main thread is blocked to | 135 // code is running on the impl thread and that the main thread is blocked to |
126 // satisfy assertion checks | 136 // satisfy assertion checks |
127 class DebugScopedSetImplThreadAndMainThreadBlocked { | 137 class DebugScopedSetImplThreadAndMainThreadBlocked { |
| 138 public: |
| 139 DebugScopedSetImplThreadAndMainThreadBlocked(Proxy* proxy) |
| 140 : m_implThread(proxy) |
| 141 , m_mainThreadBlocked(proxy) |
| 142 { |
| 143 } |
128 private: | 144 private: |
129 DebugScopedSetImplThread m_implThread; | 145 DebugScopedSetImplThread m_implThread; |
130 DebugScopedSetMainThreadBlocked m_mainThreadBlocked; | 146 DebugScopedSetMainThreadBlocked m_mainThreadBlocked; |
131 }; | 147 }; |
132 | 148 |
133 } // namespace cc | 149 } // namespace cc |
134 | 150 |
135 #endif | 151 #endif |
OLD | NEW |