Remove obsolete entries from .gitignore.
[chromium-blink-merge.git] / components / mus / surfaces / surfaces_scheduler.cc
blobf3752f83ee23b96d9f9c8bf2e737f261e8c6e30a
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.
5 #include "components/mus/surfaces/surfaces_scheduler.h"
7 #include "cc/debug/rendering_stats_instrumentation.h"
8 #include "cc/scheduler/compositor_timing_history.h"
9 #include "cc/surfaces/display.h"
11 namespace mus {
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();
29 SurfacesScheduler::~SurfacesScheduler() {}
31 void SurfacesScheduler::SetNeedsDraw() {
32 // Don't tell the scheduler we need to draw if we have no active displays
33 // which can happen if we haven't initialized displays yet or if all active
34 // displays have lost their context.
35 if (!displays_.empty())
36 scheduler_->SetNeedsRedraw();
39 void SurfacesScheduler::OnVSyncParametersUpdated(base::TimeTicks timebase,
40 base::TimeDelta interval) {
41 scheduler_->CommitVSyncParameters(timebase, interval);
44 void SurfacesScheduler::AddDisplay(cc::Display* display) {
45 DCHECK(displays_.find(display) == displays_.end());
46 displays_.insert(display);
48 // A draw might be necessary (e.g., this display might be getting added on
49 // resumption from the app being in the background as happens on android).
50 SetNeedsDraw();
53 void SurfacesScheduler::RemoveDisplay(cc::Display* display) {
54 auto it = displays_.find(display);
55 DCHECK(it != displays_.end());
56 displays_.erase(it);
59 void SurfacesScheduler::WillBeginImplFrame(const cc::BeginFrameArgs& args) {}
61 void SurfacesScheduler::DidFinishImplFrame() {}
63 void SurfacesScheduler::ScheduledActionSendBeginMainFrame() {
64 scheduler_->NotifyBeginMainFrameStarted();
65 scheduler_->NotifyReadyToCommit();
68 cc::DrawResult SurfacesScheduler::ScheduledActionDrawAndSwapIfPossible() {
69 for (const auto& it : displays_) {
70 it->DrawAndSwap();
72 return cc::DRAW_SUCCESS;
75 cc::DrawResult SurfacesScheduler::ScheduledActionDrawAndSwapForced() {
76 NOTREACHED() << "ScheduledActionDrawAndSwapIfPossible always succeeds.";
77 return cc::DRAW_SUCCESS;
80 void SurfacesScheduler::ScheduledActionAnimate() {}
82 void SurfacesScheduler::ScheduledActionCommit() {
83 scheduler_->NotifyReadyToActivate();
86 void SurfacesScheduler::ScheduledActionActivateSyncTree() {}
88 void SurfacesScheduler::ScheduledActionBeginOutputSurfaceCreation() {
89 scheduler_->DidCreateAndInitializeOutputSurface();
92 void SurfacesScheduler::ScheduledActionPrepareTiles() {}
94 void SurfacesScheduler::ScheduledActionInvalidateOutputSurface() {}
96 void SurfacesScheduler::SendBeginFramesToChildren(
97 const cc::BeginFrameArgs& args) {}
99 void SurfacesScheduler::SendBeginMainFrameNotExpectedSoon() {}
101 } // namespace mus