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/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
11 #include "base/trace_event/trace_event.h" | 11 #include "base/trace_event/trace_event.h" |
12 #include "cc/output/output_surface.h" | 12 #include "cc/output/output_surface.h" |
13 | 13 |
14 namespace cc { | 14 namespace cc { |
15 | 15 |
16 DisplayScheduler::DisplayScheduler(BeginFrameSource* begin_frame_source, | 16 DisplayScheduler::DisplayScheduler(base::SingleThreadTaskRunner* task_runner, |
17 base::SingleThreadTaskRunner* task_runner, | |
18 int max_pending_swaps) | 17 int max_pending_swaps) |
19 : begin_frame_source_(begin_frame_source), | 18 : client_(nullptr), |
| 19 begin_frame_source_(nullptr), |
20 task_runner_(task_runner), | 20 task_runner_(task_runner), |
21 inside_surface_damaged_(false), | 21 inside_surface_damaged_(false), |
22 visible_(false), | 22 visible_(false), |
23 output_surface_lost_(false), | 23 output_surface_lost_(false), |
24 root_surface_resources_locked_(true), | 24 root_surface_resources_locked_(true), |
25 inside_begin_frame_deadline_interval_(false), | 25 inside_begin_frame_deadline_interval_(false), |
26 needs_draw_(false), | 26 needs_draw_(false), |
27 expecting_root_surface_damage_because_of_resize_(false), | 27 expecting_root_surface_damage_because_of_resize_(false), |
28 all_active_child_surfaces_ready_to_draw_(false), | 28 all_active_child_surfaces_ready_to_draw_(false), |
29 pending_swaps_(0), | 29 pending_swaps_(0), |
30 max_pending_swaps_(max_pending_swaps), | 30 max_pending_swaps_(max_pending_swaps), |
31 observing_begin_frame_source_(false), | 31 observing_begin_frame_source_(false), |
32 root_surface_damaged_(false), | 32 root_surface_damaged_(false), |
33 expect_damage_from_root_surface_(false), | 33 expect_damage_from_root_surface_(false), |
34 weak_ptr_factory_(this) { | 34 weak_ptr_factory_(this) { |
35 begin_frame_deadline_closure_ = base::Bind( | 35 begin_frame_deadline_closure_ = base::Bind( |
36 &DisplayScheduler::OnBeginFrameDeadline, weak_ptr_factory_.GetWeakPtr()); | 36 &DisplayScheduler::OnBeginFrameDeadline, weak_ptr_factory_.GetWeakPtr()); |
37 } | 37 } |
38 | 38 |
39 DisplayScheduler::~DisplayScheduler() { | 39 DisplayScheduler::~DisplayScheduler() { |
40 StopObservingBeginFrames(); | 40 StopObservingBeginFrames(); |
41 } | 41 } |
42 | 42 |
43 void DisplayScheduler::SetClient(DisplaySchedulerClient* client) { | 43 void DisplayScheduler::SetClient(DisplaySchedulerClient* client) { |
44 client_ = client; | 44 client_ = client; |
45 } | 45 } |
46 | 46 |
| 47 void DisplayScheduler::SetBeginFrameSource( |
| 48 BeginFrameSource* begin_frame_source) { |
| 49 begin_frame_source_ = begin_frame_source; |
| 50 } |
| 51 |
47 void DisplayScheduler::SetVisible(bool visible) { | 52 void DisplayScheduler::SetVisible(bool visible) { |
48 if (visible_ == visible) | 53 if (visible_ == visible) |
49 return; | 54 return; |
50 | 55 |
51 visible_ = visible; | 56 visible_ = visible; |
52 // If going invisible, we'll stop observing begin frames once we try | 57 // If going invisible, we'll stop observing begin frames once we try |
53 // to draw and fail. | 58 // to draw and fail. |
54 StartObservingBeginFrames(); | 59 StartObservingBeginFrames(); |
55 ScheduleBeginFrameDeadline(); | 60 ScheduleBeginFrameDeadline(); |
56 } | 61 } |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 } | 366 } |
362 | 367 |
363 void DisplayScheduler::DidReceiveSwapBuffersAck() { | 368 void DisplayScheduler::DidReceiveSwapBuffersAck() { |
364 pending_swaps_--; | 369 pending_swaps_--; |
365 TRACE_EVENT_ASYNC_END1("cc", "DisplayScheduler:pending_swaps", this, | 370 TRACE_EVENT_ASYNC_END1("cc", "DisplayScheduler:pending_swaps", this, |
366 "pending_frames", pending_swaps_); | 371 "pending_frames", pending_swaps_); |
367 ScheduleBeginFrameDeadline(); | 372 ScheduleBeginFrameDeadline(); |
368 } | 373 } |
369 | 374 |
370 } // namespace cc | 375 } // namespace cc |
OLD | NEW |