Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/surfaces/display_scheduler.h" | 5 #include "cc/surfaces/display_scheduler.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| 11 #include "cc/output/output_surface.h" | 11 #include "cc/output/output_surface.h" |
| 12 | 12 |
| 13 namespace cc { | 13 namespace cc { |
| 14 | 14 |
| 15 DisplayScheduler::DisplayScheduler(DisplaySchedulerClient* client, | 15 DisplayScheduler::DisplayScheduler(DisplaySchedulerClient* client, |
| 16 BeginFrameSource* begin_frame_source, | 16 BeginFrameSource* begin_frame_source, |
| 17 base::SingleThreadTaskRunner* task_runner, | 17 base::SingleThreadTaskRunner* task_runner, |
| 18 int max_pending_swaps) | 18 int max_pending_swaps, |
| 19 const RendererSettings& settings) | |
| 19 : client_(client), | 20 : client_(client), |
| 20 begin_frame_source_(begin_frame_source), | 21 begin_frame_source_(begin_frame_source), |
| 21 task_runner_(task_runner), | 22 task_runner_(task_runner), |
| 22 output_surface_lost_(false), | 23 output_surface_lost_(false), |
| 23 root_surface_resources_locked_(true), | 24 root_surface_resources_locked_(true), |
| 24 inside_begin_frame_deadline_interval_(false), | 25 inside_begin_frame_deadline_interval_(false), |
| 25 needs_draw_(false), | 26 needs_draw_(false), |
| 26 expecting_root_surface_damage_because_of_resize_(false), | 27 expecting_root_surface_damage_because_of_resize_(false), |
| 27 all_active_child_surfaces_ready_to_draw_(false), | 28 all_active_child_surfaces_ready_to_draw_(false), |
| 28 pending_swaps_(0), | 29 pending_swaps_(0), |
| 29 max_pending_swaps_(max_pending_swaps), | 30 max_pending_swaps_(max_pending_swaps), |
| 30 observing_begin_frame_source_(false), | 31 observing_begin_frame_source_(false), |
| 31 root_surface_damaged_(false), | 32 root_surface_damaged_(false), |
| 32 expect_damage_from_root_surface_(false), | 33 expect_damage_from_root_surface_(false), |
| 33 weak_ptr_factory_(this) { | 34 weak_ptr_factory_(this) { |
| 34 begin_frame_deadline_closure_ = base::Bind( | 35 begin_frame_deadline_closure_ = base::Bind( |
| 35 &DisplayScheduler::OnBeginFrameDeadline, weak_ptr_factory_.GetWeakPtr()); | 36 &DisplayScheduler::OnBeginFrameDeadline, weak_ptr_factory_.GetWeakPtr()); |
| 36 | 37 |
| 37 // TODO(tansell): Set this to something useful. | 38 if (settings.disable_display_vsync) { |
|
enne (OOO)
2016/03/28 21:43:27
I like the way this worked out, in terms of the Di
sunnyps
2016/03/28 23:09:48
It feels like Display or BrowserCompositorOutputSu
enne (OOO)
2016/03/29 20:39:52
I'll make Display do it, because Display already h
| |
| 38 begin_frame_source_for_children_ = SyntheticBeginFrameSource::Create( | 39 unthrottled_begin_frame_source_ = |
| 39 task_runner, BeginFrameArgs::DefaultInterval()); | 40 BackToBackBeginFrameSource::Create(task_runner); |
| 41 begin_frame_source_ = unthrottled_begin_frame_source_.get(); | |
| 42 } | |
| 43 | |
| 44 // TODO(enne): For now, this is always the same, so just set initially. | |
| 45 client_->UpdateSchedulerBeginFrameSource(begin_frame_source_); | |
| 40 } | 46 } |
| 41 | 47 |
| 42 DisplayScheduler::~DisplayScheduler() { | 48 DisplayScheduler::~DisplayScheduler() { |
| 43 if (observing_begin_frame_source_) | 49 if (observing_begin_frame_source_) |
| 44 begin_frame_source_->RemoveObserver(this); | 50 begin_frame_source_->RemoveObserver(this); |
| 45 } | 51 } |
| 46 | 52 |
| 47 // If we try to draw when the root surface resources are locked, the | 53 // If we try to draw when the root surface resources are locked, the |
| 48 // draw will fail. | 54 // draw will fail. |
| 49 void DisplayScheduler::SetRootSurfaceResourcesLocked(bool locked) { | 55 void DisplayScheduler::SetRootSurfaceResourcesLocked(bool locked) { |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 303 } | 309 } |
| 304 | 310 |
| 305 void DisplayScheduler::DidSwapBuffersComplete() { | 311 void DisplayScheduler::DidSwapBuffersComplete() { |
| 306 pending_swaps_--; | 312 pending_swaps_--; |
| 307 TRACE_EVENT_ASYNC_END1("cc", "DisplayScheduler:pending_swaps", this, | 313 TRACE_EVENT_ASYNC_END1("cc", "DisplayScheduler:pending_swaps", this, |
| 308 "pending_frames", pending_swaps_); | 314 "pending_frames", pending_swaps_); |
| 309 ScheduleBeginFrameDeadline(); | 315 ScheduleBeginFrameDeadline(); |
| 310 } | 316 } |
| 311 | 317 |
| 312 } // namespace cc | 318 } // namespace cc |
| OLD | NEW |