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 <algorithm> | |
7 #include <set> | 8 #include <set> |
8 #include <string> | 9 #include <string> |
9 #include <vector> | 10 #include <vector> |
10 | 11 |
11 #include "base/bind.h" | 12 #include "base/bind.h" |
12 #include "base/debug/trace_event.h" | 13 #include "base/debug/trace_event.h" |
13 #include "base/logging.h" | 14 #include "base/logging.h" |
14 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
15 #include "base/strings/string_split.h" | 16 #include "base/strings/string_split.h" |
16 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
210 skipped_begin_frame_args_ = args; | 211 skipped_begin_frame_args_ = args; |
211 } else { | 212 } else { |
212 begin_frame_pending_ = true; | 213 begin_frame_pending_ = true; |
213 client_->BeginFrame(args); | 214 client_->BeginFrame(args); |
214 // args might be an alias for skipped_begin_frame_args_. | 215 // args might be an alias for skipped_begin_frame_args_. |
215 // Do not reset it before calling BeginFrame! | 216 // Do not reset it before calling BeginFrame! |
216 skipped_begin_frame_args_ = BeginFrameArgs(); | 217 skipped_begin_frame_args_ = BeginFrameArgs(); |
217 } | 218 } |
218 } | 219 } |
219 | 220 |
220 base::TimeDelta OutputSurface::RetroactiveBeginFramePeriod() { | 221 base::TimeTicks OutputSurface::RetroactiveBeginFrameDeadline() { |
brianderson
2013/07/18 02:02:49
Using this RetroactiveBeginFrameDeadline instead o
| |
221 return BeginFrameArgs::DefaultRetroactiveBeginFramePeriod(); | 222 base::TimeTicks alternative_deadline = |
223 skipped_begin_frame_args_.frame_time + | |
224 BeginFrameArgs::DefaultRetroactiveBeginFramePeriod(); | |
225 return std::max(skipped_begin_frame_args_.deadline, alternative_deadline); | |
222 } | 226 } |
223 | 227 |
224 void OutputSurface::PostCheckForRetroactiveBeginFrame() { | 228 void OutputSurface::PostCheckForRetroactiveBeginFrame() { |
225 if (!skipped_begin_frame_args_.IsValid() || | 229 if (!skipped_begin_frame_args_.IsValid() || |
226 check_for_retroactive_begin_frame_pending_) | 230 check_for_retroactive_begin_frame_pending_) |
227 return; | 231 return; |
228 | 232 |
229 base::MessageLoop::current()->PostTask( | 233 base::MessageLoop::current()->PostTask( |
230 FROM_HERE, | 234 FROM_HERE, |
231 base::Bind(&OutputSurface::CheckForRetroactiveBeginFrame, | 235 base::Bind(&OutputSurface::CheckForRetroactiveBeginFrame, |
232 weak_ptr_factory_.GetWeakPtr())); | 236 weak_ptr_factory_.GetWeakPtr())); |
233 check_for_retroactive_begin_frame_pending_ = true; | 237 check_for_retroactive_begin_frame_pending_ = true; |
234 } | 238 } |
235 | 239 |
236 void OutputSurface::CheckForRetroactiveBeginFrame() { | 240 void OutputSurface::CheckForRetroactiveBeginFrame() { |
237 TRACE_EVENT0("cc", "OutputSurface::CheckForRetroactiveBeginFrame"); | 241 TRACE_EVENT0("cc", "OutputSurface::CheckForRetroactiveBeginFrame"); |
238 check_for_retroactive_begin_frame_pending_ = false; | 242 check_for_retroactive_begin_frame_pending_ = false; |
239 base::TimeTicks now = base::TimeTicks::Now(); | 243 if (base::TimeTicks::Now() < RetroactiveBeginFrameDeadline()) |
240 base::TimeTicks alternative_deadline = | |
241 skipped_begin_frame_args_.frame_time + | |
242 RetroactiveBeginFramePeriod(); | |
243 if (now < skipped_begin_frame_args_.deadline || | |
244 now < alternative_deadline) { | |
245 BeginFrame(skipped_begin_frame_args_); | 244 BeginFrame(skipped_begin_frame_args_); |
246 } | |
247 } | 245 } |
248 | 246 |
249 void OutputSurface::DidSwapBuffers() { | 247 void OutputSurface::DidSwapBuffers() { |
250 begin_frame_pending_ = false; | 248 begin_frame_pending_ = false; |
251 pending_swap_buffers_++; | 249 pending_swap_buffers_++; |
252 TRACE_EVENT1("cc", "OutputSurface::DidSwapBuffers", | 250 TRACE_EVENT1("cc", "OutputSurface::DidSwapBuffers", |
253 "pending_swap_buffers_", pending_swap_buffers_); | 251 "pending_swap_buffers_", pending_swap_buffers_); |
254 if (frame_rate_controller_) | 252 if (frame_rate_controller_) |
255 frame_rate_controller_->DidSwapBuffers(); | 253 frame_rate_controller_->DidSwapBuffers(); |
256 PostCheckForRetroactiveBeginFrame(); | 254 PostCheckForRetroactiveBeginFrame(); |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
439 | 437 |
440 void OutputSurface::SetMemoryPolicy(const ManagedMemoryPolicy& policy, | 438 void OutputSurface::SetMemoryPolicy(const ManagedMemoryPolicy& policy, |
441 bool discard_backbuffer_when_not_visible) { | 439 bool discard_backbuffer_when_not_visible) { |
442 TRACE_EVENT2("cc", "OutputSurface::SetMemoryPolicy", | 440 TRACE_EVENT2("cc", "OutputSurface::SetMemoryPolicy", |
443 "bytes_limit_when_visible", policy.bytes_limit_when_visible, | 441 "bytes_limit_when_visible", policy.bytes_limit_when_visible, |
444 "discard_backbuffer", discard_backbuffer_when_not_visible); | 442 "discard_backbuffer", discard_backbuffer_when_not_visible); |
445 client_->SetMemoryPolicy(policy, discard_backbuffer_when_not_visible); | 443 client_->SetMemoryPolicy(policy, discard_backbuffer_when_not_visible); |
446 } | 444 } |
447 | 445 |
448 } // namespace cc | 446 } // namespace cc |
OLD | NEW |