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

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

Issue 1028333002: Chromium -> Mojo roll. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 9 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/test/ordered_simple_task_runner.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/begin_frame_args_test.h" 18 #include "cc/test/begin_frame_args_test.h"
19 #include "cc/test/fake_external_begin_frame_source.h" 19 #include "cc/test/fake_external_begin_frame_source.h"
20 #include "cc/test/fake_layer_tree_host_client.h" 20 #include "cc/test/fake_layer_tree_host_client.h"
21 #include "cc/test/fake_output_surface.h" 21 #include "cc/test/fake_output_surface.h"
22 #include "cc/test/test_context_provider.h" 22 #include "cc/test/test_context_provider.h"
23 #include "cc/test/test_gpu_memory_buffer_manager.h" 23 #include "cc/test/test_gpu_memory_buffer_manager.h"
24 #include "cc/test/test_shared_bitmap_manager.h" 24 #include "cc/test/test_shared_bitmap_manager.h"
25 #include "cc/test/test_task_graph_runner.h"
25 #include "cc/test/tiled_layer_test_common.h" 26 #include "cc/test/tiled_layer_test_common.h"
26 #include "cc/trees/layer_tree_host_client.h" 27 #include "cc/trees/layer_tree_host_client.h"
27 #include "cc/trees/layer_tree_host_impl.h" 28 #include "cc/trees/layer_tree_host_impl.h"
28 #include "cc/trees/layer_tree_host_single_thread_client.h" 29 #include "cc/trees/layer_tree_host_single_thread_client.h"
29 #include "cc/trees/layer_tree_impl.h" 30 #include "cc/trees/layer_tree_impl.h"
30 #include "cc/trees/single_thread_proxy.h" 31 #include "cc/trees/single_thread_proxy.h"
31 #include "cc/trees/thread_proxy.h" 32 #include "cc/trees/thread_proxy.h"
32 #include "testing/gmock/include/gmock/gmock.h" 33 #include "testing/gmock/include/gmock/gmock.h"
33 #include "ui/gfx/frame_time.h" 34 #include "ui/gfx/frame_time.h"
34 #include "ui/gfx/geometry/size_conversions.h" 35 #include "ui/gfx/geometry/size_conversions.h"
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 // Adapts LayerTreeHostImpl for test. Runs real code, then invokes test hooks. 203 // Adapts LayerTreeHostImpl for test. Runs real code, then invokes test hooks.
203 class LayerTreeHostImplForTesting : public LayerTreeHostImpl { 204 class LayerTreeHostImplForTesting : public LayerTreeHostImpl {
204 public: 205 public:
205 static scoped_ptr<LayerTreeHostImplForTesting> Create( 206 static scoped_ptr<LayerTreeHostImplForTesting> Create(
206 TestHooks* test_hooks, 207 TestHooks* test_hooks,
207 const LayerTreeSettings& settings, 208 const LayerTreeSettings& settings,
208 LayerTreeHostImplClient* host_impl_client, 209 LayerTreeHostImplClient* host_impl_client,
209 Proxy* proxy, 210 Proxy* proxy,
210 SharedBitmapManager* shared_bitmap_manager, 211 SharedBitmapManager* shared_bitmap_manager,
211 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, 212 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
213 TaskGraphRunner* task_graph_runner,
212 RenderingStatsInstrumentation* stats_instrumentation) { 214 RenderingStatsInstrumentation* stats_instrumentation) {
213 return make_scoped_ptr( 215 return make_scoped_ptr(new LayerTreeHostImplForTesting(
214 new LayerTreeHostImplForTesting(test_hooks, 216 test_hooks, settings, host_impl_client, proxy, shared_bitmap_manager,
215 settings, 217 gpu_memory_buffer_manager, task_graph_runner, stats_instrumentation));
216 host_impl_client,
217 proxy,
218 shared_bitmap_manager,
219 gpu_memory_buffer_manager,
220 stats_instrumentation));
221 } 218 }
222 219
223 protected: 220 protected:
224 LayerTreeHostImplForTesting( 221 LayerTreeHostImplForTesting(
225 TestHooks* test_hooks, 222 TestHooks* test_hooks,
226 const LayerTreeSettings& settings, 223 const LayerTreeSettings& settings,
227 LayerTreeHostImplClient* host_impl_client, 224 LayerTreeHostImplClient* host_impl_client,
228 Proxy* proxy, 225 Proxy* proxy,
229 SharedBitmapManager* shared_bitmap_manager, 226 SharedBitmapManager* shared_bitmap_manager,
230 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, 227 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
228 TaskGraphRunner* task_graph_runner,
231 RenderingStatsInstrumentation* stats_instrumentation) 229 RenderingStatsInstrumentation* stats_instrumentation)
232 : LayerTreeHostImpl(settings, 230 : LayerTreeHostImpl(settings,
233 host_impl_client, 231 host_impl_client,
234 proxy, 232 proxy,
235 stats_instrumentation, 233 stats_instrumentation,
236 shared_bitmap_manager, 234 shared_bitmap_manager,
237 gpu_memory_buffer_manager, 235 gpu_memory_buffer_manager,
236 task_graph_runner,
238 0), 237 0),
239 test_hooks_(test_hooks), 238 test_hooks_(test_hooks),
240 block_notify_ready_to_activate_for_testing_(false), 239 block_notify_ready_to_activate_for_testing_(false),
241 notify_ready_to_activate_was_blocked_(false) {} 240 notify_ready_to_activate_was_blocked_(false) {}
242 241
243 scoped_ptr<Rasterizer> CreateRasterizer() override { 242 scoped_ptr<Rasterizer> CreateRasterizer() override {
244 return test_hooks_->CreateRasterizer(this); 243 return test_hooks_->CreateRasterizer(this);
245 } 244 }
246 245
247 void CreateResourceAndTileTaskWorkerPool( 246 void CreateResourceAndTileTaskWorkerPool(
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 447
449 TestHooks* test_hooks_; 448 TestHooks* test_hooks_;
450 }; 449 };
451 450
452 // Adapts LayerTreeHost for test. Injects LayerTreeHostImplForTesting. 451 // Adapts LayerTreeHost for test. Injects LayerTreeHostImplForTesting.
453 class LayerTreeHostForTesting : public LayerTreeHost { 452 class LayerTreeHostForTesting : public LayerTreeHost {
454 public: 453 public:
455 static scoped_ptr<LayerTreeHostForTesting> Create( 454 static scoped_ptr<LayerTreeHostForTesting> Create(
456 TestHooks* test_hooks, 455 TestHooks* test_hooks,
457 LayerTreeHostClientForTesting* client, 456 LayerTreeHostClientForTesting* client,
457 SharedBitmapManager* shared_bitmap_manager,
458 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
459 TaskGraphRunner* task_graph_runner,
458 const LayerTreeSettings& settings, 460 const LayerTreeSettings& settings,
459 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 461 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
460 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, 462 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner,
461 scoped_ptr<BeginFrameSource> external_begin_frame_source) { 463 scoped_ptr<BeginFrameSource> external_begin_frame_source) {
462 scoped_ptr<LayerTreeHostForTesting> layer_tree_host( 464 scoped_ptr<LayerTreeHostForTesting> layer_tree_host(
463 new LayerTreeHostForTesting(test_hooks, client, settings)); 465 new LayerTreeHostForTesting(test_hooks, client, shared_bitmap_manager,
466 gpu_memory_buffer_manager,
467 task_graph_runner, settings));
464 if (impl_task_runner.get()) { 468 if (impl_task_runner.get()) {
465 layer_tree_host->InitializeForTesting( 469 layer_tree_host->InitializeForTesting(
466 ThreadProxyForTest::Create(test_hooks, 470 ThreadProxyForTest::Create(test_hooks,
467 layer_tree_host.get(), 471 layer_tree_host.get(),
468 main_task_runner, 472 main_task_runner,
469 impl_task_runner, 473 impl_task_runner,
470 external_begin_frame_source.Pass())); 474 external_begin_frame_source.Pass()));
471 } else { 475 } else {
472 layer_tree_host->InitializeForTesting( 476 layer_tree_host->InitializeForTesting(
473 SingleThreadProxyForTest::Create( 477 SingleThreadProxyForTest::Create(
474 test_hooks, 478 test_hooks,
475 layer_tree_host.get(), 479 layer_tree_host.get(),
476 client, 480 client,
477 main_task_runner, 481 main_task_runner,
478 external_begin_frame_source.Pass())); 482 external_begin_frame_source.Pass()));
479 } 483 }
480 return layer_tree_host.Pass(); 484 return layer_tree_host.Pass();
481 } 485 }
482 486
483 scoped_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl( 487 scoped_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl(
484 LayerTreeHostImplClient* host_impl_client) override { 488 LayerTreeHostImplClient* host_impl_client) override {
485 return LayerTreeHostImplForTesting::Create( 489 return LayerTreeHostImplForTesting::Create(
486 test_hooks_, 490 test_hooks_, settings(), host_impl_client, proxy(),
487 settings(), 491 shared_bitmap_manager_, gpu_memory_buffer_manager_, task_graph_runner_,
488 host_impl_client,
489 proxy(),
490 shared_bitmap_manager_.get(),
491 gpu_memory_buffer_manager_.get(),
492 rendering_stats_instrumentation()); 492 rendering_stats_instrumentation());
493 } 493 }
494 494
495 void SetNeedsCommit() override { 495 void SetNeedsCommit() override {
496 if (!test_started_) 496 if (!test_started_)
497 return; 497 return;
498 LayerTreeHost::SetNeedsCommit(); 498 LayerTreeHost::SetNeedsCommit();
499 } 499 }
500 500
501 void set_test_started(bool started) { test_started_ = started; } 501 void set_test_started(bool started) { test_started_ = started; }
502 502
503 private: 503 private:
504 LayerTreeHostForTesting(TestHooks* test_hooks, 504 LayerTreeHostForTesting(
505 LayerTreeHostClient* client, 505 TestHooks* test_hooks,
506 const LayerTreeSettings& settings) 506 LayerTreeHostClient* client,
507 : LayerTreeHost(client, NULL, NULL, settings), 507 SharedBitmapManager* shared_bitmap_manager,
508 shared_bitmap_manager_(new TestSharedBitmapManager), 508 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
509 gpu_memory_buffer_manager_(new TestGpuMemoryBufferManager), 509 TaskGraphRunner* task_graph_runner,
510 const LayerTreeSettings& settings)
511 : LayerTreeHost(client, NULL, NULL, NULL, settings),
512 shared_bitmap_manager_(shared_bitmap_manager),
513 gpu_memory_buffer_manager_(gpu_memory_buffer_manager),
514 task_graph_runner_(task_graph_runner),
510 test_hooks_(test_hooks), 515 test_hooks_(test_hooks),
511 test_started_(false) {} 516 test_started_(false) {}
512 517
513 scoped_ptr<TestSharedBitmapManager> shared_bitmap_manager_; 518 SharedBitmapManager* shared_bitmap_manager_;
514 scoped_ptr<TestGpuMemoryBufferManager> gpu_memory_buffer_manager_; 519 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_;
520 TaskGraphRunner* task_graph_runner_;
515 TestHooks* test_hooks_; 521 TestHooks* test_hooks_;
516 bool test_started_; 522 bool test_started_;
517 }; 523 };
518 524
519 LayerTreeTest::LayerTreeTest() 525 LayerTreeTest::LayerTreeTest()
520 : output_surface_(nullptr), 526 : output_surface_(nullptr),
521 external_begin_frame_source_(nullptr), 527 external_begin_frame_source_(nullptr),
522 beginning_(false), 528 beginning_(false),
523 end_when_begin_returns_(false), 529 end_when_begin_returns_(false),
524 timed_out_(false), 530 timed_out_(false),
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 662
657 scoped_ptr<FakeExternalBeginFrameSource> external_begin_frame_source; 663 scoped_ptr<FakeExternalBeginFrameSource> external_begin_frame_source;
658 if (settings_.use_external_begin_frame_source) { 664 if (settings_.use_external_begin_frame_source) {
659 external_begin_frame_source.reset(new FakeExternalBeginFrameSource( 665 external_begin_frame_source.reset(new FakeExternalBeginFrameSource(
660 settings_.renderer_settings.refresh_rate)); 666 settings_.renderer_settings.refresh_rate));
661 external_begin_frame_source_ = external_begin_frame_source.get(); 667 external_begin_frame_source_ = external_begin_frame_source.get();
662 } 668 }
663 669
664 DCHECK(!impl_thread_ || impl_thread_->message_loop_proxy().get()); 670 DCHECK(!impl_thread_ || impl_thread_->message_loop_proxy().get());
665 layer_tree_host_ = LayerTreeHostForTesting::Create( 671 layer_tree_host_ = LayerTreeHostForTesting::Create(
666 this, 672 this, client_.get(), shared_bitmap_manager_.get(),
667 client_.get(), 673 gpu_memory_buffer_manager_.get(), task_graph_runner_.get(), settings_,
668 settings_,
669 base::MessageLoopProxy::current(), 674 base::MessageLoopProxy::current(),
670 impl_thread_ ? impl_thread_->message_loop_proxy() : NULL, 675 impl_thread_ ? impl_thread_->message_loop_proxy() : NULL,
671 external_begin_frame_source.Pass()); 676 external_begin_frame_source.Pass());
672 ASSERT_TRUE(layer_tree_host_); 677 ASSERT_TRUE(layer_tree_host_);
673 678
674 started_ = true; 679 started_ = true;
675 beginning_ = true; 680 beginning_ = true;
676 SetupTree(); 681 SetupTree();
677 WillBeginTest(); 682 WillBeginTest();
678 BeginTest(); 683 BeginTest();
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 void LayerTreeTest::RunTest(bool threaded, 791 void LayerTreeTest::RunTest(bool threaded,
787 bool delegating_renderer, 792 bool delegating_renderer,
788 bool impl_side_painting) { 793 bool impl_side_painting) {
789 if (threaded) { 794 if (threaded) {
790 impl_thread_.reset(new base::Thread("Compositor")); 795 impl_thread_.reset(new base::Thread("Compositor"));
791 ASSERT_TRUE(impl_thread_->Start()); 796 ASSERT_TRUE(impl_thread_->Start());
792 } 797 }
793 798
794 main_task_runner_ = base::MessageLoopProxy::current(); 799 main_task_runner_ = base::MessageLoopProxy::current();
795 800
801 shared_bitmap_manager_.reset(new TestSharedBitmapManager);
802 gpu_memory_buffer_manager_.reset(new TestGpuMemoryBufferManager);
803 task_graph_runner_.reset(new TestTaskGraphRunner);
804
796 delegating_renderer_ = delegating_renderer; 805 delegating_renderer_ = delegating_renderer;
797 806
798 // Spend less time waiting for BeginFrame because the output is 807 // Spend less time waiting for BeginFrame because the output is
799 // mocked out. 808 // mocked out.
800 settings_.renderer_settings.refresh_rate = 200.0; 809 settings_.renderer_settings.refresh_rate = 200.0;
801 settings_.background_animation_rate = 200.0; 810 settings_.background_animation_rate = 200.0;
802 settings_.impl_side_painting = impl_side_painting; 811 settings_.impl_side_painting = impl_side_painting;
803 settings_.verify_property_trees = verify_property_trees_; 812 settings_.verify_property_trees = verify_property_trees_;
804 InitializeSettings(&settings_); 813 InitializeSettings(&settings_);
805 814
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 // Source frames start at 0, so this is invalid. 880 // Source frames start at 0, so this is invalid.
872 return -1; 881 return -1;
873 } 882 }
874 883
875 void LayerTreeTest::DestroyLayerTreeHost() { 884 void LayerTreeTest::DestroyLayerTreeHost() {
876 if (layer_tree_host_ && layer_tree_host_->root_layer()) 885 if (layer_tree_host_ && layer_tree_host_->root_layer())
877 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL); 886 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL);
878 layer_tree_host_ = nullptr; 887 layer_tree_host_ = nullptr;
879 } 888 }
880 889
890 LayerTreeHost* LayerTreeTest::layer_tree_host() {
891 // We check for a null proxy here as we sometimes ask for the layer tree host
892 // when the proxy does not exist, often for checking settings after a test has
893 // completed. For example, LTHPixelResourceTest::RunPixelResourceTest. See
894 // elsewhere in this file for other examples.
895 DCHECK(!proxy() || proxy()->IsMainThread() || proxy()->IsMainThreadBlocked());
896 return layer_tree_host_.get();
897 }
898
881 } // namespace cc 899 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/layer_tree_test.h ('k') | cc/test/ordered_simple_task_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698