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

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

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

Powered by Google App Engine
This is Rietveld 408576698