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

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: Addressed comments and rebased. Created 6 years, 8 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
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 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 DCHECK(IsMainThread()); 576 DCHECK(IsMainThread());
577 return main().commit_request_sent_to_impl_thread; 577 return main().commit_request_sent_to_impl_thread;
578 } 578 }
579 579
580 void ThreadProxy::SetNeedsRedrawOnImplThread() { 580 void ThreadProxy::SetNeedsRedrawOnImplThread() {
581 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsRedrawOnImplThread"); 581 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsRedrawOnImplThread");
582 DCHECK(IsImplThread()); 582 DCHECK(IsImplThread());
583 impl().scheduler->SetNeedsRedraw(); 583 impl().scheduler->SetNeedsRedraw();
584 } 584 }
585 585
586 void ThreadProxy::SetNeedsAnimateOnImplThread() {
587 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsAnimateOnImplThread");
588 DCHECK(IsImplThread());
589 impl().scheduler->SetNeedsAnimate();
590 }
591
586 void ThreadProxy::SetNeedsManageTilesOnImplThread() { 592 void ThreadProxy::SetNeedsManageTilesOnImplThread() {
587 DCHECK(IsImplThread()); 593 DCHECK(IsImplThread());
588 impl().scheduler->SetNeedsManageTiles(); 594 impl().scheduler->SetNeedsManageTiles();
589 } 595 }
590 596
591 void ThreadProxy::SetNeedsRedrawRectOnImplThread(const gfx::Rect& damage_rect) { 597 void ThreadProxy::SetNeedsRedrawRectOnImplThread(const gfx::Rect& damage_rect) {
592 DCHECK(IsImplThread()); 598 DCHECK(IsImplThread());
593 impl().layer_tree_host_impl->SetViewportDamage(damage_rect); 599 impl().layer_tree_host_impl->SetViewportDamage(damage_rect);
594 SetNeedsRedrawOnImplThread(); 600 SetNeedsRedrawOnImplThread();
595 } 601 }
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 DCHECK(impl().scheduler); 1056 DCHECK(impl().scheduler);
1051 DCHECK(impl().scheduler->CommitPending()); 1057 DCHECK(impl().scheduler->CommitPending());
1052 DCHECK(!impl().layer_tree_host_impl->pending_tree()); 1058 DCHECK(!impl().layer_tree_host_impl->pending_tree());
1053 1059
1054 if (did_handle) 1060 if (did_handle)
1055 SetInputThrottledUntilCommitOnImplThread(false); 1061 SetInputThrottledUntilCommitOnImplThread(false);
1056 impl().layer_tree_host_impl->BeginMainFrameAborted(did_handle); 1062 impl().layer_tree_host_impl->BeginMainFrameAborted(did_handle);
1057 impl().scheduler->BeginMainFrameAborted(did_handle); 1063 impl().scheduler->BeginMainFrameAborted(did_handle);
1058 } 1064 }
1059 1065
1066 void ThreadProxy::ScheduledActionAnimate() {
1067 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionAnimate");
1068 DCHECK(IsImplThread());
1069
1070 UpdateBackgroundAnimateTicking();
1071
1072 if (!impl().animations_frozen_until_next_draw) {
1073 impl().animation_time =
1074 impl().layer_tree_host_impl->CurrentFrameTimeTicks();
1075 }
1076 impl().layer_tree_host_impl->Animate(impl().animation_time);
1077 }
1078
1060 void ThreadProxy::ScheduledActionCommit() { 1079 void ThreadProxy::ScheduledActionCommit() {
1061 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionCommit"); 1080 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionCommit");
1062 DCHECK(IsImplThread()); 1081 DCHECK(IsImplThread());
1063 DCHECK(IsMainThreadBlocked()); 1082 DCHECK(IsMainThreadBlocked());
1064 DCHECK(impl().commit_completion_event); 1083 DCHECK(impl().commit_completion_event);
1065 DCHECK(impl().current_resource_update_controller); 1084 DCHECK(impl().current_resource_update_controller);
1066 1085
1067 // Complete all remaining texture updates. 1086 // Complete all remaining texture updates.
1068 impl().current_resource_update_controller->Finalize(); 1087 impl().current_resource_update_controller->Finalize();
1069 impl().current_resource_update_controller.reset(); 1088 impl().current_resource_update_controller.reset();
1070 1089
1071 if (impl().animations_frozen_until_next_draw) { 1090 if (impl().animations_frozen_until_next_draw) {
1072 impl().animation_freeze_time = 1091 impl().animation_time = std::max(
1073 std::max(impl().animation_freeze_time, 1092 impl().animation_time, blocked_main().last_monotonic_frame_begin_time);
1074 blocked_main().last_monotonic_frame_begin_time);
1075 } 1093 }
1076 1094
1077 blocked_main().main_thread_inside_commit = true; 1095 blocked_main().main_thread_inside_commit = true;
1078 impl().layer_tree_host_impl->BeginCommit(); 1096 impl().layer_tree_host_impl->BeginCommit();
1079 layer_tree_host()->BeginCommitOnImplThread(impl().layer_tree_host_impl.get()); 1097 layer_tree_host()->BeginCommitOnImplThread(impl().layer_tree_host_impl.get());
1080 layer_tree_host()->FinishCommitOnImplThread( 1098 layer_tree_host()->FinishCommitOnImplThread(
1081 impl().layer_tree_host_impl.get()); 1099 impl().layer_tree_host_impl.get());
1082 blocked_main().main_thread_inside_commit = false; 1100 blocked_main().main_thread_inside_commit = false;
1083 1101
1084 bool hold_commit = layer_tree_host()->settings().impl_side_painting && 1102 bool hold_commit = layer_tree_host()->settings().impl_side_painting &&
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1139 TRACE_EVENT_SYNTHETIC_DELAY("cc.DrawAndSwap"); 1157 TRACE_EVENT_SYNTHETIC_DELAY("cc.DrawAndSwap");
1140 DrawSwapReadbackResult result; 1158 DrawSwapReadbackResult result;
1141 1159
1142 DCHECK(IsImplThread()); 1160 DCHECK(IsImplThread());
1143 DCHECK(impl().layer_tree_host_impl.get()); 1161 DCHECK(impl().layer_tree_host_impl.get());
1144 1162
1145 impl().timing_history.DidStartDrawing(); 1163 impl().timing_history.DidStartDrawing();
1146 base::TimeDelta draw_duration_estimate = DrawDurationEstimate(); 1164 base::TimeDelta draw_duration_estimate = DrawDurationEstimate();
1147 base::AutoReset<bool> mark_inside(&impl().inside_draw, true); 1165 base::AutoReset<bool> mark_inside(&impl().inside_draw, true);
1148 1166
1149 // Advance our animations.
1150 base::TimeTicks monotonic_time;
1151 if (impl().animations_frozen_until_next_draw)
1152 monotonic_time = impl().animation_freeze_time;
1153 else
1154 monotonic_time = impl().layer_tree_host_impl->CurrentFrameTimeTicks();
1155
1156 // TODO(enne): This should probably happen post-animate.
1157 if (impl().layer_tree_host_impl->pending_tree()) 1167 if (impl().layer_tree_host_impl->pending_tree())
1158 impl().layer_tree_host_impl->pending_tree()->UpdateDrawProperties(); 1168 impl().layer_tree_host_impl->pending_tree()->UpdateDrawProperties();
1159 impl().layer_tree_host_impl->Animate(monotonic_time);
1160 1169
1161 // This method is called on a forced draw, regardless of whether we are able 1170 // This method is called on a forced draw, regardless of whether we are able
1162 // to produce a frame, as the calling site on main thread is blocked until its 1171 // to produce a frame, as the calling site on main thread is blocked until its
1163 // request completes, and we signal completion here. If CanDraw() is false, we 1172 // request completes, and we signal completion here. If CanDraw() is false, we
1164 // will indicate success=false to the caller, but we must still signal 1173 // will indicate success=false to the caller, but we must still signal
1165 // completion to avoid deadlock. 1174 // completion to avoid deadlock.
1166 1175
1167 // We guard PrepareToDraw() with CanDraw() because it always returns a valid 1176 // We guard PrepareToDraw() with CanDraw() because it always returns a valid
1168 // frame, so can only be used when such a frame is possible. Since 1177 // frame, so can only be used when such a frame is possible. Since
1169 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on 1178 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS && 1212 DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS &&
1204 !impl().layer_tree_host_impl->settings().impl_side_painting) { 1213 !impl().layer_tree_host_impl->settings().impl_side_painting) {
1205 // Without impl-side painting, the animated layer that is checkerboarding 1214 // Without impl-side painting, the animated layer that is checkerboarding
1206 // will continue to checkerboard until the next commit. If this layer 1215 // will continue to checkerboard until the next commit. If this layer
1207 // continues to move during the commit, it may continue to checkerboard 1216 // continues to move during the commit, it may continue to checkerboard
1208 // after the commit since the region rasterized during the commit will not 1217 // after the commit since the region rasterized during the commit will not
1209 // match the region that is currently visible; eventually this 1218 // match the region that is currently visible; eventually this
1210 // checkerboarding will be displayed when we force a draw. To avoid this, 1219 // checkerboarding will be displayed when we force a draw. To avoid this,
1211 // we freeze animations until we successfully draw. 1220 // we freeze animations until we successfully draw.
1212 impl().animations_frozen_until_next_draw = true; 1221 impl().animations_frozen_until_next_draw = true;
1213 impl().animation_freeze_time = monotonic_time;
1214 } else { 1222 } else {
1215 DCHECK_NE(DrawSwapReadbackResult::DRAW_SUCCESS, result.draw_result); 1223 DCHECK_NE(DrawSwapReadbackResult::DRAW_SUCCESS, result.draw_result);
1216 } 1224 }
1217 impl().layer_tree_host_impl->DidDrawAllLayers(frame); 1225 impl().layer_tree_host_impl->DidDrawAllLayers(frame);
1218 1226
1219 bool start_ready_animations = draw_frame; 1227 bool start_ready_animations = draw_frame;
1220 impl().layer_tree_host_impl->UpdateAnimationState(start_ready_animations); 1228 impl().layer_tree_host_impl->UpdateAnimationState(start_ready_animations);
1221 1229
1222 // Check for a pending CompositeAndReadback. 1230 // Check for a pending CompositeAndReadback.
1223 if (drawing_for_readback) { 1231 if (drawing_for_readback) {
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
1687 1695
1688 impl().timing_history.DidActivatePendingTree(); 1696 impl().timing_history.DidActivatePendingTree();
1689 } 1697 }
1690 1698
1691 void ThreadProxy::DidManageTiles() { 1699 void ThreadProxy::DidManageTiles() {
1692 DCHECK(IsImplThread()); 1700 DCHECK(IsImplThread());
1693 impl().scheduler->DidManageTiles(); 1701 impl().scheduler->DidManageTiles();
1694 } 1702 }
1695 1703
1696 } // namespace cc 1704 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698