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