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

Side by Side Diff: cc/scheduler/frame_rate_controller.cc

Issue 16871016: cc: Use BeginFrameArgs (Closed) Base URL: http://git.chromium.org/chromium/src.git@bfargs2
Patch Set: Add an --enable-deadline-scheduler commandline flag. Created 7 years, 4 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
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/scheduler/frame_rate_controller.h" 5 #include "cc/scheduler/frame_rate_controller.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 BeginFrameArgs FrameRateController::SetActive(bool active) { 69 BeginFrameArgs FrameRateController::SetActive(bool active) {
70 if (active_ == active) 70 if (active_ == active)
71 return BeginFrameArgs(); 71 return BeginFrameArgs();
72 TRACE_EVENT1("cc", "FrameRateController::SetActive", "active", active); 72 TRACE_EVENT1("cc", "FrameRateController::SetActive", "active", active);
73 active_ = active; 73 active_ = active;
74 74
75 if (is_time_source_throttling_) { 75 if (is_time_source_throttling_) {
76 base::TimeTicks missed_tick_time = time_source_->SetActive(active); 76 base::TimeTicks missed_tick_time = time_source_->SetActive(active);
77 if (!missed_tick_time.is_null()) { 77 if (!missed_tick_time.is_null()) {
78 base::TimeTicks deadline = NextTickTime(); 78 base::TimeTicks deadline = NextTickTime();
79 return BeginFrameArgs::Create(missed_tick_time, 79 BeginFrameArgs args =
80 deadline, 80 BeginFrameArgs::Create(missed_tick_time, deadline, interval_);
81 interval_); 81 args.deadline += deadline_adjustment_;
82 return args;
82 } 83 }
83 } else { 84 } else {
84 if (active) 85 if (active)
85 PostManualTick(); 86 PostManualTick();
86 else 87 else
87 weak_factory_.InvalidateWeakPtrs(); 88 weak_factory_.InvalidateWeakPtrs();
88 } 89 }
89 90
90 return BeginFrameArgs(); 91 return BeginFrameArgs();
91 } 92 }
(...skipping 19 matching lines...) Expand all
111 DCHECK(active_); 112 DCHECK(active_);
112 113
113 // Check if we have too many frames in flight. 114 // Check if we have too many frames in flight.
114 bool throttled = 115 bool throttled =
115 max_swaps_pending_ && num_frames_pending_ >= max_swaps_pending_; 116 max_swaps_pending_ && num_frames_pending_ >= max_swaps_pending_;
116 TRACE_COUNTER_ID1("cc", "ThrottledCompositor", task_runner_, throttled); 117 TRACE_COUNTER_ID1("cc", "ThrottledCompositor", task_runner_, throttled);
117 118
118 if (client_) { 119 if (client_) {
119 // TODO(brianderson): Use an adaptive parent compositor deadline. 120 // TODO(brianderson): Use an adaptive parent compositor deadline.
120 base::TimeTicks frame_time = LastTickTime(); 121 base::TimeTicks frame_time = LastTickTime();
121 base::TimeTicks deadline = NextTickTime() + deadline_adjustment_; 122 base::TimeTicks deadline = NextTickTime();
122 client_->FrameRateControllerTick( 123 BeginFrameArgs args =
123 throttled, 124 BeginFrameArgs::Create(frame_time, deadline, interval_);
124 BeginFrameArgs::Create(frame_time, deadline, interval_)); 125 args.deadline += deadline_adjustment_;
126 client_->FrameRateControllerTick(throttled, args);
125 } 127 }
126 128
127 if (!is_time_source_throttling_ && !throttled) 129 if (!is_time_source_throttling_ && !throttled)
128 PostManualTick(); 130 PostManualTick();
129 } 131 }
130 132
131 void FrameRateController::PostManualTick() { 133 void FrameRateController::PostManualTick() {
132 if (active_) { 134 if (active_) {
133 task_runner_->PostTask(FROM_HERE, 135 task_runner_->PostTask(FROM_HERE,
134 base::Bind(&FrameRateController::ManualTick, 136 base::Bind(&FrameRateController::ManualTick,
(...skipping 28 matching lines...) Expand all
163 } 165 }
164 166
165 base::TimeTicks FrameRateController::LastTickTime() { 167 base::TimeTicks FrameRateController::LastTickTime() {
166 if (is_time_source_throttling_) 168 if (is_time_source_throttling_)
167 return time_source_->LastTickTime(); 169 return time_source_->LastTickTime();
168 170
169 return base::TimeTicks::Now(); 171 return base::TimeTicks::Now();
170 } 172 }
171 173
172 } // namespace cc 174 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698