| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 | 68 |
| 69 SolidColorDrawQuad* color_quad = | 69 SolidColorDrawQuad* color_quad = |
| 70 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 70 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
| 71 bool force_anti_aliasing_off = false; | 71 bool force_anti_aliasing_off = false; |
| 72 color_quad->SetNew(pass->shared_quad_state_list.back(), | 72 color_quad->SetNew(pass->shared_quad_state_list.back(), |
| 73 rect, | 73 rect, |
| 74 rect, | 74 rect, |
| 75 SK_ColorGREEN, | 75 SK_ColorGREEN, |
| 76 force_anti_aliasing_off); | 76 force_anti_aliasing_off); |
| 77 | 77 |
| 78 std::unique_ptr<DelegatedFrameData> delegated_frame_data( |
| 79 new DelegatedFrameData); |
| 80 delegated_frame_data->render_pass_list.push_back(std::move(pass)); |
| 78 | 81 |
| 79 CompositorFrame root_frame; | 82 CompositorFrame root_frame; |
| 80 root_frame.render_pass_list.push_back(std::move(pass)); | 83 root_frame.delegated_frame_data = std::move(delegated_frame_data); |
| 81 | 84 |
| 82 LocalFrameId root_local_frame_id = allocator_.GenerateId(); | 85 LocalFrameId root_local_frame_id = allocator_.GenerateId(); |
| 83 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id); | 86 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id); |
| 84 factory_.Create(root_local_frame_id); | 87 factory_.Create(root_local_frame_id); |
| 85 factory_.SubmitCompositorFrame(root_local_frame_id, std::move(root_frame), | 88 factory_.SubmitCompositorFrame(root_local_frame_id, std::move(root_frame), |
| 86 SurfaceFactory::DrawCallback()); | 89 SurfaceFactory::DrawCallback()); |
| 87 | 90 |
| 88 SurfaceAggregator aggregator(&manager_, resource_provider_.get(), true); | 91 SurfaceAggregator aggregator(&manager_, resource_provider_.get(), true); |
| 89 CompositorFrame aggregated_frame = aggregator.Aggregate(root_surface_id); | 92 CompositorFrame aggregated_frame = aggregator.Aggregate(root_surface_id); |
| 90 factory_.Destroy(root_local_frame_id); | 93 factory_.Destroy(root_local_frame_id); |
| 91 | 94 |
| 92 bool discard_alpha = false; | 95 bool discard_alpha = false; |
| 93 ExactPixelComparator pixel_comparator(discard_alpha); | 96 ExactPixelComparator pixel_comparator(discard_alpha); |
| 94 RenderPassList* pass_list = &aggregated_frame.render_pass_list; | 97 RenderPassList* pass_list = |
| 98 &aggregated_frame.delegated_frame_data->render_pass_list; |
| 95 EXPECT_TRUE(RunPixelTest(pass_list, | 99 EXPECT_TRUE(RunPixelTest(pass_list, |
| 96 base::FilePath(FILE_PATH_LITERAL("green.png")), | 100 base::FilePath(FILE_PATH_LITERAL("green.png")), |
| 97 pixel_comparator)); | 101 pixel_comparator)); |
| 98 } | 102 } |
| 99 | 103 |
| 100 // Draws a frame with simple surface embedding. | 104 // Draws a frame with simple surface embedding. |
| 101 TEST_F(SurfacesPixelTest, DrawSimpleAggregatedFrame) { | 105 TEST_F(SurfacesPixelTest, DrawSimpleAggregatedFrame) { |
| 102 gfx::Size child_size(200, 100); | 106 gfx::Size child_size(200, 100); |
| 103 LocalFrameId child_local_frame_id = allocator_.GenerateId(); | 107 LocalFrameId child_local_frame_id = allocator_.GenerateId(); |
| 104 SurfaceId child_surface_id(factory_.frame_sink_id(), child_local_frame_id); | 108 SurfaceId child_surface_id(factory_.frame_sink_id(), child_local_frame_id); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 125 | 129 |
| 126 SolidColorDrawQuad* color_quad = | 130 SolidColorDrawQuad* color_quad = |
| 127 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 131 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
| 128 bool force_anti_aliasing_off = false; | 132 bool force_anti_aliasing_off = false; |
| 129 color_quad->SetNew(pass->shared_quad_state_list.back(), | 133 color_quad->SetNew(pass->shared_quad_state_list.back(), |
| 130 rect, | 134 rect, |
| 131 rect, | 135 rect, |
| 132 SK_ColorYELLOW, | 136 SK_ColorYELLOW, |
| 133 force_anti_aliasing_off); | 137 force_anti_aliasing_off); |
| 134 | 138 |
| 139 std::unique_ptr<DelegatedFrameData> delegated_frame_data( |
| 140 new DelegatedFrameData); |
| 141 delegated_frame_data->render_pass_list.push_back(std::move(pass)); |
| 142 |
| 135 CompositorFrame root_frame; | 143 CompositorFrame root_frame; |
| 136 root_frame.render_pass_list.push_back(std::move(pass)); | 144 root_frame.delegated_frame_data = std::move(delegated_frame_data); |
| 137 | 145 |
| 138 factory_.SubmitCompositorFrame(root_local_frame_id, std::move(root_frame), | 146 factory_.SubmitCompositorFrame(root_local_frame_id, std::move(root_frame), |
| 139 SurfaceFactory::DrawCallback()); | 147 SurfaceFactory::DrawCallback()); |
| 140 } | 148 } |
| 141 | 149 |
| 142 { | 150 { |
| 143 gfx::Rect rect(child_size); | 151 gfx::Rect rect(child_size); |
| 144 RenderPassId id(1, 1); | 152 RenderPassId id(1, 1); |
| 145 std::unique_ptr<RenderPass> pass = RenderPass::Create(); | 153 std::unique_ptr<RenderPass> pass = RenderPass::Create(); |
| 146 pass->SetNew(id, rect, rect, gfx::Transform()); | 154 pass->SetNew(id, rect, rect, gfx::Transform()); |
| 147 | 155 |
| 148 CreateAndAppendTestSharedQuadState( | 156 CreateAndAppendTestSharedQuadState( |
| 149 pass.get(), gfx::Transform(), child_size); | 157 pass.get(), gfx::Transform(), child_size); |
| 150 | 158 |
| 151 SolidColorDrawQuad* color_quad = | 159 SolidColorDrawQuad* color_quad = |
| 152 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 160 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
| 153 bool force_anti_aliasing_off = false; | 161 bool force_anti_aliasing_off = false; |
| 154 color_quad->SetNew(pass->shared_quad_state_list.back(), | 162 color_quad->SetNew(pass->shared_quad_state_list.back(), |
| 155 rect, | 163 rect, |
| 156 rect, | 164 rect, |
| 157 SK_ColorBLUE, | 165 SK_ColorBLUE, |
| 158 force_anti_aliasing_off); | 166 force_anti_aliasing_off); |
| 159 | 167 |
| 168 std::unique_ptr<DelegatedFrameData> delegated_frame_data( |
| 169 new DelegatedFrameData); |
| 170 delegated_frame_data->render_pass_list.push_back(std::move(pass)); |
| 171 |
| 160 CompositorFrame child_frame; | 172 CompositorFrame child_frame; |
| 161 child_frame.render_pass_list.push_back(std::move(pass)); | 173 child_frame.delegated_frame_data = std::move(delegated_frame_data); |
| 162 | 174 |
| 163 factory_.SubmitCompositorFrame(child_local_frame_id, std::move(child_frame), | 175 factory_.SubmitCompositorFrame(child_local_frame_id, std::move(child_frame), |
| 164 SurfaceFactory::DrawCallback()); | 176 SurfaceFactory::DrawCallback()); |
| 165 } | 177 } |
| 166 | 178 |
| 167 SurfaceAggregator aggregator(&manager_, resource_provider_.get(), true); | 179 SurfaceAggregator aggregator(&manager_, resource_provider_.get(), true); |
| 168 CompositorFrame aggregated_frame = aggregator.Aggregate(root_surface_id); | 180 CompositorFrame aggregated_frame = aggregator.Aggregate(root_surface_id); |
| 169 | 181 |
| 170 bool discard_alpha = false; | 182 bool discard_alpha = false; |
| 171 ExactPixelComparator pixel_comparator(discard_alpha); | 183 ExactPixelComparator pixel_comparator(discard_alpha); |
| 172 RenderPassList* pass_list = &aggregated_frame.render_pass_list; | 184 RenderPassList* pass_list = |
| 185 &aggregated_frame.delegated_frame_data->render_pass_list; |
| 173 EXPECT_TRUE(RunPixelTest(pass_list, | 186 EXPECT_TRUE(RunPixelTest(pass_list, |
| 174 base::FilePath(FILE_PATH_LITERAL("blue_yellow.png")), | 187 base::FilePath(FILE_PATH_LITERAL("blue_yellow.png")), |
| 175 pixel_comparator)); | 188 pixel_comparator)); |
| 176 factory_.Destroy(root_local_frame_id); | 189 factory_.Destroy(root_local_frame_id); |
| 177 factory_.Destroy(child_local_frame_id); | 190 factory_.Destroy(child_local_frame_id); |
| 178 } | 191 } |
| 179 | 192 |
| 180 // Tests a surface quad that has a non-identity transform into its pass. | 193 // Tests a surface quad that has a non-identity transform into its pass. |
| 181 TEST_F(SurfacesPixelTest, DrawAggregatedFrameWithSurfaceTransforms) { | 194 TEST_F(SurfacesPixelTest, DrawAggregatedFrameWithSurfaceTransforms) { |
| 182 gfx::Size child_size(100, 200); | 195 gfx::Size child_size(100, 200); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 CreateAndAppendTestSharedQuadState( | 232 CreateAndAppendTestSharedQuadState( |
| 220 pass.get(), surface_transform, device_viewport_size_); | 233 pass.get(), surface_transform, device_viewport_size_); |
| 221 | 234 |
| 222 SurfaceDrawQuad* right_surface_quad = | 235 SurfaceDrawQuad* right_surface_quad = |
| 223 pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); | 236 pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); |
| 224 right_surface_quad->SetNew(pass->shared_quad_state_list.back(), | 237 right_surface_quad->SetNew(pass->shared_quad_state_list.back(), |
| 225 gfx::Rect(child_size), | 238 gfx::Rect(child_size), |
| 226 gfx::Rect(child_size), | 239 gfx::Rect(child_size), |
| 227 right_child_id); | 240 right_child_id); |
| 228 | 241 |
| 242 std::unique_ptr<DelegatedFrameData> delegated_frame_data( |
| 243 new DelegatedFrameData); |
| 244 delegated_frame_data->render_pass_list.push_back(std::move(pass)); |
| 245 |
| 229 CompositorFrame root_frame; | 246 CompositorFrame root_frame; |
| 230 root_frame.render_pass_list.push_back(std::move(pass)); | 247 root_frame.delegated_frame_data = std::move(delegated_frame_data); |
| 231 | 248 |
| 232 factory_.SubmitCompositorFrame(root_local_frame_id, std::move(root_frame), | 249 factory_.SubmitCompositorFrame(root_local_frame_id, std::move(root_frame), |
| 233 SurfaceFactory::DrawCallback()); | 250 SurfaceFactory::DrawCallback()); |
| 234 } | 251 } |
| 235 | 252 |
| 236 { | 253 { |
| 237 gfx::Rect rect(child_size); | 254 gfx::Rect rect(child_size); |
| 238 RenderPassId id(1, 1); | 255 RenderPassId id(1, 1); |
| 239 std::unique_ptr<RenderPass> pass = RenderPass::Create(); | 256 std::unique_ptr<RenderPass> pass = RenderPass::Create(); |
| 240 pass->SetNew(id, rect, rect, gfx::Transform()); | 257 pass->SetNew(id, rect, rect, gfx::Transform()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 252 force_anti_aliasing_off); | 269 force_anti_aliasing_off); |
| 253 | 270 |
| 254 SolidColorDrawQuad* bottom_color_quad = | 271 SolidColorDrawQuad* bottom_color_quad = |
| 255 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 272 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
| 256 bottom_color_quad->SetNew(pass->shared_quad_state_list.back(), | 273 bottom_color_quad->SetNew(pass->shared_quad_state_list.back(), |
| 257 gfx::Rect(0, 100, 100, 100), | 274 gfx::Rect(0, 100, 100, 100), |
| 258 gfx::Rect(0, 100, 100, 100), | 275 gfx::Rect(0, 100, 100, 100), |
| 259 SK_ColorBLUE, | 276 SK_ColorBLUE, |
| 260 force_anti_aliasing_off); | 277 force_anti_aliasing_off); |
| 261 | 278 |
| 279 std::unique_ptr<DelegatedFrameData> delegated_frame_data( |
| 280 new DelegatedFrameData); |
| 281 delegated_frame_data->render_pass_list.push_back(std::move(pass)); |
| 282 |
| 262 CompositorFrame child_frame; | 283 CompositorFrame child_frame; |
| 263 child_frame.render_pass_list.push_back(std::move(pass)); | 284 child_frame.delegated_frame_data = std::move(delegated_frame_data); |
| 264 | 285 |
| 265 factory_.SubmitCompositorFrame(left_child_local_id, std::move(child_frame), | 286 factory_.SubmitCompositorFrame(left_child_local_id, std::move(child_frame), |
| 266 SurfaceFactory::DrawCallback()); | 287 SurfaceFactory::DrawCallback()); |
| 267 } | 288 } |
| 268 | 289 |
| 269 { | 290 { |
| 270 gfx::Rect rect(child_size); | 291 gfx::Rect rect(child_size); |
| 271 RenderPassId id(1, 1); | 292 RenderPassId id(1, 1); |
| 272 std::unique_ptr<RenderPass> pass = RenderPass::Create(); | 293 std::unique_ptr<RenderPass> pass = RenderPass::Create(); |
| 273 pass->SetNew(id, rect, rect, gfx::Transform()); | 294 pass->SetNew(id, rect, rect, gfx::Transform()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 285 force_anti_aliasing_off); | 306 force_anti_aliasing_off); |
| 286 | 307 |
| 287 SolidColorDrawQuad* bottom_color_quad = | 308 SolidColorDrawQuad* bottom_color_quad = |
| 288 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 309 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
| 289 bottom_color_quad->SetNew(pass->shared_quad_state_list.back(), | 310 bottom_color_quad->SetNew(pass->shared_quad_state_list.back(), |
| 290 gfx::Rect(0, 100, 100, 100), | 311 gfx::Rect(0, 100, 100, 100), |
| 291 gfx::Rect(0, 100, 100, 100), | 312 gfx::Rect(0, 100, 100, 100), |
| 292 SK_ColorGREEN, | 313 SK_ColorGREEN, |
| 293 force_anti_aliasing_off); | 314 force_anti_aliasing_off); |
| 294 | 315 |
| 316 std::unique_ptr<DelegatedFrameData> delegated_frame_data( |
| 317 new DelegatedFrameData); |
| 318 delegated_frame_data->render_pass_list.push_back(std::move(pass)); |
| 319 |
| 295 CompositorFrame child_frame; | 320 CompositorFrame child_frame; |
| 296 child_frame.render_pass_list.push_back(std::move(pass)); | 321 child_frame.delegated_frame_data = std::move(delegated_frame_data); |
| 297 | 322 |
| 298 factory_.SubmitCompositorFrame(right_child_local_id, std::move(child_frame), | 323 factory_.SubmitCompositorFrame(right_child_local_id, std::move(child_frame), |
| 299 SurfaceFactory::DrawCallback()); | 324 SurfaceFactory::DrawCallback()); |
| 300 } | 325 } |
| 301 | 326 |
| 302 SurfaceAggregator aggregator(&manager_, resource_provider_.get(), true); | 327 SurfaceAggregator aggregator(&manager_, resource_provider_.get(), true); |
| 303 CompositorFrame aggregated_frame = aggregator.Aggregate(root_surface_id); | 328 CompositorFrame aggregated_frame = aggregator.Aggregate(root_surface_id); |
| 304 | 329 |
| 305 bool discard_alpha = false; | 330 bool discard_alpha = false; |
| 306 ExactPixelComparator pixel_comparator(discard_alpha); | 331 ExactPixelComparator pixel_comparator(discard_alpha); |
| 307 RenderPassList* pass_list = &aggregated_frame.render_pass_list; | 332 RenderPassList* pass_list = |
| 333 &aggregated_frame.delegated_frame_data->render_pass_list; |
| 308 EXPECT_TRUE(RunPixelTest( | 334 EXPECT_TRUE(RunPixelTest( |
| 309 pass_list, | 335 pass_list, |
| 310 base::FilePath(FILE_PATH_LITERAL("four_blue_green_checkers.png")), | 336 base::FilePath(FILE_PATH_LITERAL("four_blue_green_checkers.png")), |
| 311 pixel_comparator)); | 337 pixel_comparator)); |
| 312 | 338 |
| 313 factory_.Destroy(root_local_frame_id); | 339 factory_.Destroy(root_local_frame_id); |
| 314 factory_.Destroy(left_child_local_id); | 340 factory_.Destroy(left_child_local_id); |
| 315 factory_.Destroy(right_child_local_id); | 341 factory_.Destroy(right_child_local_id); |
| 316 } | 342 } |
| 317 | 343 |
| 318 } // namespace | 344 } // namespace |
| 319 } // namespace cc | 345 } // namespace cc |
| 320 | 346 |
| 321 #endif // !defined(OS_ANDROID) | 347 #endif // !defined(OS_ANDROID) |
| OLD | NEW |