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

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

Issue 1902893002: cc: Move calculation of content rect to RenderSurfaceImpl class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@targetid
Patch Set: Created 4 years, 8 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
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_impl_task_runner_provider.h" 10 #include "cc/test/fake_impl_task_runner_provider.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 host_impl.active_tree()->ResetAllChangeTracking( 51 host_impl.active_tree()->ResetAllChangeTracking(
52 PropertyTrees::ResetFlags::ALL_TREES); 52 PropertyTrees::ResetFlags::ALL_TREES);
53 53
54 // Currently, the content_rect, clip_rect, and 54 // Currently, the content_rect, clip_rect, and
55 // owning_layer->layerPropertyChanged() are the only sources of change. 55 // owning_layer->layerPropertyChanged() are the only sources of change.
56 EXECUTE_AND_VERIFY_SURFACE_CHANGED(render_surface->SetClipRect(test_rect)); 56 EXECUTE_AND_VERIFY_SURFACE_CHANGED(render_surface->SetClipRect(test_rect));
57 EXECUTE_AND_VERIFY_SURFACE_CHANGED(render_surface->SetContentRect(test_rect)); 57 EXECUTE_AND_VERIFY_SURFACE_CHANGED(
58 render_surface->SetContentRectForTesting(test_rect));
58 59
59 owning_layer->SetOpacity(0.5f); 60 owning_layer->SetOpacity(0.5f);
60 EXPECT_TRUE(render_surface->SurfacePropertyChanged()); 61 EXPECT_TRUE(render_surface->SurfacePropertyChanged());
61 host_impl.active_tree()->ResetAllChangeTracking( 62 host_impl.active_tree()->ResetAllChangeTracking(
62 PropertyTrees::ResetFlags::ALL_TREES); 63 PropertyTrees::ResetFlags::ALL_TREES);
63 64
64 // Setting the surface properties to the same values again should not be 65 // Setting the surface properties to the same values again should not be
65 // considered "change". 66 // considered "change".
66 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE( 67 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(
67 render_surface->SetClipRect(test_rect)); 68 render_surface->SetClipRect(test_rect));
68 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE( 69 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(
69 render_surface->SetContentRect(test_rect)); 70 render_surface->SetContentRectForTesting(test_rect));
70 71
71 std::unique_ptr<LayerImpl> dummy_mask = 72 std::unique_ptr<LayerImpl> dummy_mask =
72 LayerImpl::Create(host_impl.active_tree(), 2); 73 LayerImpl::Create(host_impl.active_tree(), 2);
73 gfx::Transform dummy_matrix; 74 gfx::Transform dummy_matrix;
74 dummy_matrix.Translate(1.0, 2.0); 75 dummy_matrix.Translate(1.0, 2.0);
75 76
76 // The rest of the surface properties are either internal and should not cause 77 // The rest of the surface properties are either internal and should not cause
77 // change, or they are already accounted for by the 78 // change, or they are already accounted for by the
78 // owninglayer->layerPropertyChanged(). 79 // owninglayer->layerPropertyChanged().
79 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE( 80 EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(
(...skipping 23 matching lines...) Expand all
103 owning_layer->SetBlendMode(blend_mode); 104 owning_layer->SetBlendMode(blend_mode);
104 RenderSurfaceImpl* render_surface = owning_layer->render_surface(); 105 RenderSurfaceImpl* render_surface = owning_layer->render_surface();
105 106
106 root_layer->AddChild(std::move(owning_layer)); 107 root_layer->AddChild(std::move(owning_layer));
107 108
108 gfx::Rect content_rect(0, 0, 50, 50); 109 gfx::Rect content_rect(0, 0, 50, 50);
109 gfx::Rect clip_rect(5, 5, 40, 40); 110 gfx::Rect clip_rect(5, 5, 40, 40);
110 gfx::Transform origin; 111 gfx::Transform origin;
111 origin.Translate(30, 40); 112 origin.Translate(30, 40);
112 113
113 render_surface->SetContentRect(content_rect); 114 render_surface->SetContentRectForTesting(content_rect);
114 render_surface->SetClipRect(clip_rect); 115 render_surface->SetClipRect(clip_rect);
115 render_surface->SetDrawOpacity(1.f); 116 render_surface->SetDrawOpacity(1.f);
116 117
117 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); 118 std::unique_ptr<RenderPass> render_pass = RenderPass::Create();
118 AppendQuadsData append_quads_data; 119 AppendQuadsData append_quads_data;
119 120
120 render_surface->AppendQuads(render_pass.get(), origin, Occlusion(), 121 render_surface->AppendQuads(render_pass.get(), origin, Occlusion(),
121 SK_ColorBLACK, 1.f, nullptr, &append_quads_data, 122 SK_ColorBLACK, 1.f, nullptr, &append_quads_data,
122 RenderPassId(2, 0)); 123 RenderPassId(2, 0));
123 124
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 ASSERT_TRUE(owning_layer->render_surface()); 167 ASSERT_TRUE(owning_layer->render_surface());
167 RenderSurfaceImpl* render_surface = owning_layer->render_surface(); 168 RenderSurfaceImpl* render_surface = owning_layer->render_surface();
168 169
169 root_layer->AddChild(std::move(owning_layer)); 170 root_layer->AddChild(std::move(owning_layer));
170 171
171 gfx::Rect content_rect(0, 0, 50, 50); 172 gfx::Rect content_rect(0, 0, 50, 50);
172 gfx::Transform origin; 173 gfx::Transform origin;
173 origin.Translate(30.0, 40.0); 174 origin.Translate(30.0, 40.0);
174 175
175 render_surface->SetScreenSpaceTransform(origin); 176 render_surface->SetScreenSpaceTransform(origin);
176 render_surface->SetContentRect(content_rect); 177 render_surface->SetContentRectForTesting(content_rect);
177 178
178 TestRenderPassSink pass_sink; 179 TestRenderPassSink pass_sink;
179 180
180 render_surface->AppendRenderPasses(&pass_sink); 181 render_surface->AppendRenderPasses(&pass_sink);
181 182
182 ASSERT_EQ(1u, pass_sink.RenderPasses().size()); 183 ASSERT_EQ(1u, pass_sink.RenderPasses().size());
183 RenderPass* pass = pass_sink.RenderPasses()[0].get(); 184 RenderPass* pass = pass_sink.RenderPasses()[0].get();
184 185
185 EXPECT_EQ(RenderPassId(2, 0), pass->id); 186 EXPECT_EQ(RenderPassId(2, 0), pass->id);
186 EXPECT_EQ(content_rect, pass->output_rect); 187 EXPECT_EQ(content_rect, pass->output_rect);
187 EXPECT_EQ(origin, pass->transform_to_root_target); 188 EXPECT_EQ(origin, pass->transform_to_root_target);
188 } 189 }
189 190
190 } // namespace 191 } // namespace
191 } // namespace cc 192 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698