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

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

Issue 2571263002: cc: Remove map lookup from RenderSurfaceImpl::EffectTreeIndex (Closed)
Patch Set: Fix post-rebase unit test failure Created 3 years, 11 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/render_surface_impl.cc ('k') | cc/trees/draw_property_utils.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/layers/append_quads_data.h" 5 #include "cc/layers/append_quads_data.h"
6 #include "cc/layers/layer_impl.h" 6 #include "cc/layers/layer_impl.h"
7 #include "cc/layers/render_pass_sink.h" 7 #include "cc/layers/render_pass_sink.h"
8 #include "cc/layers/render_surface_impl.h" 8 #include "cc/layers/render_surface_impl.h"
9 #include "cc/quads/shared_quad_state.h" 9 #include "cc/quads/shared_quad_state.h"
10 #include "cc/test/fake_compositor_frame_sink.h" 10 #include "cc/test/fake_compositor_frame_sink.h"
(...skipping 21 matching lines...) Expand all
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 FakeImplTaskRunnerProvider task_runner_provider; 40 FakeImplTaskRunnerProvider task_runner_provider;
41 TestTaskGraphRunner task_graph_runner; 41 TestTaskGraphRunner task_graph_runner;
42 std::unique_ptr<CompositorFrameSink> compositor_frame_sink =
43 FakeCompositorFrameSink::Create3d();
42 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); 44 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner);
43 std::unique_ptr<LayerImpl> owning_layer = 45 std::unique_ptr<LayerImpl> owning_layer =
44 LayerImpl::Create(host_impl.active_tree(), 1); 46 LayerImpl::Create(host_impl.active_tree(), 1);
45 owning_layer->SetHasRenderSurface(true); 47 owning_layer->test_properties()->force_render_surface = true;
46 ASSERT_TRUE(owning_layer->render_surface());
47 RenderSurfaceImpl* render_surface = owning_layer->render_surface();
48 gfx::Rect test_rect(3, 4, 5, 6); 48 gfx::Rect test_rect(3, 4, 5, 6);
49 host_impl.active_tree()->ResetAllChangeTracking(); 49 host_impl.active_tree()->ResetAllChangeTracking();
50 host_impl.active_tree()->SetRootLayerForTesting(std::move(owning_layer)); 50 host_impl.active_tree()->SetRootLayerForTesting(std::move(owning_layer));
51 host_impl.active_tree()->BuildPropertyTreesForTesting(); 51 host_impl.SetVisible(true);
52 host_impl.InitializeRenderer(compositor_frame_sink.get());
53 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting();
54 host_impl.active_tree()->UpdateDrawProperties(false /* update_lcd_text */);
55
56 RenderSurfaceImpl* render_surface =
57 host_impl.active_tree()->root_layer_for_testing()->render_surface();
58 ASSERT_TRUE(render_surface);
52 59
53 // Currently, the content_rect, clip_rect, and 60 // Currently, the content_rect, clip_rect, and
54 // owning_layer->layerPropertyChanged() are the only sources of change. 61 // owning_layer->layerPropertyChanged() are the only sources of change.
55 EXECUTE_AND_VERIFY_SURFACE_CHANGED(render_surface->SetClipRect(test_rect)); 62 EXECUTE_AND_VERIFY_SURFACE_CHANGED(render_surface->SetClipRect(test_rect));
56 EXECUTE_AND_VERIFY_SURFACE_CHANGED( 63 EXECUTE_AND_VERIFY_SURFACE_CHANGED(
57 render_surface->SetContentRectForTesting(test_rect)); 64 render_surface->SetContentRectForTesting(test_rect));
58 65
59 host_impl.active_tree()->property_trees()->effect_tree.OnOpacityAnimated( 66 host_impl.active_tree()->property_trees()->effect_tree.OnOpacityAnimated(
60 0.5f, 67 0.5f,
61 host_impl.active_tree()->root_layer_for_testing()->effect_tree_index(), 68 host_impl.active_tree()->root_layer_for_testing()->effect_tree_index(),
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 return render_passes_; 158 return render_passes_;
152 } 159 }
153 160
154 private: 161 private:
155 RenderPassList render_passes_; 162 RenderPassList render_passes_;
156 }; 163 };
157 164
158 TEST(RenderSurfaceTest, SanityCheckSurfaceCreatesCorrectRenderPass) { 165 TEST(RenderSurfaceTest, SanityCheckSurfaceCreatesCorrectRenderPass) {
159 FakeImplTaskRunnerProvider task_runner_provider; 166 FakeImplTaskRunnerProvider task_runner_provider;
160 TestTaskGraphRunner task_graph_runner; 167 TestTaskGraphRunner task_graph_runner;
168 std::unique_ptr<CompositorFrameSink> compositor_frame_sink =
169 FakeCompositorFrameSink::Create3d();
161 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); 170 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner);
162 std::unique_ptr<LayerImpl> root_layer = 171 std::unique_ptr<LayerImpl> root_layer =
163 LayerImpl::Create(host_impl.active_tree(), 1); 172 LayerImpl::Create(host_impl.active_tree(), 1);
164 173
174 int owning_layer_id = 2;
165 std::unique_ptr<LayerImpl> owning_layer = 175 std::unique_ptr<LayerImpl> owning_layer =
166 LayerImpl::Create(host_impl.active_tree(), 2); 176 LayerImpl::Create(host_impl.active_tree(), owning_layer_id);
167 owning_layer->SetHasRenderSurface(true); 177 owning_layer->test_properties()->force_render_surface = true;
168 ASSERT_TRUE(owning_layer->render_surface());
169 RenderSurfaceImpl* render_surface = owning_layer->render_surface();
170 178
171 root_layer->test_properties()->AddChild(std::move(owning_layer)); 179 root_layer->test_properties()->AddChild(std::move(owning_layer));
172 host_impl.active_tree()->SetRootLayerForTesting(std::move(root_layer)); 180 host_impl.active_tree()->SetRootLayerForTesting(std::move(root_layer));
181 host_impl.SetVisible(true);
182 host_impl.InitializeRenderer(compositor_frame_sink.get());
173 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting(); 183 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting();
184 host_impl.active_tree()->UpdateDrawProperties(false /* update_lcd_text */);
185
186 ASSERT_TRUE(
187 host_impl.active_tree()->LayerById(owning_layer_id)->render_surface());
188 RenderSurfaceImpl* render_surface =
189 host_impl.active_tree()->LayerById(owning_layer_id)->render_surface();
174 190
175 gfx::Rect content_rect(0, 0, 50, 50); 191 gfx::Rect content_rect(0, 0, 50, 50);
176 gfx::Transform origin; 192 gfx::Transform origin;
177 origin.Translate(30.0, 40.0); 193 origin.Translate(30.0, 40.0);
178 194
179 render_surface->SetScreenSpaceTransform(origin); 195 render_surface->SetScreenSpaceTransform(origin);
180 render_surface->SetContentRectForTesting(content_rect); 196 render_surface->SetContentRectForTesting(content_rect);
181 197
182 TestRenderPassSink pass_sink; 198 TestRenderPassSink pass_sink;
183 199
184 render_surface->AppendRenderPasses(&pass_sink); 200 render_surface->AppendRenderPasses(&pass_sink);
185 201
186 ASSERT_EQ(1u, pass_sink.RenderPasses().size()); 202 ASSERT_EQ(1u, pass_sink.RenderPasses().size());
187 RenderPass* pass = pass_sink.RenderPasses()[0].get(); 203 RenderPass* pass = pass_sink.RenderPasses()[0].get();
188 204
189 EXPECT_EQ(2, pass->id); 205 EXPECT_EQ(2, pass->id);
190 EXPECT_EQ(content_rect, pass->output_rect); 206 EXPECT_EQ(content_rect, pass->output_rect);
191 EXPECT_EQ(origin, pass->transform_to_root_target); 207 EXPECT_EQ(origin, pass->transform_to_root_target);
192 } 208 }
193 209
194 } // namespace 210 } // namespace
195 } // namespace cc 211 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/render_surface_impl.cc ('k') | cc/trees/draw_property_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698