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 "mojo/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 |
| 42 void SurfacesScheduler::RemoveDisplay(cc::Display* display) { |
| 43 auto it = displays_.find(display); |
| 44 DCHECK(it != displays_.end()); |
| 45 displays_.erase(it); |
| 46 } |
| 47 |
| 48 void SurfacesScheduler::WillBeginImplFrame(const cc::BeginFrameArgs& args) { |
| 49 } |
| 50 |
| 51 void SurfacesScheduler::ScheduledActionSendBeginMainFrame() { |
| 52 scheduler_->NotifyBeginMainFrameStarted(); |
| 53 scheduler_->NotifyReadyToCommit(); |
| 54 } |
| 55 |
| 56 cc::DrawResult SurfacesScheduler::ScheduledActionDrawAndSwapIfPossible() { |
| 57 base::TimeTicks start = base::TimeTicks::Now(); |
| 58 for (const auto& it : displays_) { |
| 59 it->Draw(); |
| 60 } |
| 61 base::TimeDelta duration = base::TimeTicks::Now() - start; |
| 62 |
| 63 draw_estimate_ = (duration + draw_estimate_) / 2; |
| 64 return cc::DRAW_SUCCESS; |
| 65 } |
| 66 |
| 67 cc::DrawResult SurfacesScheduler::ScheduledActionDrawAndSwapForced() { |
| 68 NOTREACHED() << "ScheduledActionDrawAndSwapIfPossible always succeeds."; |
| 69 return cc::DRAW_SUCCESS; |
| 70 } |
| 71 |
| 72 void SurfacesScheduler::ScheduledActionAnimate() { |
| 73 } |
| 74 |
| 75 void SurfacesScheduler::ScheduledActionCommit() { |
| 76 } |
| 77 |
| 78 void SurfacesScheduler::ScheduledActionActivateSyncTree() { |
| 79 } |
| 80 |
| 81 void SurfacesScheduler::ScheduledActionBeginOutputSurfaceCreation() { |
| 82 scheduler_->DidCreateAndInitializeOutputSurface(); |
| 83 } |
| 84 |
| 85 void SurfacesScheduler::ScheduledActionPrepareTiles() { |
| 86 } |
| 87 |
| 88 void SurfacesScheduler::DidAnticipatedDrawTimeChange(base::TimeTicks time) { |
| 89 } |
| 90 |
| 91 base::TimeDelta SurfacesScheduler::DrawDurationEstimate() { |
| 92 return draw_estimate_; |
| 93 } |
| 94 |
| 95 base::TimeDelta SurfacesScheduler::BeginMainFrameToCommitDurationEstimate() { |
| 96 return base::TimeDelta(); |
| 97 } |
| 98 |
| 99 base::TimeDelta SurfacesScheduler::CommitToActivateDurationEstimate() { |
| 100 return base::TimeDelta(); |
| 101 } |
| 102 |
| 103 void SurfacesScheduler::DidBeginImplFrameDeadline() { |
| 104 } |
| 105 |
| 106 void SurfacesScheduler::SendBeginFramesToChildren( |
| 107 const cc::BeginFrameArgs& args) { |
| 108 } |
| 109 |
| 110 void SurfacesScheduler::SendBeginMainFrameNotExpectedSoon() { |
| 111 } |
| 112 |
| 113 } // namespace mojo |
OLD | NEW |