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

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

Issue 17391006: cc: Add BeginFrameArgs (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase Created 7 years, 6 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
« 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 »
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/scheduler/frame_rate_controller.h" 5 #include "cc/scheduler/frame_rate_controller.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 20 matching lines...) Expand all
31 FrameRateController* frame_rate_controller) 31 FrameRateController* frame_rate_controller)
32 : frame_rate_controller_(frame_rate_controller) {} 32 : frame_rate_controller_(frame_rate_controller) {}
33 33
34 FrameRateController* frame_rate_controller_; 34 FrameRateController* frame_rate_controller_;
35 }; 35 };
36 36
37 FrameRateController::FrameRateController(scoped_refptr<TimeSource> timer) 37 FrameRateController::FrameRateController(scoped_refptr<TimeSource> timer)
38 : client_(NULL), 38 : client_(NULL),
39 num_frames_pending_(0), 39 num_frames_pending_(0),
40 max_swaps_pending_(0), 40 max_swaps_pending_(0),
41 interval_(BeginFrameArgs::DefaultInterval()),
41 time_source_(timer), 42 time_source_(timer),
42 active_(false), 43 active_(false),
43 is_time_source_throttling_(true), 44 is_time_source_throttling_(true),
44 weak_factory_(this), 45 weak_factory_(this),
45 task_runner_(NULL) { 46 task_runner_(NULL) {
46 time_source_client_adapter_ = 47 time_source_client_adapter_ =
47 FrameRateControllerTimeSourceAdapter::Create(this); 48 FrameRateControllerTimeSourceAdapter::Create(this);
48 time_source_->SetClient(time_source_client_adapter_.get()); 49 time_source_->SetClient(time_source_client_adapter_.get());
49 } 50 }
50 51
51 FrameRateController::FrameRateController( 52 FrameRateController::FrameRateController(
52 base::SingleThreadTaskRunner* task_runner) 53 base::SingleThreadTaskRunner* task_runner)
53 : client_(NULL), 54 : client_(NULL),
54 num_frames_pending_(0), 55 num_frames_pending_(0),
55 max_swaps_pending_(0), 56 max_swaps_pending_(0),
57 interval_(BeginFrameArgs::DefaultInterval()),
56 active_(false), 58 active_(false),
57 is_time_source_throttling_(false), 59 is_time_source_throttling_(false),
58 weak_factory_(this), 60 weak_factory_(this),
59 task_runner_(task_runner) {} 61 task_runner_(task_runner) {}
60 62
61 FrameRateController::~FrameRateController() { 63 FrameRateController::~FrameRateController() {
62 if (is_time_source_throttling_) 64 if (is_time_source_throttling_)
63 time_source_->SetActive(false); 65 time_source_->SetActive(false);
64 } 66 }
65 67
(...skipping 13 matching lines...) Expand all
79 } 81 }
80 } 82 }
81 83
82 void FrameRateController::SetMaxSwapsPending(int max_swaps_pending) { 84 void FrameRateController::SetMaxSwapsPending(int max_swaps_pending) {
83 DCHECK_GE(max_swaps_pending, 0); 85 DCHECK_GE(max_swaps_pending, 0);
84 max_swaps_pending_ = max_swaps_pending; 86 max_swaps_pending_ = max_swaps_pending;
85 } 87 }
86 88
87 void FrameRateController::SetTimebaseAndInterval(base::TimeTicks timebase, 89 void FrameRateController::SetTimebaseAndInterval(base::TimeTicks timebase,
88 base::TimeDelta interval) { 90 base::TimeDelta interval) {
91 interval_ = interval;
89 if (is_time_source_throttling_) 92 if (is_time_source_throttling_)
90 time_source_->SetTimebaseAndInterval(timebase, interval); 93 time_source_->SetTimebaseAndInterval(timebase, interval);
91 } 94 }
92 95
96 void FrameRateController::SetDeadlineAdjustment(base::TimeDelta delta) {
97 deadline_adjustment_ = delta;
98 }
99
93 void FrameRateController::OnTimerTick() { 100 void FrameRateController::OnTimerTick() {
94 TRACE_EVENT0("cc", "FrameRateController::OnTimerTick"); 101 TRACE_EVENT0("cc", "FrameRateController::OnTimerTick");
95 DCHECK(active_); 102 DCHECK(active_);
96 103
97 // Check if we have too many frames in flight. 104 // Check if we have too many frames in flight.
98 bool throttled = 105 bool throttled =
99 max_swaps_pending_ && num_frames_pending_ >= max_swaps_pending_; 106 max_swaps_pending_ && num_frames_pending_ >= max_swaps_pending_;
100 TRACE_COUNTER_ID1("cc", "ThrottledCompositor", task_runner_, throttled); 107 TRACE_COUNTER_ID1("cc", "ThrottledCompositor", task_runner_, throttled);
101 108
102 if (client_) { 109 if (client_) {
103 client_->FrameRateControllerTick(throttled); 110 // TODO(brianderson): Use an adaptive parent compositor deadline.
111 base::TimeTicks frame_time = LastTickTime();
112 base::TimeTicks deadline = NextTickTime() + deadline_adjustment_;
113 client_->FrameRateControllerTick(
114 throttled,
115 BeginFrameArgs::Create(frame_time, deadline, interval_));
104 } 116 }
105 117
106 if (!is_time_source_throttling_ && !throttled) 118 if (!is_time_source_throttling_ && !throttled)
107 PostManualTick(); 119 PostManualTick();
108 } 120 }
109 121
110 void FrameRateController::PostManualTick() { 122 void FrameRateController::PostManualTick() {
111 if (active_) { 123 if (active_) {
112 task_runner_->PostTask(FROM_HERE, 124 task_runner_->PostTask(FROM_HERE,
113 base::Bind(&FrameRateController::ManualTick, 125 base::Bind(&FrameRateController::ManualTick,
(...skipping 28 matching lines...) Expand all
142 } 154 }
143 155
144 base::TimeTicks FrameRateController::LastTickTime() { 156 base::TimeTicks FrameRateController::LastTickTime() {
145 if (is_time_source_throttling_) 157 if (is_time_source_throttling_)
146 return time_source_->LastTickTime(); 158 return time_source_->LastTickTime();
147 159
148 return base::TimeTicks::Now(); 160 return base::TimeTicks::Now();
149 } 161 }
150 162
151 } // namespace cc 163 } // namespace cc
OLDNEW
« 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