| 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 "components/view_manager/surfaces/surfaces_scheduler.h" | 5 #include "components/view_manager/surfaces/surfaces_scheduler.h" |
| 6 | 6 |
| 7 #include "cc/debug/rendering_stats_instrumentation.h" |
| 8 #include "cc/scheduler/compositor_timing_history.h" |
| 7 #include "cc/surfaces/display.h" | 9 #include "cc/surfaces/display.h" |
| 8 | 10 |
| 9 namespace surfaces { | 11 namespace surfaces { |
| 10 | 12 |
| 11 SurfacesScheduler::SurfacesScheduler() { | 13 SurfacesScheduler::SurfacesScheduler() |
| 14 : rendering_stats_instrumentation_( |
| 15 cc::RenderingStatsInstrumentation::Create()) { |
| 12 cc::SchedulerSettings settings; | 16 cc::SchedulerSettings settings; |
| 17 scoped_ptr<cc::CompositorTimingHistory> compositor_timing_history( |
| 18 new cc::CompositorTimingHistory(rendering_stats_instrumentation_.get())); |
| 13 scheduler_ = cc::Scheduler::Create( | 19 scheduler_ = cc::Scheduler::Create( |
| 14 this, settings, 0, base::MessageLoop::current()->task_runner().get(), | 20 this, settings, 0, base::MessageLoop::current()->task_runner().get(), |
| 15 nullptr); | 21 nullptr, compositor_timing_history.Pass()); |
| 16 scheduler_->SetCanStart(); | 22 scheduler_->SetCanStart(); |
| 17 scheduler_->SetVisible(true); | 23 scheduler_->SetVisible(true); |
| 18 scheduler_->SetCanDraw(true); | 24 scheduler_->SetCanDraw(true); |
| 19 scheduler_->SetNeedsCommit(); | 25 scheduler_->SetNeedsCommit(); |
| 20 } | 26 } |
| 21 | 27 |
| 22 SurfacesScheduler::~SurfacesScheduler() { | 28 SurfacesScheduler::~SurfacesScheduler() { |
| 23 } | 29 } |
| 24 | 30 |
| 25 void SurfacesScheduler::SetNeedsDraw() { | 31 void SurfacesScheduler::SetNeedsDraw() { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 55 | 61 |
| 56 void SurfacesScheduler::DidFinishImplFrame() { | 62 void SurfacesScheduler::DidFinishImplFrame() { |
| 57 } | 63 } |
| 58 | 64 |
| 59 void SurfacesScheduler::ScheduledActionSendBeginMainFrame() { | 65 void SurfacesScheduler::ScheduledActionSendBeginMainFrame() { |
| 60 scheduler_->NotifyBeginMainFrameStarted(); | 66 scheduler_->NotifyBeginMainFrameStarted(); |
| 61 scheduler_->NotifyReadyToCommit(); | 67 scheduler_->NotifyReadyToCommit(); |
| 62 } | 68 } |
| 63 | 69 |
| 64 cc::DrawResult SurfacesScheduler::ScheduledActionDrawAndSwapIfPossible() { | 70 cc::DrawResult SurfacesScheduler::ScheduledActionDrawAndSwapIfPossible() { |
| 65 base::TimeTicks start = base::TimeTicks::Now(); | |
| 66 for (const auto& it : displays_) { | 71 for (const auto& it : displays_) { |
| 67 it->DrawAndSwap(); | 72 it->DrawAndSwap(); |
| 68 } | 73 } |
| 69 base::TimeDelta duration = base::TimeTicks::Now() - start; | |
| 70 | |
| 71 draw_estimate_ = (duration + draw_estimate_) / 2; | |
| 72 return cc::DRAW_SUCCESS; | 74 return cc::DRAW_SUCCESS; |
| 73 } | 75 } |
| 74 | 76 |
| 75 cc::DrawResult SurfacesScheduler::ScheduledActionDrawAndSwapForced() { | 77 cc::DrawResult SurfacesScheduler::ScheduledActionDrawAndSwapForced() { |
| 76 NOTREACHED() << "ScheduledActionDrawAndSwapIfPossible always succeeds."; | 78 NOTREACHED() << "ScheduledActionDrawAndSwapIfPossible always succeeds."; |
| 77 return cc::DRAW_SUCCESS; | 79 return cc::DRAW_SUCCESS; |
| 78 } | 80 } |
| 79 | 81 |
| 80 void SurfacesScheduler::ScheduledActionAnimate() { | 82 void SurfacesScheduler::ScheduledActionAnimate() { |
| 81 } | 83 } |
| 82 | 84 |
| 83 void SurfacesScheduler::ScheduledActionCommit() { | 85 void SurfacesScheduler::ScheduledActionCommit() { |
| 84 scheduler_->NotifyReadyToActivate(); | 86 scheduler_->NotifyReadyToActivate(); |
| 85 } | 87 } |
| 86 | 88 |
| 87 void SurfacesScheduler::ScheduledActionActivateSyncTree() { | 89 void SurfacesScheduler::ScheduledActionActivateSyncTree() { |
| 88 } | 90 } |
| 89 | 91 |
| 90 void SurfacesScheduler::ScheduledActionBeginOutputSurfaceCreation() { | 92 void SurfacesScheduler::ScheduledActionBeginOutputSurfaceCreation() { |
| 91 scheduler_->DidCreateAndInitializeOutputSurface(); | 93 scheduler_->DidCreateAndInitializeOutputSurface(); |
| 92 } | 94 } |
| 93 | 95 |
| 94 void SurfacesScheduler::ScheduledActionPrepareTiles() { | 96 void SurfacesScheduler::ScheduledActionPrepareTiles() { |
| 95 } | 97 } |
| 96 | 98 |
| 97 void SurfacesScheduler::ScheduledActionInvalidateOutputSurface() { | 99 void SurfacesScheduler::ScheduledActionInvalidateOutputSurface() { |
| 98 } | 100 } |
| 99 | 101 |
| 100 base::TimeDelta SurfacesScheduler::DrawDurationEstimate() { | |
| 101 return draw_estimate_; | |
| 102 } | |
| 103 | |
| 104 base::TimeDelta SurfacesScheduler::BeginMainFrameToCommitDurationEstimate() { | |
| 105 return base::TimeDelta(); | |
| 106 } | |
| 107 | |
| 108 base::TimeDelta SurfacesScheduler::CommitToActivateDurationEstimate() { | |
| 109 return base::TimeDelta(); | |
| 110 } | |
| 111 | |
| 112 void SurfacesScheduler::SendBeginFramesToChildren( | 102 void SurfacesScheduler::SendBeginFramesToChildren( |
| 113 const cc::BeginFrameArgs& args) { | 103 const cc::BeginFrameArgs& args) { |
| 114 } | 104 } |
| 115 | 105 |
| 116 void SurfacesScheduler::SendBeginMainFrameNotExpectedSoon() { | 106 void SurfacesScheduler::SendBeginMainFrameNotExpectedSoon() { |
| 117 } | 107 } |
| 118 | 108 |
| 119 } // namespace mojo | 109 } // namespace mojo |
| OLD | NEW |