| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "cc/quads/draw_quad.h" | 5 #include "cc/quads/draw_quad.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 SETUP_AND_COPY_QUAD_ALL(Type, quad_all); | 344 SETUP_AND_COPY_QUAD_ALL(Type, quad_all); |
| 345 | 345 |
| 346 #define CREATE_QUAD_12_NEW(Type, a, b, c, d, e, f, g, h, i, j, k, l) \ | 346 #define CREATE_QUAD_12_NEW(Type, a, b, c, d, e, f, g, h, i, j, k, l) \ |
| 347 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \ | 347 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \ |
| 348 { \ | 348 { \ |
| 349 QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a, b, c, d, e, f, g, \ | 349 QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a, b, c, d, e, f, g, \ |
| 350 h, i, j, k, l); \ | 350 h, i, j, k, l); \ |
| 351 } \ | 351 } \ |
| 352 SETUP_AND_COPY_QUAD_NEW(Type, quad_new); | 352 SETUP_AND_COPY_QUAD_NEW(Type, quad_new); |
| 353 | 353 |
| 354 #define CREATE_QUAD_12_ALL(Type, a, b, c, d, e, f, g, h, i, j, k, l) \ |
| 355 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \ |
| 356 { \ |
| 357 QUAD_DATA quad_all->SetAll(shared_state, quad_rect, quad_opaque_rect, \ |
| 358 quad_visible_rect, needs_blending, a, b, c, d, \ |
| 359 e, f, g, h, i, j, k, l); \ |
| 360 } \ |
| 361 SETUP_AND_COPY_QUAD_ALL(Type, quad_all); |
| 362 |
| 354 #define CREATE_QUAD_13_NEW(Type, a, b, c, d, e, f, g, h, i, j, k, l, m) \ | 363 #define CREATE_QUAD_13_NEW(Type, a, b, c, d, e, f, g, h, i, j, k, l, m) \ |
| 355 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \ | 364 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \ |
| 356 { \ | 365 { \ |
| 357 QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a, b, c, d, e, f, g, \ | 366 QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a, b, c, d, e, f, g, \ |
| 358 h, i, j, k, l, m); \ | 367 h, i, j, k, l, m); \ |
| 359 } \ | 368 } \ |
| 360 SETUP_AND_COPY_QUAD_NEW(Type, quad_new); | 369 SETUP_AND_COPY_QUAD_NEW(Type, quad_new); |
| 361 | 370 |
| 371 #define CREATE_QUAD_14_NEW(Type, a, b, c, d, e, f, g, h, i, j, k, l, m, n) \ |
| 372 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \ |
| 373 { \ |
| 374 QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a, b, c, d, e, f, g, \ |
| 375 h, i, j, k, l, m, n); \ |
| 376 } \ |
| 377 SETUP_AND_COPY_QUAD_NEW(Type, quad_new); |
| 378 |
| 362 #define CREATE_QUAD_ALL_RP(Type, a, b, c, d, e, f, g, copy_a) \ | 379 #define CREATE_QUAD_ALL_RP(Type, a, b, c, d, e, f, g, copy_a) \ |
| 363 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \ | 380 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \ |
| 364 { \ | 381 { \ |
| 365 QUAD_DATA quad_all->SetAll(shared_state, \ | 382 QUAD_DATA quad_all->SetAll(shared_state, \ |
| 366 quad_rect, \ | 383 quad_rect, \ |
| 367 quad_opaque_rect, \ | 384 quad_opaque_rect, \ |
| 368 quad_visible_rect, \ | 385 quad_visible_rect, \ |
| 369 needs_blending, \ | 386 needs_blending, \ |
| 370 a, \ | 387 a, \ |
| 371 b, \ | 388 b, \ |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 gfx::RectF ya_tex_coord_rect(40, 50, 30, 20); | 630 gfx::RectF ya_tex_coord_rect(40, 50, 30, 20); |
| 614 gfx::RectF uv_tex_coord_rect(20, 25, 15, 10); | 631 gfx::RectF uv_tex_coord_rect(20, 25, 15, 10); |
| 615 gfx::Size ya_tex_size(32, 68); | 632 gfx::Size ya_tex_size(32, 68); |
| 616 gfx::Size uv_tex_size(41, 51); | 633 gfx::Size uv_tex_size(41, 51); |
| 617 ResourceId y_plane_resource_id = 45; | 634 ResourceId y_plane_resource_id = 45; |
| 618 ResourceId u_plane_resource_id = 532; | 635 ResourceId u_plane_resource_id = 532; |
| 619 ResourceId v_plane_resource_id = 4; | 636 ResourceId v_plane_resource_id = 4; |
| 620 ResourceId a_plane_resource_id = 63; | 637 ResourceId a_plane_resource_id = 63; |
| 621 float resource_offset = 0.5f; | 638 float resource_offset = 0.5f; |
| 622 float resource_multiplier = 2.001f; | 639 float resource_multiplier = 2.001f; |
| 640 int bits_per_channel = 5; |
| 623 YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::JPEG; | 641 YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::JPEG; |
| 624 CREATE_SHARED_STATE(); | 642 CREATE_SHARED_STATE(); |
| 625 | 643 |
| 626 CREATE_QUAD_13_NEW(YUVVideoDrawQuad, opaque_rect, visible_rect, | 644 CREATE_QUAD_14_NEW(YUVVideoDrawQuad, opaque_rect, visible_rect, |
| 627 ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size, | 645 ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size, |
| 628 uv_tex_size, y_plane_resource_id, u_plane_resource_id, | 646 uv_tex_size, y_plane_resource_id, u_plane_resource_id, |
| 629 v_plane_resource_id, a_plane_resource_id, color_space, | 647 v_plane_resource_id, a_plane_resource_id, color_space, |
| 630 resource_offset, resource_multiplier); | 648 resource_offset, resource_multiplier, bits_per_channel); |
| 631 EXPECT_EQ(DrawQuad::YUV_VIDEO_CONTENT, copy_quad->material); | 649 EXPECT_EQ(DrawQuad::YUV_VIDEO_CONTENT, copy_quad->material); |
| 632 EXPECT_EQ(opaque_rect, copy_quad->opaque_rect); | 650 EXPECT_EQ(opaque_rect, copy_quad->opaque_rect); |
| 633 EXPECT_EQ(visible_rect, copy_quad->visible_rect); | 651 EXPECT_EQ(visible_rect, copy_quad->visible_rect); |
| 634 EXPECT_EQ(ya_tex_coord_rect, copy_quad->ya_tex_coord_rect); | 652 EXPECT_EQ(ya_tex_coord_rect, copy_quad->ya_tex_coord_rect); |
| 635 EXPECT_EQ(uv_tex_coord_rect, copy_quad->uv_tex_coord_rect); | 653 EXPECT_EQ(uv_tex_coord_rect, copy_quad->uv_tex_coord_rect); |
| 636 EXPECT_EQ(ya_tex_size, copy_quad->ya_tex_size); | 654 EXPECT_EQ(ya_tex_size, copy_quad->ya_tex_size); |
| 637 EXPECT_EQ(uv_tex_size, copy_quad->uv_tex_size); | 655 EXPECT_EQ(uv_tex_size, copy_quad->uv_tex_size); |
| 638 EXPECT_EQ(y_plane_resource_id, copy_quad->y_plane_resource_id()); | 656 EXPECT_EQ(y_plane_resource_id, copy_quad->y_plane_resource_id()); |
| 639 EXPECT_EQ(u_plane_resource_id, copy_quad->u_plane_resource_id()); | 657 EXPECT_EQ(u_plane_resource_id, copy_quad->u_plane_resource_id()); |
| 640 EXPECT_EQ(v_plane_resource_id, copy_quad->v_plane_resource_id()); | 658 EXPECT_EQ(v_plane_resource_id, copy_quad->v_plane_resource_id()); |
| 641 EXPECT_EQ(a_plane_resource_id, copy_quad->a_plane_resource_id()); | 659 EXPECT_EQ(a_plane_resource_id, copy_quad->a_plane_resource_id()); |
| 642 EXPECT_EQ(color_space, copy_quad->color_space); | 660 EXPECT_EQ(color_space, copy_quad->color_space); |
| 643 EXPECT_EQ(resource_offset, copy_quad->resource_offset); | 661 EXPECT_EQ(resource_offset, copy_quad->resource_offset); |
| 644 EXPECT_EQ(resource_multiplier, copy_quad->resource_multiplier); | 662 EXPECT_EQ(resource_multiplier, copy_quad->resource_multiplier); |
| 663 EXPECT_EQ(bits_per_channel, copy_quad->bits_per_channel); |
| 645 | 664 |
| 646 CREATE_QUAD_11_ALL(YUVVideoDrawQuad, ya_tex_coord_rect, uv_tex_coord_rect, | 665 CREATE_QUAD_12_ALL(YUVVideoDrawQuad, ya_tex_coord_rect, uv_tex_coord_rect, |
| 647 ya_tex_size, uv_tex_size, y_plane_resource_id, | 666 ya_tex_size, uv_tex_size, y_plane_resource_id, |
| 648 u_plane_resource_id, v_plane_resource_id, | 667 u_plane_resource_id, v_plane_resource_id, |
| 649 a_plane_resource_id, color_space, resource_offset, | 668 a_plane_resource_id, color_space, resource_offset, |
| 650 resource_multiplier); | 669 resource_multiplier, bits_per_channel); |
| 651 EXPECT_EQ(DrawQuad::YUV_VIDEO_CONTENT, copy_quad->material); | 670 EXPECT_EQ(DrawQuad::YUV_VIDEO_CONTENT, copy_quad->material); |
| 652 EXPECT_EQ(ya_tex_coord_rect, copy_quad->ya_tex_coord_rect); | 671 EXPECT_EQ(ya_tex_coord_rect, copy_quad->ya_tex_coord_rect); |
| 653 EXPECT_EQ(uv_tex_coord_rect, copy_quad->uv_tex_coord_rect); | 672 EXPECT_EQ(uv_tex_coord_rect, copy_quad->uv_tex_coord_rect); |
| 654 EXPECT_EQ(ya_tex_size, copy_quad->ya_tex_size); | 673 EXPECT_EQ(ya_tex_size, copy_quad->ya_tex_size); |
| 655 EXPECT_EQ(uv_tex_size, copy_quad->uv_tex_size); | 674 EXPECT_EQ(uv_tex_size, copy_quad->uv_tex_size); |
| 656 EXPECT_EQ(y_plane_resource_id, copy_quad->y_plane_resource_id()); | 675 EXPECT_EQ(y_plane_resource_id, copy_quad->y_plane_resource_id()); |
| 657 EXPECT_EQ(u_plane_resource_id, copy_quad->u_plane_resource_id()); | 676 EXPECT_EQ(u_plane_resource_id, copy_quad->u_plane_resource_id()); |
| 658 EXPECT_EQ(v_plane_resource_id, copy_quad->v_plane_resource_id()); | 677 EXPECT_EQ(v_plane_resource_id, copy_quad->v_plane_resource_id()); |
| 659 EXPECT_EQ(a_plane_resource_id, copy_quad->a_plane_resource_id()); | 678 EXPECT_EQ(a_plane_resource_id, copy_quad->a_plane_resource_id()); |
| 660 EXPECT_EQ(color_space, copy_quad->color_space); | 679 EXPECT_EQ(color_space, copy_quad->color_space); |
| 661 EXPECT_EQ(resource_offset, copy_quad->resource_offset); | 680 EXPECT_EQ(resource_offset, copy_quad->resource_offset); |
| 662 EXPECT_EQ(resource_multiplier, copy_quad->resource_multiplier); | 681 EXPECT_EQ(resource_multiplier, copy_quad->resource_multiplier); |
| 682 EXPECT_EQ(bits_per_channel, copy_quad->bits_per_channel); |
| 663 } | 683 } |
| 664 | 684 |
| 665 TEST(DrawQuadTest, CopyPictureDrawQuad) { | 685 TEST(DrawQuadTest, CopyPictureDrawQuad) { |
| 666 gfx::Rect opaque_rect(33, 44, 22, 33); | 686 gfx::Rect opaque_rect(33, 44, 22, 33); |
| 667 gfx::Rect visible_rect(40, 50, 30, 20); | 687 gfx::Rect visible_rect(40, 50, 30, 20); |
| 668 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f); | 688 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f); |
| 669 gfx::Size texture_size(85, 32); | 689 gfx::Size texture_size(85, 32); |
| 670 bool nearest_neighbor = true; | 690 bool nearest_neighbor = true; |
| 671 ResourceFormat texture_format = RGBA_8888; | 691 ResourceFormat texture_format = RGBA_8888; |
| 672 gfx::Rect content_rect(30, 40, 20, 30); | 692 gfx::Rect content_rect(30, 40, 20, 30); |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 gfx::RectF uv_tex_coord_rect(0.0f, 0.0f, 0.375f, 0.25f); | 874 gfx::RectF uv_tex_coord_rect(0.0f, 0.0f, 0.375f, 0.25f); |
| 855 gfx::Size ya_tex_size(32, 68); | 875 gfx::Size ya_tex_size(32, 68); |
| 856 gfx::Size uv_tex_size(41, 51); | 876 gfx::Size uv_tex_size(41, 51); |
| 857 ResourceId y_plane_resource_id = 45; | 877 ResourceId y_plane_resource_id = 45; |
| 858 ResourceId u_plane_resource_id = 532; | 878 ResourceId u_plane_resource_id = 532; |
| 859 ResourceId v_plane_resource_id = 4; | 879 ResourceId v_plane_resource_id = 4; |
| 860 ResourceId a_plane_resource_id = 63; | 880 ResourceId a_plane_resource_id = 63; |
| 861 YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::JPEG; | 881 YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::JPEG; |
| 862 | 882 |
| 863 CREATE_SHARED_STATE(); | 883 CREATE_SHARED_STATE(); |
| 864 CREATE_QUAD_13_NEW(YUVVideoDrawQuad, opaque_rect, visible_rect, | 884 CREATE_QUAD_14_NEW(YUVVideoDrawQuad, opaque_rect, visible_rect, |
| 865 ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size, | 885 ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size, |
| 866 uv_tex_size, y_plane_resource_id, u_plane_resource_id, | 886 uv_tex_size, y_plane_resource_id, u_plane_resource_id, |
| 867 v_plane_resource_id, a_plane_resource_id, color_space, 0.0, | 887 v_plane_resource_id, a_plane_resource_id, color_space, 0.0, |
| 868 1.0); | 888 1.0, 5); |
| 869 EXPECT_EQ(DrawQuad::YUV_VIDEO_CONTENT, copy_quad->material); | 889 EXPECT_EQ(DrawQuad::YUV_VIDEO_CONTENT, copy_quad->material); |
| 870 EXPECT_EQ(y_plane_resource_id, quad_new->y_plane_resource_id()); | 890 EXPECT_EQ(y_plane_resource_id, quad_new->y_plane_resource_id()); |
| 871 EXPECT_EQ(u_plane_resource_id, quad_new->u_plane_resource_id()); | 891 EXPECT_EQ(u_plane_resource_id, quad_new->u_plane_resource_id()); |
| 872 EXPECT_EQ(v_plane_resource_id, quad_new->v_plane_resource_id()); | 892 EXPECT_EQ(v_plane_resource_id, quad_new->v_plane_resource_id()); |
| 873 EXPECT_EQ(a_plane_resource_id, quad_new->a_plane_resource_id()); | 893 EXPECT_EQ(a_plane_resource_id, quad_new->a_plane_resource_id()); |
| 874 EXPECT_EQ(color_space, quad_new->color_space); | 894 EXPECT_EQ(color_space, quad_new->color_space); |
| 875 EXPECT_EQ(4, IterateAndCount(quad_new)); | 895 EXPECT_EQ(4, IterateAndCount(quad_new)); |
| 876 EXPECT_EQ(y_plane_resource_id + 1, quad_new->y_plane_resource_id()); | 896 EXPECT_EQ(y_plane_resource_id + 1, quad_new->y_plane_resource_id()); |
| 877 EXPECT_EQ(u_plane_resource_id + 1, quad_new->u_plane_resource_id()); | 897 EXPECT_EQ(u_plane_resource_id + 1, quad_new->u_plane_resource_id()); |
| 878 EXPECT_EQ(v_plane_resource_id + 1, quad_new->v_plane_resource_id()); | 898 EXPECT_EQ(v_plane_resource_id + 1, quad_new->v_plane_resource_id()); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 973 LOG(ERROR) << "YUVVideoDrawQuad " << sizeof(YUVVideoDrawQuad); | 993 LOG(ERROR) << "YUVVideoDrawQuad " << sizeof(YUVVideoDrawQuad); |
| 974 break; | 994 break; |
| 975 case DrawQuad::INVALID: | 995 case DrawQuad::INVALID: |
| 976 break; | 996 break; |
| 977 } | 997 } |
| 978 } | 998 } |
| 979 } | 999 } |
| 980 | 1000 |
| 981 } // namespace | 1001 } // namespace |
| 982 } // namespace cc | 1002 } // namespace cc |
| OLD | NEW |