| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "services/surfaces/surfaces_scheduler.h" | 5 #include "services/surfaces/surfaces_scheduler.h" |
| 6 | 6 |
| 7 #include "cc/surfaces/display.h" |
| 8 |
| 7 namespace surfaces { | 9 namespace surfaces { |
| 8 | 10 |
| 9 SurfacesScheduler::Client::~Client() { | 11 SurfacesScheduler::SurfacesScheduler() { |
| 10 } | |
| 11 | |
| 12 SurfacesScheduler::SurfacesScheduler(Client* client) : client_(client) { | |
| 13 cc::SchedulerSettings settings; | 12 cc::SchedulerSettings settings; |
| 14 scheduler_ = cc::Scheduler::Create( | 13 scheduler_ = cc::Scheduler::Create( |
| 15 this, settings, 0, base::MessageLoop::current()->task_runner(), nullptr, | 14 this, settings, 0, base::MessageLoop::current()->task_runner(), nullptr, |
| 16 nullptr); | 15 nullptr); |
| 17 scheduler_->SetCanStart(); | 16 scheduler_->SetCanStart(); |
| 18 scheduler_->SetVisible(true); | 17 scheduler_->SetVisible(true); |
| 19 scheduler_->SetCanDraw(true); | 18 scheduler_->SetCanDraw(true); |
| 20 scheduler_->SetNeedsCommit(); | 19 scheduler_->SetNeedsCommit(); |
| 21 } | 20 } |
| 22 | 21 |
| 23 SurfacesScheduler::~SurfacesScheduler() { | 22 SurfacesScheduler::~SurfacesScheduler() { |
| 24 } | 23 } |
| 25 | 24 |
| 26 void SurfacesScheduler::SetNeedsDraw() { | 25 void SurfacesScheduler::SetNeedsDraw() { |
| 27 scheduler_->SetNeedsRedraw(); | 26 scheduler_->SetNeedsRedraw(); |
| 28 } | 27 } |
| 29 | 28 |
| 30 void SurfacesScheduler::OnVSyncParametersUpdated(base::TimeTicks timebase, | 29 void SurfacesScheduler::OnVSyncParametersUpdated(base::TimeTicks timebase, |
| 31 base::TimeDelta interval) { | 30 base::TimeDelta interval) { |
| 32 scheduler_->CommitVSyncParameters(timebase, interval); | 31 scheduler_->CommitVSyncParameters(timebase, interval); |
| 33 } | 32 } |
| 34 | 33 |
| 34 void SurfacesScheduler::AddDisplay(cc::Display* display) { |
| 35 DCHECK(displays_.find(display) == displays_.end()); |
| 36 displays_.insert(display); |
| 37 } |
| 38 |
| 39 void SurfacesScheduler::RemoveDisplay(cc::Display* display) { |
| 40 auto it = displays_.find(display); |
| 41 DCHECK(it != displays_.end()); |
| 42 displays_.erase(it); |
| 43 } |
| 44 |
| 35 void SurfacesScheduler::WillBeginImplFrame(const cc::BeginFrameArgs& args) { | 45 void SurfacesScheduler::WillBeginImplFrame(const cc::BeginFrameArgs& args) { |
| 36 } | 46 } |
| 37 | 47 |
| 38 void SurfacesScheduler::ScheduledActionSendBeginMainFrame() { | 48 void SurfacesScheduler::ScheduledActionSendBeginMainFrame() { |
| 39 scheduler_->NotifyBeginMainFrameStarted(); | 49 scheduler_->NotifyBeginMainFrameStarted(); |
| 40 scheduler_->NotifyReadyToCommit(); | 50 scheduler_->NotifyReadyToCommit(); |
| 41 } | 51 } |
| 42 | 52 |
| 43 cc::DrawResult SurfacesScheduler::ScheduledActionDrawAndSwapIfPossible() { | 53 cc::DrawResult SurfacesScheduler::ScheduledActionDrawAndSwapIfPossible() { |
| 44 base::TimeTicks start = base::TimeTicks::Now(); | 54 base::TimeTicks start = base::TimeTicks::Now(); |
| 45 client_->Draw(); | 55 for (const auto& it : displays_) { |
| 56 it->Draw(); |
| 57 } |
| 46 base::TimeDelta duration = base::TimeTicks::Now() - start; | 58 base::TimeDelta duration = base::TimeTicks::Now() - start; |
| 47 | 59 |
| 48 draw_estimate_ = (duration + draw_estimate_) / 2; | 60 draw_estimate_ = (duration + draw_estimate_) / 2; |
| 49 return cc::DRAW_SUCCESS; | 61 return cc::DRAW_SUCCESS; |
| 50 } | 62 } |
| 51 | 63 |
| 52 cc::DrawResult SurfacesScheduler::ScheduledActionDrawAndSwapForced() { | 64 cc::DrawResult SurfacesScheduler::ScheduledActionDrawAndSwapForced() { |
| 53 NOTREACHED() << "ScheduledActionDrawAndSwapIfPossible always succeeds."; | 65 NOTREACHED() << "ScheduledActionDrawAndSwapIfPossible always succeeds."; |
| 54 return cc::DRAW_SUCCESS; | 66 return cc::DRAW_SUCCESS; |
| 55 } | 67 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 } | 101 } |
| 90 | 102 |
| 91 void SurfacesScheduler::SendBeginFramesToChildren( | 103 void SurfacesScheduler::SendBeginFramesToChildren( |
| 92 const cc::BeginFrameArgs& args) { | 104 const cc::BeginFrameArgs& args) { |
| 93 } | 105 } |
| 94 | 106 |
| 95 void SurfacesScheduler::SendBeginMainFrameNotExpectedSoon() { | 107 void SurfacesScheduler::SendBeginMainFrameNotExpectedSoon() { |
| 96 } | 108 } |
| 97 | 109 |
| 98 } // namespace mojo | 110 } // namespace mojo |
| OLD | NEW |