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

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

Issue 22926024: cc: Control activation from the Scheduler (Closed) Base URL: http://git.chromium.org/chromium/src.git@schedOutputSurface4
Patch Set: git cl format Created 7 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
« no previous file with comments | « cc/test/layer_tree_test.h ('k') | cc/trees/layer_tree_host_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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/layer_tree_test.h" 5 #include "cc/test/layer_tree_test.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "cc/animation/animation.h" 8 #include "cc/animation/animation.h"
9 #include "cc/animation/animation_registrar.h" 9 #include "cc/animation/animation_registrar.h"
10 #include "cc/animation/layer_animation_controller.h" 10 #include "cc/animation/layer_animation_controller.h"
(...skipping 19 matching lines...) Expand all
30 TestHooks::TestHooks() {} 30 TestHooks::TestHooks() {}
31 31
32 TestHooks::~TestHooks() {} 32 TestHooks::~TestHooks() {}
33 33
34 bool TestHooks::PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, 34 bool TestHooks::PrepareToDrawOnThread(LayerTreeHostImpl* host_impl,
35 LayerTreeHostImpl::FrameData* frame_data, 35 LayerTreeHostImpl::FrameData* frame_data,
36 bool result) { 36 bool result) {
37 return true; 37 return true;
38 } 38 }
39 39
40 bool TestHooks::CanActivatePendingTree(LayerTreeHostImpl* host_impl) {
41 return true;
42 }
43
44 bool TestHooks::CanActivatePendingTreeIfNeeded(LayerTreeHostImpl* host_impl) {
45 return true;
46 }
47
48 // Adapts LayerTreeHostImpl for test. Runs real code, then invokes test hooks. 40 // Adapts LayerTreeHostImpl for test. Runs real code, then invokes test hooks.
49 class LayerTreeHostImplForTesting : public LayerTreeHostImpl { 41 class LayerTreeHostImplForTesting : public LayerTreeHostImpl {
50 public: 42 public:
51 static scoped_ptr<LayerTreeHostImplForTesting> Create( 43 static scoped_ptr<LayerTreeHostImplForTesting> Create(
52 TestHooks* test_hooks, 44 TestHooks* test_hooks,
53 const LayerTreeSettings& settings, 45 const LayerTreeSettings& settings,
54 LayerTreeHostImplClient* host_impl_client, 46 LayerTreeHostImplClient* host_impl_client,
55 Proxy* proxy, 47 Proxy* proxy,
56 RenderingStatsInstrumentation* stats_instrumentation) { 48 RenderingStatsInstrumentation* stats_instrumentation) {
57 return make_scoped_ptr( 49 return make_scoped_ptr(
58 new LayerTreeHostImplForTesting(test_hooks, 50 new LayerTreeHostImplForTesting(test_hooks,
59 settings, 51 settings,
60 host_impl_client, 52 host_impl_client,
61 proxy, 53 proxy,
62 stats_instrumentation)); 54 stats_instrumentation));
63 } 55 }
64 56
65 protected: 57 protected:
66 LayerTreeHostImplForTesting( 58 LayerTreeHostImplForTesting(
67 TestHooks* test_hooks, 59 TestHooks* test_hooks,
68 const LayerTreeSettings& settings, 60 const LayerTreeSettings& settings,
69 LayerTreeHostImplClient* host_impl_client, 61 LayerTreeHostImplClient* host_impl_client,
70 Proxy* proxy, 62 Proxy* proxy,
71 RenderingStatsInstrumentation* stats_instrumentation) 63 RenderingStatsInstrumentation* stats_instrumentation)
72 : LayerTreeHostImpl(settings, 64 : LayerTreeHostImpl(settings,
73 host_impl_client, 65 host_impl_client,
74 proxy, 66 proxy,
75 stats_instrumentation), 67 stats_instrumentation),
76 test_hooks_(test_hooks) {} 68 test_hooks_(test_hooks),
69 block_notify_ready_to_activate_for_testing_(false),
70 notify_ready_to_activate_was_blocked_(false) {}
71
72 virtual void BeginFrame(const BeginFrameArgs& args) OVERRIDE {
73 test_hooks_->WillBeginImplFrameOnThread(this, args);
74 LayerTreeHostImpl::BeginFrame(args);
75 }
77 76
78 virtual void BeginCommit() OVERRIDE { 77 virtual void BeginCommit() OVERRIDE {
79 LayerTreeHostImpl::BeginCommit(); 78 LayerTreeHostImpl::BeginCommit();
80 test_hooks_->BeginCommitOnThread(this); 79 test_hooks_->BeginCommitOnThread(this);
81 } 80 }
82 81
83 virtual void CommitComplete() OVERRIDE { 82 virtual void CommitComplete() OVERRIDE {
84 LayerTreeHostImpl::CommitComplete(); 83 LayerTreeHostImpl::CommitComplete();
85 test_hooks_->CommitCompleteOnThread(this); 84 test_hooks_->CommitCompleteOnThread(this);
86 85
(...skipping 20 matching lines...) Expand all
107 bool result = LayerTreeHostImpl::SwapBuffers(frame); 106 bool result = LayerTreeHostImpl::SwapBuffers(frame);
108 test_hooks_->SwapBuffersOnThread(this, result); 107 test_hooks_->SwapBuffersOnThread(this, result);
109 return result; 108 return result;
110 } 109 }
111 110
112 virtual void OnSwapBuffersComplete(const CompositorFrameAck* ack) OVERRIDE { 111 virtual void OnSwapBuffersComplete(const CompositorFrameAck* ack) OVERRIDE {
113 LayerTreeHostImpl::OnSwapBuffersComplete(ack); 112 LayerTreeHostImpl::OnSwapBuffersComplete(ack);
114 test_hooks_->SwapBuffersCompleteOnThread(this); 113 test_hooks_->SwapBuffersCompleteOnThread(this);
115 } 114 }
116 115
117 virtual void ActivatePendingTreeIfNeeded() OVERRIDE { 116 virtual void NotifyReadyToActivate() OVERRIDE {
118 if (!pending_tree()) 117 if (block_notify_ready_to_activate_for_testing_)
119 return; 118 notify_ready_to_activate_was_blocked_ = true;
119 else
120 client_->NotifyReadyToActivate();
121 }
120 122
121 if (!test_hooks_->CanActivatePendingTreeIfNeeded(this)) 123 virtual void BlockNotifyReadyToActivateForTesting(bool block) OVERRIDE {
122 return; 124 block_notify_ready_to_activate_for_testing_ = block;
123 125 if (!block && notify_ready_to_activate_was_blocked_) {
124 LayerTreeHostImpl::ActivatePendingTreeIfNeeded(); 126 NotifyReadyToActivate();
127 notify_ready_to_activate_was_blocked_ = false;
128 }
125 } 129 }
126 130
127 virtual void ActivatePendingTree() OVERRIDE { 131 virtual void ActivatePendingTree() OVERRIDE {
128 if (!test_hooks_->CanActivatePendingTree(this))
129 return;
130
131 test_hooks_->WillActivateTreeOnThread(this); 132 test_hooks_->WillActivateTreeOnThread(this);
132 LayerTreeHostImpl::ActivatePendingTree(); 133 LayerTreeHostImpl::ActivatePendingTree();
133 DCHECK(!pending_tree()); 134 DCHECK(!pending_tree());
134 test_hooks_->DidActivateTreeOnThread(this); 135 test_hooks_->DidActivateTreeOnThread(this);
135 } 136 }
136 137
137 virtual bool InitializeRenderer(scoped_ptr<OutputSurface> output_surface) 138 virtual bool InitializeRenderer(scoped_ptr<OutputSurface> output_surface)
138 OVERRIDE { 139 OVERRIDE {
139 bool success = LayerTreeHostImpl::InitializeRenderer(output_surface.Pass()); 140 bool success = LayerTreeHostImpl::InitializeRenderer(output_surface.Pass());
140 test_hooks_->InitializedRendererOnThread(this, success); 141 test_hooks_->InitializedRendererOnThread(this, success);
(...skipping 25 matching lines...) Expand all
166 } 167 }
167 test_hooks_->UpdateAnimationState(this, has_unfinished_animation); 168 test_hooks_->UpdateAnimationState(this, has_unfinished_animation);
168 } 169 }
169 170
170 virtual base::TimeDelta LowFrequencyAnimationInterval() const OVERRIDE { 171 virtual base::TimeDelta LowFrequencyAnimationInterval() const OVERRIDE {
171 return base::TimeDelta::FromMilliseconds(16); 172 return base::TimeDelta::FromMilliseconds(16);
172 } 173 }
173 174
174 private: 175 private:
175 TestHooks* test_hooks_; 176 TestHooks* test_hooks_;
177 bool block_notify_ready_to_activate_for_testing_;
178 bool notify_ready_to_activate_was_blocked_;
176 }; 179 };
177 180
178 // Adapts LayerTreeHost for test. Injects LayerTreeHostImplForTesting. 181 // Adapts LayerTreeHost for test. Injects LayerTreeHostImplForTesting.
179 class LayerTreeHostForTesting : public cc::LayerTreeHost { 182 class LayerTreeHostForTesting : public cc::LayerTreeHost {
180 public: 183 public:
181 static scoped_ptr<LayerTreeHostForTesting> Create( 184 static scoped_ptr<LayerTreeHostForTesting> Create(
182 TestHooks* test_hooks, 185 TestHooks* test_hooks,
183 cc::LayerTreeHostClient* host_client, 186 cc::LayerTreeHostClient* host_client,
184 const cc::LayerTreeSettings& settings, 187 const cc::LayerTreeSettings& settings,
185 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { 188 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) {
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 627
625 scoped_refptr<cc::ContextProvider> LayerTreeTest:: 628 scoped_refptr<cc::ContextProvider> LayerTreeTest::
626 OffscreenContextProviderForCompositorThread() { 629 OffscreenContextProviderForCompositorThread() {
627 if (!compositor_thread_contexts_.get() || 630 if (!compositor_thread_contexts_.get() ||
628 compositor_thread_contexts_->DestroyedOnMainThread()) 631 compositor_thread_contexts_->DestroyedOnMainThread())
629 compositor_thread_contexts_ = TestContextProvider::Create(); 632 compositor_thread_contexts_ = TestContextProvider::Create();
630 return compositor_thread_contexts_; 633 return compositor_thread_contexts_;
631 } 634 }
632 635
633 } // namespace cc 636 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/layer_tree_test.h ('k') | cc/trees/layer_tree_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698