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

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

Issue 845393002: cc: Create ProxyBeginFrameSource (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 5 years, 10 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
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 void TestHooks::CreateResourceAndTileTaskWorkerPool( 54 void TestHooks::CreateResourceAndTileTaskWorkerPool(
55 LayerTreeHostImpl* host_impl, 55 LayerTreeHostImpl* host_impl,
56 scoped_ptr<TileTaskWorkerPool>* tile_task_worker_pool, 56 scoped_ptr<TileTaskWorkerPool>* tile_task_worker_pool,
57 scoped_ptr<ResourcePool>* resource_pool, 57 scoped_ptr<ResourcePool>* resource_pool,
58 scoped_ptr<ResourcePool>* staging_resource_pool) { 58 scoped_ptr<ResourcePool>* staging_resource_pool) {
59 host_impl->LayerTreeHostImpl::CreateResourceAndTileTaskWorkerPool( 59 host_impl->LayerTreeHostImpl::CreateResourceAndTileTaskWorkerPool(
60 tile_task_worker_pool, resource_pool, staging_resource_pool); 60 tile_task_worker_pool, resource_pool, staging_resource_pool);
61 } 61 }
62 62
63 class TestProxyBeginFrameSource : public ProxyBeginFrameSource {
64 public:
65 explicit TestProxyBeginFrameSource(TestHooks* test_hooks)
66 : test_hooks_(test_hooks) {}
67 ~TestProxyBeginFrameSource() override {}
68
69 void BeginFrames(const BeginFrameArgs& args) override {
70 test_hooks_->SendBeginFramesToChildren(args);
71 }
72
73 private:
74 TestHooks* test_hooks_;
75 };
76
63 // Adapts ThreadProxy for test. Injects test hooks for testing. 77 // Adapts ThreadProxy for test. Injects test hooks for testing.
64 class ThreadProxyForTest : public ThreadProxy { 78 class ThreadProxyForTest : public ThreadProxy {
65 public: 79 public:
66 static scoped_ptr<Proxy> Create( 80 static scoped_ptr<Proxy> Create(
67 TestHooks* test_hooks, 81 TestHooks* test_hooks,
68 LayerTreeHost* host, 82 LayerTreeHost* host,
69 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 83 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
70 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, 84 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner,
71 scoped_ptr<BeginFrameSource> external_begin_frame_source) { 85 scoped_ptr<BeginFrameSource> external_begin_frame_source) {
72 return make_scoped_ptr(new ThreadProxyForTest( 86 return make_scoped_ptr(new ThreadProxyForTest(
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 } 356 }
343 357
344 void RequestNewOutputSurface() override { 358 void RequestNewOutputSurface() override {
345 test_hooks_->RequestNewOutputSurface(); 359 test_hooks_->RequestNewOutputSurface();
346 } 360 }
347 361
348 void DidInitializeOutputSurface() override { 362 void DidInitializeOutputSurface() override {
349 test_hooks_->DidInitializeOutputSurface(); 363 test_hooks_->DidInitializeOutputSurface();
350 } 364 }
351 365
352 void SendBeginFramesToChildren(const BeginFrameArgs& args) override {
353 test_hooks_->SendBeginFramesToChildren(args);
354 }
355
356 void DidFailToInitializeOutputSurface() override { 366 void DidFailToInitializeOutputSurface() override {
357 test_hooks_->DidFailToInitializeOutputSurface(); 367 test_hooks_->DidFailToInitializeOutputSurface();
358 RequestNewOutputSurface(); 368 RequestNewOutputSurface();
359 } 369 }
360 370
361 void WillCommit() override { test_hooks_->WillCommit(); } 371 void WillCommit() override { test_hooks_->WillCommit(); }
362 372
363 void DidCommit() override { test_hooks_->DidCommit(); } 373 void DidCommit() override { test_hooks_->DidCommit(); }
364 374
365 void DidCommitAndDrawFrame() override { 375 void DidCommitAndDrawFrame() override {
(...skipping 18 matching lines...) Expand all
384 394
385 // Adapts LayerTreeHost for test. Injects LayerTreeHostImplForTesting. 395 // Adapts LayerTreeHost for test. Injects LayerTreeHostImplForTesting.
386 class LayerTreeHostForTesting : public LayerTreeHost { 396 class LayerTreeHostForTesting : public LayerTreeHost {
387 public: 397 public:
388 static scoped_ptr<LayerTreeHostForTesting> Create( 398 static scoped_ptr<LayerTreeHostForTesting> Create(
389 TestHooks* test_hooks, 399 TestHooks* test_hooks,
390 LayerTreeHostClientForTesting* client, 400 LayerTreeHostClientForTesting* client,
391 const LayerTreeSettings& settings, 401 const LayerTreeSettings& settings,
392 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 402 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
393 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, 403 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner,
394 scoped_ptr<BeginFrameSource> external_begin_frame_source) { 404 scoped_ptr<BeginFrameSource> external_begin_frame_source,
405 ProxyBeginFrameSource* proxy_begin_frame_source) {
395 scoped_ptr<LayerTreeHostForTesting> layer_tree_host( 406 scoped_ptr<LayerTreeHostForTesting> layer_tree_host(
396 new LayerTreeHostForTesting(test_hooks, client, settings)); 407 new LayerTreeHostForTesting(test_hooks, client, settings));
397 if (impl_task_runner.get()) { 408 if (impl_task_runner.get()) {
398 layer_tree_host->InitializeForTesting( 409 layer_tree_host->InitializeForTesting(
399 ThreadProxyForTest::Create(test_hooks, 410 ThreadProxyForTest::Create(test_hooks,
400 layer_tree_host.get(), 411 layer_tree_host.get(),
401 main_task_runner, 412 main_task_runner,
402 impl_task_runner, 413 impl_task_runner,
403 external_begin_frame_source.Pass())); 414 external_begin_frame_source.Pass()));
404 } else { 415 } else {
405 layer_tree_host->InitializeForTesting(SingleThreadProxy::Create( 416 layer_tree_host->InitializeForTesting(SingleThreadProxy::Create(
406 layer_tree_host.get(), 417 layer_tree_host.get(),
407 client, 418 client,
408 main_task_runner, 419 main_task_runner,
409 external_begin_frame_source.Pass())); 420 external_begin_frame_source.Pass(),
421 proxy_begin_frame_source));
410 } 422 }
411 return layer_tree_host.Pass(); 423 return layer_tree_host.Pass();
412 } 424 }
413 425
414 scoped_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl( 426 scoped_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl(
415 LayerTreeHostImplClient* host_impl_client) override { 427 LayerTreeHostImplClient* host_impl_client) override {
416 return LayerTreeHostImplForTesting::Create( 428 return LayerTreeHostImplForTesting::Create(
417 test_hooks_, 429 test_hooks_,
418 settings(), 430 settings(),
419 host_impl_client, 431 host_impl_client,
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 void LayerTreeTest::DoBeginTest() { 592 void LayerTreeTest::DoBeginTest() {
581 client_ = LayerTreeHostClientForTesting::Create(this); 593 client_ = LayerTreeHostClientForTesting::Create(this);
582 594
583 scoped_ptr<FakeExternalBeginFrameSource> external_begin_frame_source; 595 scoped_ptr<FakeExternalBeginFrameSource> external_begin_frame_source;
584 if (settings_.use_external_begin_frame_source) { 596 if (settings_.use_external_begin_frame_source) {
585 external_begin_frame_source.reset(new FakeExternalBeginFrameSource( 597 external_begin_frame_source.reset(new FakeExternalBeginFrameSource(
586 settings_.renderer_settings.refresh_rate)); 598 settings_.renderer_settings.refresh_rate));
587 external_begin_frame_source_ = external_begin_frame_source.get(); 599 external_begin_frame_source_ = external_begin_frame_source.get();
588 } 600 }
589 601
602 if (settings_.forward_begin_frames_to_children) {
603 proxy_begin_frame_source_.reset(new TestProxyBeginFrameSource(this));
604 }
605
590 DCHECK(!impl_thread_ || impl_thread_->message_loop_proxy().get()); 606 DCHECK(!impl_thread_ || impl_thread_->message_loop_proxy().get());
591 layer_tree_host_ = LayerTreeHostForTesting::Create( 607 layer_tree_host_ = LayerTreeHostForTesting::Create(
592 this, 608 this,
593 client_.get(), 609 client_.get(),
594 settings_, 610 settings_,
595 base::MessageLoopProxy::current(), 611 base::MessageLoopProxy::current(),
596 impl_thread_ ? impl_thread_->message_loop_proxy() : NULL, 612 impl_thread_ ? impl_thread_->message_loop_proxy() : NULL,
597 external_begin_frame_source.Pass()); 613 external_begin_frame_source.Pass(),
614 proxy_begin_frame_source_.get());
598 ASSERT_TRUE(layer_tree_host_); 615 ASSERT_TRUE(layer_tree_host_);
599 616
600 started_ = true; 617 started_ = true;
601 beginning_ = true; 618 beginning_ = true;
602 SetupTree(); 619 SetupTree();
603 WillBeginTest(); 620 WillBeginTest();
604 BeginTest(); 621 BeginTest();
605 beginning_ = false; 622 beginning_ = false;
606 if (end_when_begin_returns_) 623 if (end_when_begin_returns_)
607 RealEndTest(); 624 RealEndTest();
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 return -1; 808 return -1;
792 } 809 }
793 810
794 void LayerTreeTest::DestroyLayerTreeHost() { 811 void LayerTreeTest::DestroyLayerTreeHost() {
795 if (layer_tree_host_ && layer_tree_host_->root_layer()) 812 if (layer_tree_host_ && layer_tree_host_->root_layer())
796 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL); 813 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL);
797 layer_tree_host_ = nullptr; 814 layer_tree_host_ = nullptr;
798 } 815 }
799 816
800 } // namespace cc 817 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698