OLD | NEW |
| (Empty) |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "services/surfaces/surfaces_scheduler.h" | |
6 | |
7 #include "cc/surfaces/display.h" | |
8 | |
9 namespace surfaces { | |
10 | |
11 SurfacesScheduler::SurfacesScheduler() { | |
12 cc::SchedulerSettings settings; | |
13 scheduler_ = cc::Scheduler::Create( | |
14 this, settings, 0, base::MessageLoop::current()->task_runner(), nullptr); | |
15 scheduler_->SetCanStart(); | |
16 scheduler_->SetVisible(true); | |
17 scheduler_->SetCanDraw(true); | |
18 scheduler_->SetNeedsCommit(); | |
19 } | |
20 | |
21 SurfacesScheduler::~SurfacesScheduler() { | |
22 } | |
23 | |
24 void SurfacesScheduler::SetNeedsDraw() { | |
25 // Don't tell the scheduler we need to draw if we have no active displays | |
26 // which can happen if we haven't initialized displays yet or if all active | |
27 // displays have lost their context. | |
28 if (!displays_.empty()) | |
29 scheduler_->SetNeedsRedraw(); | |
30 } | |
31 | |
32 void SurfacesScheduler::OnVSyncParametersUpdated(base::TimeTicks timebase, | |
33 base::TimeDelta interval) { | |
34 scheduler_->CommitVSyncParameters(timebase, interval); | |
35 } | |
36 | |
37 void SurfacesScheduler::AddDisplay(cc::Display* display) { | |
38 DCHECK(displays_.find(display) == displays_.end()); | |
39 displays_.insert(display); | |
40 | |
41 // A draw might be necessary (e.g., this display might be getting added on | |
42 // resumption from backgrounding). | |
43 SetNeedsDraw(); | |
44 } | |
45 | |
46 void SurfacesScheduler::RemoveDisplay(cc::Display* display) { | |
47 auto it = displays_.find(display); | |
48 DCHECK(it != displays_.end()); | |
49 displays_.erase(it); | |
50 } | |
51 | |
52 void SurfacesScheduler::WillBeginImplFrame(const cc::BeginFrameArgs& args) { | |
53 } | |
54 | |
55 void SurfacesScheduler::ScheduledActionSendBeginMainFrame() { | |
56 scheduler_->NotifyBeginMainFrameStarted(); | |
57 scheduler_->NotifyReadyToCommit(); | |
58 } | |
59 | |
60 cc::DrawResult SurfacesScheduler::ScheduledActionDrawAndSwapIfPossible() { | |
61 base::TimeTicks start = base::TimeTicks::Now(); | |
62 for (const auto& it : displays_) { | |
63 it->Draw(); | |
64 } | |
65 base::TimeDelta duration = base::TimeTicks::Now() - start; | |
66 | |
67 draw_estimate_ = (duration + draw_estimate_) / 2; | |
68 return cc::DRAW_SUCCESS; | |
69 } | |
70 | |
71 cc::DrawResult SurfacesScheduler::ScheduledActionDrawAndSwapForced() { | |
72 NOTREACHED() << "ScheduledActionDrawAndSwapIfPossible always succeeds."; | |
73 return cc::DRAW_SUCCESS; | |
74 } | |
75 | |
76 void SurfacesScheduler::ScheduledActionAnimate() { | |
77 } | |
78 | |
79 void SurfacesScheduler::ScheduledActionCommit() { | |
80 } | |
81 | |
82 void SurfacesScheduler::ScheduledActionActivateSyncTree() { | |
83 } | |
84 | |
85 void SurfacesScheduler::ScheduledActionBeginOutputSurfaceCreation() { | |
86 scheduler_->DidCreateAndInitializeOutputSurface(); | |
87 } | |
88 | |
89 void SurfacesScheduler::ScheduledActionPrepareTiles() { | |
90 } | |
91 | |
92 void SurfacesScheduler::DidAnticipatedDrawTimeChange(base::TimeTicks time) { | |
93 } | |
94 | |
95 base::TimeDelta SurfacesScheduler::DrawDurationEstimate() { | |
96 return draw_estimate_; | |
97 } | |
98 | |
99 base::TimeDelta SurfacesScheduler::BeginMainFrameToCommitDurationEstimate() { | |
100 return base::TimeDelta(); | |
101 } | |
102 | |
103 base::TimeDelta SurfacesScheduler::CommitToActivateDurationEstimate() { | |
104 return base::TimeDelta(); | |
105 } | |
106 | |
107 void SurfacesScheduler::DidBeginImplFrameDeadline() { | |
108 } | |
109 | |
110 void SurfacesScheduler::SendBeginFramesToChildren( | |
111 const cc::BeginFrameArgs& args) { | |
112 } | |
113 | |
114 void SurfacesScheduler::SendBeginMainFrameNotExpectedSoon() { | |
115 } | |
116 | |
117 } // namespace mojo | |
OLD | NEW |