OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/output/compositor_frame.h" | 5 #include "cc/output/compositor_frame.h" |
6 #include "cc/quads/render_pass.h" | 6 #include "cc/quads/render_pass.h" |
7 #include "cc/quads/solid_color_draw_quad.h" | 7 #include "cc/quads/solid_color_draw_quad.h" |
8 #include "cc/quads/surface_draw_quad.h" | 8 #include "cc/quads/surface_draw_quad.h" |
9 #include "cc/surfaces/surface.h" | 9 #include "cc/surfaces/surface.h" |
10 #include "cc/surfaces/surface_aggregator.h" | 10 #include "cc/surfaces/surface_aggregator.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 color_quad->SetNew(pass->shared_quad_state_list.back(), | 70 color_quad->SetNew(pass->shared_quad_state_list.back(), |
71 rect, | 71 rect, |
72 rect, | 72 rect, |
73 SK_ColorGREEN, | 73 SK_ColorGREEN, |
74 force_anti_aliasing_off); | 74 force_anti_aliasing_off); |
75 | 75 |
76 std::unique_ptr<DelegatedFrameData> delegated_frame_data( | 76 std::unique_ptr<DelegatedFrameData> delegated_frame_data( |
77 new DelegatedFrameData); | 77 new DelegatedFrameData); |
78 delegated_frame_data->render_pass_list.push_back(std::move(pass)); | 78 delegated_frame_data->render_pass_list.push_back(std::move(pass)); |
79 | 79 |
80 std::unique_ptr<CompositorFrame> root_frame(new CompositorFrame); | 80 CompositorFrame root_frame; |
81 root_frame->delegated_frame_data = std::move(delegated_frame_data); | 81 root_frame.delegated_frame_data = std::move(delegated_frame_data); |
82 | 82 |
83 SurfaceId root_surface_id = allocator_.GenerateId(); | 83 SurfaceId root_surface_id = allocator_.GenerateId(); |
84 factory_.Create(root_surface_id); | 84 factory_.Create(root_surface_id); |
85 factory_.SubmitCompositorFrame(root_surface_id, std::move(root_frame), | 85 factory_.SubmitCompositorFrame(root_surface_id, std::move(root_frame), |
86 SurfaceFactory::DrawCallback()); | 86 SurfaceFactory::DrawCallback()); |
87 | 87 |
88 SurfaceAggregator aggregator(&manager_, resource_provider_.get(), true); | 88 SurfaceAggregator aggregator(&manager_, resource_provider_.get(), true); |
89 std::unique_ptr<CompositorFrame> aggregated_frame = | 89 CompositorFrame aggregated_frame = aggregator.Aggregate(root_surface_id); |
90 aggregator.Aggregate(root_surface_id); | |
91 factory_.Destroy(root_surface_id); | 90 factory_.Destroy(root_surface_id); |
92 | 91 |
93 bool discard_alpha = false; | 92 bool discard_alpha = false; |
94 ExactPixelComparator pixel_comparator(discard_alpha); | 93 ExactPixelComparator pixel_comparator(discard_alpha); |
95 RenderPassList* pass_list = | 94 RenderPassList* pass_list = |
96 &aggregated_frame->delegated_frame_data->render_pass_list; | 95 &aggregated_frame.delegated_frame_data->render_pass_list; |
97 EXPECT_TRUE(RunPixelTest(pass_list, | 96 EXPECT_TRUE(RunPixelTest(pass_list, |
98 base::FilePath(FILE_PATH_LITERAL("green.png")), | 97 base::FilePath(FILE_PATH_LITERAL("green.png")), |
99 pixel_comparator)); | 98 pixel_comparator)); |
100 } | 99 } |
101 | 100 |
102 // Draws a frame with simple surface embedding. | 101 // Draws a frame with simple surface embedding. |
103 TEST_F(SurfacesPixelTest, DrawSimpleAggregatedFrame) { | 102 TEST_F(SurfacesPixelTest, DrawSimpleAggregatedFrame) { |
104 gfx::Size child_size(200, 100); | 103 gfx::Size child_size(200, 100); |
105 SurfaceId child_surface_id = allocator_.GenerateId(); | 104 SurfaceId child_surface_id = allocator_.GenerateId(); |
106 SurfaceId root_surface_id = allocator_.GenerateId(); | 105 SurfaceId root_surface_id = allocator_.GenerateId(); |
(...skipping 21 matching lines...) Expand all Loading... |
128 color_quad->SetNew(pass->shared_quad_state_list.back(), | 127 color_quad->SetNew(pass->shared_quad_state_list.back(), |
129 rect, | 128 rect, |
130 rect, | 129 rect, |
131 SK_ColorYELLOW, | 130 SK_ColorYELLOW, |
132 force_anti_aliasing_off); | 131 force_anti_aliasing_off); |
133 | 132 |
134 std::unique_ptr<DelegatedFrameData> delegated_frame_data( | 133 std::unique_ptr<DelegatedFrameData> delegated_frame_data( |
135 new DelegatedFrameData); | 134 new DelegatedFrameData); |
136 delegated_frame_data->render_pass_list.push_back(std::move(pass)); | 135 delegated_frame_data->render_pass_list.push_back(std::move(pass)); |
137 | 136 |
138 std::unique_ptr<CompositorFrame> root_frame(new CompositorFrame); | 137 CompositorFrame root_frame; |
139 root_frame->delegated_frame_data = std::move(delegated_frame_data); | 138 root_frame.delegated_frame_data = std::move(delegated_frame_data); |
140 | 139 |
141 factory_.SubmitCompositorFrame(root_surface_id, std::move(root_frame), | 140 factory_.SubmitCompositorFrame(root_surface_id, std::move(root_frame), |
142 SurfaceFactory::DrawCallback()); | 141 SurfaceFactory::DrawCallback()); |
143 } | 142 } |
144 | 143 |
145 { | 144 { |
146 gfx::Rect rect(child_size); | 145 gfx::Rect rect(child_size); |
147 RenderPassId id(1, 1); | 146 RenderPassId id(1, 1); |
148 std::unique_ptr<RenderPass> pass = RenderPass::Create(); | 147 std::unique_ptr<RenderPass> pass = RenderPass::Create(); |
149 pass->SetNew(id, rect, rect, gfx::Transform()); | 148 pass->SetNew(id, rect, rect, gfx::Transform()); |
150 | 149 |
151 CreateAndAppendTestSharedQuadState( | 150 CreateAndAppendTestSharedQuadState( |
152 pass.get(), gfx::Transform(), child_size); | 151 pass.get(), gfx::Transform(), child_size); |
153 | 152 |
154 SolidColorDrawQuad* color_quad = | 153 SolidColorDrawQuad* color_quad = |
155 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 154 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
156 bool force_anti_aliasing_off = false; | 155 bool force_anti_aliasing_off = false; |
157 color_quad->SetNew(pass->shared_quad_state_list.back(), | 156 color_quad->SetNew(pass->shared_quad_state_list.back(), |
158 rect, | 157 rect, |
159 rect, | 158 rect, |
160 SK_ColorBLUE, | 159 SK_ColorBLUE, |
161 force_anti_aliasing_off); | 160 force_anti_aliasing_off); |
162 | 161 |
163 std::unique_ptr<DelegatedFrameData> delegated_frame_data( | 162 std::unique_ptr<DelegatedFrameData> delegated_frame_data( |
164 new DelegatedFrameData); | 163 new DelegatedFrameData); |
165 delegated_frame_data->render_pass_list.push_back(std::move(pass)); | 164 delegated_frame_data->render_pass_list.push_back(std::move(pass)); |
166 | 165 |
167 std::unique_ptr<CompositorFrame> child_frame(new CompositorFrame); | 166 CompositorFrame child_frame; |
168 child_frame->delegated_frame_data = std::move(delegated_frame_data); | 167 child_frame.delegated_frame_data = std::move(delegated_frame_data); |
169 | 168 |
170 factory_.SubmitCompositorFrame(child_surface_id, std::move(child_frame), | 169 factory_.SubmitCompositorFrame(child_surface_id, std::move(child_frame), |
171 SurfaceFactory::DrawCallback()); | 170 SurfaceFactory::DrawCallback()); |
172 } | 171 } |
173 | 172 |
174 SurfaceAggregator aggregator(&manager_, resource_provider_.get(), true); | 173 SurfaceAggregator aggregator(&manager_, resource_provider_.get(), true); |
175 std::unique_ptr<CompositorFrame> aggregated_frame = | 174 CompositorFrame aggregated_frame = aggregator.Aggregate(root_surface_id); |
176 aggregator.Aggregate(root_surface_id); | |
177 | 175 |
178 bool discard_alpha = false; | 176 bool discard_alpha = false; |
179 ExactPixelComparator pixel_comparator(discard_alpha); | 177 ExactPixelComparator pixel_comparator(discard_alpha); |
180 RenderPassList* pass_list = | 178 RenderPassList* pass_list = |
181 &aggregated_frame->delegated_frame_data->render_pass_list; | 179 &aggregated_frame.delegated_frame_data->render_pass_list; |
182 EXPECT_TRUE(RunPixelTest(pass_list, | 180 EXPECT_TRUE(RunPixelTest(pass_list, |
183 base::FilePath(FILE_PATH_LITERAL("blue_yellow.png")), | 181 base::FilePath(FILE_PATH_LITERAL("blue_yellow.png")), |
184 pixel_comparator)); | 182 pixel_comparator)); |
185 factory_.Destroy(root_surface_id); | 183 factory_.Destroy(root_surface_id); |
186 factory_.Destroy(child_surface_id); | 184 factory_.Destroy(child_surface_id); |
187 } | 185 } |
188 | 186 |
189 // Tests a surface quad that has a non-identity transform into its pass. | 187 // Tests a surface quad that has a non-identity transform into its pass. |
190 TEST_F(SurfacesPixelTest, DrawAggregatedFrameWithSurfaceTransforms) { | 188 TEST_F(SurfacesPixelTest, DrawAggregatedFrameWithSurfaceTransforms) { |
191 gfx::Size child_size(100, 200); | 189 gfx::Size child_size(100, 200); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); | 227 pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); |
230 right_surface_quad->SetNew(pass->shared_quad_state_list.back(), | 228 right_surface_quad->SetNew(pass->shared_quad_state_list.back(), |
231 gfx::Rect(child_size), | 229 gfx::Rect(child_size), |
232 gfx::Rect(child_size), | 230 gfx::Rect(child_size), |
233 right_child_id); | 231 right_child_id); |
234 | 232 |
235 std::unique_ptr<DelegatedFrameData> delegated_frame_data( | 233 std::unique_ptr<DelegatedFrameData> delegated_frame_data( |
236 new DelegatedFrameData); | 234 new DelegatedFrameData); |
237 delegated_frame_data->render_pass_list.push_back(std::move(pass)); | 235 delegated_frame_data->render_pass_list.push_back(std::move(pass)); |
238 | 236 |
239 std::unique_ptr<CompositorFrame> root_frame(new CompositorFrame); | 237 CompositorFrame root_frame; |
240 root_frame->delegated_frame_data = std::move(delegated_frame_data); | 238 root_frame.delegated_frame_data = std::move(delegated_frame_data); |
241 | 239 |
242 factory_.SubmitCompositorFrame(root_surface_id, std::move(root_frame), | 240 factory_.SubmitCompositorFrame(root_surface_id, std::move(root_frame), |
243 SurfaceFactory::DrawCallback()); | 241 SurfaceFactory::DrawCallback()); |
244 } | 242 } |
245 | 243 |
246 { | 244 { |
247 gfx::Rect rect(child_size); | 245 gfx::Rect rect(child_size); |
248 RenderPassId id(1, 1); | 246 RenderPassId id(1, 1); |
249 std::unique_ptr<RenderPass> pass = RenderPass::Create(); | 247 std::unique_ptr<RenderPass> pass = RenderPass::Create(); |
250 pass->SetNew(id, rect, rect, gfx::Transform()); | 248 pass->SetNew(id, rect, rect, gfx::Transform()); |
(...skipping 15 matching lines...) Expand all Loading... |
266 bottom_color_quad->SetNew(pass->shared_quad_state_list.back(), | 264 bottom_color_quad->SetNew(pass->shared_quad_state_list.back(), |
267 gfx::Rect(0, 100, 100, 100), | 265 gfx::Rect(0, 100, 100, 100), |
268 gfx::Rect(0, 100, 100, 100), | 266 gfx::Rect(0, 100, 100, 100), |
269 SK_ColorBLUE, | 267 SK_ColorBLUE, |
270 force_anti_aliasing_off); | 268 force_anti_aliasing_off); |
271 | 269 |
272 std::unique_ptr<DelegatedFrameData> delegated_frame_data( | 270 std::unique_ptr<DelegatedFrameData> delegated_frame_data( |
273 new DelegatedFrameData); | 271 new DelegatedFrameData); |
274 delegated_frame_data->render_pass_list.push_back(std::move(pass)); | 272 delegated_frame_data->render_pass_list.push_back(std::move(pass)); |
275 | 273 |
276 std::unique_ptr<CompositorFrame> child_frame(new CompositorFrame); | 274 CompositorFrame child_frame; |
277 child_frame->delegated_frame_data = std::move(delegated_frame_data); | 275 child_frame.delegated_frame_data = std::move(delegated_frame_data); |
278 | 276 |
279 factory_.SubmitCompositorFrame(left_child_id, std::move(child_frame), | 277 factory_.SubmitCompositorFrame(left_child_id, std::move(child_frame), |
280 SurfaceFactory::DrawCallback()); | 278 SurfaceFactory::DrawCallback()); |
281 } | 279 } |
282 | 280 |
283 { | 281 { |
284 gfx::Rect rect(child_size); | 282 gfx::Rect rect(child_size); |
285 RenderPassId id(1, 1); | 283 RenderPassId id(1, 1); |
286 std::unique_ptr<RenderPass> pass = RenderPass::Create(); | 284 std::unique_ptr<RenderPass> pass = RenderPass::Create(); |
287 pass->SetNew(id, rect, rect, gfx::Transform()); | 285 pass->SetNew(id, rect, rect, gfx::Transform()); |
(...skipping 15 matching lines...) Expand all Loading... |
303 bottom_color_quad->SetNew(pass->shared_quad_state_list.back(), | 301 bottom_color_quad->SetNew(pass->shared_quad_state_list.back(), |
304 gfx::Rect(0, 100, 100, 100), | 302 gfx::Rect(0, 100, 100, 100), |
305 gfx::Rect(0, 100, 100, 100), | 303 gfx::Rect(0, 100, 100, 100), |
306 SK_ColorGREEN, | 304 SK_ColorGREEN, |
307 force_anti_aliasing_off); | 305 force_anti_aliasing_off); |
308 | 306 |
309 std::unique_ptr<DelegatedFrameData> delegated_frame_data( | 307 std::unique_ptr<DelegatedFrameData> delegated_frame_data( |
310 new DelegatedFrameData); | 308 new DelegatedFrameData); |
311 delegated_frame_data->render_pass_list.push_back(std::move(pass)); | 309 delegated_frame_data->render_pass_list.push_back(std::move(pass)); |
312 | 310 |
313 std::unique_ptr<CompositorFrame> child_frame(new CompositorFrame); | 311 CompositorFrame child_frame; |
314 child_frame->delegated_frame_data = std::move(delegated_frame_data); | 312 child_frame.delegated_frame_data = std::move(delegated_frame_data); |
315 | 313 |
316 factory_.SubmitCompositorFrame(right_child_id, std::move(child_frame), | 314 factory_.SubmitCompositorFrame(right_child_id, std::move(child_frame), |
317 SurfaceFactory::DrawCallback()); | 315 SurfaceFactory::DrawCallback()); |
318 } | 316 } |
319 | 317 |
320 SurfaceAggregator aggregator(&manager_, resource_provider_.get(), true); | 318 SurfaceAggregator aggregator(&manager_, resource_provider_.get(), true); |
321 std::unique_ptr<CompositorFrame> aggregated_frame = | 319 CompositorFrame aggregated_frame = aggregator.Aggregate(root_surface_id); |
322 aggregator.Aggregate(root_surface_id); | |
323 | 320 |
324 bool discard_alpha = false; | 321 bool discard_alpha = false; |
325 ExactPixelComparator pixel_comparator(discard_alpha); | 322 ExactPixelComparator pixel_comparator(discard_alpha); |
326 RenderPassList* pass_list = | 323 RenderPassList* pass_list = |
327 &aggregated_frame->delegated_frame_data->render_pass_list; | 324 &aggregated_frame.delegated_frame_data->render_pass_list; |
328 EXPECT_TRUE(RunPixelTest( | 325 EXPECT_TRUE(RunPixelTest( |
329 pass_list, | 326 pass_list, |
330 base::FilePath(FILE_PATH_LITERAL("four_blue_green_checkers.png")), | 327 base::FilePath(FILE_PATH_LITERAL("four_blue_green_checkers.png")), |
331 pixel_comparator)); | 328 pixel_comparator)); |
332 | 329 |
333 factory_.Destroy(root_surface_id); | 330 factory_.Destroy(root_surface_id); |
334 factory_.Destroy(left_child_id); | 331 factory_.Destroy(left_child_id); |
335 factory_.Destroy(right_child_id); | 332 factory_.Destroy(right_child_id); |
336 } | 333 } |
337 | 334 |
338 } // namespace | 335 } // namespace |
339 } // namespace cc | 336 } // namespace cc |
340 | 337 |
341 #endif // !defined(OS_ANDROID) | 338 #endif // !defined(OS_ANDROID) |
OLD | NEW |