Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(472)

Side by Side Diff: cc/test/scheduler_test_common.cc

Issue 267783004: Refactoring the way begin frame sources inside scheduler work. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Major rewrite based on Brian's comments. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <string> 7 #include <string>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 10
(...skipping 16 matching lines...) Expand all
27 return now_src_->Now(); 27 return now_src_->Now();
28 } 28 }
29 29
30 std::string TestDelayBasedTimeSource::TypeString() const { 30 std::string TestDelayBasedTimeSource::TypeString() const {
31 return "TestDelayBasedTimeSource"; 31 return "TestDelayBasedTimeSource";
32 } 32 }
33 33
34 TestDelayBasedTimeSource::~TestDelayBasedTimeSource() { 34 TestDelayBasedTimeSource::~TestDelayBasedTimeSource() {
35 } 35 }
36 36
37 bool FakeBeginFrameSource::NeedsBeginFrames() {
38 return needs_begin_frames_;
39 }
40 void FakeBeginFrameSource::SetNeedsBeginFrames(bool needs_begin_frames) {
41 needs_begin_frames_ = needs_begin_frames;
42 }
43 void FakeBeginFrameSource::FinishedFrame(size_t remaining_frames) {
44 remaining_frames_ = remaining_frames;
45 }
46 void FakeBeginFrameSource::AsValueInto(base::debug::TracedValue* dict) const {
47 dict->SetString("type", "FakeBeginFrameSource");
48 }
49
37 TestScheduler::TestScheduler( 50 TestScheduler::TestScheduler(
38 scoped_refptr<TestNowSource> now_src, 51 scoped_refptr<TestNowSource> now_src,
39 SchedulerClient* client, 52 SchedulerClient* client,
40 const SchedulerSettings& scheduler_settings, 53 const SchedulerSettings& scheduler_settings,
41 int layer_tree_host_id, 54 int layer_tree_host_id,
42 const scoped_refptr<OrderedSimpleTaskRunner>& test_task_runner) 55 const scoped_refptr<OrderedSimpleTaskRunner>& test_task_runner)
43 : Scheduler(client, 56 : Scheduler(client,
44 scheduler_settings, 57 scheduler_settings,
45 layer_tree_host_id, 58 layer_tree_host_id,
46 test_task_runner), 59 test_task_runner),
47 now_src_(now_src), 60 now_src_(now_src),
48 test_task_runner_(test_task_runner.get()) { 61 test_task_runner_(test_task_runner.get()) {
62 }
63
64 void TestScheduler::SetUpBackgroundFrameSource() {
65 background_frame_source_store_ = TestSyntheticBeginFrameSource::Create(
66 now_src_, test_task_runner_, base::TimeDelta::FromSeconds(1));
67 }
68
69 void TestScheduler::SetUpPrimaryFrameSource() {
49 if (!settings_.begin_frame_scheduling_enabled) { 70 if (!settings_.begin_frame_scheduling_enabled) {
50 scoped_refptr<DelayBasedTimeSource> time_source = 71 primary_frame_source_store_ = TestSyntheticBeginFrameSource::Create(
51 TestDelayBasedTimeSource::Create( 72 now_src_, test_task_runner_, BeginFrameArgs::DefaultInterval());
52 now_src, VSyncInterval(), test_task_runner_); 73 primary_frame_source_ = primary_frame_source_store_.get();
53 synthetic_begin_frame_source_.reset( 74 } else {
54 new SyntheticBeginFrameSource(this, time_source)); 75 Scheduler::SetUpPrimaryFrameSource();
55 } 76 }
56 } 77 }
57 78
58 base::TimeTicks TestScheduler::Now() const { 79 base::TimeTicks TestScheduler::Now() const {
59 return now_src_->Now(); 80 return now_src_->Now();
60 } 81 }
61 82
62 TestScheduler::~TestScheduler() { 83 TestScheduler::~TestScheduler() {
63 } 84 }
64 85
65 } // namespace cc 86 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698