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 "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "cc/base/thread.h" | 10 #include "cc/base/thread.h" |
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 TRACE_EVENT0("cc", "ThreadProxy::FinishAllRenderingOnImplThread"); | 598 TRACE_EVENT0("cc", "ThreadProxy::FinishAllRenderingOnImplThread"); |
599 DCHECK(IsImplThread()); | 599 DCHECK(IsImplThread()); |
600 layer_tree_host_impl_->FinishAllRendering(); | 600 layer_tree_host_impl_->FinishAllRendering(); |
601 completion->Signal(); | 601 completion->Signal(); |
602 } | 602 } |
603 | 603 |
604 void ThreadProxy::ScheduledActionSendBeginFrameToMainThread() { | 604 void ThreadProxy::ScheduledActionSendBeginFrameToMainThread() { |
605 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionSendBeginFrameToMainThread"); | 605 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionSendBeginFrameToMainThread"); |
606 scoped_ptr<BeginFrameAndCommitState> begin_frame_state( | 606 scoped_ptr<BeginFrameAndCommitState> begin_frame_state( |
607 new BeginFrameAndCommitState); | 607 new BeginFrameAndCommitState); |
608 begin_frame_state->monotonic_frame_begin_time = base::TimeTicks::Now(); | 608 begin_frame_state->monotonic_frame_begin_time = |
| 609 layer_tree_host_impl_->CurrentPhysicalTimeTicks(); |
609 begin_frame_state->scroll_info = | 610 begin_frame_state->scroll_info = |
610 layer_tree_host_impl_->ProcessScrollDeltas(); | 611 layer_tree_host_impl_->ProcessScrollDeltas(); |
611 DCHECK_GT(layer_tree_host_impl_->memory_allocation_limit_bytes(), 0u); | 612 DCHECK_GT(layer_tree_host_impl_->memory_allocation_limit_bytes(), 0u); |
612 begin_frame_state->memory_allocation_limit_bytes = | 613 begin_frame_state->memory_allocation_limit_bytes = |
613 layer_tree_host_impl_->memory_allocation_limit_bytes(); | 614 layer_tree_host_impl_->memory_allocation_limit_bytes(); |
614 Proxy::MainThread()->PostTask( | 615 Proxy::MainThread()->PostTask( |
615 base::Bind(&ThreadProxy::BeginFrameOnMainThread, | 616 base::Bind(&ThreadProxy::BeginFrameOnMainThread, |
616 main_thread_weak_ptr_, | 617 main_thread_weak_ptr_, |
617 base::Passed(&begin_frame_state))); | 618 base::Passed(&begin_frame_state))); |
618 | 619 |
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1293 *picture = layer_tree_host_impl_->CapturePicture(); | 1294 *picture = layer_tree_host_impl_->CapturePicture(); |
1294 completion->Signal(); | 1295 completion->Signal(); |
1295 } | 1296 } |
1296 | 1297 |
1297 void ThreadProxy::RenewTreePriority() { | 1298 void ThreadProxy::RenewTreePriority() { |
1298 bool smoothness_takes_priority = | 1299 bool smoothness_takes_priority = |
1299 layer_tree_host_impl_->pinch_gesture_active() || | 1300 layer_tree_host_impl_->pinch_gesture_active() || |
1300 layer_tree_host_impl_->CurrentlyScrollingLayer() || | 1301 layer_tree_host_impl_->CurrentlyScrollingLayer() || |
1301 layer_tree_host_impl_->page_scale_animation_active(); | 1302 layer_tree_host_impl_->page_scale_animation_active(); |
1302 | 1303 |
| 1304 base::TimeTicks now = layer_tree_host_impl_->CurrentPhysicalTimeTicks(); |
| 1305 |
1303 // Update expiration time if smoothness currently takes priority. | 1306 // Update expiration time if smoothness currently takes priority. |
1304 if (smoothness_takes_priority) { | 1307 if (smoothness_takes_priority) { |
1305 smoothness_takes_priority_expiration_time_ = | 1308 smoothness_takes_priority_expiration_time_ = |
1306 base::TimeTicks::Now() + | 1309 now + base::TimeDelta::FromMilliseconds( |
1307 base::TimeDelta::FromMilliseconds( | 1310 kSmoothnessTakesPriorityExpirationDelay * 1000); |
1308 kSmoothnessTakesPriorityExpirationDelay * 1000); | |
1309 } | 1311 } |
1310 | 1312 |
1311 // We use the same priority for both trees by default. | 1313 // We use the same priority for both trees by default. |
1312 TreePriority priority = SAME_PRIORITY_FOR_BOTH_TREES; | 1314 TreePriority priority = SAME_PRIORITY_FOR_BOTH_TREES; |
1313 | 1315 |
1314 // Smoothness takes priority if expiration time is in the future. | 1316 // Smoothness takes priority if expiration time is in the future. |
1315 if (smoothness_takes_priority_expiration_time_ > base::TimeTicks::Now()) | 1317 if (smoothness_takes_priority_expiration_time_ > now) |
1316 priority = SMOOTHNESS_TAKES_PRIORITY; | 1318 priority = SMOOTHNESS_TAKES_PRIORITY; |
1317 | 1319 |
1318 // New content always takes priority when the active tree has | 1320 // New content always takes priority when the active tree has |
1319 // evicted resources or there is an invalid viewport size. | 1321 // evicted resources or there is an invalid viewport size. |
1320 if (layer_tree_host_impl_->active_tree()->ContentsTexturesPurged() || | 1322 if (layer_tree_host_impl_->active_tree()->ContentsTexturesPurged() || |
1321 layer_tree_host_impl_->active_tree()->ViewportSizeInvalid()) | 1323 layer_tree_host_impl_->active_tree()->ViewportSizeInvalid()) |
1322 priority = NEW_CONTENT_TAKES_PRIORITY; | 1324 priority = NEW_CONTENT_TAKES_PRIORITY; |
1323 | 1325 |
1324 layer_tree_host_impl_->SetTreePriority(priority); | 1326 layer_tree_host_impl_->SetTreePriority(priority); |
1325 | 1327 |
1326 // Notify the the client of this compositor via the output surface. | 1328 // Notify the the client of this compositor via the output surface. |
1327 // TODO(epenner): Route this to compositor-thread instead of output-surface | 1329 // TODO(epenner): Route this to compositor-thread instead of output-surface |
1328 // after GTFO refactor of compositor-thread (http://crbug/170828). | 1330 // after GTFO refactor of compositor-thread (http://crbug/170828). |
1329 if (layer_tree_host_impl_->output_surface()) { | 1331 if (layer_tree_host_impl_->output_surface()) { |
1330 layer_tree_host_impl_->output_surface()-> | 1332 layer_tree_host_impl_->output_surface()-> |
1331 UpdateSmoothnessTakesPriority(priority == SMOOTHNESS_TAKES_PRIORITY); | 1333 UpdateSmoothnessTakesPriority(priority == SMOOTHNESS_TAKES_PRIORITY); |
1332 } | 1334 } |
1333 | 1335 |
1334 base::TimeDelta delay = | 1336 base::TimeDelta delay = smoothness_takes_priority_expiration_time_ - now; |
1335 smoothness_takes_priority_expiration_time_ - base::TimeTicks::Now(); | |
1336 | 1337 |
1337 // Need to make sure a delayed task is posted when we have smoothness | 1338 // Need to make sure a delayed task is posted when we have smoothness |
1338 // takes priority expiration time in the future. | 1339 // takes priority expiration time in the future. |
1339 if (delay <= base::TimeDelta()) | 1340 if (delay <= base::TimeDelta()) |
1340 return; | 1341 return; |
1341 if (renew_tree_priority_on_impl_thread_pending_) | 1342 if (renew_tree_priority_on_impl_thread_pending_) |
1342 return; | 1343 return; |
1343 | 1344 |
1344 Proxy::ImplThread()->PostDelayedTask( | 1345 Proxy::ImplThread()->PostDelayedTask( |
1345 base::Bind(&ThreadProxy::RenewTreePriorityOnImplThread, | 1346 base::Bind(&ThreadProxy::RenewTreePriorityOnImplThread, |
(...skipping 11 matching lines...) Expand all Loading... |
1357 } | 1358 } |
1358 | 1359 |
1359 void ThreadProxy::RequestScrollbarAnimationOnImplThread(base::TimeDelta delay) { | 1360 void ThreadProxy::RequestScrollbarAnimationOnImplThread(base::TimeDelta delay) { |
1360 Proxy::ImplThread()->PostDelayedTask( | 1361 Proxy::ImplThread()->PostDelayedTask( |
1361 base::Bind(&ThreadProxy::StartScrollbarAnimationOnImplThread, | 1362 base::Bind(&ThreadProxy::StartScrollbarAnimationOnImplThread, |
1362 impl_thread_weak_ptr_), | 1363 impl_thread_weak_ptr_), |
1363 delay); | 1364 delay); |
1364 } | 1365 } |
1365 | 1366 |
1366 void ThreadProxy::StartScrollbarAnimationOnImplThread() { | 1367 void ThreadProxy::StartScrollbarAnimationOnImplThread() { |
1367 layer_tree_host_impl_->StartScrollbarAnimation( | 1368 layer_tree_host_impl_->StartScrollbarAnimation(); |
1368 layer_tree_host_impl_->CurrentFrameTimeTicks()); | |
1369 } | 1369 } |
1370 | 1370 |
1371 void ThreadProxy::DidActivatePendingTree() { | 1371 void ThreadProxy::DidActivatePendingTree() { |
1372 DCHECK(IsImplThread()); | 1372 DCHECK(IsImplThread()); |
1373 TRACE_EVENT0("cc", "ThreadProxy::DidActivatePendingTreeOnImplThread"); | 1373 TRACE_EVENT0("cc", "ThreadProxy::DidActivatePendingTreeOnImplThread"); |
1374 | 1374 |
1375 if (completion_event_for_commit_held_on_tree_activation_ && | 1375 if (completion_event_for_commit_held_on_tree_activation_ && |
1376 !layer_tree_host_impl_->pending_tree()) { | 1376 !layer_tree_host_impl_->pending_tree()) { |
1377 TRACE_EVENT_INSTANT0("cc", "ReleaseCommitbyActivation", | 1377 TRACE_EVENT_INSTANT0("cc", "ReleaseCommitbyActivation", |
1378 TRACE_EVENT_SCOPE_THREAD); | 1378 TRACE_EVENT_SCOPE_THREAD); |
1379 DCHECK(layer_tree_host_impl_->settings().impl_side_painting); | 1379 DCHECK(layer_tree_host_impl_->settings().impl_side_painting); |
1380 completion_event_for_commit_held_on_tree_activation_->Signal(); | 1380 completion_event_for_commit_held_on_tree_activation_->Signal(); |
1381 completion_event_for_commit_held_on_tree_activation_ = NULL; | 1381 completion_event_for_commit_held_on_tree_activation_ = NULL; |
1382 } | 1382 } |
1383 } | 1383 } |
1384 | 1384 |
1385 } // namespace cc | 1385 } // namespace cc |
OLD | NEW |