| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "cc/test/scheduler_test_common.h" | 5 #include "cc/test/scheduler_test_common.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "cc/debug/rendering_stats_instrumentation.h" | 13 #include "cc/debug/rendering_stats_instrumentation.h" |
| 14 | 14 |
| 15 namespace cc { | 15 namespace cc { |
| 16 | 16 |
| 17 void FakeDelayBasedTimeSourceClient::OnTimerTick() { | 17 void FakeDelayBasedTimeSourceClient::OnTimerTick() { |
| 18 tick_called_ = true; | 18 tick_called_ = true; |
| 19 } | 19 } |
| 20 | 20 |
| 21 base::TimeTicks FakeDelayBasedTimeSource::Now() const { return now_; } | 21 base::TimeTicks FakeDelayBasedTimeSource::Now() const { |
| 22 return now_; |
| 23 } |
| 22 | 24 |
| 23 TestDelayBasedTimeSource::TestDelayBasedTimeSource( | 25 TestDelayBasedTimeSource::TestDelayBasedTimeSource( |
| 24 base::SimpleTestTickClock* now_src, | 26 base::SimpleTestTickClock* now_src, |
| 25 OrderedSimpleTaskRunner* task_runner) | 27 OrderedSimpleTaskRunner* task_runner) |
| 26 : DelayBasedTimeSource(task_runner), now_src_(now_src) {} | 28 : DelayBasedTimeSource(task_runner), now_src_(now_src) {} |
| 27 | 29 |
| 28 base::TimeTicks TestDelayBasedTimeSource::Now() const { | 30 base::TimeTicks TestDelayBasedTimeSource::Now() const { |
| 29 return now_src_->NowTicks(); | 31 return now_src_->NowTicks(); |
| 30 } | 32 } |
| 31 | 33 |
| 32 std::string TestDelayBasedTimeSource::TypeString() const { | 34 std::string TestDelayBasedTimeSource::TypeString() const { |
| 33 return "TestDelayBasedTimeSource"; | 35 return "TestDelayBasedTimeSource"; |
| 34 } | 36 } |
| 35 | 37 |
| 36 TestDelayBasedTimeSource::~TestDelayBasedTimeSource() { | 38 TestDelayBasedTimeSource::~TestDelayBasedTimeSource() {} |
| 37 } | |
| 38 | 39 |
| 39 std::unique_ptr<FakeCompositorTimingHistory> | 40 std::unique_ptr<FakeCompositorTimingHistory> |
| 40 FakeCompositorTimingHistory::Create( | 41 FakeCompositorTimingHistory::Create( |
| 41 bool using_synchronous_renderer_compositor) { | 42 bool using_synchronous_renderer_compositor) { |
| 42 std::unique_ptr<RenderingStatsInstrumentation> | 43 std::unique_ptr<RenderingStatsInstrumentation> |
| 43 rendering_stats_instrumentation = RenderingStatsInstrumentation::Create(); | 44 rendering_stats_instrumentation = RenderingStatsInstrumentation::Create(); |
| 44 return base::WrapUnique(new FakeCompositorTimingHistory( | 45 return base::WrapUnique(new FakeCompositorTimingHistory( |
| 45 using_synchronous_renderer_compositor, | 46 using_synchronous_renderer_compositor, |
| 46 std::move(rendering_stats_instrumentation))); | 47 std::move(rendering_stats_instrumentation))); |
| 47 } | 48 } |
| 48 | 49 |
| 49 FakeCompositorTimingHistory::FakeCompositorTimingHistory( | 50 FakeCompositorTimingHistory::FakeCompositorTimingHistory( |
| 50 bool using_synchronous_renderer_compositor, | 51 bool using_synchronous_renderer_compositor, |
| 51 std::unique_ptr<RenderingStatsInstrumentation> | 52 std::unique_ptr<RenderingStatsInstrumentation> |
| 52 rendering_stats_instrumentation) | 53 rendering_stats_instrumentation) |
| 53 : CompositorTimingHistory(using_synchronous_renderer_compositor, | 54 : CompositorTimingHistory(using_synchronous_renderer_compositor, |
| 54 CompositorTimingHistory::NULL_UMA, | 55 CompositorTimingHistory::NULL_UMA, |
| 55 rendering_stats_instrumentation.get()), | 56 rendering_stats_instrumentation.get()), |
| 56 rendering_stats_instrumentation_owned_( | 57 rendering_stats_instrumentation_owned_( |
| 57 std::move(rendering_stats_instrumentation)) {} | 58 std::move(rendering_stats_instrumentation)) {} |
| 58 | 59 |
| 59 FakeCompositorTimingHistory::~FakeCompositorTimingHistory() { | 60 FakeCompositorTimingHistory::~FakeCompositorTimingHistory() {} |
| 60 } | |
| 61 | 61 |
| 62 void FakeCompositorTimingHistory::SetAllEstimatesTo(base::TimeDelta duration) { | 62 void FakeCompositorTimingHistory::SetAllEstimatesTo(base::TimeDelta duration) { |
| 63 begin_main_frame_queue_duration_critical_ = duration; | 63 begin_main_frame_queue_duration_critical_ = duration; |
| 64 begin_main_frame_queue_duration_not_critical_ = duration; | 64 begin_main_frame_queue_duration_not_critical_ = duration; |
| 65 begin_main_frame_start_to_commit_duration_ = duration; | 65 begin_main_frame_start_to_commit_duration_ = duration; |
| 66 commit_to_ready_to_activate_duration_ = duration; | 66 commit_to_ready_to_activate_duration_ = duration; |
| 67 prepare_tiles_duration_ = duration; | 67 prepare_tiles_duration_ = duration; |
| 68 activate_duration_ = duration; | 68 activate_duration_ = duration; |
| 69 draw_duration_ = duration; | 69 draw_duration_ = duration; |
| 70 } | 70 } |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 int layer_tree_host_id, | 148 int layer_tree_host_id, |
| 149 OrderedSimpleTaskRunner* task_runner, | 149 OrderedSimpleTaskRunner* task_runner, |
| 150 BeginFrameSource* begin_frame_source, | 150 BeginFrameSource* begin_frame_source, |
| 151 std::unique_ptr<CompositorTimingHistory> compositor_timing_history) | 151 std::unique_ptr<CompositorTimingHistory> compositor_timing_history) |
| 152 : Scheduler(client, | 152 : Scheduler(client, |
| 153 scheduler_settings, | 153 scheduler_settings, |
| 154 layer_tree_host_id, | 154 layer_tree_host_id, |
| 155 task_runner, | 155 task_runner, |
| 156 begin_frame_source, | 156 begin_frame_source, |
| 157 std::move(compositor_timing_history)), | 157 std::move(compositor_timing_history)), |
| 158 now_src_(now_src) {} | 158 now_src_(now_src), |
| 159 num_begin_frames_(0) {} |
| 159 | 160 |
| 160 base::TimeTicks TestScheduler::Now() const { | 161 base::TimeTicks TestScheduler::Now() const { |
| 161 return now_src_->NowTicks(); | 162 return now_src_->NowTicks(); |
| 162 } | 163 } |
| 163 | 164 |
| 164 TestScheduler::~TestScheduler() { | 165 bool TestScheduler::OnBeginFrameDerivedImpl(const BeginFrameArgs& args) { |
| 166 num_begin_frames_++; |
| 167 return Scheduler::OnBeginFrameDerivedImpl(args); |
| 165 } | 168 } |
| 166 | 169 |
| 170 base::Callback<bool(void)> TestScheduler::InCurrentFrame() const { |
| 171 return base::Bind(&TestScheduler::InCurrentFrameCallback, |
| 172 base::Unretained(this), num_begin_frames_); |
| 173 } |
| 174 |
| 175 bool TestScheduler::InCurrentFrameCallback(int num_begin_frames) const { |
| 176 return num_begin_frames_ == num_begin_frames; |
| 177 } |
| 178 |
| 179 TestScheduler::~TestScheduler() {} |
| 180 |
| 167 } // namespace cc | 181 } // namespace cc |
| OLD | NEW |