| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <string.h> | 6 #include <string.h> |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 static constexpr cc::FrameSinkId kArbitraryFrameSinkId(1, 1); | 47 static constexpr cc::FrameSinkId kArbitraryFrameSinkId(1, 1); |
| 48 | 48 |
| 49 class CCParamTraitsTest : public testing::Test { | 49 class CCParamTraitsTest : public testing::Test { |
| 50 protected: | 50 protected: |
| 51 void Compare(const RenderPass* a, const RenderPass* b) { | 51 void Compare(const RenderPass* a, const RenderPass* b) { |
| 52 EXPECT_EQ(a->id, b->id); | 52 EXPECT_EQ(a->id, b->id); |
| 53 EXPECT_EQ(a->output_rect.ToString(), b->output_rect.ToString()); | 53 EXPECT_EQ(a->output_rect.ToString(), b->output_rect.ToString()); |
| 54 EXPECT_EQ(a->damage_rect.ToString(), b->damage_rect.ToString()); | 54 EXPECT_EQ(a->damage_rect.ToString(), b->damage_rect.ToString()); |
| 55 EXPECT_EQ(a->transform_to_root_target, b->transform_to_root_target); | 55 EXPECT_EQ(a->transform_to_root_target, b->transform_to_root_target); |
| 56 EXPECT_EQ(a->filters.size(), b->filters.size()); |
| 57 for (size_t i = 0; i < a->filters.size(); ++i) { |
| 58 if (a->filters.at(i).type() != cc::FilterOperation::REFERENCE) { |
| 59 EXPECT_EQ(a->filters.at(i), b->filters.at(i)); |
| 60 } else { |
| 61 EXPECT_EQ(b->filters.at(i).type(), cc::FilterOperation::REFERENCE); |
| 62 EXPECT_EQ(a->filters.at(i).image_filter()->countInputs(), |
| 63 b->filters.at(i).image_filter()->countInputs()); |
| 64 } |
| 65 } |
| 66 EXPECT_EQ(a->background_filters.size(), b->background_filters.size()); |
| 67 for (size_t i = 0; i < a->background_filters.size(); ++i) { |
| 68 if (a->background_filters.at(i).type() != |
| 69 cc::FilterOperation::REFERENCE) { |
| 70 EXPECT_EQ(a->background_filters.at(i), b->background_filters.at(i)); |
| 71 } else { |
| 72 EXPECT_EQ(b->background_filters.at(i).type(), |
| 73 cc::FilterOperation::REFERENCE); |
| 74 EXPECT_EQ(a->background_filters.at(i).image_filter()->countInputs(), |
| 75 b->background_filters.at(i).image_filter()->countInputs()); |
| 76 } |
| 77 } |
| 56 EXPECT_EQ(a->has_transparent_background, b->has_transparent_background); | 78 EXPECT_EQ(a->has_transparent_background, b->has_transparent_background); |
| 57 } | 79 } |
| 58 | 80 |
| 59 void Compare(const SharedQuadState* a, const SharedQuadState* b) { | 81 void Compare(const SharedQuadState* a, const SharedQuadState* b) { |
| 60 EXPECT_EQ(a->quad_to_target_transform, b->quad_to_target_transform); | 82 EXPECT_EQ(a->quad_to_target_transform, b->quad_to_target_transform); |
| 61 EXPECT_EQ(a->quad_layer_bounds, b->quad_layer_bounds); | 83 EXPECT_EQ(a->quad_layer_bounds, b->quad_layer_bounds); |
| 62 EXPECT_EQ(a->visible_quad_layer_rect, b->visible_quad_layer_rect); | 84 EXPECT_EQ(a->visible_quad_layer_rect, b->visible_quad_layer_rect); |
| 63 EXPECT_EQ(a->clip_rect, b->clip_rect); | 85 EXPECT_EQ(a->clip_rect, b->clip_rect); |
| 64 EXPECT_EQ(a->is_clipped, b->is_clipped); | 86 EXPECT_EQ(a->is_clipped, b->is_clipped); |
| 65 EXPECT_EQ(a->opacity, b->opacity); | 87 EXPECT_EQ(a->opacity, b->opacity); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 void Compare(const DebugBorderDrawQuad* a, const DebugBorderDrawQuad* b) { | 143 void Compare(const DebugBorderDrawQuad* a, const DebugBorderDrawQuad* b) { |
| 122 EXPECT_EQ(a->color, b->color); | 144 EXPECT_EQ(a->color, b->color); |
| 123 EXPECT_EQ(a->width, b->width); | 145 EXPECT_EQ(a->width, b->width); |
| 124 } | 146 } |
| 125 | 147 |
| 126 void Compare(const RenderPassDrawQuad* a, const RenderPassDrawQuad* b) { | 148 void Compare(const RenderPassDrawQuad* a, const RenderPassDrawQuad* b) { |
| 127 EXPECT_EQ(a->render_pass_id, b->render_pass_id); | 149 EXPECT_EQ(a->render_pass_id, b->render_pass_id); |
| 128 EXPECT_EQ(a->mask_resource_id(), b->mask_resource_id()); | 150 EXPECT_EQ(a->mask_resource_id(), b->mask_resource_id()); |
| 129 EXPECT_EQ(a->mask_uv_scale.ToString(), b->mask_uv_scale.ToString()); | 151 EXPECT_EQ(a->mask_uv_scale.ToString(), b->mask_uv_scale.ToString()); |
| 130 EXPECT_EQ(a->mask_texture_size.ToString(), b->mask_texture_size.ToString()); | 152 EXPECT_EQ(a->mask_texture_size.ToString(), b->mask_texture_size.ToString()); |
| 131 EXPECT_EQ(a->filters.size(), b->filters.size()); | |
| 132 for (size_t i = 0; i < a->filters.size(); ++i) { | |
| 133 if (a->filters.at(i).type() != cc::FilterOperation::REFERENCE) { | |
| 134 EXPECT_EQ(a->filters.at(i), b->filters.at(i)); | |
| 135 } else { | |
| 136 EXPECT_EQ(b->filters.at(i).type(), cc::FilterOperation::REFERENCE); | |
| 137 EXPECT_EQ(a->filters.at(i).image_filter()->countInputs(), | |
| 138 b->filters.at(i).image_filter()->countInputs()); | |
| 139 } | |
| 140 } | |
| 141 EXPECT_EQ(a->filters_scale, b->filters_scale); | 153 EXPECT_EQ(a->filters_scale, b->filters_scale); |
| 142 EXPECT_EQ(a->filters_origin, b->filters_origin); | 154 EXPECT_EQ(a->filters_origin, b->filters_origin); |
| 143 EXPECT_EQ(a->background_filters, b->background_filters); | |
| 144 } | 155 } |
| 145 | 156 |
| 146 void Compare(const SolidColorDrawQuad* a, const SolidColorDrawQuad* b) { | 157 void Compare(const SolidColorDrawQuad* a, const SolidColorDrawQuad* b) { |
| 147 EXPECT_EQ(a->color, b->color); | 158 EXPECT_EQ(a->color, b->color); |
| 148 EXPECT_EQ(a->force_anti_aliasing_off, b->force_anti_aliasing_off); | 159 EXPECT_EQ(a->force_anti_aliasing_off, b->force_anti_aliasing_off); |
| 149 } | 160 } |
| 150 | 161 |
| 151 void Compare(const StreamVideoDrawQuad* a, const StreamVideoDrawQuad* b) { | 162 void Compare(const StreamVideoDrawQuad* a, const StreamVideoDrawQuad* b) { |
| 152 EXPECT_EQ(a->resource_id(), b->resource_id()); | 163 EXPECT_EQ(a->resource_id(), b->resource_id()); |
| 153 EXPECT_EQ(a->resource_size_in_pixels(), b->resource_size_in_pixels()); | 164 EXPECT_EQ(a->resource_size_in_pixels(), b->resource_size_in_pixels()); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 FilterOperation::CreateGrayscaleFilter(arbitrary_float1)); | 290 FilterOperation::CreateGrayscaleFilter(arbitrary_float1)); |
| 280 arbitrary_filters1.Append(cc::FilterOperation::CreateReferenceFilter( | 291 arbitrary_filters1.Append(cc::FilterOperation::CreateReferenceFilter( |
| 281 SkBlurImageFilter::Make(arbitrary_sigma, arbitrary_sigma, nullptr))); | 292 SkBlurImageFilter::Make(arbitrary_sigma, arbitrary_sigma, nullptr))); |
| 282 | 293 |
| 283 FilterOperations arbitrary_filters2; | 294 FilterOperations arbitrary_filters2; |
| 284 arbitrary_filters2.Append( | 295 arbitrary_filters2.Append( |
| 285 FilterOperation::CreateBrightnessFilter(arbitrary_float2)); | 296 FilterOperation::CreateBrightnessFilter(arbitrary_float2)); |
| 286 | 297 |
| 287 std::unique_ptr<RenderPass> child_pass_in = RenderPass::Create(); | 298 std::unique_ptr<RenderPass> child_pass_in = RenderPass::Create(); |
| 288 child_pass_in->SetAll(child_id, arbitrary_rect2, arbitrary_rect3, | 299 child_pass_in->SetAll(child_id, arbitrary_rect2, arbitrary_rect3, |
| 289 arbitrary_matrix2, arbitrary_bool2); | 300 arbitrary_matrix2, arbitrary_filters1, |
| 301 arbitrary_filters2, arbitrary_bool2); |
| 290 | 302 |
| 291 std::unique_ptr<RenderPass> child_pass_cmp = RenderPass::Create(); | 303 std::unique_ptr<RenderPass> child_pass_cmp = RenderPass::Create(); |
| 292 child_pass_cmp->SetAll(child_id, arbitrary_rect2, arbitrary_rect3, | 304 child_pass_cmp->SetAll(child_id, arbitrary_rect2, arbitrary_rect3, |
| 293 arbitrary_matrix2, arbitrary_bool2); | 305 arbitrary_matrix2, arbitrary_filters1, |
| 306 arbitrary_filters2, arbitrary_bool2); |
| 294 | 307 |
| 295 std::unique_ptr<RenderPass> pass_in = RenderPass::Create(); | 308 std::unique_ptr<RenderPass> pass_in = RenderPass::Create(); |
| 296 pass_in->SetAll(root_id, arbitrary_rect1, arbitrary_rect2, arbitrary_matrix1, | 309 pass_in->SetAll(root_id, arbitrary_rect1, arbitrary_rect2, arbitrary_matrix1, |
| 297 arbitrary_bool1); | 310 arbitrary_filters2, arbitrary_filters1, arbitrary_bool1); |
| 298 | 311 |
| 299 SharedQuadState* shared_state1_in = pass_in->CreateAndAppendSharedQuadState(); | 312 SharedQuadState* shared_state1_in = pass_in->CreateAndAppendSharedQuadState(); |
| 300 shared_state1_in->SetAll(arbitrary_matrix1, arbitrary_size1, arbitrary_rect1, | 313 shared_state1_in->SetAll(arbitrary_matrix1, arbitrary_size1, arbitrary_rect1, |
| 301 arbitrary_rect2, arbitrary_bool1, arbitrary_float1, | 314 arbitrary_rect2, arbitrary_bool1, arbitrary_float1, |
| 302 arbitrary_blend_mode1, arbitrary_context_id1); | 315 arbitrary_blend_mode1, arbitrary_context_id1); |
| 303 | 316 |
| 304 std::unique_ptr<RenderPass> pass_cmp = RenderPass::Create(); | 317 std::unique_ptr<RenderPass> pass_cmp = RenderPass::Create(); |
| 305 pass_cmp->SetAll(root_id, arbitrary_rect1, arbitrary_rect2, arbitrary_matrix1, | 318 pass_cmp->SetAll(root_id, arbitrary_rect1, arbitrary_rect2, arbitrary_matrix1, |
| 306 arbitrary_bool1); | 319 arbitrary_filters2, arbitrary_filters1, arbitrary_bool1); |
| 307 | 320 |
| 308 SharedQuadState* shared_state1_cmp = | 321 SharedQuadState* shared_state1_cmp = |
| 309 pass_cmp->CreateAndAppendSharedQuadState(); | 322 pass_cmp->CreateAndAppendSharedQuadState(); |
| 310 *shared_state1_cmp = *shared_state1_in; | 323 *shared_state1_cmp = *shared_state1_in; |
| 311 | 324 |
| 312 DebugBorderDrawQuad* debugborder_in = | 325 DebugBorderDrawQuad* debugborder_in = |
| 313 pass_in->CreateAndAppendDrawQuad<DebugBorderDrawQuad>(); | 326 pass_in->CreateAndAppendDrawQuad<DebugBorderDrawQuad>(); |
| 314 debugborder_in->SetAll(shared_state1_in, arbitrary_rect3, | 327 debugborder_in->SetAll(shared_state1_in, arbitrary_rect3, |
| 315 arbitrary_rect1_inside_rect3, | 328 arbitrary_rect1_inside_rect3, |
| 316 arbitrary_rect2_inside_rect3, arbitrary_bool1, | 329 arbitrary_rect2_inside_rect3, arbitrary_bool1, |
| 317 arbitrary_color, arbitrary_int); | 330 arbitrary_color, arbitrary_int); |
| 318 pass_cmp->CopyFromAndAppendDrawQuad(debugborder_in, | 331 pass_cmp->CopyFromAndAppendDrawQuad(debugborder_in, |
| 319 debugborder_in->shared_quad_state); | 332 debugborder_in->shared_quad_state); |
| 320 | 333 |
| 321 SharedQuadState* shared_state2_in = pass_in->CreateAndAppendSharedQuadState(); | 334 SharedQuadState* shared_state2_in = pass_in->CreateAndAppendSharedQuadState(); |
| 322 shared_state2_in->SetAll(arbitrary_matrix2, arbitrary_size2, arbitrary_rect2, | 335 shared_state2_in->SetAll(arbitrary_matrix2, arbitrary_size2, arbitrary_rect2, |
| 323 arbitrary_rect3, arbitrary_bool1, arbitrary_float2, | 336 arbitrary_rect3, arbitrary_bool1, arbitrary_float2, |
| 324 arbitrary_blend_mode2, arbitrary_context_id2); | 337 arbitrary_blend_mode2, arbitrary_context_id2); |
| 325 SharedQuadState* shared_state2_cmp = | 338 SharedQuadState* shared_state2_cmp = |
| 326 pass_cmp->CreateAndAppendSharedQuadState(); | 339 pass_cmp->CreateAndAppendSharedQuadState(); |
| 327 *shared_state2_cmp = *shared_state2_in; | 340 *shared_state2_cmp = *shared_state2_in; |
| 328 | 341 |
| 329 RenderPassDrawQuad* renderpass_in = | 342 RenderPassDrawQuad* renderpass_in = |
| 330 pass_in->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); | 343 pass_in->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); |
| 331 renderpass_in->SetAll( | 344 renderpass_in->SetAll( |
| 332 shared_state2_in, arbitrary_rect1, arbitrary_rect2_inside_rect1, | 345 shared_state2_in, arbitrary_rect1, arbitrary_rect2_inside_rect1, |
| 333 arbitrary_rect1_inside_rect1, arbitrary_bool1, child_id, | 346 arbitrary_rect1_inside_rect1, arbitrary_bool1, child_id, |
| 334 arbitrary_resourceid2, arbitrary_vector2df1, arbitrary_size1, | 347 arbitrary_resourceid2, arbitrary_vector2df1, arbitrary_size1, |
| 335 arbitrary_filters1, arbitrary_vector2df2, arbitrary_pointf2, | 348 arbitrary_vector2df2, arbitrary_pointf2); |
| 336 arbitrary_filters2); | |
| 337 pass_cmp->CopyFromAndAppendRenderPassDrawQuad( | 349 pass_cmp->CopyFromAndAppendRenderPassDrawQuad( |
| 338 renderpass_in, renderpass_in->shared_quad_state, | 350 renderpass_in, renderpass_in->shared_quad_state, |
| 339 renderpass_in->render_pass_id); | 351 renderpass_in->render_pass_id); |
| 340 | 352 |
| 341 SharedQuadState* shared_state3_in = pass_in->CreateAndAppendSharedQuadState(); | 353 SharedQuadState* shared_state3_in = pass_in->CreateAndAppendSharedQuadState(); |
| 342 shared_state3_in->SetAll(arbitrary_matrix1, arbitrary_size3, arbitrary_rect3, | 354 shared_state3_in->SetAll(arbitrary_matrix1, arbitrary_size3, arbitrary_rect3, |
| 343 arbitrary_rect1, arbitrary_bool1, arbitrary_float3, | 355 arbitrary_rect1, arbitrary_bool1, arbitrary_float3, |
| 344 arbitrary_blend_mode3, arbitrary_context_id3); | 356 arbitrary_blend_mode3, arbitrary_context_id3); |
| 345 SharedQuadState* shared_state3_cmp = | 357 SharedQuadState* shared_state3_cmp = |
| 346 pass_cmp->CreateAndAppendSharedQuadState(); | 358 pass_cmp->CreateAndAppendSharedQuadState(); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 pass_cmp->quad_list.ElementAt(i - 1)->shared_quad_state; | 485 pass_cmp->quad_list.ElementAt(i - 1)->shared_quad_state; |
| 474 bool same_shared_quad_state_out = | 486 bool same_shared_quad_state_out = |
| 475 pass_out->quad_list.ElementAt(i)->shared_quad_state == | 487 pass_out->quad_list.ElementAt(i)->shared_quad_state == |
| 476 pass_out->quad_list.ElementAt(i - 1)->shared_quad_state; | 488 pass_out->quad_list.ElementAt(i - 1)->shared_quad_state; |
| 477 EXPECT_EQ(same_shared_quad_state_cmp, same_shared_quad_state_out); | 489 EXPECT_EQ(same_shared_quad_state_cmp, same_shared_quad_state_out); |
| 478 } | 490 } |
| 479 } | 491 } |
| 480 | 492 |
| 481 TEST_F(CCParamTraitsTest, UnusedSharedQuadStates) { | 493 TEST_F(CCParamTraitsTest, UnusedSharedQuadStates) { |
| 482 std::unique_ptr<RenderPass> pass_in = RenderPass::Create(); | 494 std::unique_ptr<RenderPass> pass_in = RenderPass::Create(); |
| 483 pass_in->SetAll(1, gfx::Rect(100, 100), gfx::Rect(), gfx::Transform(), false); | 495 pass_in->SetAll(1, gfx::Rect(100, 100), gfx::Rect(), gfx::Transform(), |
| 496 FilterOperations(), FilterOperations(), false); |
| 484 | 497 |
| 485 // The first SharedQuadState is used. | 498 // The first SharedQuadState is used. |
| 486 SharedQuadState* shared_state1_in = pass_in->CreateAndAppendSharedQuadState(); | 499 SharedQuadState* shared_state1_in = pass_in->CreateAndAppendSharedQuadState(); |
| 487 shared_state1_in->SetAll(gfx::Transform(), gfx::Size(1, 1), gfx::Rect(), | 500 shared_state1_in->SetAll(gfx::Transform(), gfx::Size(1, 1), gfx::Rect(), |
| 488 gfx::Rect(), false, 1.f, SkBlendMode::kSrcOver, 0); | 501 gfx::Rect(), false, 1.f, SkBlendMode::kSrcOver, 0); |
| 489 | 502 |
| 490 SolidColorDrawQuad* quad1 = | 503 SolidColorDrawQuad* quad1 = |
| 491 pass_in->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 504 pass_in->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
| 492 quad1->SetAll(shared_state1_in, gfx::Rect(10, 10), gfx::Rect(10, 10), | 505 quad1->SetAll(shared_state1_in, gfx::Rect(10, 10), gfx::Rect(10, 10), |
| 493 gfx::Rect(10, 10), false, SK_ColorRED, false); | 506 gfx::Rect(10, 10), false, SK_ColorRED, false); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 base::PickleIterator iter(msg); | 619 base::PickleIterator iter(msg); |
| 607 EXPECT_TRUE(IPC::ParamTraits<CompositorFrame>::Read(&msg, &iter, &frame_out)); | 620 EXPECT_TRUE(IPC::ParamTraits<CompositorFrame>::Read(&msg, &iter, &frame_out)); |
| 608 | 621 |
| 609 ASSERT_EQ(2u, frame_out.resource_list.size()); | 622 ASSERT_EQ(2u, frame_out.resource_list.size()); |
| 610 Compare(arbitrary_resource1, frame_out.resource_list[0]); | 623 Compare(arbitrary_resource1, frame_out.resource_list[0]); |
| 611 Compare(arbitrary_resource2, frame_out.resource_list[1]); | 624 Compare(arbitrary_resource2, frame_out.resource_list[1]); |
| 612 } | 625 } |
| 613 | 626 |
| 614 } // namespace | 627 } // namespace |
| 615 } // namespace content | 628 } // namespace content |
| OLD | NEW |