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

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

Issue 1783613004: CC Animation: Erase cc::LayerSettings everywhere. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@eraseandroid
Patch Set: Rebase. Created 4 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/tiles/tile_manager_unittest.cc » ('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 "base/location.h" 8 #include "base/location.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
(...skipping 28 matching lines...) Expand all
39 #include "cc/trees/threaded_channel.h" 39 #include "cc/trees/threaded_channel.h"
40 #include "testing/gmock/include/gmock/gmock.h" 40 #include "testing/gmock/include/gmock/gmock.h"
41 #include "ui/gfx/geometry/size_conversions.h" 41 #include "ui/gfx/geometry/size_conversions.h"
42 42
43 namespace cc { 43 namespace cc {
44 44
45 void CreateVirtualViewportLayers(Layer* root_layer, 45 void CreateVirtualViewportLayers(Layer* root_layer,
46 scoped_refptr<Layer> outer_scroll_layer, 46 scoped_refptr<Layer> outer_scroll_layer,
47 const gfx::Size& inner_bounds, 47 const gfx::Size& inner_bounds,
48 const gfx::Size& outer_bounds, 48 const gfx::Size& outer_bounds,
49 LayerTreeHost* host, 49 LayerTreeHost* host) {
50 const LayerSettings& layer_settings) { 50 scoped_refptr<Layer> inner_viewport_container_layer = Layer::Create();
51 scoped_refptr<Layer> inner_viewport_container_layer = 51 scoped_refptr<Layer> inner_viewport_scroll_layer = Layer::Create();
52 Layer::Create(layer_settings); 52 scoped_refptr<Layer> outer_viewport_container_layer = Layer::Create();
53 scoped_refptr<Layer> inner_viewport_scroll_layer = 53 scoped_refptr<Layer> page_scale_layer = Layer::Create();
54 Layer::Create(layer_settings);
55 scoped_refptr<Layer> outer_viewport_container_layer =
56 Layer::Create(layer_settings);
57 scoped_refptr<Layer> page_scale_layer = Layer::Create(layer_settings);
58 54
59 root_layer->AddChild(inner_viewport_container_layer); 55 root_layer->AddChild(inner_viewport_container_layer);
60 inner_viewport_container_layer->AddChild(page_scale_layer); 56 inner_viewport_container_layer->AddChild(page_scale_layer);
61 page_scale_layer->AddChild(inner_viewport_scroll_layer); 57 page_scale_layer->AddChild(inner_viewport_scroll_layer);
62 inner_viewport_scroll_layer->AddChild(outer_viewport_container_layer); 58 inner_viewport_scroll_layer->AddChild(outer_viewport_container_layer);
63 outer_viewport_container_layer->AddChild(outer_scroll_layer); 59 outer_viewport_container_layer->AddChild(outer_scroll_layer);
64 60
65 inner_viewport_scroll_layer->SetScrollClipLayerId( 61 inner_viewport_scroll_layer->SetScrollClipLayerId(
66 inner_viewport_container_layer->id()); 62 inner_viewport_container_layer->id());
67 outer_scroll_layer->SetScrollClipLayerId( 63 outer_scroll_layer->SetScrollClipLayerId(
68 outer_viewport_container_layer->id()); 64 outer_viewport_container_layer->id());
69 65
70 inner_viewport_container_layer->SetBounds(inner_bounds); 66 inner_viewport_container_layer->SetBounds(inner_bounds);
71 inner_viewport_scroll_layer->SetBounds(outer_bounds); 67 inner_viewport_scroll_layer->SetBounds(outer_bounds);
72 outer_viewport_container_layer->SetBounds(outer_bounds); 68 outer_viewport_container_layer->SetBounds(outer_bounds);
73 69
74 inner_viewport_scroll_layer->SetIsContainerForFixedPositionLayers(true); 70 inner_viewport_scroll_layer->SetIsContainerForFixedPositionLayers(true);
75 outer_scroll_layer->SetIsContainerForFixedPositionLayers(true); 71 outer_scroll_layer->SetIsContainerForFixedPositionLayers(true);
76 host->RegisterViewportLayers(NULL, page_scale_layer, 72 host->RegisterViewportLayers(NULL, page_scale_layer,
77 inner_viewport_scroll_layer, 73 inner_viewport_scroll_layer, outer_scroll_layer);
78 outer_scroll_layer);
79 } 74 }
80 75
81 void CreateVirtualViewportLayers(Layer* root_layer, 76 void CreateVirtualViewportLayers(Layer* root_layer,
82 const gfx::Size& inner_bounds, 77 const gfx::Size& inner_bounds,
83 const gfx::Size& outer_bounds, 78 const gfx::Size& outer_bounds,
84 const gfx::Size& scroll_bounds, 79 const gfx::Size& scroll_bounds,
85 LayerTreeHost* host, 80 LayerTreeHost* host) {
86 const LayerSettings& layer_settings) { 81 scoped_refptr<Layer> outer_viewport_scroll_layer = Layer::Create();
87 scoped_refptr<Layer> outer_viewport_scroll_layer =
88 Layer::Create(layer_settings);
89 82
90 outer_viewport_scroll_layer->SetBounds(scroll_bounds); 83 outer_viewport_scroll_layer->SetBounds(scroll_bounds);
91 outer_viewport_scroll_layer->SetIsDrawable(true); 84 outer_viewport_scroll_layer->SetIsDrawable(true);
92 CreateVirtualViewportLayers(root_layer, 85 CreateVirtualViewportLayers(root_layer, outer_viewport_scroll_layer,
93 outer_viewport_scroll_layer, 86 inner_bounds, outer_bounds, host);
94 inner_bounds,
95 outer_bounds,
96 host,
97 layer_settings);
98 } 87 }
99 88
100 // Creates a SingleThreadProxy that notifies the supplied |test_hooks| of 89 // Creates a SingleThreadProxy that notifies the supplied |test_hooks| of
101 // various actions. 90 // various actions.
102 class SingleThreadProxyForTest : public SingleThreadProxy { 91 class SingleThreadProxyForTest : public SingleThreadProxy {
103 public: 92 public:
104 static scoped_ptr<Proxy> Create(TestHooks* test_hooks, 93 static scoped_ptr<Proxy> Create(TestHooks* test_hooks,
105 LayerTreeHost* host, 94 LayerTreeHost* host,
106 LayerTreeHostSingleThreadClient* client, 95 LayerTreeHostSingleThreadClient* client,
107 TaskRunnerProvider* task_runner_provider) { 96 TaskRunnerProvider* task_runner_provider) {
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 // Allow commits to happen once BeginTest() has had a chance to post tasks 728 // Allow commits to happen once BeginTest() has had a chance to post tasks
740 // so that those tasks will happen before the first commit. 729 // so that those tasks will happen before the first commit.
741 if (layer_tree_host_) { 730 if (layer_tree_host_) {
742 static_cast<LayerTreeHostForTesting*>(layer_tree_host_.get()) 731 static_cast<LayerTreeHostForTesting*>(layer_tree_host_.get())
743 ->set_test_started(true); 732 ->set_test_started(true);
744 } 733 }
745 } 734 }
746 735
747 void LayerTreeTest::SetupTree() { 736 void LayerTreeTest::SetupTree() {
748 if (!layer_tree_host_->root_layer()) { 737 if (!layer_tree_host_->root_layer()) {
749 scoped_refptr<Layer> root_layer = Layer::Create(layer_settings_); 738 scoped_refptr<Layer> root_layer = Layer::Create();
750 root_layer->SetBounds(gfx::Size(1, 1)); 739 root_layer->SetBounds(gfx::Size(1, 1));
751 layer_tree_host_->SetRootLayer(root_layer); 740 layer_tree_host_->SetRootLayer(root_layer);
752 } 741 }
753 742
754 gfx::Size root_bounds = layer_tree_host_->root_layer()->bounds(); 743 gfx::Size root_bounds = layer_tree_host_->root_layer()->bounds();
755 gfx::Size device_root_bounds = gfx::ScaleToCeiledSize( 744 gfx::Size device_root_bounds = gfx::ScaleToCeiledSize(
756 root_bounds, layer_tree_host_->device_scale_factor()); 745 root_bounds, layer_tree_host_->device_scale_factor());
757 layer_tree_host_->SetViewportSize(device_root_bounds); 746 layer_tree_host_->SetViewportSize(device_root_bounds);
758 layer_tree_host_->root_layer()->SetIsDrawable(true); 747 layer_tree_host_->root_layer()->SetIsDrawable(true);
759 } 748 }
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 gpu_memory_buffer_manager_.reset(new TestGpuMemoryBufferManager); 859 gpu_memory_buffer_manager_.reset(new TestGpuMemoryBufferManager);
871 task_graph_runner_.reset(new TestTaskGraphRunner); 860 task_graph_runner_.reset(new TestTaskGraphRunner);
872 861
873 delegating_renderer_ = delegating_renderer; 862 delegating_renderer_ = delegating_renderer;
874 863
875 // Spend less time waiting for BeginFrame because the output is 864 // Spend less time waiting for BeginFrame because the output is
876 // mocked out. 865 // mocked out.
877 settings_.renderer_settings.refresh_rate = 200.0; 866 settings_.renderer_settings.refresh_rate = 200.0;
878 settings_.background_animation_rate = 200.0; 867 settings_.background_animation_rate = 200.0;
879 InitializeSettings(&settings_); 868 InitializeSettings(&settings_);
880 InitializeLayerSettings(&layer_settings_);
881 869
882 main_task_runner_->PostTask( 870 main_task_runner_->PostTask(
883 FROM_HERE, 871 FROM_HERE,
884 base::Bind(&LayerTreeTest::DoBeginTest, base::Unretained(this))); 872 base::Bind(&LayerTreeTest::DoBeginTest, base::Unretained(this)));
885 873
886 if (timeout_seconds_) { 874 if (timeout_seconds_) {
887 timeout_.Reset(base::Bind(&LayerTreeTest::Timeout, base::Unretained(this))); 875 timeout_.Reset(base::Bind(&LayerTreeTest::Timeout, base::Unretained(this)));
888 main_task_runner_->PostDelayedTask( 876 main_task_runner_->PostDelayedTask(
889 FROM_HERE, 877 FROM_HERE,
890 timeout_.callback(), 878 timeout_.callback(),
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 1021
1034 RemoteChannelImplForTest* LayerTreeTest::GetRemoteChannelImplForTest() const { 1022 RemoteChannelImplForTest* LayerTreeTest::GetRemoteChannelImplForTest() const {
1035 DCHECK(IsRemoteTest()); 1023 DCHECK(IsRemoteTest());
1036 DCHECK(remote_client_layer_tree_host_); 1024 DCHECK(remote_client_layer_tree_host_);
1037 1025
1038 return static_cast<RemoteChannelImplForTest*>( 1026 return static_cast<RemoteChannelImplForTest*>(
1039 remote_client_layer_tree_host_->proxy()); 1027 remote_client_layer_tree_host_->proxy());
1040 } 1028 }
1041 1029
1042 } // namespace cc 1030 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/layer_tree_test.h ('k') | cc/tiles/tile_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698