| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 if (a->background_filters.at(i).type() != | 68 if (a->background_filters.at(i).type() != |
| 69 cc::FilterOperation::REFERENCE) { | 69 cc::FilterOperation::REFERENCE) { |
| 70 EXPECT_EQ(a->background_filters.at(i), b->background_filters.at(i)); | 70 EXPECT_EQ(a->background_filters.at(i), b->background_filters.at(i)); |
| 71 } else { | 71 } else { |
| 72 EXPECT_EQ(b->background_filters.at(i).type(), | 72 EXPECT_EQ(b->background_filters.at(i).type(), |
| 73 cc::FilterOperation::REFERENCE); | 73 cc::FilterOperation::REFERENCE); |
| 74 EXPECT_EQ(a->background_filters.at(i).image_filter()->countInputs(), | 74 EXPECT_EQ(a->background_filters.at(i).image_filter()->countInputs(), |
| 75 b->background_filters.at(i).image_filter()->countInputs()); | 75 b->background_filters.at(i).image_filter()->countInputs()); |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 EXPECT_EQ(a->color_space, b->color_space); |
| 78 EXPECT_EQ(a->has_transparent_background, b->has_transparent_background); | 79 EXPECT_EQ(a->has_transparent_background, b->has_transparent_background); |
| 79 } | 80 } |
| 80 | 81 |
| 81 void Compare(const SharedQuadState* a, const SharedQuadState* b) { | 82 void Compare(const SharedQuadState* a, const SharedQuadState* b) { |
| 82 EXPECT_EQ(a->quad_to_target_transform, b->quad_to_target_transform); | 83 EXPECT_EQ(a->quad_to_target_transform, b->quad_to_target_transform); |
| 83 EXPECT_EQ(a->quad_layer_bounds, b->quad_layer_bounds); | 84 EXPECT_EQ(a->quad_layer_bounds, b->quad_layer_bounds); |
| 84 EXPECT_EQ(a->visible_quad_layer_rect, b->visible_quad_layer_rect); | 85 EXPECT_EQ(a->visible_quad_layer_rect, b->visible_quad_layer_rect); |
| 85 EXPECT_EQ(a->clip_rect, b->clip_rect); | 86 EXPECT_EQ(a->clip_rect, b->clip_rect); |
| 86 EXPECT_EQ(a->is_clipped, b->is_clipped); | 87 EXPECT_EQ(a->is_clipped, b->is_clipped); |
| 87 EXPECT_EQ(a->opacity, b->opacity); | 88 EXPECT_EQ(a->opacity, b->opacity); |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 int arbitrary_int = 13; | 272 int arbitrary_int = 13; |
| 272 SkColor arbitrary_color = SkColorSetARGB(25, 36, 47, 58); | 273 SkColor arbitrary_color = SkColorSetARGB(25, 36, 47, 58); |
| 273 SkBlendMode arbitrary_blend_mode1 = SkBlendMode::kScreen; | 274 SkBlendMode arbitrary_blend_mode1 = SkBlendMode::kScreen; |
| 274 SkBlendMode arbitrary_blend_mode2 = SkBlendMode::kLighten; | 275 SkBlendMode arbitrary_blend_mode2 = SkBlendMode::kLighten; |
| 275 SkBlendMode arbitrary_blend_mode3 = SkBlendMode::kOverlay; | 276 SkBlendMode arbitrary_blend_mode3 = SkBlendMode::kOverlay; |
| 276 ResourceId arbitrary_resourceid1 = 55; | 277 ResourceId arbitrary_resourceid1 = 55; |
| 277 ResourceId arbitrary_resourceid2 = 47; | 278 ResourceId arbitrary_resourceid2 = 47; |
| 278 ResourceId arbitrary_resourceid3 = 23; | 279 ResourceId arbitrary_resourceid3 = 23; |
| 279 ResourceId arbitrary_resourceid4 = 16; | 280 ResourceId arbitrary_resourceid4 = 16; |
| 280 SkScalar arbitrary_sigma = SkFloatToScalar(2.0f); | 281 SkScalar arbitrary_sigma = SkFloatToScalar(2.0f); |
| 281 YUVVideoDrawQuad::ColorSpace arbitrary_color_space = | 282 gfx::ColorSpace arbitrary_color_space = gfx::ColorSpace::CreateREC601(); |
| 283 YUVVideoDrawQuad::ColorSpace arbitrary_video_color_space = |
| 282 YUVVideoDrawQuad::REC_601; | 284 YUVVideoDrawQuad::REC_601; |
| 283 gfx::ColorSpace arbitrary_video_color_space = gfx::ColorSpace::CreateREC601(); | |
| 284 | 285 |
| 285 int child_id = 30; | 286 int child_id = 30; |
| 286 int root_id = 14; | 287 int root_id = 14; |
| 287 | 288 |
| 288 FilterOperations arbitrary_filters1; | 289 FilterOperations arbitrary_filters1; |
| 289 arbitrary_filters1.Append( | 290 arbitrary_filters1.Append( |
| 290 FilterOperation::CreateGrayscaleFilter(arbitrary_float1)); | 291 FilterOperation::CreateGrayscaleFilter(arbitrary_float1)); |
| 291 arbitrary_filters1.Append(cc::FilterOperation::CreateReferenceFilter( | 292 arbitrary_filters1.Append(cc::FilterOperation::CreateReferenceFilter( |
| 292 SkBlurImageFilter::Make(arbitrary_sigma, arbitrary_sigma, nullptr))); | 293 SkBlurImageFilter::Make(arbitrary_sigma, arbitrary_sigma, nullptr))); |
| 293 | 294 |
| 294 FilterOperations arbitrary_filters2; | 295 FilterOperations arbitrary_filters2; |
| 295 arbitrary_filters2.Append( | 296 arbitrary_filters2.Append( |
| 296 FilterOperation::CreateBrightnessFilter(arbitrary_float2)); | 297 FilterOperation::CreateBrightnessFilter(arbitrary_float2)); |
| 297 | 298 |
| 298 std::unique_ptr<RenderPass> child_pass_in = RenderPass::Create(); | 299 std::unique_ptr<RenderPass> child_pass_in = RenderPass::Create(); |
| 299 child_pass_in->SetAll(child_id, arbitrary_rect2, arbitrary_rect3, | 300 child_pass_in->SetAll(child_id, arbitrary_rect2, arbitrary_rect3, |
| 300 arbitrary_matrix2, arbitrary_filters1, | 301 arbitrary_matrix2, arbitrary_filters1, |
| 301 arbitrary_filters2, arbitrary_bool2); | 302 arbitrary_filters2, arbitrary_color_space, |
| 303 arbitrary_bool2); |
| 302 | 304 |
| 303 std::unique_ptr<RenderPass> child_pass_cmp = RenderPass::Create(); | 305 std::unique_ptr<RenderPass> child_pass_cmp = RenderPass::Create(); |
| 304 child_pass_cmp->SetAll(child_id, arbitrary_rect2, arbitrary_rect3, | 306 child_pass_cmp->SetAll(child_id, arbitrary_rect2, arbitrary_rect3, |
| 305 arbitrary_matrix2, arbitrary_filters1, | 307 arbitrary_matrix2, arbitrary_filters1, |
| 306 arbitrary_filters2, arbitrary_bool2); | 308 arbitrary_filters2, arbitrary_color_space, |
| 309 arbitrary_bool2); |
| 307 | 310 |
| 308 std::unique_ptr<RenderPass> pass_in = RenderPass::Create(); | 311 std::unique_ptr<RenderPass> pass_in = RenderPass::Create(); |
| 309 pass_in->SetAll(root_id, arbitrary_rect1, arbitrary_rect2, arbitrary_matrix1, | 312 pass_in->SetAll(root_id, arbitrary_rect1, arbitrary_rect2, arbitrary_matrix1, |
| 310 arbitrary_filters2, arbitrary_filters1, arbitrary_bool1); | 313 arbitrary_filters2, arbitrary_filters1, arbitrary_color_space, |
| 314 arbitrary_bool1); |
| 311 | 315 |
| 312 SharedQuadState* shared_state1_in = pass_in->CreateAndAppendSharedQuadState(); | 316 SharedQuadState* shared_state1_in = pass_in->CreateAndAppendSharedQuadState(); |
| 313 shared_state1_in->SetAll(arbitrary_matrix1, arbitrary_size1, arbitrary_rect1, | 317 shared_state1_in->SetAll(arbitrary_matrix1, arbitrary_size1, arbitrary_rect1, |
| 314 arbitrary_rect2, arbitrary_bool1, arbitrary_float1, | 318 arbitrary_rect2, arbitrary_bool1, arbitrary_float1, |
| 315 arbitrary_blend_mode1, arbitrary_context_id1); | 319 arbitrary_blend_mode1, arbitrary_context_id1); |
| 316 | 320 |
| 317 std::unique_ptr<RenderPass> pass_cmp = RenderPass::Create(); | 321 std::unique_ptr<RenderPass> pass_cmp = RenderPass::Create(); |
| 318 pass_cmp->SetAll(root_id, arbitrary_rect1, arbitrary_rect2, arbitrary_matrix1, | 322 pass_cmp->SetAll(root_id, arbitrary_rect1, arbitrary_rect2, arbitrary_matrix1, |
| 319 arbitrary_filters2, arbitrary_filters1, arbitrary_bool1); | 323 arbitrary_filters2, arbitrary_filters1, |
| 324 arbitrary_color_space, arbitrary_bool1); |
| 320 | 325 |
| 321 SharedQuadState* shared_state1_cmp = | 326 SharedQuadState* shared_state1_cmp = |
| 322 pass_cmp->CreateAndAppendSharedQuadState(); | 327 pass_cmp->CreateAndAppendSharedQuadState(); |
| 323 *shared_state1_cmp = *shared_state1_in; | 328 *shared_state1_cmp = *shared_state1_in; |
| 324 | 329 |
| 325 DebugBorderDrawQuad* debugborder_in = | 330 DebugBorderDrawQuad* debugborder_in = |
| 326 pass_in->CreateAndAppendDrawQuad<DebugBorderDrawQuad>(); | 331 pass_in->CreateAndAppendDrawQuad<DebugBorderDrawQuad>(); |
| 327 debugborder_in->SetAll(shared_state1_in, arbitrary_rect3, | 332 debugborder_in->SetAll(shared_state1_in, arbitrary_rect3, |
| 328 arbitrary_rect1_inside_rect3, | 333 arbitrary_rect1_inside_rect3, |
| 329 arbitrary_rect2_inside_rect3, arbitrary_bool1, | 334 arbitrary_rect2_inside_rect3, arbitrary_bool1, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 arbitrary_size1, arbitrary_bool2, arbitrary_bool3); | 410 arbitrary_size1, arbitrary_bool2, arbitrary_bool3); |
| 406 pass_cmp->CopyFromAndAppendDrawQuad(tile_in, tile_in->shared_quad_state); | 411 pass_cmp->CopyFromAndAppendDrawQuad(tile_in, tile_in->shared_quad_state); |
| 407 | 412 |
| 408 YUVVideoDrawQuad* yuvvideo_in = | 413 YUVVideoDrawQuad* yuvvideo_in = |
| 409 pass_in->CreateAndAppendDrawQuad<YUVVideoDrawQuad>(); | 414 pass_in->CreateAndAppendDrawQuad<YUVVideoDrawQuad>(); |
| 410 yuvvideo_in->SetAll( | 415 yuvvideo_in->SetAll( |
| 411 shared_state3_in, arbitrary_rect1, arbitrary_rect2_inside_rect1, | 416 shared_state3_in, arbitrary_rect1, arbitrary_rect2_inside_rect1, |
| 412 arbitrary_rect1_inside_rect1, arbitrary_bool1, arbitrary_rectf1, | 417 arbitrary_rect1_inside_rect1, arbitrary_bool1, arbitrary_rectf1, |
| 413 arbitrary_rectf2, arbitrary_size1, arbitrary_size2, arbitrary_resourceid1, | 418 arbitrary_rectf2, arbitrary_size1, arbitrary_size2, arbitrary_resourceid1, |
| 414 arbitrary_resourceid2, arbitrary_resourceid3, arbitrary_resourceid4, | 419 arbitrary_resourceid2, arbitrary_resourceid3, arbitrary_resourceid4, |
| 415 arbitrary_color_space, arbitrary_video_color_space, arbitrary_float1, | 420 arbitrary_video_color_space, arbitrary_color_space, arbitrary_float1, |
| 416 arbitrary_float2, arbitrary_int); | 421 arbitrary_float2, arbitrary_int); |
| 417 pass_cmp->CopyFromAndAppendDrawQuad(yuvvideo_in, | 422 pass_cmp->CopyFromAndAppendDrawQuad(yuvvideo_in, |
| 418 yuvvideo_in->shared_quad_state); | 423 yuvvideo_in->shared_quad_state); |
| 419 | 424 |
| 420 // Make sure the in and cmp RenderPasses match. | 425 // Make sure the in and cmp RenderPasses match. |
| 421 Compare(child_pass_cmp.get(), child_pass_in.get()); | 426 Compare(child_pass_cmp.get(), child_pass_in.get()); |
| 422 ASSERT_EQ(0u, child_pass_in->shared_quad_state_list.size()); | 427 ASSERT_EQ(0u, child_pass_in->shared_quad_state_list.size()); |
| 423 ASSERT_EQ(0u, child_pass_in->quad_list.size()); | 428 ASSERT_EQ(0u, child_pass_in->quad_list.size()); |
| 424 Compare(pass_cmp.get(), pass_in.get()); | 429 Compare(pass_cmp.get(), pass_in.get()); |
| 425 ASSERT_EQ(3u, pass_in->shared_quad_state_list.size()); | 430 ASSERT_EQ(3u, pass_in->shared_quad_state_list.size()); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 bool same_shared_quad_state_out = | 491 bool same_shared_quad_state_out = |
| 487 pass_out->quad_list.ElementAt(i)->shared_quad_state == | 492 pass_out->quad_list.ElementAt(i)->shared_quad_state == |
| 488 pass_out->quad_list.ElementAt(i - 1)->shared_quad_state; | 493 pass_out->quad_list.ElementAt(i - 1)->shared_quad_state; |
| 489 EXPECT_EQ(same_shared_quad_state_cmp, same_shared_quad_state_out); | 494 EXPECT_EQ(same_shared_quad_state_cmp, same_shared_quad_state_out); |
| 490 } | 495 } |
| 491 } | 496 } |
| 492 | 497 |
| 493 TEST_F(CCParamTraitsTest, UnusedSharedQuadStates) { | 498 TEST_F(CCParamTraitsTest, UnusedSharedQuadStates) { |
| 494 std::unique_ptr<RenderPass> pass_in = RenderPass::Create(); | 499 std::unique_ptr<RenderPass> pass_in = RenderPass::Create(); |
| 495 pass_in->SetAll(1, gfx::Rect(100, 100), gfx::Rect(), gfx::Transform(), | 500 pass_in->SetAll(1, gfx::Rect(100, 100), gfx::Rect(), gfx::Transform(), |
| 496 FilterOperations(), FilterOperations(), false); | 501 FilterOperations(), FilterOperations(), |
| 502 gfx::ColorSpace::CreateSRGB(), false); |
| 497 | 503 |
| 498 // The first SharedQuadState is used. | 504 // The first SharedQuadState is used. |
| 499 SharedQuadState* shared_state1_in = pass_in->CreateAndAppendSharedQuadState(); | 505 SharedQuadState* shared_state1_in = pass_in->CreateAndAppendSharedQuadState(); |
| 500 shared_state1_in->SetAll(gfx::Transform(), gfx::Size(1, 1), gfx::Rect(), | 506 shared_state1_in->SetAll(gfx::Transform(), gfx::Size(1, 1), gfx::Rect(), |
| 501 gfx::Rect(), false, 1.f, SkBlendMode::kSrcOver, 0); | 507 gfx::Rect(), false, 1.f, SkBlendMode::kSrcOver, 0); |
| 502 | 508 |
| 503 SolidColorDrawQuad* quad1 = | 509 SolidColorDrawQuad* quad1 = |
| 504 pass_in->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 510 pass_in->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
| 505 quad1->SetAll(shared_state1_in, gfx::Rect(10, 10), gfx::Rect(10, 10), | 511 quad1->SetAll(shared_state1_in, gfx::Rect(10, 10), gfx::Rect(10, 10), |
| 506 gfx::Rect(10, 10), false, SK_ColorRED, false); | 512 gfx::Rect(10, 10), false, SK_ColorRED, false); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 base::PickleIterator iter(msg); | 625 base::PickleIterator iter(msg); |
| 620 EXPECT_TRUE(IPC::ParamTraits<CompositorFrame>::Read(&msg, &iter, &frame_out)); | 626 EXPECT_TRUE(IPC::ParamTraits<CompositorFrame>::Read(&msg, &iter, &frame_out)); |
| 621 | 627 |
| 622 ASSERT_EQ(2u, frame_out.resource_list.size()); | 628 ASSERT_EQ(2u, frame_out.resource_list.size()); |
| 623 Compare(arbitrary_resource1, frame_out.resource_list[0]); | 629 Compare(arbitrary_resource1, frame_out.resource_list[0]); |
| 624 Compare(arbitrary_resource2, frame_out.resource_list[1]); | 630 Compare(arbitrary_resource2, frame_out.resource_list[1]); |
| 625 } | 631 } |
| 626 | 632 |
| 627 } // namespace | 633 } // namespace |
| 628 } // namespace content | 634 } // namespace content |
| OLD | NEW |