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 #include "cc/trees/thread_proxy.h" | 5 #include "cc/trees/thread_proxy.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 namespace { | 34 namespace { |
35 | 35 |
36 // Measured in seconds. | 36 // Measured in seconds. |
37 const double kSmoothnessTakesPriorityExpirationDelay = 0.25; | 37 const double kSmoothnessTakesPriorityExpirationDelay = 0.25; |
38 | 38 |
39 unsigned int nextBeginFrameId = 0; | 39 unsigned int nextBeginFrameId = 0; |
40 | 40 |
41 } // namespace | 41 } // namespace |
42 | 42 |
43 struct ThreadProxy::CommitPendingRequest { | |
44 CompletionEvent completion; | |
45 bool commit_pending; | |
46 }; | |
47 | |
48 struct ThreadProxy::SchedulerStateRequest { | 43 struct ThreadProxy::SchedulerStateRequest { |
49 CompletionEvent completion; | 44 CompletionEvent completion; |
50 scoped_ptr<base::Value> state; | 45 scoped_ptr<base::Value> state; |
51 }; | 46 }; |
52 | 47 |
53 scoped_ptr<Proxy> ThreadProxy::Create( | 48 scoped_ptr<Proxy> ThreadProxy::Create( |
54 LayerTreeHost* layer_tree_host, | 49 LayerTreeHost* layer_tree_host, |
55 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 50 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
56 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { | 51 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { |
57 return make_scoped_ptr(new ThreadProxy(layer_tree_host, | 52 return make_scoped_ptr(new ThreadProxy(layer_tree_host, |
(...skipping 1233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1291 } | 1286 } |
1292 | 1287 |
1293 void ThreadProxy::AsValueOnImplThread(CompletionEvent* completion, | 1288 void ThreadProxy::AsValueOnImplThread(CompletionEvent* completion, |
1294 base::debug::TracedValue* state) const { | 1289 base::debug::TracedValue* state) const { |
1295 state->BeginDictionary("layer_tree_host_impl"); | 1290 state->BeginDictionary("layer_tree_host_impl"); |
1296 impl().layer_tree_host_impl->AsValueInto(state); | 1291 impl().layer_tree_host_impl->AsValueInto(state); |
1297 state->EndDictionary(); | 1292 state->EndDictionary(); |
1298 completion->Signal(); | 1293 completion->Signal(); |
1299 } | 1294 } |
1300 | 1295 |
1301 bool ThreadProxy::CommitPendingForTesting() { | 1296 bool ThreadProxy::MainFrameWillHappenForTesting() { |
1302 DCHECK(IsMainThread()); | 1297 DCHECK(IsMainThread()); |
1303 CommitPendingRequest commit_pending_request; | 1298 CompletionEvent completion; |
| 1299 bool main_frame_will_happen = false; |
1304 { | 1300 { |
1305 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 1301 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
1306 Proxy::ImplThreadTaskRunner()->PostTask( | 1302 Proxy::ImplThreadTaskRunner()->PostTask( |
1307 FROM_HERE, | 1303 FROM_HERE, |
1308 base::Bind(&ThreadProxy::CommitPendingOnImplThreadForTesting, | 1304 base::Bind(&ThreadProxy::MainFrameWillHappenOnImplThreadForTesting, |
1309 impl_thread_weak_ptr_, | 1305 impl_thread_weak_ptr_, |
1310 &commit_pending_request)); | 1306 &completion, |
1311 commit_pending_request.completion.Wait(); | 1307 &main_frame_will_happen)); |
| 1308 completion.Wait(); |
1312 } | 1309 } |
1313 return commit_pending_request.commit_pending; | 1310 return main_frame_will_happen; |
1314 } | 1311 } |
1315 | 1312 |
1316 void ThreadProxy::CommitPendingOnImplThreadForTesting( | 1313 void ThreadProxy::MainFrameWillHappenOnImplThreadForTesting( |
1317 CommitPendingRequest* request) { | 1314 CompletionEvent* completion, |
| 1315 bool* main_frame_will_happen) { |
1318 DCHECK(IsImplThread()); | 1316 DCHECK(IsImplThread()); |
1319 if (impl().layer_tree_host_impl->output_surface()) | 1317 if (impl().layer_tree_host_impl->output_surface()) { |
1320 request->commit_pending = impl().scheduler->CommitPending(); | 1318 *main_frame_will_happen = impl().scheduler->MainFrameForTestingWillHappen(); |
1321 else | 1319 } else { |
1322 request->commit_pending = false; | 1320 *main_frame_will_happen = false; |
1323 request->completion.Signal(); | 1321 } |
| 1322 completion->Signal(); |
1324 } | 1323 } |
1325 | 1324 |
1326 void ThreadProxy::RenewTreePriority() { | 1325 void ThreadProxy::RenewTreePriority() { |
1327 DCHECK(IsImplThread()); | 1326 DCHECK(IsImplThread()); |
1328 bool smoothness_takes_priority = | 1327 bool smoothness_takes_priority = |
1329 impl().layer_tree_host_impl->pinch_gesture_active() || | 1328 impl().layer_tree_host_impl->pinch_gesture_active() || |
1330 impl().layer_tree_host_impl->page_scale_animation_active() || | 1329 impl().layer_tree_host_impl->page_scale_animation_active() || |
1331 (impl().layer_tree_host_impl->IsCurrentlyScrolling() && | 1330 (impl().layer_tree_host_impl->IsCurrentlyScrolling() && |
1332 !impl().layer_tree_host_impl->scroll_affects_scroll_handler()); | 1331 !impl().layer_tree_host_impl->scroll_affects_scroll_handler()); |
1333 | 1332 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1391 | 1390 |
1392 impl().timing_history.DidActivateSyncTree(); | 1391 impl().timing_history.DidActivateSyncTree(); |
1393 } | 1392 } |
1394 | 1393 |
1395 void ThreadProxy::DidManageTiles() { | 1394 void ThreadProxy::DidManageTiles() { |
1396 DCHECK(IsImplThread()); | 1395 DCHECK(IsImplThread()); |
1397 impl().scheduler->DidManageTiles(); | 1396 impl().scheduler->DidManageTiles(); |
1398 } | 1397 } |
1399 | 1398 |
1400 } // namespace cc | 1399 } // namespace cc |
OLD | NEW |