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 61823008: Introduce separate client and init path for single-threaded cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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
« no previous file with comments | « cc/test/fake_layer_tree_host_client.h ('k') | cc/trees/layer_tree_host.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"
11 #include "cc/animation/timing_function.h" 11 #include "cc/animation/timing_function.h"
12 #include "cc/base/switches.h" 12 #include "cc/base/switches.h"
13 #include "cc/input/input_handler.h" 13 #include "cc/input/input_handler.h"
14 #include "cc/layers/content_layer.h" 14 #include "cc/layers/content_layer.h"
15 #include "cc/layers/layer.h" 15 #include "cc/layers/layer.h"
16 #include "cc/layers/layer_impl.h" 16 #include "cc/layers/layer_impl.h"
17 #include "cc/test/animation_test_common.h" 17 #include "cc/test/animation_test_common.h"
18 #include "cc/test/fake_layer_tree_host_client.h" 18 #include "cc/test/fake_layer_tree_host_client.h"
19 #include "cc/test/fake_output_surface.h" 19 #include "cc/test/fake_output_surface.h"
20 #include "cc/test/occlusion_tracker_test_common.h" 20 #include "cc/test/occlusion_tracker_test_common.h"
21 #include "cc/test/test_context_provider.h" 21 #include "cc/test/test_context_provider.h"
22 #include "cc/test/tiled_layer_test_common.h" 22 #include "cc/test/tiled_layer_test_common.h"
23 #include "cc/trees/layer_tree_host_client.h"
23 #include "cc/trees/layer_tree_host_impl.h" 24 #include "cc/trees/layer_tree_host_impl.h"
25 #include "cc/trees/layer_tree_host_single_thread_client.h"
24 #include "cc/trees/single_thread_proxy.h" 26 #include "cc/trees/single_thread_proxy.h"
25 #include "testing/gmock/include/gmock/gmock.h" 27 #include "testing/gmock/include/gmock/gmock.h"
26 #include "ui/gfx/frame_time.h" 28 #include "ui/gfx/frame_time.h"
27 #include "ui/gfx/size_conversions.h" 29 #include "ui/gfx/size_conversions.h"
28 30
29 namespace cc { 31 namespace cc {
30 32
31 TestHooks::TestHooks() {} 33 TestHooks::TestHooks() {}
32 34
33 TestHooks::~TestHooks() {} 35 TestHooks::~TestHooks() {}
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 virtual base::TimeDelta LowFrequencyAnimationInterval() const OVERRIDE { 189 virtual base::TimeDelta LowFrequencyAnimationInterval() const OVERRIDE {
188 return test_hooks_->LowFrequencyAnimationInterval(); 190 return test_hooks_->LowFrequencyAnimationInterval();
189 } 191 }
190 192
191 private: 193 private:
192 TestHooks* test_hooks_; 194 TestHooks* test_hooks_;
193 bool block_notify_ready_to_activate_for_testing_; 195 bool block_notify_ready_to_activate_for_testing_;
194 bool notify_ready_to_activate_was_blocked_; 196 bool notify_ready_to_activate_was_blocked_;
195 }; 197 };
196 198
197 // Adapts LayerTreeHost for test. Injects LayerTreeHostImplForTesting.
198 class LayerTreeHostForTesting : public LayerTreeHost {
199 public:
200 static scoped_ptr<LayerTreeHostForTesting> Create(
201 TestHooks* test_hooks,
202 LayerTreeHostClient* host_client,
203 const LayerTreeSettings& settings,
204 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) {
205 scoped_ptr<LayerTreeHostForTesting> layer_tree_host(
206 new LayerTreeHostForTesting(test_hooks, host_client, settings));
207 bool success = layer_tree_host->Initialize(impl_task_runner);
208 EXPECT_TRUE(success);
209 return layer_tree_host.Pass();
210 }
211
212 virtual scoped_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl(
213 LayerTreeHostImplClient* host_impl_client) OVERRIDE {
214 return LayerTreeHostImplForTesting::Create(
215 test_hooks_,
216 settings(),
217 host_impl_client,
218 proxy(),
219 rendering_stats_instrumentation()).PassAs<LayerTreeHostImpl>();
220 }
221
222 virtual void SetNeedsCommit() OVERRIDE {
223 if (!test_started_)
224 return;
225 LayerTreeHost::SetNeedsCommit();
226 }
227
228 void set_test_started(bool started) { test_started_ = started; }
229
230 virtual void DidDeferCommit() OVERRIDE {
231 test_hooks_->DidDeferCommit();
232 }
233
234 private:
235 LayerTreeHostForTesting(TestHooks* test_hooks,
236 LayerTreeHostClient* client,
237 const LayerTreeSettings& settings)
238 : LayerTreeHost(client, NULL, settings),
239 test_hooks_(test_hooks),
240 test_started_(false) {}
241
242 TestHooks* test_hooks_;
243 bool test_started_;
244 };
245
246 // Implementation of LayerTreeHost callback interface. 199 // Implementation of LayerTreeHost callback interface.
247 class LayerTreeHostClientForTesting : public LayerTreeHostClient { 200 class LayerTreeHostClientForTesting : public LayerTreeHostClient,
201 public LayerTreeHostSingleThreadClient {
248 public: 202 public:
249 static scoped_ptr<LayerTreeHostClientForTesting> Create( 203 static scoped_ptr<LayerTreeHostClientForTesting> Create(
250 TestHooks* test_hooks) { 204 TestHooks* test_hooks) {
251 return make_scoped_ptr(new LayerTreeHostClientForTesting(test_hooks)); 205 return make_scoped_ptr(new LayerTreeHostClientForTesting(test_hooks));
252 } 206 }
253 virtual ~LayerTreeHostClientForTesting() {} 207 virtual ~LayerTreeHostClientForTesting() {}
254 208
255 virtual void WillBeginMainFrame() OVERRIDE { 209 virtual void WillBeginMainFrame() OVERRIDE {
256 test_hooks_->WillBeginMainFrame(); 210 test_hooks_->WillBeginMainFrame();
257 } 211 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 } 252 }
299 253
300 virtual void DidCompleteSwapBuffers() OVERRIDE { 254 virtual void DidCompleteSwapBuffers() OVERRIDE {
301 test_hooks_->DidCompleteSwapBuffers(); 255 test_hooks_->DidCompleteSwapBuffers();
302 } 256 }
303 257
304 virtual void ScheduleComposite() OVERRIDE { 258 virtual void ScheduleComposite() OVERRIDE {
305 test_hooks_->ScheduleComposite(); 259 test_hooks_->ScheduleComposite();
306 } 260 }
307 261
262 virtual void DidPostSwapBuffers() OVERRIDE {}
263 virtual void DidAbortSwapBuffers() OVERRIDE {}
264
308 virtual scoped_refptr<ContextProvider> OffscreenContextProvider() OVERRIDE { 265 virtual scoped_refptr<ContextProvider> OffscreenContextProvider() OVERRIDE {
309 return test_hooks_->OffscreenContextProvider(); 266 return test_hooks_->OffscreenContextProvider();
310 } 267 }
311 268
312 private: 269 private:
313 explicit LayerTreeHostClientForTesting(TestHooks* test_hooks) 270 explicit LayerTreeHostClientForTesting(TestHooks* test_hooks)
314 : test_hooks_(test_hooks) {} 271 : test_hooks_(test_hooks) {}
315 272
316 TestHooks* test_hooks_; 273 TestHooks* test_hooks_;
317 }; 274 };
318 275
276 // Adapts LayerTreeHost for test. Injects LayerTreeHostImplForTesting.
277 class LayerTreeHostForTesting : public LayerTreeHost {
278 public:
279 static scoped_ptr<LayerTreeHostForTesting> Create(
280 TestHooks* test_hooks,
281 LayerTreeHostClientForTesting* client,
282 const LayerTreeSettings& settings,
283 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) {
284 scoped_ptr<LayerTreeHostForTesting> layer_tree_host(
285 new LayerTreeHostForTesting(test_hooks, client, settings));
286 bool success;
287 if (impl_task_runner.get())
288 success = layer_tree_host->InitializeThreaded(impl_task_runner);
289 else
290 success = layer_tree_host->InitializeSingleThreaded(client);
291 EXPECT_TRUE(success);
292 return layer_tree_host.Pass();
293 }
294
295 virtual scoped_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl(
296 LayerTreeHostImplClient* host_impl_client) OVERRIDE {
297 return LayerTreeHostImplForTesting::Create(
298 test_hooks_,
299 settings(),
300 host_impl_client,
301 proxy(),
302 rendering_stats_instrumentation()).PassAs<LayerTreeHostImpl>();
303 }
304
305 virtual void SetNeedsCommit() OVERRIDE {
306 if (!test_started_)
307 return;
308 LayerTreeHost::SetNeedsCommit();
309 }
310
311 void set_test_started(bool started) { test_started_ = started; }
312
313 virtual void DidDeferCommit() OVERRIDE {
314 test_hooks_->DidDeferCommit();
315 }
316
317 private:
318 LayerTreeHostForTesting(TestHooks* test_hooks,
319 LayerTreeHostClient* client,
320 const LayerTreeSettings& settings)
321 : LayerTreeHost(client, NULL, settings),
322 test_hooks_(test_hooks),
323 test_started_(false) {}
324
325 TestHooks* test_hooks_;
326 bool test_started_;
327 };
328
319 LayerTreeTest::LayerTreeTest() 329 LayerTreeTest::LayerTreeTest()
320 : beginning_(false), 330 : beginning_(false),
321 end_when_begin_returns_(false), 331 end_when_begin_returns_(false),
322 timed_out_(false), 332 timed_out_(false),
323 scheduled_(false), 333 scheduled_(false),
324 schedule_when_set_visible_true_(false), 334 schedule_when_set_visible_true_(false),
325 started_(false), 335 started_(false),
326 ended_(false), 336 ended_(false),
327 delegating_renderer_(false), 337 delegating_renderer_(false),
328 timeout_seconds_(0), 338 timeout_seconds_(0),
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 } 668 }
659 669
660 scoped_refptr<ContextProvider> LayerTreeTest::OffscreenContextProvider() { 670 scoped_refptr<ContextProvider> LayerTreeTest::OffscreenContextProvider() {
661 if (!compositor_contexts_.get() || 671 if (!compositor_contexts_.get() ||
662 compositor_contexts_->DestroyedOnMainThread()) 672 compositor_contexts_->DestroyedOnMainThread())
663 compositor_contexts_ = TestContextProvider::Create(); 673 compositor_contexts_ = TestContextProvider::Create();
664 return compositor_contexts_; 674 return compositor_contexts_;
665 } 675 }
666 676
667 } // namespace cc 677 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/fake_layer_tree_host_client.h ('k') | cc/trees/layer_tree_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698