Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Side by Side Diff: cc/trees/thread_proxy.cc

Issue 206793003: cc: Split animating and drawing into separate actions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/trees/thread_proxy.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 void ThreadProxy::SetNeedsBeginImplFrame(bool enable) { 446 void ThreadProxy::SetNeedsBeginImplFrame(bool enable) {
447 TRACE_EVENT1("cc", "ThreadProxy::SetNeedsBeginImplFrame", "enable", enable); 447 TRACE_EVENT1("cc", "ThreadProxy::SetNeedsBeginImplFrame", "enable", enable);
448 DCHECK(IsImplThread()); 448 DCHECK(IsImplThread());
449 impl().layer_tree_host_impl->SetNeedsBeginImplFrame(enable); 449 impl().layer_tree_host_impl->SetNeedsBeginImplFrame(enable);
450 UpdateBackgroundAnimateTicking(); 450 UpdateBackgroundAnimateTicking();
451 } 451 }
452 452
453 void ThreadProxy::BeginImplFrame(const BeginFrameArgs& args) { 453 void ThreadProxy::BeginImplFrame(const BeginFrameArgs& args) {
454 TRACE_EVENT0("cc", "ThreadProxy::BeginImplFrame"); 454 TRACE_EVENT0("cc", "ThreadProxy::BeginImplFrame");
455 DCHECK(IsImplThread()); 455 DCHECK(IsImplThread());
456
457 // Sample the frame time now. This time will be used for updating animations
458 // when we draw.
459 impl().layer_tree_host_impl->CurrentFrameTimeTicks();
460
461 impl().scheduler->BeginImplFrame(args); 456 impl().scheduler->BeginImplFrame(args);
462 } 457 }
463 458
464 void ThreadProxy::OnCanDrawStateChanged(bool can_draw) { 459 void ThreadProxy::OnCanDrawStateChanged(bool can_draw) {
465 TRACE_EVENT1( 460 TRACE_EVENT1(
466 "cc", "ThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); 461 "cc", "ThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw);
467 DCHECK(IsImplThread()); 462 DCHECK(IsImplThread());
468 impl().scheduler->SetCanDraw(can_draw); 463 impl().scheduler->SetCanDraw(can_draw);
469 UpdateBackgroundAnimateTicking(); 464 UpdateBackgroundAnimateTicking();
470 } 465 }
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 DCHECK(impl().scheduler); 1041 DCHECK(impl().scheduler);
1047 DCHECK(impl().scheduler->CommitPending()); 1042 DCHECK(impl().scheduler->CommitPending());
1048 DCHECK(!impl().layer_tree_host_impl->pending_tree()); 1043 DCHECK(!impl().layer_tree_host_impl->pending_tree());
1049 1044
1050 if (did_handle) 1045 if (did_handle)
1051 SetInputThrottledUntilCommitOnImplThread(false); 1046 SetInputThrottledUntilCommitOnImplThread(false);
1052 impl().layer_tree_host_impl->BeginMainFrameAborted(did_handle); 1047 impl().layer_tree_host_impl->BeginMainFrameAborted(did_handle);
1053 impl().scheduler->BeginMainFrameAborted(did_handle); 1048 impl().scheduler->BeginMainFrameAborted(did_handle);
1054 } 1049 }
1055 1050
1051 void ThreadProxy::ScheduledActionAnimate() {
1052 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionAnimate");
1053 DCHECK(IsImplThread());
1054
1055 if (!impl().animations_frozen_until_next_draw) {
1056 impl().animation_time =
1057 impl().layer_tree_host_impl->CurrentFrameTimeTicks();
1058 }
1059
1060 // TODO(enne): This should probably happen post-animate.
1061 if (impl().layer_tree_host_impl->pending_tree())
1062 impl().layer_tree_host_impl->pending_tree()->UpdateDrawProperties();
ajuma 2014/03/21 15:05:14 We should move this down by a line so that it happ
1063 impl().layer_tree_host_impl->Animate(impl().animation_time);
1064 }
1065
1056 void ThreadProxy::ScheduledActionCommit() { 1066 void ThreadProxy::ScheduledActionCommit() {
1057 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionCommit"); 1067 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionCommit");
1058 DCHECK(IsImplThread()); 1068 DCHECK(IsImplThread());
1059 DCHECK(IsMainThreadBlocked()); 1069 DCHECK(IsMainThreadBlocked());
1060 DCHECK(impl().commit_completion_event); 1070 DCHECK(impl().commit_completion_event);
1061 DCHECK(impl().current_resource_update_controller); 1071 DCHECK(impl().current_resource_update_controller);
1062 1072
1063 // Complete all remaining texture updates. 1073 // Complete all remaining texture updates.
1064 impl().current_resource_update_controller->Finalize(); 1074 impl().current_resource_update_controller->Finalize();
1065 impl().current_resource_update_controller.reset(); 1075 impl().current_resource_update_controller.reset();
1066 1076
1067 if (impl().animations_frozen_until_next_draw) { 1077 if (impl().animations_frozen_until_next_draw) {
1068 impl().animation_freeze_time = 1078 impl().animation_time = std::max(
1069 std::max(impl().animation_freeze_time, 1079 impl().animation_time, blocked_main().last_monotonic_frame_begin_time);
1070 blocked_main().last_monotonic_frame_begin_time);
1071 } 1080 }
1072 1081
1073 blocked_main().main_thread_inside_commit = true; 1082 blocked_main().main_thread_inside_commit = true;
1074 impl().layer_tree_host_impl->BeginCommit(); 1083 impl().layer_tree_host_impl->BeginCommit();
1075 layer_tree_host()->BeginCommitOnImplThread(impl().layer_tree_host_impl.get()); 1084 layer_tree_host()->BeginCommitOnImplThread(impl().layer_tree_host_impl.get());
1076 layer_tree_host()->FinishCommitOnImplThread( 1085 layer_tree_host()->FinishCommitOnImplThread(
1077 impl().layer_tree_host_impl.get()); 1086 impl().layer_tree_host_impl.get());
1078 blocked_main().main_thread_inside_commit = false; 1087 blocked_main().main_thread_inside_commit = false;
1079 1088
1080 bool hold_commit = layer_tree_host()->settings().impl_side_painting && 1089 bool hold_commit = layer_tree_host()->settings().impl_side_painting &&
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 TRACE_EVENT_SYNTHETIC_DELAY("cc.DrawAndSwap"); 1147 TRACE_EVENT_SYNTHETIC_DELAY("cc.DrawAndSwap");
1139 DrawSwapReadbackResult result; 1148 DrawSwapReadbackResult result;
1140 1149
1141 DCHECK(IsImplThread()); 1150 DCHECK(IsImplThread());
1142 DCHECK(impl().layer_tree_host_impl.get()); 1151 DCHECK(impl().layer_tree_host_impl.get());
1143 1152
1144 impl().timing_history.DidStartDrawing(); 1153 impl().timing_history.DidStartDrawing();
1145 base::TimeDelta draw_duration_estimate = DrawDurationEstimate(); 1154 base::TimeDelta draw_duration_estimate = DrawDurationEstimate();
1146 base::AutoReset<bool> mark_inside(&impl().inside_draw, true); 1155 base::AutoReset<bool> mark_inside(&impl().inside_draw, true);
1147 1156
1148 // Advance our animations.
1149 base::TimeTicks monotonic_time;
1150 if (impl().animations_frozen_until_next_draw)
1151 monotonic_time = impl().animation_freeze_time;
1152 else
1153 monotonic_time = impl().layer_tree_host_impl->CurrentFrameTimeTicks();
1154
1155 // TODO(enne): This should probably happen post-animate.
1156 if (impl().layer_tree_host_impl->pending_tree())
1157 impl().layer_tree_host_impl->pending_tree()->UpdateDrawProperties();
1158 impl().layer_tree_host_impl->Animate(monotonic_time);
1159
1160 // This method is called on a forced draw, regardless of whether we are able 1157 // This method is called on a forced draw, regardless of whether we are able
1161 // to produce a frame, as the calling site on main thread is blocked until its 1158 // to produce a frame, as the calling site on main thread is blocked until its
1162 // request completes, and we signal completion here. If CanDraw() is false, we 1159 // request completes, and we signal completion here. If CanDraw() is false, we
1163 // will indicate success=false to the caller, but we must still signal 1160 // will indicate success=false to the caller, but we must still signal
1164 // completion to avoid deadlock. 1161 // completion to avoid deadlock.
1165 1162
1166 // We guard PrepareToDraw() with CanDraw() because it always returns a valid 1163 // We guard PrepareToDraw() with CanDraw() because it always returns a valid
1167 // frame, so can only be used when such a frame is possible. Since 1164 // frame, so can only be used when such a frame is possible. Since
1168 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on 1165 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on
1169 // CanDraw() as well. 1166 // CanDraw() as well.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1202 DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS && 1199 DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS &&
1203 !impl().layer_tree_host_impl->settings().impl_side_painting) { 1200 !impl().layer_tree_host_impl->settings().impl_side_painting) {
1204 // Without impl-side painting, the animated layer that is checkerboarding 1201 // Without impl-side painting, the animated layer that is checkerboarding
1205 // will continue to checkerboard until the next commit. If this layer 1202 // will continue to checkerboard until the next commit. If this layer
1206 // continues to move during the commit, it may continue to checkerboard 1203 // continues to move during the commit, it may continue to checkerboard
1207 // after the commit since the region rasterized during the commit will not 1204 // after the commit since the region rasterized during the commit will not
1208 // match the region that is currently visible; eventually this 1205 // match the region that is currently visible; eventually this
1209 // checkerboarding will be displayed when we force a draw. To avoid this, 1206 // checkerboarding will be displayed when we force a draw. To avoid this,
1210 // we freeze animations until we successfully draw. 1207 // we freeze animations until we successfully draw.
1211 impl().animations_frozen_until_next_draw = true; 1208 impl().animations_frozen_until_next_draw = true;
1212 impl().animation_freeze_time = monotonic_time;
1213 } else { 1209 } else {
1214 DCHECK_NE(DrawSwapReadbackResult::DRAW_SUCCESS, result.draw_result); 1210 DCHECK_NE(DrawSwapReadbackResult::DRAW_SUCCESS, result.draw_result);
1215 } 1211 }
1216 impl().layer_tree_host_impl->DidDrawAllLayers(frame); 1212 impl().layer_tree_host_impl->DidDrawAllLayers(frame);
1217 1213
1218 bool start_ready_animations = draw_frame; 1214 bool start_ready_animations = draw_frame;
1219 impl().layer_tree_host_impl->UpdateAnimationState(start_ready_animations); 1215 impl().layer_tree_host_impl->UpdateAnimationState(start_ready_animations);
1220 1216
1221 // Check for a pending CompositeAndReadback. 1217 // Check for a pending CompositeAndReadback.
1222 if (drawing_for_readback) { 1218 if (drawing_for_readback) {
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
1732 1728
1733 impl().timing_history.DidActivatePendingTree(); 1729 impl().timing_history.DidActivatePendingTree();
1734 } 1730 }
1735 1731
1736 void ThreadProxy::DidManageTiles() { 1732 void ThreadProxy::DidManageTiles() {
1737 DCHECK(IsImplThread()); 1733 DCHECK(IsImplThread());
1738 impl().scheduler->DidManageTiles(); 1734 impl().scheduler->DidManageTiles();
1739 } 1735 }
1740 1736
1741 } // namespace cc 1737 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/thread_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698