OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/output/output_surface.h" | 5 #include "cc/output/output_surface.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 if (throttle_frame_production){ | 97 if (throttle_frame_production){ |
98 frame_rate_controller_.reset( | 98 frame_rate_controller_.reset( |
99 new FrameRateController( | 99 new FrameRateController( |
100 DelayBasedTimeSource::Create(interval, task_runner))); | 100 DelayBasedTimeSource::Create(interval, task_runner))); |
101 } else { | 101 } else { |
102 frame_rate_controller_.reset(new FrameRateController(task_runner)); | 102 frame_rate_controller_.reset(new FrameRateController(task_runner)); |
103 } | 103 } |
104 | 104 |
105 frame_rate_controller_->SetClient(this); | 105 frame_rate_controller_->SetClient(this); |
106 frame_rate_controller_->SetMaxSwapsPending(max_frames_pending_); | 106 frame_rate_controller_->SetMaxSwapsPending(max_frames_pending_); |
| 107 frame_rate_controller_->SetDeadlineAdjustment( |
| 108 capabilities_.adjust_deadline_for_parent ? |
| 109 BeginFrameArgs::DefaultDeadlineAdjustment() : base::TimeDelta()); |
107 | 110 |
108 // The new frame rate controller will consume the swap acks of the old | 111 // The new frame rate controller will consume the swap acks of the old |
109 // frame rate controller, so we set that expectation up here. | 112 // frame rate controller, so we set that expectation up here. |
110 for (int i = 0; i < pending_swap_buffers_; i++) | 113 for (int i = 0; i < pending_swap_buffers_; i++) |
111 frame_rate_controller_->DidSwapBuffers(); | 114 frame_rate_controller_->DidSwapBuffers(); |
112 } | 115 } |
113 | 116 |
114 void OutputSurface::SetMaxFramesPending(int max_frames_pending) { | 117 void OutputSurface::SetMaxFramesPending(int max_frames_pending) { |
115 if (frame_rate_controller_) | 118 if (frame_rate_controller_) |
116 frame_rate_controller_->SetMaxSwapsPending(max_frames_pending); | 119 frame_rate_controller_->SetMaxSwapsPending(max_frames_pending); |
117 max_frames_pending_ = max_frames_pending; | 120 max_frames_pending_ = max_frames_pending; |
118 } | 121 } |
119 | 122 |
120 void OutputSurface::OnVSyncParametersChanged(base::TimeTicks timebase, | 123 void OutputSurface::OnVSyncParametersChanged(base::TimeTicks timebase, |
121 base::TimeDelta interval) { | 124 base::TimeDelta interval) { |
122 TRACE_EVENT2("cc", "OutputSurface::OnVSyncParametersChanged", | 125 TRACE_EVENT2("cc", "OutputSurface::OnVSyncParametersChanged", |
123 "timebase", (timebase - base::TimeTicks()).InSecondsF(), | 126 "timebase", (timebase - base::TimeTicks()).InSecondsF(), |
124 "interval", interval.InSecondsF()); | 127 "interval", interval.InSecondsF()); |
125 if (frame_rate_controller_) | 128 if (frame_rate_controller_) |
126 frame_rate_controller_->SetTimebaseAndInterval(timebase, interval); | 129 frame_rate_controller_->SetTimebaseAndInterval(timebase, interval); |
127 } | 130 } |
128 | 131 |
129 void OutputSurface::FrameRateControllerTick(bool throttled) { | 132 void OutputSurface::FrameRateControllerTick(bool throttled, |
| 133 const BeginFrameArgs& args) { |
130 DCHECK(frame_rate_controller_); | 134 DCHECK(frame_rate_controller_); |
131 if (!throttled) | 135 if (!throttled) |
132 BeginFrame(frame_rate_controller_->LastTickTime()); | 136 BeginFrame(args); |
133 } | 137 } |
134 | 138 |
135 // Forwarded to OutputSurfaceClient | 139 // Forwarded to OutputSurfaceClient |
136 void OutputSurface::SetNeedsRedrawRect(gfx::Rect damage_rect) { | 140 void OutputSurface::SetNeedsRedrawRect(gfx::Rect damage_rect) { |
137 TRACE_EVENT0("cc", "OutputSurface::SetNeedsRedrawRect"); | 141 TRACE_EVENT0("cc", "OutputSurface::SetNeedsRedrawRect"); |
138 client_->SetNeedsRedrawRect(damage_rect); | 142 client_->SetNeedsRedrawRect(damage_rect); |
139 } | 143 } |
140 | 144 |
141 void OutputSurface::SetNeedsBeginFrame(bool enable) { | 145 void OutputSurface::SetNeedsBeginFrame(bool enable) { |
142 TRACE_EVENT1("cc", "OutputSurface::SetNeedsBeginFrame", "enable", enable); | 146 TRACE_EVENT1("cc", "OutputSurface::SetNeedsBeginFrame", "enable", enable); |
143 begin_frame_pending_ = false; | 147 begin_frame_pending_ = false; |
144 if (frame_rate_controller_) | 148 if (frame_rate_controller_) |
145 frame_rate_controller_->SetActive(enable); | 149 frame_rate_controller_->SetActive(enable); |
146 } | 150 } |
147 | 151 |
148 void OutputSurface::BeginFrame(base::TimeTicks frame_time) { | 152 void OutputSurface::BeginFrame(const BeginFrameArgs& args) { |
149 TRACE_EVENT2("cc", "OutputSurface::BeginFrame", | 153 TRACE_EVENT2("cc", "OutputSurface::BeginFrame", |
150 "begin_frame_pending_", begin_frame_pending_, | 154 "begin_frame_pending_", begin_frame_pending_, |
151 "pending_swap_buffers_", pending_swap_buffers_); | 155 "pending_swap_buffers_", pending_swap_buffers_); |
152 if (begin_frame_pending_ || | 156 if (begin_frame_pending_ || |
153 (pending_swap_buffers_ >= max_frames_pending_ && max_frames_pending_ > 0)) | 157 (pending_swap_buffers_ >= max_frames_pending_ && max_frames_pending_ > 0)) |
154 return; | 158 return; |
155 begin_frame_pending_ = true; | 159 begin_frame_pending_ = true; |
156 client_->BeginFrame(frame_time); | 160 client_->BeginFrame(args); |
157 } | 161 } |
158 | 162 |
159 void OutputSurface::DidSwapBuffers() { | 163 void OutputSurface::DidSwapBuffers() { |
160 begin_frame_pending_ = false; | 164 begin_frame_pending_ = false; |
161 pending_swap_buffers_++; | 165 pending_swap_buffers_++; |
162 TRACE_EVENT1("cc", "OutputSurface::DidSwapBuffers", | 166 TRACE_EVENT1("cc", "OutputSurface::DidSwapBuffers", |
163 "pending_swap_buffers_", pending_swap_buffers_); | 167 "pending_swap_buffers_", pending_swap_buffers_); |
164 if (frame_rate_controller_) | 168 if (frame_rate_controller_) |
165 frame_rate_controller_->DidSwapBuffers(); | 169 frame_rate_controller_->DidSwapBuffers(); |
166 } | 170 } |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 | 326 |
323 void OutputSurface::PostSwapBuffersComplete() { | 327 void OutputSurface::PostSwapBuffersComplete() { |
324 base::MessageLoop::current()->PostTask( | 328 base::MessageLoop::current()->PostTask( |
325 FROM_HERE, | 329 FROM_HERE, |
326 base::Bind(&OutputSurface::OnSwapBuffersComplete, | 330 base::Bind(&OutputSurface::OnSwapBuffersComplete, |
327 weak_ptr_factory_.GetWeakPtr(), | 331 weak_ptr_factory_.GetWeakPtr(), |
328 static_cast<CompositorFrameAck*>(NULL))); | 332 static_cast<CompositorFrameAck*>(NULL))); |
329 } | 333 } |
330 | 334 |
331 } // namespace cc | 335 } // namespace cc |
OLD | NEW |