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

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

Issue 26880010: gfx: Add FrameTime and DisplayTime classes (Closed) Base URL: http://git.chromium.org/chromium/src.git@checkHighResNow4
Patch Set: WIP Created 7 years, 1 month 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
« no previous file with comments | « cc/trees/thread_proxy.h ('k') | chrome/browser/ui/autofill/loading_animation.h » ('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 <string> 7 #include <string>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 DCHECK(IsImplThread()); 682 DCHECK(IsImplThread());
683 layer_tree_host_impl_->FinishAllRendering(); 683 layer_tree_host_impl_->FinishAllRendering();
684 completion->Signal(); 684 completion->Signal();
685 } 685 }
686 686
687 void ThreadProxy::ScheduledActionSendBeginMainFrame() { 687 void ThreadProxy::ScheduledActionSendBeginMainFrame() {
688 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionSendBeginMainFrame"); 688 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionSendBeginMainFrame");
689 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state( 689 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state(
690 new BeginMainFrameAndCommitState); 690 new BeginMainFrameAndCommitState);
691 begin_main_frame_state->monotonic_frame_begin_time = 691 begin_main_frame_state->monotonic_frame_begin_time =
692 layer_tree_host_impl_->CurrentPhysicalTimeTicks(); 692 layer_tree_host_impl_->CurrentFrameTimeTicks();
693 begin_main_frame_state->scroll_info = 693 begin_main_frame_state->scroll_info =
694 layer_tree_host_impl_->ProcessScrollDeltas(); 694 layer_tree_host_impl_->ProcessScrollDeltas();
695 695
696 if (!layer_tree_host_impl_->settings().impl_side_painting) { 696 if (!layer_tree_host_impl_->settings().impl_side_painting) {
697 DCHECK_GT(layer_tree_host_impl_->memory_allocation_limit_bytes(), 0u); 697 DCHECK_GT(layer_tree_host_impl_->memory_allocation_limit_bytes(), 0u);
698 } 698 }
699 begin_main_frame_state->memory_allocation_limit_bytes = 699 begin_main_frame_state->memory_allocation_limit_bytes =
700 layer_tree_host_impl_->memory_allocation_limit_bytes(); 700 layer_tree_host_impl_->memory_allocation_limit_bytes();
701 begin_main_frame_state->memory_allocation_priority_cutoff = 701 begin_main_frame_state->memory_allocation_priority_cutoff =
702 layer_tree_host_impl_->memory_allocation_priority_cutoff(); 702 layer_tree_host_impl_->memory_allocation_priority_cutoff();
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 1037
1038 DCHECK(layer_tree_host_impl_->renderer()); 1038 DCHECK(layer_tree_host_impl_->renderer());
1039 if (!layer_tree_host_impl_->renderer()) 1039 if (!layer_tree_host_impl_->renderer())
1040 return result; 1040 return result;
1041 1041
1042 base::TimeTicks start_time = base::TimeTicks::HighResNow(); 1042 base::TimeTicks start_time = base::TimeTicks::HighResNow();
1043 base::TimeDelta draw_duration_estimate = DrawDurationEstimate(); 1043 base::TimeDelta draw_duration_estimate = DrawDurationEstimate();
1044 base::AutoReset<bool> mark_inside(&inside_draw_, true); 1044 base::AutoReset<bool> mark_inside(&inside_draw_, true);
1045 1045
1046 // Advance our animations. 1046 // Advance our animations.
1047 base::TimeTicks monotonic_time = 1047 gfx::FrameTime monotonic_time =
1048 layer_tree_host_impl_->CurrentFrameTimeTicks(); 1048 layer_tree_host_impl_->CurrentFrameTimeTicks();
1049 base::Time wall_clock_time = layer_tree_host_impl_->CurrentFrameTime(); 1049 base::Time wall_clock_time = layer_tree_host_impl_->CurrentFrameTime();
1050 1050
1051 // TODO(enne): This should probably happen post-animate. 1051 // TODO(enne): This should probably happen post-animate.
1052 if (layer_tree_host_impl_->pending_tree()) 1052 if (layer_tree_host_impl_->pending_tree())
1053 layer_tree_host_impl_->pending_tree()->UpdateDrawProperties(); 1053 layer_tree_host_impl_->pending_tree()->UpdateDrawProperties();
1054 layer_tree_host_impl_->Animate(monotonic_time, wall_clock_time); 1054 layer_tree_host_impl_->Animate(monotonic_time, wall_clock_time);
1055 1055
1056 // This method is called on a forced draw, regardless of whether we are able 1056 // This method is called on a forced draw, regardless of whether we are able
1057 // to produce a frame, as the calling site on main thread is blocked until its 1057 // to produce a frame, as the calling site on main thread is blocked until its
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1223 1223
1224 DrawSwapReadbackResult ThreadProxy::ScheduledActionDrawAndReadback() { 1224 DrawSwapReadbackResult ThreadProxy::ScheduledActionDrawAndReadback() {
1225 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionDrawAndReadback"); 1225 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionDrawAndReadback");
1226 bool forced_draw = true; 1226 bool forced_draw = true;
1227 bool swap_requested = false; 1227 bool swap_requested = false;
1228 bool readback_requested = true; 1228 bool readback_requested = true;
1229 return DrawSwapReadbackInternal( 1229 return DrawSwapReadbackInternal(
1230 forced_draw, swap_requested, readback_requested); 1230 forced_draw, swap_requested, readback_requested);
1231 } 1231 }
1232 1232
1233 void ThreadProxy::DidAnticipatedDrawTimeChange(base::TimeTicks time) { 1233 void ThreadProxy::DidAnticipatedDrawTimeChange(gfx::FrameTime time) {
1234 if (current_resource_update_controller_on_impl_thread_) 1234 if (current_resource_update_controller_on_impl_thread_)
1235 current_resource_update_controller_on_impl_thread_->PerformMoreUpdates( 1235 current_resource_update_controller_on_impl_thread_->PerformMoreUpdates(
1236 time); 1236 time);
1237 } 1237 }
1238 1238
1239 base::TimeDelta ThreadProxy::DrawDurationEstimate() { 1239 base::TimeDelta ThreadProxy::DrawDurationEstimate() {
1240 base::TimeDelta historical_estimate = 1240 base::TimeDelta historical_estimate =
1241 draw_duration_history_.Percentile(kDrawDurationEstimationPercentile); 1241 draw_duration_history_.Percentile(kDrawDurationEstimationPercentile);
1242 base::TimeDelta padding = base::TimeDelta::FromMicroseconds( 1242 base::TimeDelta padding = base::TimeDelta::FromMicroseconds(
1243 kDrawDurationEstimatePaddingInMicroseconds); 1243 kDrawDurationEstimatePaddingInMicroseconds);
1244 return historical_estimate + padding; 1244 return historical_estimate + padding;
1245 } 1245 }
1246 1246
1247 base::TimeDelta ThreadProxy::BeginMainFrameToCommitDurationEstimate() { 1247 base::TimeDelta ThreadProxy::BeginMainFrameToCommitDurationEstimate() {
1248 return begin_main_frame_to_commit_duration_history_.Percentile( 1248 return begin_main_frame_to_commit_duration_history_.Percentile(
1249 kCommitAndActivationDurationEstimationPercentile); 1249 kCommitAndActivationDurationEstimationPercentile);
1250 } 1250 }
1251 1251
1252 base::TimeDelta ThreadProxy::CommitToActivateDurationEstimate() { 1252 base::TimeDelta ThreadProxy::CommitToActivateDurationEstimate() {
1253 return commit_to_activate_duration_history_.Percentile( 1253 return commit_to_activate_duration_history_.Percentile(
1254 kCommitAndActivationDurationEstimationPercentile); 1254 kCommitAndActivationDurationEstimationPercentile);
1255 } 1255 }
1256 1256
1257 void ThreadProxy::PostBeginImplFrameDeadline(const base::Closure& closure, 1257 void ThreadProxy::PostBeginImplFrameDeadline(
1258 base::TimeTicks deadline) { 1258 const base::Closure& closure,
1259 gfx::FrameTime deadline) {
1259 base::TimeDelta delta = deadline - gfx::FrameTime::Now(); 1260 base::TimeDelta delta = deadline - gfx::FrameTime::Now();
1260 if (delta <= base::TimeDelta()) 1261 if (delta <= base::TimeDelta())
1261 delta = base::TimeDelta(); 1262 delta = base::TimeDelta();
1262 Proxy::ImplThreadTaskRunner()->PostDelayedTask(FROM_HERE, closure, delta); 1263 Proxy::ImplThreadTaskRunner()->PostDelayedTask(FROM_HERE, closure, delta);
1263 } 1264 }
1264 1265
1265 void ThreadProxy::DidBeginImplFrameDeadline() { 1266 void ThreadProxy::DidBeginImplFrameDeadline() {
1266 layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame(); 1267 layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame();
1267 } 1268 }
1268 1269
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1492 request->completion.Signal(); 1493 request->completion.Signal();
1493 } 1494 }
1494 1495
1495 void ThreadProxy::RenewTreePriority() { 1496 void ThreadProxy::RenewTreePriority() {
1496 DCHECK(IsImplThread()); 1497 DCHECK(IsImplThread());
1497 bool smoothness_takes_priority = 1498 bool smoothness_takes_priority =
1498 layer_tree_host_impl_->pinch_gesture_active() || 1499 layer_tree_host_impl_->pinch_gesture_active() ||
1499 layer_tree_host_impl_->IsCurrentlyScrolling() || 1500 layer_tree_host_impl_->IsCurrentlyScrolling() ||
1500 layer_tree_host_impl_->page_scale_animation_active(); 1501 layer_tree_host_impl_->page_scale_animation_active();
1501 1502
1502 base::TimeTicks now = layer_tree_host_impl_->CurrentPhysicalTimeTicks(); 1503 base::TimeTicks now = base::TimeTicks::Now();
1503 1504
1504 // Update expiration time if smoothness currently takes priority. 1505 // Update expiration time if smoothness currently takes priority.
1505 if (smoothness_takes_priority) { 1506 if (smoothness_takes_priority) {
1506 smoothness_takes_priority_expiration_time_ = 1507 smoothness_takes_priority_expiration_time_ =
1507 now + base::TimeDelta::FromMilliseconds( 1508 now + base::TimeDelta::FromMilliseconds(
1508 kSmoothnessTakesPriorityExpirationDelay * 1000); 1509 kSmoothnessTakesPriorityExpirationDelay * 1000);
1509 } 1510 }
1510 1511
1511 // We use the same priority for both trees by default. 1512 // We use the same priority for both trees by default.
1512 TreePriority priority = SAME_PRIORITY_FOR_BOTH_TREES; 1513 TreePriority priority = SAME_PRIORITY_FOR_BOTH_TREES;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1585 completion_event_for_commit_held_on_tree_activation_ = NULL; 1586 completion_event_for_commit_held_on_tree_activation_ = NULL;
1586 } 1587 }
1587 1588
1588 UpdateBackgroundAnimateTicking(); 1589 UpdateBackgroundAnimateTicking();
1589 1590
1590 commit_to_activate_duration_history_.InsertSample( 1591 commit_to_activate_duration_history_.InsertSample(
1591 base::TimeTicks::HighResNow() - commit_complete_time_); 1592 base::TimeTicks::HighResNow() - commit_complete_time_);
1592 } 1593 }
1593 1594
1594 } // namespace cc 1595 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/thread_proxy.h ('k') | chrome/browser/ui/autofill/loading_animation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698