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

Side by Side Diff: cc/layers/render_surface_unittest.cc

Issue 1411663002: cc: Split Proxy to eliminate unnecessary dependencies on the impl side (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update perf tests. Created 5 years, 2 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/layers/picture_layer_impl_unittest.cc ('k') | cc/layers/scrollbar_layer_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/base/scoped_ptr_vector.h" 5 #include "cc/base/scoped_ptr_vector.h"
6 #include "cc/layers/append_quads_data.h" 6 #include "cc/layers/append_quads_data.h"
7 #include "cc/layers/layer_impl.h" 7 #include "cc/layers/layer_impl.h"
8 #include "cc/layers/render_pass_sink.h" 8 #include "cc/layers/render_pass_sink.h"
9 #include "cc/layers/render_surface_impl.h" 9 #include "cc/layers/render_surface_impl.h"
10 #include "cc/quads/shared_quad_state.h" 10 #include "cc/quads/shared_quad_state.h"
11 #include "cc/test/fake_impl_proxy.h" 11 #include "cc/test/fake_impl_task_runner_provider.h"
12 #include "cc/test/fake_layer_tree_host_impl.h" 12 #include "cc/test/fake_layer_tree_host_impl.h"
13 #include "cc/test/geometry_test_utils.h" 13 #include "cc/test/geometry_test_utils.h"
14 #include "cc/test/mock_occlusion_tracker.h" 14 #include "cc/test/mock_occlusion_tracker.h"
15 #include "cc/test/test_shared_bitmap_manager.h" 15 #include "cc/test/test_shared_bitmap_manager.h"
16 #include "cc/test/test_task_graph_runner.h" 16 #include "cc/test/test_task_graph_runner.h"
17 #include "cc/trees/single_thread_proxy.h" 17 #include "cc/trees/single_thread_proxy.h"
18 #include "testing/gmock/include/gmock/gmock.h" 18 #include "testing/gmock/include/gmock/gmock.h"
19 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
20 #include "ui/gfx/transform.h" 20 #include "ui/gfx/transform.h"
21 21
22 namespace cc { 22 namespace cc {
23 namespace { 23 namespace {
24 24
25 #define EXECUTE_AND_VERIFY_SURFACE_CHANGED(code_to_test) \ 25 #define EXECUTE_AND_VERIFY_SURFACE_CHANGED(code_to_test) \
26 render_surface->ResetPropertyChangedFlag(); \ 26 render_surface->ResetPropertyChangedFlag(); \
27 code_to_test; \ 27 code_to_test; \
28 EXPECT_TRUE(render_surface->SurfacePropertyChanged()) 28 EXPECT_TRUE(render_surface->SurfacePropertyChanged())
29 29
30 #define EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(code_to_test) \ 30 #define EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(code_to_test) \
31 render_surface->ResetPropertyChangedFlag(); \ 31 render_surface->ResetPropertyChangedFlag(); \
32 code_to_test; \ 32 code_to_test; \
33 EXPECT_FALSE(render_surface->SurfacePropertyChanged()) 33 EXPECT_FALSE(render_surface->SurfacePropertyChanged())
34 34
35 TEST(RenderSurfaceTest, VerifySurfaceChangesAreTrackedProperly) { 35 TEST(RenderSurfaceTest, VerifySurfaceChangesAreTrackedProperly) {
36 // 36 //
37 // This test checks that SurfacePropertyChanged() has the correct behavior. 37 // This test checks that SurfacePropertyChanged() has the correct behavior.
38 // 38 //
39 39
40 FakeImplProxy proxy; 40 FakeImplTaskRunnerProvider task_runner_provider;
41 TestSharedBitmapManager shared_bitmap_manager; 41 TestSharedBitmapManager shared_bitmap_manager;
42 TestTaskGraphRunner task_graph_runner; 42 TestTaskGraphRunner task_graph_runner;
43 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, 43 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
44 &task_graph_runner); 44 &task_graph_runner);
45 scoped_ptr<LayerImpl> owning_layer = 45 scoped_ptr<LayerImpl> owning_layer =
46 LayerImpl::Create(host_impl.active_tree(), 1); 46 LayerImpl::Create(host_impl.active_tree(), 1);
47 owning_layer->SetHasRenderSurface(true); 47 owning_layer->SetHasRenderSurface(true);
48 ASSERT_TRUE(owning_layer->render_surface()); 48 ASSERT_TRUE(owning_layer->render_surface());
49 RenderSurfaceImpl* render_surface = owning_layer->render_surface(); 49 RenderSurfaceImpl* render_surface = owning_layer->render_surface();
50 gfx::Rect test_rect(3, 4, 5, 6); 50 gfx::Rect test_rect(3, 4, 5, 6);
51 owning_layer->ResetAllChangeTrackingForSubtree(); 51 owning_layer->ResetAllChangeTrackingForSubtree();
52 52
53 // Currently, the content_rect, clip_rect, and 53 // Currently, the content_rect, clip_rect, and
(...skipping 23 matching lines...) Expand all
77 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE( 77 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(
78 render_surface->SetDrawOpacity(0.5f)); 78 render_surface->SetDrawOpacity(0.5f));
79 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE( 79 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(
80 render_surface->SetDrawTransform(dummy_matrix)); 80 render_surface->SetDrawTransform(dummy_matrix));
81 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE( 81 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(
82 render_surface->SetReplicaDrawTransform(dummy_matrix)); 82 render_surface->SetReplicaDrawTransform(dummy_matrix));
83 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(render_surface->ClearLayerLists()); 83 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(render_surface->ClearLayerLists());
84 } 84 }
85 85
86 TEST(RenderSurfaceTest, SanityCheckSurfaceCreatesCorrectSharedQuadState) { 86 TEST(RenderSurfaceTest, SanityCheckSurfaceCreatesCorrectSharedQuadState) {
87 FakeImplProxy proxy; 87 FakeImplTaskRunnerProvider task_runner_provider;
88 TestSharedBitmapManager shared_bitmap_manager; 88 TestSharedBitmapManager shared_bitmap_manager;
89 TestTaskGraphRunner task_graph_runner; 89 TestTaskGraphRunner task_graph_runner;
90 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, 90 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
91 &task_graph_runner); 91 &task_graph_runner);
92 scoped_ptr<LayerImpl> root_layer = 92 scoped_ptr<LayerImpl> root_layer =
93 LayerImpl::Create(host_impl.active_tree(), 1); 93 LayerImpl::Create(host_impl.active_tree(), 1);
94 94
95 scoped_ptr<LayerImpl> owning_layer = 95 scoped_ptr<LayerImpl> owning_layer =
96 LayerImpl::Create(host_impl.active_tree(), 2); 96 LayerImpl::Create(host_impl.active_tree(), 2);
97 owning_layer->SetHasRenderSurface(true); 97 owning_layer->SetHasRenderSurface(true);
98 ASSERT_TRUE(owning_layer->render_surface()); 98 ASSERT_TRUE(owning_layer->render_surface());
99 owning_layer->draw_properties().render_target = owning_layer.get(); 99 owning_layer->draw_properties().render_target = owning_layer.get();
100 100
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 144
145 const RenderPassList& RenderPasses() const { 145 const RenderPassList& RenderPasses() const {
146 return render_passes_; 146 return render_passes_;
147 } 147 }
148 148
149 private: 149 private:
150 RenderPassList render_passes_; 150 RenderPassList render_passes_;
151 }; 151 };
152 152
153 TEST(RenderSurfaceTest, SanityCheckSurfaceCreatesCorrectRenderPass) { 153 TEST(RenderSurfaceTest, SanityCheckSurfaceCreatesCorrectRenderPass) {
154 FakeImplProxy proxy; 154 FakeImplTaskRunnerProvider task_runner_provider;
155 TestSharedBitmapManager shared_bitmap_manager; 155 TestSharedBitmapManager shared_bitmap_manager;
156 TestTaskGraphRunner task_graph_runner; 156 TestTaskGraphRunner task_graph_runner;
157 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, 157 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
158 &task_graph_runner); 158 &task_graph_runner);
159 scoped_ptr<LayerImpl> root_layer = 159 scoped_ptr<LayerImpl> root_layer =
160 LayerImpl::Create(host_impl.active_tree(), 1); 160 LayerImpl::Create(host_impl.active_tree(), 1);
161 161
162 scoped_ptr<LayerImpl> owning_layer = 162 scoped_ptr<LayerImpl> owning_layer =
163 LayerImpl::Create(host_impl.active_tree(), 2); 163 LayerImpl::Create(host_impl.active_tree(), 2);
164 owning_layer->SetHasRenderSurface(true); 164 owning_layer->SetHasRenderSurface(true);
165 ASSERT_TRUE(owning_layer->render_surface()); 165 ASSERT_TRUE(owning_layer->render_surface());
166 owning_layer->draw_properties().render_target = owning_layer.get(); 166 owning_layer->draw_properties().render_target = owning_layer.get();
167 RenderSurfaceImpl* render_surface = owning_layer->render_surface(); 167 RenderSurfaceImpl* render_surface = owning_layer->render_surface();
(...skipping 14 matching lines...) Expand all
182 ASSERT_EQ(1u, pass_sink.RenderPasses().size()); 182 ASSERT_EQ(1u, pass_sink.RenderPasses().size());
183 RenderPass* pass = pass_sink.RenderPasses()[0]; 183 RenderPass* pass = pass_sink.RenderPasses()[0];
184 184
185 EXPECT_EQ(RenderPassId(2, 0), pass->id); 185 EXPECT_EQ(RenderPassId(2, 0), pass->id);
186 EXPECT_EQ(content_rect, pass->output_rect); 186 EXPECT_EQ(content_rect, pass->output_rect);
187 EXPECT_EQ(origin, pass->transform_to_root_target); 187 EXPECT_EQ(origin, pass->transform_to_root_target);
188 } 188 }
189 189
190 } // namespace 190 } // namespace
191 } // namespace cc 191 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_impl_unittest.cc ('k') | cc/layers/scrollbar_layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698