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 "components/view_manager/surfaces/surfaces_scheduler.h" | |
6 | |
7 #include "cc/debug/rendering_stats_instrumentation.h" | |
8 #include "cc/scheduler/compositor_timing_history.h" | |
9 #include "cc/surfaces/display.h" | |
10 | |
11 namespace surfaces { | |
12 | |
13 SurfacesScheduler::SurfacesScheduler() | |
14 : rendering_stats_instrumentation_( | |
15 cc::RenderingStatsInstrumentation::Create()) { | |
16 cc::SchedulerSettings settings; | |
17 scoped_ptr<cc::CompositorTimingHistory> compositor_timing_history( | |
18 new cc::CompositorTimingHistory(cc::CompositorTimingHistory::NULL_UMA, | |
19 rendering_stats_instrumentation_.get())); | |
20 scheduler_ = cc::Scheduler::Create( | |
21 this, settings, 0, base::MessageLoop::current()->task_runner().get(), | |
22 nullptr, compositor_timing_history.Pass()); | |
23 scheduler_->SetCanStart(); | |
24 scheduler_->SetVisible(true); | |
25 scheduler_->SetCanDraw(true); | |
26 scheduler_->SetNeedsBeginMainFrame(); | |
27 } | |
28 | |
29 SurfacesScheduler::~SurfacesScheduler() { | |
30 } | |
31 | |
32 void SurfacesScheduler::SetNeedsDraw() { | |
33 // Don't tell the scheduler we need to draw if we have no active displays | |
34 // which can happen if we haven't initialized displays yet or if all active | |
35 // displays have lost their context. | |
36 if (!displays_.empty()) | |
37 scheduler_->SetNeedsRedraw(); | |
38 } | |
39 | |
40 void SurfacesScheduler::OnVSyncParametersUpdated(base::TimeTicks timebase, | |
41 base::TimeDelta interval) { | |
42 scheduler_->CommitVSyncParameters(timebase, interval); | |
43 } | |
44 | |
45 void SurfacesScheduler::AddDisplay(cc::Display* display) { | |
46 DCHECK(displays_.find(display) == displays_.end()); | |
47 displays_.insert(display); | |
48 | |
49 // A draw might be necessary (e.g., this display might be getting added on | |
50 // resumption from the app being in the background as happens on android). | |
51 SetNeedsDraw(); | |
52 } | |
53 | |
54 void SurfacesScheduler::RemoveDisplay(cc::Display* display) { | |
55 auto it = displays_.find(display); | |
56 DCHECK(it != displays_.end()); | |
57 displays_.erase(it); | |
58 } | |
59 | |
60 void SurfacesScheduler::WillBeginImplFrame(const cc::BeginFrameArgs& args) { | |
61 } | |
62 | |
63 void SurfacesScheduler::DidFinishImplFrame() { | |
64 } | |
65 | |
66 void SurfacesScheduler::ScheduledActionSendBeginMainFrame() { | |
67 scheduler_->NotifyBeginMainFrameStarted(); | |
68 scheduler_->NotifyReadyToCommit(); | |
69 } | |
70 | |
71 cc::DrawResult SurfacesScheduler::ScheduledActionDrawAndSwapIfPossible() { | |
72 for (const auto& it : displays_) { | |
73 it->DrawAndSwap(); | |
74 } | |
75 return cc::DRAW_SUCCESS; | |
76 } | |
77 | |
78 cc::DrawResult SurfacesScheduler::ScheduledActionDrawAndSwapForced() { | |
79 NOTREACHED() << "ScheduledActionDrawAndSwapIfPossible always succeeds."; | |
80 return cc::DRAW_SUCCESS; | |
81 } | |
82 | |
83 void SurfacesScheduler::ScheduledActionAnimate() { | |
84 } | |
85 | |
86 void SurfacesScheduler::ScheduledActionCommit() { | |
87 scheduler_->NotifyReadyToActivate(); | |
88 } | |
89 | |
90 void SurfacesScheduler::ScheduledActionActivateSyncTree() { | |
91 } | |
92 | |
93 void SurfacesScheduler::ScheduledActionBeginOutputSurfaceCreation() { | |
94 scheduler_->DidCreateAndInitializeOutputSurface(); | |
95 } | |
96 | |
97 void SurfacesScheduler::ScheduledActionPrepareTiles() { | |
98 } | |
99 | |
100 void SurfacesScheduler::ScheduledActionInvalidateOutputSurface() { | |
101 } | |
102 | |
103 void SurfacesScheduler::SendBeginFramesToChildren( | |
104 const cc::BeginFrameArgs& args) { | |
105 } | |
106 | |
107 void SurfacesScheduler::SendBeginMainFrameNotExpectedSoon() { | |
108 } | |
109 | |
110 } // namespace mojo | |
OLD | NEW |