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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 rect, | 74 rect, |
75 SK_ColorGREEN, | 75 SK_ColorGREEN, |
76 force_anti_aliasing_off); | 76 force_anti_aliasing_off); |
77 | 77 |
78 | 78 |
79 CompositorFrame root_frame; | 79 CompositorFrame root_frame; |
80 root_frame.render_pass_list.push_back(std::move(pass)); | 80 root_frame.render_pass_list.push_back(std::move(pass)); |
81 | 81 |
82 LocalFrameId root_local_frame_id = allocator_.GenerateId(); | 82 LocalFrameId root_local_frame_id = allocator_.GenerateId(); |
83 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id); | 83 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id); |
84 factory_.Create(root_local_frame_id); | |
85 factory_.SubmitCompositorFrame(root_local_frame_id, std::move(root_frame), | 84 factory_.SubmitCompositorFrame(root_local_frame_id, std::move(root_frame), |
86 SurfaceFactory::DrawCallback()); | 85 SurfaceFactory::DrawCallback()); |
87 | 86 |
88 SurfaceAggregator aggregator(&manager_, resource_provider_.get(), true); | 87 SurfaceAggregator aggregator(&manager_, resource_provider_.get(), true); |
89 CompositorFrame aggregated_frame = aggregator.Aggregate(root_surface_id); | 88 CompositorFrame aggregated_frame = aggregator.Aggregate(root_surface_id); |
90 factory_.Destroy(root_local_frame_id); | |
91 | 89 |
92 bool discard_alpha = false; | 90 bool discard_alpha = false; |
93 ExactPixelComparator pixel_comparator(discard_alpha); | 91 ExactPixelComparator pixel_comparator(discard_alpha); |
94 RenderPassList* pass_list = &aggregated_frame.render_pass_list; | 92 RenderPassList* pass_list = &aggregated_frame.render_pass_list; |
95 EXPECT_TRUE(RunPixelTest(pass_list, | 93 EXPECT_TRUE(RunPixelTest(pass_list, |
96 base::FilePath(FILE_PATH_LITERAL("green.png")), | 94 base::FilePath(FILE_PATH_LITERAL("green.png")), |
97 pixel_comparator)); | 95 pixel_comparator)); |
98 } | 96 } |
99 | 97 |
100 // Draws a frame with simple surface embedding. | 98 // Draws a frame with simple surface embedding. |
101 TEST_F(SurfacesPixelTest, DrawSimpleAggregatedFrame) { | 99 TEST_F(SurfacesPixelTest, DrawSimpleAggregatedFrame) { |
102 gfx::Size child_size(200, 100); | 100 gfx::Size child_size(200, 100); |
103 LocalFrameId child_local_frame_id = allocator_.GenerateId(); | 101 LocalFrameId child_local_frame_id = allocator_.GenerateId(); |
104 SurfaceId child_surface_id(factory_.frame_sink_id(), child_local_frame_id); | 102 SurfaceId child_surface_id(factory_.frame_sink_id(), child_local_frame_id); |
105 LocalFrameId root_local_frame_id = allocator_.GenerateId(); | 103 LocalFrameId root_local_frame_id = allocator_.GenerateId(); |
106 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id); | 104 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id); |
| 105 SurfaceFactory child_factory(kArbitraryFrameSinkId, &manager_, &client_); |
107 | 106 |
108 factory_.Create(child_local_frame_id); | |
109 factory_.Create(root_local_frame_id); | |
110 { | 107 { |
111 gfx::Rect rect(device_viewport_size_); | 108 gfx::Rect rect(device_viewport_size_); |
112 RenderPassId id(1, 1); | 109 RenderPassId id(1, 1); |
113 std::unique_ptr<RenderPass> pass = RenderPass::Create(); | 110 std::unique_ptr<RenderPass> pass = RenderPass::Create(); |
114 pass->SetNew(id, rect, rect, gfx::Transform()); | 111 pass->SetNew(id, rect, rect, gfx::Transform()); |
115 | 112 |
116 CreateAndAppendTestSharedQuadState( | 113 CreateAndAppendTestSharedQuadState( |
117 pass.get(), gfx::Transform(), device_viewport_size_); | 114 pass.get(), gfx::Transform(), device_viewport_size_); |
118 | 115 |
119 SurfaceDrawQuad* surface_quad = | 116 SurfaceDrawQuad* surface_quad = |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 bool force_anti_aliasing_off = false; | 150 bool force_anti_aliasing_off = false; |
154 color_quad->SetNew(pass->shared_quad_state_list.back(), | 151 color_quad->SetNew(pass->shared_quad_state_list.back(), |
155 rect, | 152 rect, |
156 rect, | 153 rect, |
157 SK_ColorBLUE, | 154 SK_ColorBLUE, |
158 force_anti_aliasing_off); | 155 force_anti_aliasing_off); |
159 | 156 |
160 CompositorFrame child_frame; | 157 CompositorFrame child_frame; |
161 child_frame.render_pass_list.push_back(std::move(pass)); | 158 child_frame.render_pass_list.push_back(std::move(pass)); |
162 | 159 |
163 factory_.SubmitCompositorFrame(child_local_frame_id, std::move(child_frame), | 160 child_factory.SubmitCompositorFrame(child_local_frame_id, |
164 SurfaceFactory::DrawCallback()); | 161 std::move(child_frame), |
| 162 SurfaceFactory::DrawCallback()); |
165 } | 163 } |
166 | 164 |
167 SurfaceAggregator aggregator(&manager_, resource_provider_.get(), true); | 165 SurfaceAggregator aggregator(&manager_, resource_provider_.get(), true); |
168 CompositorFrame aggregated_frame = aggregator.Aggregate(root_surface_id); | 166 CompositorFrame aggregated_frame = aggregator.Aggregate(root_surface_id); |
169 | 167 |
170 bool discard_alpha = false; | 168 bool discard_alpha = false; |
171 ExactPixelComparator pixel_comparator(discard_alpha); | 169 ExactPixelComparator pixel_comparator(discard_alpha); |
172 RenderPassList* pass_list = &aggregated_frame.render_pass_list; | 170 RenderPassList* pass_list = &aggregated_frame.render_pass_list; |
173 EXPECT_TRUE(RunPixelTest(pass_list, | 171 EXPECT_TRUE(RunPixelTest(pass_list, |
174 base::FilePath(FILE_PATH_LITERAL("blue_yellow.png")), | 172 base::FilePath(FILE_PATH_LITERAL("blue_yellow.png")), |
175 pixel_comparator)); | 173 pixel_comparator)); |
176 factory_.Destroy(root_local_frame_id); | |
177 factory_.Destroy(child_local_frame_id); | |
178 } | 174 } |
179 | 175 |
180 // Tests a surface quad that has a non-identity transform into its pass. | 176 // Tests a surface quad that has a non-identity transform into its pass. |
181 TEST_F(SurfacesPixelTest, DrawAggregatedFrameWithSurfaceTransforms) { | 177 TEST_F(SurfacesPixelTest, DrawAggregatedFrameWithSurfaceTransforms) { |
182 gfx::Size child_size(100, 200); | 178 gfx::Size child_size(100, 200); |
183 gfx::Size quad_size(100, 100); | 179 gfx::Size quad_size(100, 100); |
184 // Structure: | 180 // Structure: |
185 // root (200x200) -> left_child (100x200 @ 0x0, | 181 // root (200x200) -> left_child (100x200 @ 0x0, |
186 // right_child (100x200 @ 0x100) | 182 // right_child (100x200 @ 0x100) |
187 // left_child -> top_green_quad (100x100 @ 0x0), | 183 // left_child -> top_green_quad (100x100 @ 0x0), |
188 // bottom_blue_quad (100x100 @ 0x100) | 184 // bottom_blue_quad (100x100 @ 0x100) |
189 // right_child -> top_blue_quad (100x100 @ 0x0), | 185 // right_child -> top_blue_quad (100x100 @ 0x0), |
190 // bottom_green_quad (100x100 @ 0x100) | 186 // bottom_green_quad (100x100 @ 0x100) |
191 LocalFrameId left_child_local_id = allocator_.GenerateId(); | 187 LocalFrameId left_child_local_id = allocator_.GenerateId(); |
192 SurfaceId left_child_id(factory_.frame_sink_id(), left_child_local_id); | 188 SurfaceId left_child_id(factory_.frame_sink_id(), left_child_local_id); |
193 LocalFrameId right_child_local_id = allocator_.GenerateId(); | 189 LocalFrameId right_child_local_id = allocator_.GenerateId(); |
194 SurfaceId right_child_id(factory_.frame_sink_id(), right_child_local_id); | 190 SurfaceId right_child_id(factory_.frame_sink_id(), right_child_local_id); |
195 LocalFrameId root_local_frame_id = allocator_.GenerateId(); | 191 LocalFrameId root_local_frame_id = allocator_.GenerateId(); |
196 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id); | 192 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id); |
197 factory_.Create(left_child_local_id); | 193 SurfaceFactory left_factory(kArbitraryFrameSinkId, &manager_, &client_); |
198 factory_.Create(right_child_local_id); | 194 SurfaceFactory right_factory(kArbitraryFrameSinkId, &manager_, &client_); |
199 factory_.Create(root_local_frame_id); | |
200 | 195 |
201 { | 196 { |
202 gfx::Rect rect(device_viewport_size_); | 197 gfx::Rect rect(device_viewport_size_); |
203 RenderPassId id(1, 1); | 198 RenderPassId id(1, 1); |
204 std::unique_ptr<RenderPass> pass = RenderPass::Create(); | 199 std::unique_ptr<RenderPass> pass = RenderPass::Create(); |
205 pass->SetNew(id, rect, rect, gfx::Transform()); | 200 pass->SetNew(id, rect, rect, gfx::Transform()); |
206 | 201 |
207 gfx::Transform surface_transform; | 202 gfx::Transform surface_transform; |
208 CreateAndAppendTestSharedQuadState( | 203 CreateAndAppendTestSharedQuadState( |
209 pass.get(), surface_transform, device_viewport_size_); | 204 pass.get(), surface_transform, device_viewport_size_); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 250 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
256 bottom_color_quad->SetNew(pass->shared_quad_state_list.back(), | 251 bottom_color_quad->SetNew(pass->shared_quad_state_list.back(), |
257 gfx::Rect(0, 100, 100, 100), | 252 gfx::Rect(0, 100, 100, 100), |
258 gfx::Rect(0, 100, 100, 100), | 253 gfx::Rect(0, 100, 100, 100), |
259 SK_ColorBLUE, | 254 SK_ColorBLUE, |
260 force_anti_aliasing_off); | 255 force_anti_aliasing_off); |
261 | 256 |
262 CompositorFrame child_frame; | 257 CompositorFrame child_frame; |
263 child_frame.render_pass_list.push_back(std::move(pass)); | 258 child_frame.render_pass_list.push_back(std::move(pass)); |
264 | 259 |
265 factory_.SubmitCompositorFrame(left_child_local_id, std::move(child_frame), | 260 left_factory.SubmitCompositorFrame(left_child_local_id, |
266 SurfaceFactory::DrawCallback()); | 261 std::move(child_frame), |
| 262 SurfaceFactory::DrawCallback()); |
267 } | 263 } |
268 | 264 |
269 { | 265 { |
270 gfx::Rect rect(child_size); | 266 gfx::Rect rect(child_size); |
271 RenderPassId id(1, 1); | 267 RenderPassId id(1, 1); |
272 std::unique_ptr<RenderPass> pass = RenderPass::Create(); | 268 std::unique_ptr<RenderPass> pass = RenderPass::Create(); |
273 pass->SetNew(id, rect, rect, gfx::Transform()); | 269 pass->SetNew(id, rect, rect, gfx::Transform()); |
274 | 270 |
275 CreateAndAppendTestSharedQuadState( | 271 CreateAndAppendTestSharedQuadState( |
276 pass.get(), gfx::Transform(), child_size); | 272 pass.get(), gfx::Transform(), child_size); |
(...skipping 11 matching lines...) Expand all Loading... |
288 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 284 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
289 bottom_color_quad->SetNew(pass->shared_quad_state_list.back(), | 285 bottom_color_quad->SetNew(pass->shared_quad_state_list.back(), |
290 gfx::Rect(0, 100, 100, 100), | 286 gfx::Rect(0, 100, 100, 100), |
291 gfx::Rect(0, 100, 100, 100), | 287 gfx::Rect(0, 100, 100, 100), |
292 SK_ColorGREEN, | 288 SK_ColorGREEN, |
293 force_anti_aliasing_off); | 289 force_anti_aliasing_off); |
294 | 290 |
295 CompositorFrame child_frame; | 291 CompositorFrame child_frame; |
296 child_frame.render_pass_list.push_back(std::move(pass)); | 292 child_frame.render_pass_list.push_back(std::move(pass)); |
297 | 293 |
298 factory_.SubmitCompositorFrame(right_child_local_id, std::move(child_frame), | 294 right_factory.SubmitCompositorFrame(right_child_local_id, |
299 SurfaceFactory::DrawCallback()); | 295 std::move(child_frame), |
| 296 SurfaceFactory::DrawCallback()); |
300 } | 297 } |
301 | 298 |
302 SurfaceAggregator aggregator(&manager_, resource_provider_.get(), true); | 299 SurfaceAggregator aggregator(&manager_, resource_provider_.get(), true); |
303 CompositorFrame aggregated_frame = aggregator.Aggregate(root_surface_id); | 300 CompositorFrame aggregated_frame = aggregator.Aggregate(root_surface_id); |
304 | 301 |
305 bool discard_alpha = false; | 302 bool discard_alpha = false; |
306 ExactPixelComparator pixel_comparator(discard_alpha); | 303 ExactPixelComparator pixel_comparator(discard_alpha); |
307 RenderPassList* pass_list = &aggregated_frame.render_pass_list; | 304 RenderPassList* pass_list = &aggregated_frame.render_pass_list; |
308 EXPECT_TRUE(RunPixelTest( | 305 EXPECT_TRUE(RunPixelTest( |
309 pass_list, | 306 pass_list, |
310 base::FilePath(FILE_PATH_LITERAL("four_blue_green_checkers.png")), | 307 base::FilePath(FILE_PATH_LITERAL("four_blue_green_checkers.png")), |
311 pixel_comparator)); | 308 pixel_comparator)); |
312 | |
313 factory_.Destroy(root_local_frame_id); | |
314 factory_.Destroy(left_child_local_id); | |
315 factory_.Destroy(right_child_local_id); | |
316 } | 309 } |
317 | 310 |
318 } // namespace | 311 } // namespace |
319 } // namespace cc | 312 } // namespace cc |
320 | 313 |
321 #endif // !defined(OS_ANDROID) | 314 #endif // !defined(OS_ANDROID) |
OLD | NEW |