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

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

Issue 801973002: Introduce CompositorDependencies for RenderWidgetCompositor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: compdep: . Created 6 years 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') | content/content_renderer.gypi » ('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_layer_tree_host_client.h" 20 #include "cc/test/fake_layer_tree_host_client.h"
20 #include "cc/test/fake_output_surface.h" 21 #include "cc/test/fake_output_surface.h"
21 #include "cc/test/test_context_provider.h" 22 #include "cc/test/test_context_provider.h"
22 #include "cc/test/test_gpu_memory_buffer_manager.h" 23 #include "cc/test/test_gpu_memory_buffer_manager.h"
23 #include "cc/test/test_shared_bitmap_manager.h" 24 #include "cc/test/test_shared_bitmap_manager.h"
24 #include "cc/test/tiled_layer_test_common.h" 25 #include "cc/test/tiled_layer_test_common.h"
25 #include "cc/trees/layer_tree_host_client.h" 26 #include "cc/trees/layer_tree_host_client.h"
26 #include "cc/trees/layer_tree_host_impl.h" 27 #include "cc/trees/layer_tree_host_impl.h"
27 #include "cc/trees/layer_tree_host_single_thread_client.h" 28 #include "cc/trees/layer_tree_host_single_thread_client.h"
28 #include "cc/trees/layer_tree_impl.h" 29 #include "cc/trees/layer_tree_impl.h"
(...skipping 18 matching lines...) Expand all
47 48
48 void TestHooks::CreateResourceAndTileTaskWorkerPool( 49 void TestHooks::CreateResourceAndTileTaskWorkerPool(
49 LayerTreeHostImpl* host_impl, 50 LayerTreeHostImpl* host_impl,
50 scoped_ptr<TileTaskWorkerPool>* tile_task_worker_pool, 51 scoped_ptr<TileTaskWorkerPool>* tile_task_worker_pool,
51 scoped_ptr<ResourcePool>* resource_pool, 52 scoped_ptr<ResourcePool>* resource_pool,
52 scoped_ptr<ResourcePool>* staging_resource_pool) { 53 scoped_ptr<ResourcePool>* staging_resource_pool) {
53 host_impl->LayerTreeHostImpl::CreateResourceAndTileTaskWorkerPool( 54 host_impl->LayerTreeHostImpl::CreateResourceAndTileTaskWorkerPool(
54 tile_task_worker_pool, resource_pool, staging_resource_pool); 55 tile_task_worker_pool, resource_pool, staging_resource_pool);
55 } 56 }
56 57
57 class ExternalBeginFrameSourceForTest
58 : public BeginFrameSourceMixIn,
59 public NON_EXPORTED_BASE(base::NonThreadSafe) {
60 public:
61 explicit ExternalBeginFrameSourceForTest(double refresh_rate)
62 : milliseconds_per_frame_(1000.0 / refresh_rate),
63 is_ready_(false),
64 weak_ptr_factory_(this) {
65 DetachFromThread();
66 }
67
68 virtual ~ExternalBeginFrameSourceForTest() {
69 DCHECK(CalledOnValidThread());
70 }
71
72 void OnNeedsBeginFramesChange(bool needs_begin_frames) override {
73 DCHECK(CalledOnValidThread());
74 if (needs_begin_frames) {
75 base::MessageLoop::current()->PostDelayedTask(
76 FROM_HERE,
77 base::Bind(&ExternalBeginFrameSourceForTest::TestOnBeginFrame,
78 weak_ptr_factory_.GetWeakPtr()),
79 base::TimeDelta::FromMilliseconds(milliseconds_per_frame_));
80 }
81 }
82
83 void SetClientReady() override {
84 DCHECK(CalledOnValidThread());
85 is_ready_ = true;
86 }
87
88 bool is_ready() const {
89 return is_ready_;
90 }
91
92 void TestOnBeginFrame() {
93 DCHECK(CalledOnValidThread());
94 CallOnBeginFrame(CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE));
95 }
96
97 private:
98 double milliseconds_per_frame_;
99 bool is_ready_;
100 base::WeakPtrFactory<ExternalBeginFrameSourceForTest> weak_ptr_factory_;
101 };
102
103 // Adapts ThreadProxy for test. Injects test hooks for testing. 58 // Adapts ThreadProxy for test. Injects test hooks for testing.
104 class ThreadProxyForTest : public ThreadProxy { 59 class ThreadProxyForTest : public ThreadProxy {
105 public: 60 public:
106 static scoped_ptr<Proxy> Create( 61 static scoped_ptr<Proxy> Create(
107 TestHooks* test_hooks, 62 TestHooks* test_hooks,
108 LayerTreeHost* host, 63 LayerTreeHost* host,
109 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 64 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
110 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, 65 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner,
111 scoped_ptr<BeginFrameSource> external_begin_frame_source) { 66 scoped_ptr<BeginFrameSource> external_begin_frame_source) {
112 return make_scoped_ptr(new ThreadProxyForTest( 67 return make_scoped_ptr(new ThreadProxyForTest(
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 main_thread_weak_ptr_)); 562 main_thread_weak_ptr_));
608 } 563 }
609 564
610 void LayerTreeTest::WillBeginTest() { 565 void LayerTreeTest::WillBeginTest() {
611 layer_tree_host_->SetLayerTreeHostClientReady(); 566 layer_tree_host_->SetLayerTreeHostClientReady();
612 } 567 }
613 568
614 void LayerTreeTest::DoBeginTest() { 569 void LayerTreeTest::DoBeginTest() {
615 client_ = LayerTreeHostClientForTesting::Create(this); 570 client_ = LayerTreeHostClientForTesting::Create(this);
616 571
617 scoped_ptr<ExternalBeginFrameSourceForTest> external_begin_frame_source; 572 scoped_ptr<FakeExternalBeginFrameSource> external_begin_frame_source;
618 if (settings_.use_external_begin_frame_source && 573 if (settings_.use_external_begin_frame_source &&
619 settings_.throttle_frame_production) { 574 settings_.throttle_frame_production) {
620 external_begin_frame_source.reset(new ExternalBeginFrameSourceForTest( 575 external_begin_frame_source.reset(new FakeExternalBeginFrameSource(
621 settings_.renderer_settings.refresh_rate)); 576 settings_.renderer_settings.refresh_rate));
622 external_begin_frame_source_ = external_begin_frame_source.get(); 577 external_begin_frame_source_ = external_begin_frame_source.get();
623 } 578 }
624 579
625 DCHECK(!impl_thread_ || impl_thread_->message_loop_proxy().get()); 580 DCHECK(!impl_thread_ || impl_thread_->message_loop_proxy().get());
626 layer_tree_host_ = LayerTreeHostForTesting::Create( 581 layer_tree_host_ = LayerTreeHostForTesting::Create(
627 this, 582 this,
628 client_.get(), 583 client_.get(),
629 settings_, 584 settings_,
630 base::MessageLoopProxy::current(), 585 base::MessageLoopProxy::current(),
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 return -1; 781 return -1;
827 } 782 }
828 783
829 void LayerTreeTest::DestroyLayerTreeHost() { 784 void LayerTreeTest::DestroyLayerTreeHost() {
830 if (layer_tree_host_ && layer_tree_host_->root_layer()) 785 if (layer_tree_host_ && layer_tree_host_->root_layer())
831 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL); 786 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL);
832 layer_tree_host_ = nullptr; 787 layer_tree_host_ = nullptr;
833 } 788 }
834 789
835 } // namespace cc 790 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/layer_tree_test.h ('k') | content/content_renderer.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698