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

Unified Diff: cc/scheduler/frame_rate_controller.cc

Issue 199523002: cc: Throttle swaps in Scheduler instead of OutputSurface (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Actually, unittests need CC_EXPORT. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/scheduler/frame_rate_controller.h ('k') | cc/scheduler/frame_rate_controller_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/scheduler/frame_rate_controller.cc
diff --git a/cc/scheduler/frame_rate_controller.cc b/cc/scheduler/frame_rate_controller.cc
index 243ef6b62918a1f4b753e24cf70e93d4ac3050dc..beaa1e157657c64af5f0ed5baa569d089ba6aa8e 100644
--- a/cc/scheduler/frame_rate_controller.cc
+++ b/cc/scheduler/frame_rate_controller.cc
@@ -15,59 +15,15 @@
namespace cc {
-class FrameRateControllerTimeSourceAdapter : public TimeSourceClient {
- public:
- static scoped_ptr<FrameRateControllerTimeSourceAdapter> Create(
- FrameRateController* frame_rate_controller) {
- return make_scoped_ptr(
- new FrameRateControllerTimeSourceAdapter(frame_rate_controller));
- }
- virtual ~FrameRateControllerTimeSourceAdapter() {}
-
- virtual void OnTimerTick() OVERRIDE {
- frame_rate_controller_->OnTimerTick();
- }
-
- private:
- explicit FrameRateControllerTimeSourceAdapter(
- FrameRateController* frame_rate_controller)
- : frame_rate_controller_(frame_rate_controller) {}
-
- FrameRateController* frame_rate_controller_;
-};
-
FrameRateController::FrameRateController(scoped_refptr<TimeSource> timer)
: client_(NULL),
- num_frames_pending_(0),
- max_swaps_pending_(0),
interval_(BeginFrameArgs::DefaultInterval()),
time_source_(timer),
- active_(false),
- is_time_source_throttling_(true),
- manual_tick_pending_(false),
- task_runner_(NULL),
- weak_factory_(this) {
- time_source_client_adapter_ =
- FrameRateControllerTimeSourceAdapter::Create(this);
- time_source_->SetClient(time_source_client_adapter_.get());
+ active_(false) {
+ time_source_->SetClient(this);
}
-FrameRateController::FrameRateController(
- base::SingleThreadTaskRunner* task_runner)
- : client_(NULL),
- num_frames_pending_(0),
- max_swaps_pending_(0),
- interval_(BeginFrameArgs::DefaultInterval()),
- active_(false),
- is_time_source_throttling_(false),
- manual_tick_pending_(false),
- task_runner_(task_runner),
- weak_factory_(this) {}
-
-FrameRateController::~FrameRateController() {
- if (is_time_source_throttling_)
- time_source_->SetActive(false);
-}
+FrameRateController::~FrameRateController() { time_source_->SetActive(false); }
BeginFrameArgs FrameRateController::SetActive(bool active) {
if (active_ == active)
@@ -75,35 +31,20 @@ BeginFrameArgs FrameRateController::SetActive(bool active) {
TRACE_EVENT1("cc", "FrameRateController::SetActive", "active", active);
active_ = active;
- if (is_time_source_throttling_) {
- base::TimeTicks missed_tick_time = time_source_->SetActive(active);
- if (!missed_tick_time.is_null()) {
- base::TimeTicks deadline = NextTickTime();
- return BeginFrameArgs::Create(
- missed_tick_time, deadline + deadline_adjustment_, interval_);
- }
- } else {
- if (active) {
- PostManualTick();
- } else {
- weak_factory_.InvalidateWeakPtrs();
- manual_tick_pending_ = false;
- }
+ base::TimeTicks missed_tick_time = time_source_->SetActive(active);
+ if (!missed_tick_time.is_null()) {
+ base::TimeTicks deadline = NextTickTime();
+ return BeginFrameArgs::Create(
+ missed_tick_time, deadline + deadline_adjustment_, interval_);
}
return BeginFrameArgs();
}
-void FrameRateController::SetMaxSwapsPending(int max_swaps_pending) {
- DCHECK_GE(max_swaps_pending, 0);
- max_swaps_pending_ = max_swaps_pending;
-}
-
void FrameRateController::SetTimebaseAndInterval(base::TimeTicks timebase,
base::TimeDelta interval) {
interval_ = interval;
- if (is_time_source_throttling_)
- time_source_->SetTimebaseAndInterval(timebase, interval);
+ time_source_->SetTimebaseAndInterval(timebase, interval);
}
void FrameRateController::SetDeadlineAdjustment(base::TimeDelta delta) {
@@ -114,65 +55,22 @@ void FrameRateController::OnTimerTick() {
TRACE_EVENT0("cc", "FrameRateController::OnTimerTick");
DCHECK(active_);
- // Check if we have too many frames in flight.
- bool throttled =
- max_swaps_pending_ && num_frames_pending_ >= max_swaps_pending_;
- TRACE_COUNTER_ID1("cc", "ThrottledCompositor", task_runner_, throttled);
-
if (client_) {
// TODO(brianderson): Use an adaptive parent compositor deadline.
base::TimeTicks frame_time = LastTickTime();
base::TimeTicks deadline = NextTickTime();
BeginFrameArgs args = BeginFrameArgs::Create(
frame_time, deadline + deadline_adjustment_, interval_);
- client_->FrameRateControllerTick(throttled, args);
+ client_->FrameRateControllerTick(args);
}
-
- if (!is_time_source_throttling_ && !throttled)
- PostManualTick();
-}
-
-void FrameRateController::PostManualTick() {
- if (active_ && !manual_tick_pending_) {
- manual_tick_pending_ = true;
- task_runner_->PostTask(FROM_HERE,
- base::Bind(&FrameRateController::ManualTick,
- weak_factory_.GetWeakPtr()));
- }
-}
-
-void FrameRateController::ManualTick() {
- manual_tick_pending_ = false;
- OnTimerTick();
-}
-
-void FrameRateController::DidSwapBuffers() {
- num_frames_pending_++;
-}
-
-void FrameRateController::DidSwapBuffersComplete() {
- DCHECK_GT(num_frames_pending_, 0);
- num_frames_pending_--;
- if (!is_time_source_throttling_)
- PostManualTick();
-}
-
-void FrameRateController::DidAbortAllPendingFrames() {
- num_frames_pending_ = 0;
}
base::TimeTicks FrameRateController::NextTickTime() {
- if (is_time_source_throttling_)
- return time_source_->NextTickTime();
-
- return base::TimeTicks();
+ return time_source_->NextTickTime();
}
base::TimeTicks FrameRateController::LastTickTime() {
- if (is_time_source_throttling_)
- return time_source_->LastTickTime();
-
- return gfx::FrameTime::Now();
+ return time_source_->LastTickTime();
}
} // namespace cc
« no previous file with comments | « cc/scheduler/frame_rate_controller.h ('k') | cc/scheduler/frame_rate_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698