OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "content/renderer/gpu/compositor_output_surface.h" | 5 #include "content/renderer/gpu/compositor_output_surface.h" |
6 | 6 |
7 #include "base/message_loop_proxy.h" | 7 #include "base/message_loop_proxy.h" |
8 #include "cc/compositor_frame.h" | 8 #include "cc/compositor_frame.h" |
9 #include "cc/output_surface_client.h" | 9 #include "cc/output_surface_client.h" |
10 #include "content/common/view_messages.h" | 10 #include "content/common/view_messages.h" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
142 setpriority(PRIO_PROCESS, id, nice_value); | 142 setpriority(PRIO_PROCESS, id, nice_value); |
143 } | 143 } |
144 #else | 144 #else |
145 void SetThreadsPriorityToIdle(base::PlatformThreadId id) {} | 145 void SetThreadsPriorityToIdle(base::PlatformThreadId id) {} |
146 void SetThreadsPriorityToDefault(base::PlatformThreadId id) {} | 146 void SetThreadsPriorityToDefault(base::PlatformThreadId id) {} |
147 #endif | 147 #endif |
148 } | 148 } |
149 | 149 |
150 void CompositorOutputSurface::UpdateSmoothnessTakesPriority( | 150 void CompositorOutputSurface::UpdateSmoothnessTakesPriority( |
151 bool prefers_smoothness) { | 151 bool prefers_smoothness) { |
152 #if ENABLE_DCHECK | 152 #ifndef NDEBUG |
153 // If we use different compositor threads, we need to | 153 // If we use different compositor threads, we need to |
154 // use an atomic int to track prefer smoothness count. | 154 // use an atomic int to track prefer smoothness count. |
155 static int g_last_thread = base::PlatformThread::CurrentId(); | 155 base::PlatformThreadId g_last_thread = base::PlatformThread::CurrentId(); |
joth
2013/04/05 05:30:32
removing the static here makes the dcheck below po
| |
156 DCHECK_EQ(g_last_thread, base::PlatformThread::CurrentId()); | 156 DCHECK_EQ(g_last_thread, base::PlatformThread::CurrentId()); |
157 #endif | 157 #endif |
158 if (prefers_smoothness_ == prefers_smoothness) | 158 if (prefers_smoothness_ == prefers_smoothness) |
159 return; | 159 return; |
160 // If this is the first surface to start preferring smoothness, | 160 // If this is the first surface to start preferring smoothness, |
161 // Throttle the main thread's priority. | 161 // Throttle the main thread's priority. |
162 if (prefers_smoothness_ == false && | 162 if (prefers_smoothness_ == false && |
163 ++g_prefer_smoothness_count == 1) { | 163 ++g_prefer_smoothness_count == 1) { |
164 SetThreadsPriorityToIdle(main_thread_id_); | 164 SetThreadsPriorityToIdle(main_thread_id_); |
165 } | 165 } |
166 // If this is the last surface to stop preferring smoothness, | 166 // If this is the last surface to stop preferring smoothness, |
167 // Reset the main thread's priority to the default. | 167 // Reset the main thread's priority to the default. |
168 if (prefers_smoothness_ == true && | 168 if (prefers_smoothness_ == true && |
169 --g_prefer_smoothness_count == 0) { | 169 --g_prefer_smoothness_count == 0) { |
170 SetThreadsPriorityToDefault(main_thread_id_); | 170 SetThreadsPriorityToDefault(main_thread_id_); |
171 } | 171 } |
172 prefers_smoothness_ = prefers_smoothness; | 172 prefers_smoothness_ = prefers_smoothness; |
173 } | 173 } |
174 | 174 |
175 } // namespace content | 175 } // namespace content |
OLD | NEW |