| 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/compositor_frame_sink_support.h" | 9 #include "cc/surfaces/compositor_frame_sink_support.h" |
| 10 #include "cc/surfaces/local_surface_id_allocator.h" | 10 #include "cc/surfaces/local_surface_id_allocator.h" |
| 11 #include "cc/surfaces/surface.h" | 11 #include "cc/surfaces/surface.h" |
| 12 #include "cc/surfaces/surface_aggregator.h" | 12 #include "cc/surfaces/surface_aggregator.h" |
| 13 #include "cc/surfaces/surface_manager.h" | 13 #include "cc/surfaces/surface_manager.h" |
| 14 #include "cc/test/compositor_frame_helpers.h" |
| 14 #include "cc/test/pixel_comparator.h" | 15 #include "cc/test/pixel_comparator.h" |
| 15 #include "cc/test/pixel_test.h" | 16 #include "cc/test/pixel_test.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 18 |
| 18 #if !defined(OS_ANDROID) | 19 #if !defined(OS_ANDROID) |
| 19 | 20 |
| 20 namespace cc { | 21 namespace cc { |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 constexpr FrameSinkId kArbitraryRootFrameSinkId(1, 1); | 24 constexpr FrameSinkId kArbitraryRootFrameSinkId(1, 1); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 76 |
| 76 SolidColorDrawQuad* color_quad = | 77 SolidColorDrawQuad* color_quad = |
| 77 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 78 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
| 78 bool force_anti_aliasing_off = false; | 79 bool force_anti_aliasing_off = false; |
| 79 color_quad->SetNew(pass->shared_quad_state_list.back(), | 80 color_quad->SetNew(pass->shared_quad_state_list.back(), |
| 80 rect, | 81 rect, |
| 81 rect, | 82 rect, |
| 82 SK_ColorGREEN, | 83 SK_ColorGREEN, |
| 83 force_anti_aliasing_off); | 84 force_anti_aliasing_off); |
| 84 | 85 |
| 85 | 86 CompositorFrame root_frame = test::MakeCompositorFrame(); |
| 86 CompositorFrame root_frame; | |
| 87 root_frame.render_pass_list.push_back(std::move(pass)); | 87 root_frame.render_pass_list.push_back(std::move(pass)); |
| 88 | 88 |
| 89 LocalSurfaceId root_local_surface_id = allocator_.GenerateId(); | 89 LocalSurfaceId root_local_surface_id = allocator_.GenerateId(); |
| 90 SurfaceId root_surface_id(support_->frame_sink_id(), root_local_surface_id); | 90 SurfaceId root_surface_id(support_->frame_sink_id(), root_local_surface_id); |
| 91 support_->SubmitCompositorFrame(root_local_surface_id, std::move(root_frame)); | 91 support_->SubmitCompositorFrame(root_local_surface_id, std::move(root_frame)); |
| 92 | 92 |
| 93 SurfaceAggregator aggregator(&manager_, resource_provider_.get(), true); | 93 SurfaceAggregator aggregator(&manager_, resource_provider_.get(), true); |
| 94 CompositorFrame aggregated_frame = aggregator.Aggregate(root_surface_id); | 94 CompositorFrame aggregated_frame = aggregator.Aggregate(root_surface_id); |
| 95 | 95 |
| 96 bool discard_alpha = false; | 96 bool discard_alpha = false; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 | 133 |
| 134 SolidColorDrawQuad* color_quad = | 134 SolidColorDrawQuad* color_quad = |
| 135 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 135 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
| 136 bool force_anti_aliasing_off = false; | 136 bool force_anti_aliasing_off = false; |
| 137 color_quad->SetNew(pass->shared_quad_state_list.back(), | 137 color_quad->SetNew(pass->shared_quad_state_list.back(), |
| 138 rect, | 138 rect, |
| 139 rect, | 139 rect, |
| 140 SK_ColorYELLOW, | 140 SK_ColorYELLOW, |
| 141 force_anti_aliasing_off); | 141 force_anti_aliasing_off); |
| 142 | 142 |
| 143 CompositorFrame root_frame; | 143 CompositorFrame root_frame = test::MakeCompositorFrame(); |
| 144 root_frame.render_pass_list.push_back(std::move(pass)); | 144 root_frame.render_pass_list.push_back(std::move(pass)); |
| 145 | 145 |
| 146 support_->SubmitCompositorFrame(root_local_surface_id, | 146 support_->SubmitCompositorFrame(root_local_surface_id, |
| 147 std::move(root_frame)); | 147 std::move(root_frame)); |
| 148 } | 148 } |
| 149 | 149 |
| 150 { | 150 { |
| 151 gfx::Rect rect(child_size); | 151 gfx::Rect rect(child_size); |
| 152 int id = 1; | 152 int id = 1; |
| 153 std::unique_ptr<RenderPass> pass = RenderPass::Create(); | 153 std::unique_ptr<RenderPass> pass = RenderPass::Create(); |
| 154 pass->SetNew(id, rect, rect, gfx::Transform()); | 154 pass->SetNew(id, rect, rect, gfx::Transform()); |
| 155 | 155 |
| 156 CreateAndAppendTestSharedQuadState( | 156 CreateAndAppendTestSharedQuadState( |
| 157 pass.get(), gfx::Transform(), child_size); | 157 pass.get(), gfx::Transform(), child_size); |
| 158 | 158 |
| 159 SolidColorDrawQuad* color_quad = | 159 SolidColorDrawQuad* color_quad = |
| 160 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 160 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
| 161 bool force_anti_aliasing_off = false; | 161 bool force_anti_aliasing_off = false; |
| 162 color_quad->SetNew(pass->shared_quad_state_list.back(), | 162 color_quad->SetNew(pass->shared_quad_state_list.back(), |
| 163 rect, | 163 rect, |
| 164 rect, | 164 rect, |
| 165 SK_ColorBLUE, | 165 SK_ColorBLUE, |
| 166 force_anti_aliasing_off); | 166 force_anti_aliasing_off); |
| 167 | 167 |
| 168 CompositorFrame child_frame; | 168 CompositorFrame child_frame = test::MakeCompositorFrame(); |
| 169 child_frame.render_pass_list.push_back(std::move(pass)); | 169 child_frame.render_pass_list.push_back(std::move(pass)); |
| 170 | 170 |
| 171 child_support->SubmitCompositorFrame(child_local_surface_id, | 171 child_support->SubmitCompositorFrame(child_local_surface_id, |
| 172 std::move(child_frame)); | 172 std::move(child_frame)); |
| 173 } | 173 } |
| 174 | 174 |
| 175 SurfaceAggregator aggregator(&manager_, resource_provider_.get(), true); | 175 SurfaceAggregator aggregator(&manager_, resource_provider_.get(), true); |
| 176 CompositorFrame aggregated_frame = aggregator.Aggregate(root_surface_id); | 176 CompositorFrame aggregated_frame = aggregator.Aggregate(root_surface_id); |
| 177 | 177 |
| 178 bool discard_alpha = false; | 178 bool discard_alpha = false; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 CreateAndAppendTestSharedQuadState( | 233 CreateAndAppendTestSharedQuadState( |
| 234 pass.get(), surface_transform, device_viewport_size_); | 234 pass.get(), surface_transform, device_viewport_size_); |
| 235 | 235 |
| 236 SurfaceDrawQuad* right_surface_quad = | 236 SurfaceDrawQuad* right_surface_quad = |
| 237 pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); | 237 pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); |
| 238 right_surface_quad->SetNew(pass->shared_quad_state_list.back(), | 238 right_surface_quad->SetNew(pass->shared_quad_state_list.back(), |
| 239 gfx::Rect(child_size), gfx::Rect(child_size), | 239 gfx::Rect(child_size), gfx::Rect(child_size), |
| 240 right_child_id, SurfaceDrawQuadType::PRIMARY, | 240 right_child_id, SurfaceDrawQuadType::PRIMARY, |
| 241 nullptr); | 241 nullptr); |
| 242 | 242 |
| 243 CompositorFrame root_frame; | 243 CompositorFrame root_frame = test::MakeCompositorFrame(); |
| 244 root_frame.render_pass_list.push_back(std::move(pass)); | 244 root_frame.render_pass_list.push_back(std::move(pass)); |
| 245 | 245 |
| 246 support_->SubmitCompositorFrame(root_local_surface_id, | 246 support_->SubmitCompositorFrame(root_local_surface_id, |
| 247 std::move(root_frame)); | 247 std::move(root_frame)); |
| 248 } | 248 } |
| 249 | 249 |
| 250 { | 250 { |
| 251 gfx::Rect rect(child_size); | 251 gfx::Rect rect(child_size); |
| 252 int id = 1; | 252 int id = 1; |
| 253 std::unique_ptr<RenderPass> pass = RenderPass::Create(); | 253 std::unique_ptr<RenderPass> pass = RenderPass::Create(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 266 force_anti_aliasing_off); | 266 force_anti_aliasing_off); |
| 267 | 267 |
| 268 SolidColorDrawQuad* bottom_color_quad = | 268 SolidColorDrawQuad* bottom_color_quad = |
| 269 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 269 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
| 270 bottom_color_quad->SetNew(pass->shared_quad_state_list.back(), | 270 bottom_color_quad->SetNew(pass->shared_quad_state_list.back(), |
| 271 gfx::Rect(0, 100, 100, 100), | 271 gfx::Rect(0, 100, 100, 100), |
| 272 gfx::Rect(0, 100, 100, 100), | 272 gfx::Rect(0, 100, 100, 100), |
| 273 SK_ColorBLUE, | 273 SK_ColorBLUE, |
| 274 force_anti_aliasing_off); | 274 force_anti_aliasing_off); |
| 275 | 275 |
| 276 CompositorFrame child_frame; | 276 CompositorFrame child_frame = test::MakeCompositorFrame(); |
| 277 child_frame.render_pass_list.push_back(std::move(pass)); | 277 child_frame.render_pass_list.push_back(std::move(pass)); |
| 278 | 278 |
| 279 left_support->SubmitCompositorFrame(left_child_local_id, | 279 left_support->SubmitCompositorFrame(left_child_local_id, |
| 280 std::move(child_frame)); | 280 std::move(child_frame)); |
| 281 } | 281 } |
| 282 | 282 |
| 283 { | 283 { |
| 284 gfx::Rect rect(child_size); | 284 gfx::Rect rect(child_size); |
| 285 int id = 1; | 285 int id = 1; |
| 286 std::unique_ptr<RenderPass> pass = RenderPass::Create(); | 286 std::unique_ptr<RenderPass> pass = RenderPass::Create(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 299 force_anti_aliasing_off); | 299 force_anti_aliasing_off); |
| 300 | 300 |
| 301 SolidColorDrawQuad* bottom_color_quad = | 301 SolidColorDrawQuad* bottom_color_quad = |
| 302 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 302 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
| 303 bottom_color_quad->SetNew(pass->shared_quad_state_list.back(), | 303 bottom_color_quad->SetNew(pass->shared_quad_state_list.back(), |
| 304 gfx::Rect(0, 100, 100, 100), | 304 gfx::Rect(0, 100, 100, 100), |
| 305 gfx::Rect(0, 100, 100, 100), | 305 gfx::Rect(0, 100, 100, 100), |
| 306 SK_ColorGREEN, | 306 SK_ColorGREEN, |
| 307 force_anti_aliasing_off); | 307 force_anti_aliasing_off); |
| 308 | 308 |
| 309 CompositorFrame child_frame; | 309 CompositorFrame child_frame = test::MakeCompositorFrame(); |
| 310 child_frame.render_pass_list.push_back(std::move(pass)); | 310 child_frame.render_pass_list.push_back(std::move(pass)); |
| 311 | 311 |
| 312 right_support->SubmitCompositorFrame(right_child_local_id, | 312 right_support->SubmitCompositorFrame(right_child_local_id, |
| 313 std::move(child_frame)); | 313 std::move(child_frame)); |
| 314 } | 314 } |
| 315 | 315 |
| 316 SurfaceAggregator aggregator(&manager_, resource_provider_.get(), true); | 316 SurfaceAggregator aggregator(&manager_, resource_provider_.get(), true); |
| 317 CompositorFrame aggregated_frame = aggregator.Aggregate(root_surface_id); | 317 CompositorFrame aggregated_frame = aggregator.Aggregate(root_surface_id); |
| 318 | 318 |
| 319 bool discard_alpha = false; | 319 bool discard_alpha = false; |
| 320 ExactPixelComparator pixel_comparator(discard_alpha); | 320 ExactPixelComparator pixel_comparator(discard_alpha); |
| 321 RenderPassList* pass_list = &aggregated_frame.render_pass_list; | 321 RenderPassList* pass_list = &aggregated_frame.render_pass_list; |
| 322 EXPECT_TRUE(RunPixelTest( | 322 EXPECT_TRUE(RunPixelTest( |
| 323 pass_list, | 323 pass_list, |
| 324 base::FilePath(FILE_PATH_LITERAL("four_blue_green_checkers.png")), | 324 base::FilePath(FILE_PATH_LITERAL("four_blue_green_checkers.png")), |
| 325 pixel_comparator)); | 325 pixel_comparator)); |
| 326 | 326 |
| 327 left_support->EvictFrame(); | 327 left_support->EvictFrame(); |
| 328 right_support->EvictFrame(); | 328 right_support->EvictFrame(); |
| 329 } | 329 } |
| 330 | 330 |
| 331 } // namespace | 331 } // namespace |
| 332 } // namespace cc | 332 } // namespace cc |
| 333 | 333 |
| 334 #endif // !defined(OS_ANDROID) | 334 #endif // !defined(OS_ANDROID) |
| OLD | NEW |