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

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: Fix input handler proxy test build. Created 6 years, 7 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') | content/renderer/input/input_handler_proxy.cc » ('j') | 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 : layer_tree_host_id(layer_tree_host_id), 118 : layer_tree_host_id(layer_tree_host_id),
119 contents_texture_manager(NULL), 119 contents_texture_manager(NULL),
120 begin_main_frame_sent_completion_event(NULL), 120 begin_main_frame_sent_completion_event(NULL),
121 readback_request(NULL), 121 readback_request(NULL),
122 commit_completion_event(NULL), 122 commit_completion_event(NULL),
123 completion_event_for_commit_held_on_tree_activation(NULL), 123 completion_event_for_commit_held_on_tree_activation(NULL),
124 next_frame_is_newly_committed_frame(false), 124 next_frame_is_newly_committed_frame(false),
125 inside_draw(false), 125 inside_draw(false),
126 input_throttled_until_commit(false), 126 input_throttled_until_commit(false),
127 animations_frozen_until_next_draw(false), 127 animations_frozen_until_next_draw(false),
128 did_commit_after_animating(false),
128 renew_tree_priority_pending(false), 129 renew_tree_priority_pending(false),
129 weak_factory(proxy) {} 130 weak_factory(proxy) {
131 }
130 132
131 ThreadProxy::CompositorThreadOnly::~CompositorThreadOnly() {} 133 ThreadProxy::CompositorThreadOnly::~CompositorThreadOnly() {}
132 134
133 ThreadProxy::~ThreadProxy() { 135 ThreadProxy::~ThreadProxy() {
134 TRACE_EVENT0("cc", "ThreadProxy::~ThreadProxy"); 136 TRACE_EVENT0("cc", "ThreadProxy::~ThreadProxy");
135 DCHECK(IsMainThread()); 137 DCHECK(IsMainThread());
136 DCHECK(!main().started); 138 DCHECK(!main().started);
137 } 139 }
138 140
139 bool ThreadProxy::CompositeAndReadback(void* pixels, const gfx::Rect& rect) { 141 bool ThreadProxy::CompositeAndReadback(void* pixels, const gfx::Rect& rect) {
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 DCHECK(IsMainThread()); 558 DCHECK(IsMainThread());
557 return main().commit_request_sent_to_impl_thread; 559 return main().commit_request_sent_to_impl_thread;
558 } 560 }
559 561
560 void ThreadProxy::SetNeedsRedrawOnImplThread() { 562 void ThreadProxy::SetNeedsRedrawOnImplThread() {
561 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsRedrawOnImplThread"); 563 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsRedrawOnImplThread");
562 DCHECK(IsImplThread()); 564 DCHECK(IsImplThread());
563 impl().scheduler->SetNeedsRedraw(); 565 impl().scheduler->SetNeedsRedraw();
564 } 566 }
565 567
568 void ThreadProxy::SetNeedsAnimateOnImplThread() {
569 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsAnimateOnImplThread");
570 DCHECK(IsImplThread());
571 impl().scheduler->SetNeedsAnimate();
572 }
573
566 void ThreadProxy::SetNeedsManageTilesOnImplThread() { 574 void ThreadProxy::SetNeedsManageTilesOnImplThread() {
567 DCHECK(IsImplThread()); 575 DCHECK(IsImplThread());
568 impl().scheduler->SetNeedsManageTiles(); 576 impl().scheduler->SetNeedsManageTiles();
569 } 577 }
570 578
571 void ThreadProxy::SetNeedsRedrawRectOnImplThread(const gfx::Rect& damage_rect) { 579 void ThreadProxy::SetNeedsRedrawRectOnImplThread(const gfx::Rect& damage_rect) {
572 DCHECK(IsImplThread()); 580 DCHECK(IsImplThread());
573 impl().layer_tree_host_impl->SetViewportDamage(damage_rect); 581 impl().layer_tree_host_impl->SetViewportDamage(damage_rect);
574 SetNeedsRedrawOnImplThread(); 582 SetNeedsRedrawOnImplThread();
575 } 583 }
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 DCHECK(impl().scheduler); 1021 DCHECK(impl().scheduler);
1014 DCHECK(impl().scheduler->CommitPending()); 1022 DCHECK(impl().scheduler->CommitPending());
1015 DCHECK(!impl().layer_tree_host_impl->pending_tree()); 1023 DCHECK(!impl().layer_tree_host_impl->pending_tree());
1016 1024
1017 if (did_handle) 1025 if (did_handle)
1018 SetInputThrottledUntilCommitOnImplThread(false); 1026 SetInputThrottledUntilCommitOnImplThread(false);
1019 impl().layer_tree_host_impl->BeginMainFrameAborted(did_handle); 1027 impl().layer_tree_host_impl->BeginMainFrameAborted(did_handle);
1020 impl().scheduler->BeginMainFrameAborted(did_handle); 1028 impl().scheduler->BeginMainFrameAborted(did_handle);
1021 } 1029 }
1022 1030
1031 void ThreadProxy::ScheduledActionAnimate() {
1032 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionAnimate");
1033 DCHECK(IsImplThread());
1034
1035 if (!impl().animations_frozen_until_next_draw) {
1036 impl().animation_time =
1037 impl().layer_tree_host_impl->CurrentFrameTimeTicks();
1038 }
1039 impl().layer_tree_host_impl->Animate(impl().animation_time);
1040 impl().did_commit_after_animating = false;
1041 }
1042
1023 void ThreadProxy::ScheduledActionCommit() { 1043 void ThreadProxy::ScheduledActionCommit() {
1024 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionCommit"); 1044 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionCommit");
1025 DCHECK(IsImplThread()); 1045 DCHECK(IsImplThread());
1026 DCHECK(IsMainThreadBlocked()); 1046 DCHECK(IsMainThreadBlocked());
1027 DCHECK(impl().commit_completion_event); 1047 DCHECK(impl().commit_completion_event);
1028 DCHECK(impl().current_resource_update_controller); 1048 DCHECK(impl().current_resource_update_controller);
1029 1049
1030 // Complete all remaining texture updates. 1050 // Complete all remaining texture updates.
1031 impl().current_resource_update_controller->Finalize(); 1051 impl().current_resource_update_controller->Finalize();
1032 impl().current_resource_update_controller.reset(); 1052 impl().current_resource_update_controller.reset();
1033 1053
1034 if (impl().animations_frozen_until_next_draw) { 1054 if (impl().animations_frozen_until_next_draw) {
1035 impl().animation_freeze_time = 1055 impl().animation_time = std::max(
1036 std::max(impl().animation_freeze_time, 1056 impl().animation_time, blocked_main().last_monotonic_frame_begin_time);
1037 blocked_main().last_monotonic_frame_begin_time);
1038 } 1057 }
1058 impl().did_commit_after_animating = true;
1039 1059
1040 blocked_main().main_thread_inside_commit = true; 1060 blocked_main().main_thread_inside_commit = true;
1041 impl().layer_tree_host_impl->BeginCommit(); 1061 impl().layer_tree_host_impl->BeginCommit();
1042 layer_tree_host()->BeginCommitOnImplThread(impl().layer_tree_host_impl.get()); 1062 layer_tree_host()->BeginCommitOnImplThread(impl().layer_tree_host_impl.get());
1043 layer_tree_host()->FinishCommitOnImplThread( 1063 layer_tree_host()->FinishCommitOnImplThread(
1044 impl().layer_tree_host_impl.get()); 1064 impl().layer_tree_host_impl.get());
1045 blocked_main().main_thread_inside_commit = false; 1065 blocked_main().main_thread_inside_commit = false;
1046 1066
1047 bool hold_commit = layer_tree_host()->settings().impl_side_painting && 1067 bool hold_commit = layer_tree_host()->settings().impl_side_painting &&
1048 blocked_main().commit_waits_for_activation; 1068 blocked_main().commit_waits_for_activation;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 TRACE_EVENT_SYNTHETIC_DELAY("cc.DrawAndSwap"); 1122 TRACE_EVENT_SYNTHETIC_DELAY("cc.DrawAndSwap");
1103 DrawSwapReadbackResult result; 1123 DrawSwapReadbackResult result;
1104 1124
1105 DCHECK(IsImplThread()); 1125 DCHECK(IsImplThread());
1106 DCHECK(impl().layer_tree_host_impl.get()); 1126 DCHECK(impl().layer_tree_host_impl.get());
1107 1127
1108 impl().timing_history.DidStartDrawing(); 1128 impl().timing_history.DidStartDrawing();
1109 base::TimeDelta draw_duration_estimate = DrawDurationEstimate(); 1129 base::TimeDelta draw_duration_estimate = DrawDurationEstimate();
1110 base::AutoReset<bool> mark_inside(&impl().inside_draw, true); 1130 base::AutoReset<bool> mark_inside(&impl().inside_draw, true);
1111 1131
1112 // Advance our animations. 1132 if (impl().did_commit_after_animating) {
1113 base::TimeTicks monotonic_time; 1133 impl().layer_tree_host_impl->Animate(impl().animation_time);
1114 if (impl().animations_frozen_until_next_draw) 1134 impl().did_commit_after_animating = false;
1115 monotonic_time = impl().animation_freeze_time; 1135 }
1116 else
1117 monotonic_time = impl().layer_tree_host_impl->CurrentFrameTimeTicks();
1118 1136
1119 // TODO(enne): This should probably happen post-animate.
1120 if (impl().layer_tree_host_impl->pending_tree()) 1137 if (impl().layer_tree_host_impl->pending_tree())
1121 impl().layer_tree_host_impl->pending_tree()->UpdateDrawProperties(); 1138 impl().layer_tree_host_impl->pending_tree()->UpdateDrawProperties();
1122 impl().layer_tree_host_impl->Animate(monotonic_time);
1123 1139
1124 // This method is called on a forced draw, regardless of whether we are able 1140 // This method is called on a forced draw, regardless of whether we are able
1125 // to produce a frame, as the calling site on main thread is blocked until its 1141 // to produce a frame, as the calling site on main thread is blocked until its
1126 // request completes, and we signal completion here. If CanDraw() is false, we 1142 // request completes, and we signal completion here. If CanDraw() is false, we
1127 // will indicate success=false to the caller, but we must still signal 1143 // will indicate success=false to the caller, but we must still signal
1128 // completion to avoid deadlock. 1144 // completion to avoid deadlock.
1129 1145
1130 // We guard PrepareToDraw() with CanDraw() because it always returns a valid 1146 // We guard PrepareToDraw() with CanDraw() because it always returns a valid
1131 // frame, so can only be used when such a frame is possible. Since 1147 // frame, so can only be used when such a frame is possible. Since
1132 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on 1148 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1166 DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS && 1182 DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS &&
1167 !impl().layer_tree_host_impl->settings().impl_side_painting) { 1183 !impl().layer_tree_host_impl->settings().impl_side_painting) {
1168 // Without impl-side painting, the animated layer that is checkerboarding 1184 // Without impl-side painting, the animated layer that is checkerboarding
1169 // will continue to checkerboard until the next commit. If this layer 1185 // will continue to checkerboard until the next commit. If this layer
1170 // continues to move during the commit, it may continue to checkerboard 1186 // continues to move during the commit, it may continue to checkerboard
1171 // after the commit since the region rasterized during the commit will not 1187 // after the commit since the region rasterized during the commit will not
1172 // match the region that is currently visible; eventually this 1188 // match the region that is currently visible; eventually this
1173 // checkerboarding will be displayed when we force a draw. To avoid this, 1189 // checkerboarding will be displayed when we force a draw. To avoid this,
1174 // we freeze animations until we successfully draw. 1190 // we freeze animations until we successfully draw.
1175 impl().animations_frozen_until_next_draw = true; 1191 impl().animations_frozen_until_next_draw = true;
1176 impl().animation_freeze_time = monotonic_time;
1177 } else { 1192 } else {
1178 DCHECK_NE(DrawSwapReadbackResult::DRAW_SUCCESS, result.draw_result); 1193 DCHECK_NE(DrawSwapReadbackResult::DRAW_SUCCESS, result.draw_result);
1179 } 1194 }
1180 impl().layer_tree_host_impl->DidDrawAllLayers(frame); 1195 impl().layer_tree_host_impl->DidDrawAllLayers(frame);
1181 1196
1182 bool start_ready_animations = draw_frame; 1197 bool start_ready_animations = draw_frame;
1183 impl().layer_tree_host_impl->UpdateAnimationState(start_ready_animations); 1198 impl().layer_tree_host_impl->UpdateAnimationState(start_ready_animations);
1184 1199
1185 // Check for a pending CompositeAndReadback. 1200 // Check for a pending CompositeAndReadback.
1186 if (drawing_for_readback) { 1201 if (drawing_for_readback) {
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
1644 1659
1645 impl().timing_history.DidActivatePendingTree(); 1660 impl().timing_history.DidActivatePendingTree();
1646 } 1661 }
1647 1662
1648 void ThreadProxy::DidManageTiles() { 1663 void ThreadProxy::DidManageTiles() {
1649 DCHECK(IsImplThread()); 1664 DCHECK(IsImplThread());
1650 impl().scheduler->DidManageTiles(); 1665 impl().scheduler->DidManageTiles();
1651 } 1666 }
1652 1667
1653 } // namespace cc 1668 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/thread_proxy.h ('k') | content/renderer/input/input_handler_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698