| 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 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 SETUP_AND_COPY_QUAD_ALL(Type, quad_all); | 363 SETUP_AND_COPY_QUAD_ALL(Type, quad_all); |
| 364 | 364 |
| 365 #define CREATE_QUAD_13_NEW(Type, a, b, c, d, e, f, g, h, i, j, k, l, m) \ | 365 #define CREATE_QUAD_13_NEW(Type, a, b, c, d, e, f, g, h, i, j, k, l, m) \ |
| 366 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \ | 366 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \ |
| 367 { \ | 367 { \ |
| 368 QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a, b, c, d, e, f, g, \ | 368 QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a, b, c, d, e, f, g, \ |
| 369 h, i, j, k, l, m); \ | 369 h, i, j, k, l, m); \ |
| 370 } \ | 370 } \ |
| 371 SETUP_AND_COPY_QUAD_NEW(Type, quad_new); | 371 SETUP_AND_COPY_QUAD_NEW(Type, quad_new); |
| 372 | 372 |
| 373 #define CREATE_QUAD_13_ALL(Type, a, b, c, d, e, f, g, h, i, j, k, l, m) \ | |
| 374 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \ | |
| 375 { \ | |
| 376 QUAD_DATA quad_all->SetAll(shared_state, quad_rect, quad_opaque_rect, \ | |
| 377 quad_visible_rect, needs_blending, a, b, c, d, \ | |
| 378 e, f, g, h, i, j, k, l, m); \ | |
| 379 } \ | |
| 380 SETUP_AND_COPY_QUAD_ALL(Type, quad_all); | |
| 381 | |
| 382 #define CREATE_QUAD_14_NEW(Type, a, b, c, d, e, f, g, h, i, j, k, l, m, n) \ | 373 #define CREATE_QUAD_14_NEW(Type, a, b, c, d, e, f, g, h, i, j, k, l, m, n) \ |
| 383 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \ | 374 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \ |
| 384 { \ | 375 { \ |
| 385 QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a, b, c, d, e, f, g, \ | 376 QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a, b, c, d, e, f, g, \ |
| 386 h, i, j, k, l, m, n); \ | 377 h, i, j, k, l, m, n); \ |
| 387 } \ | 378 } \ |
| 388 SETUP_AND_COPY_QUAD_NEW(Type, quad_new); | 379 SETUP_AND_COPY_QUAD_NEW(Type, quad_new); |
| 389 | 380 |
| 390 #define CREATE_QUAD_15_NEW(Type, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) \ | |
| 391 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \ | |
| 392 { \ | |
| 393 QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a, b, c, d, e, f, g, \ | |
| 394 h, i, j, k, l, m, n, o); \ | |
| 395 } \ | |
| 396 SETUP_AND_COPY_QUAD_NEW(Type, quad_new); | |
| 397 | |
| 398 #define CREATE_QUAD_ALL_RP(Type, a, b, c, d, e, f, g, copy_a) \ | 381 #define CREATE_QUAD_ALL_RP(Type, a, b, c, d, e, f, g, copy_a) \ |
| 399 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \ | 382 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \ |
| 400 { \ | 383 { \ |
| 401 QUAD_DATA quad_all->SetAll(shared_state, quad_rect, quad_opaque_rect, \ | 384 QUAD_DATA quad_all->SetAll(shared_state, quad_rect, quad_opaque_rect, \ |
| 402 quad_visible_rect, needs_blending, a, b, c, d, \ | 385 quad_visible_rect, needs_blending, a, b, c, d, \ |
| 403 e, f, g); \ | 386 e, f, g); \ |
| 404 } \ | 387 } \ |
| 405 SETUP_AND_COPY_QUAD_ALL_RP(Type, quad_all, copy_a); | 388 SETUP_AND_COPY_QUAD_ALL_RP(Type, quad_all, copy_a); |
| 406 | 389 |
| 407 #define CREATE_QUAD_NEW_RP(Type, a, b, c, d, e, f, g, h, copy_a) \ | 390 #define CREATE_QUAD_NEW_RP(Type, a, b, c, d, e, f, g, h, copy_a) \ |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 gfx::RectF uv_tex_coord_rect(20, 25, 15, 10); | 612 gfx::RectF uv_tex_coord_rect(20, 25, 15, 10); |
| 630 gfx::Size ya_tex_size(32, 68); | 613 gfx::Size ya_tex_size(32, 68); |
| 631 gfx::Size uv_tex_size(41, 51); | 614 gfx::Size uv_tex_size(41, 51); |
| 632 ResourceId y_plane_resource_id = 45; | 615 ResourceId y_plane_resource_id = 45; |
| 633 ResourceId u_plane_resource_id = 532; | 616 ResourceId u_plane_resource_id = 532; |
| 634 ResourceId v_plane_resource_id = 4; | 617 ResourceId v_plane_resource_id = 4; |
| 635 ResourceId a_plane_resource_id = 63; | 618 ResourceId a_plane_resource_id = 63; |
| 636 float resource_offset = 0.5f; | 619 float resource_offset = 0.5f; |
| 637 float resource_multiplier = 2.001f; | 620 float resource_multiplier = 2.001f; |
| 638 uint32_t bits_per_channel = 5; | 621 uint32_t bits_per_channel = 5; |
| 639 YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::JPEG; | |
| 640 gfx::ColorSpace video_color_space = gfx::ColorSpace::CreateJpeg(); | |
| 641 CREATE_SHARED_STATE(); | 622 CREATE_SHARED_STATE(); |
| 642 | 623 |
| 643 CREATE_QUAD_15_NEW(YUVVideoDrawQuad, opaque_rect, visible_rect, | 624 CREATE_QUAD_13_NEW(YUVVideoDrawQuad, opaque_rect, visible_rect, |
| 644 ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size, | 625 ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size, |
| 645 uv_tex_size, y_plane_resource_id, u_plane_resource_id, | 626 uv_tex_size, y_plane_resource_id, u_plane_resource_id, |
| 646 v_plane_resource_id, a_plane_resource_id, color_space, | 627 v_plane_resource_id, a_plane_resource_id, resource_offset, |
| 647 video_color_space, resource_offset, resource_multiplier, | 628 resource_multiplier, bits_per_channel); |
| 648 bits_per_channel); | |
| 649 EXPECT_EQ(DrawQuad::YUV_VIDEO_CONTENT, copy_quad->material); | 629 EXPECT_EQ(DrawQuad::YUV_VIDEO_CONTENT, copy_quad->material); |
| 650 EXPECT_EQ(opaque_rect, copy_quad->opaque_rect); | 630 EXPECT_EQ(opaque_rect, copy_quad->opaque_rect); |
| 651 EXPECT_EQ(visible_rect, copy_quad->visible_rect); | 631 EXPECT_EQ(visible_rect, copy_quad->visible_rect); |
| 652 EXPECT_EQ(ya_tex_coord_rect, copy_quad->ya_tex_coord_rect); | 632 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); | 633 EXPECT_EQ(uv_tex_coord_rect, copy_quad->uv_tex_coord_rect); |
| 654 EXPECT_EQ(ya_tex_size, copy_quad->ya_tex_size); | 634 EXPECT_EQ(ya_tex_size, copy_quad->ya_tex_size); |
| 655 EXPECT_EQ(uv_tex_size, copy_quad->uv_tex_size); | 635 EXPECT_EQ(uv_tex_size, copy_quad->uv_tex_size); |
| 656 EXPECT_EQ(y_plane_resource_id, copy_quad->y_plane_resource_id()); | 636 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()); | 637 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()); | 638 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()); | 639 EXPECT_EQ(a_plane_resource_id, copy_quad->a_plane_resource_id()); |
| 660 EXPECT_EQ(color_space, copy_quad->color_space); | |
| 661 EXPECT_EQ(resource_offset, copy_quad->resource_offset); | 640 EXPECT_EQ(resource_offset, copy_quad->resource_offset); |
| 662 EXPECT_EQ(resource_multiplier, copy_quad->resource_multiplier); | 641 EXPECT_EQ(resource_multiplier, copy_quad->resource_multiplier); |
| 663 EXPECT_EQ(bits_per_channel, copy_quad->bits_per_channel); | 642 EXPECT_EQ(bits_per_channel, copy_quad->bits_per_channel); |
| 664 | 643 |
| 665 CREATE_QUAD_13_ALL(YUVVideoDrawQuad, ya_tex_coord_rect, uv_tex_coord_rect, | 644 CREATE_QUAD_11_ALL(YUVVideoDrawQuad, ya_tex_coord_rect, uv_tex_coord_rect, |
| 666 ya_tex_size, uv_tex_size, y_plane_resource_id, | 645 ya_tex_size, uv_tex_size, y_plane_resource_id, |
| 667 u_plane_resource_id, v_plane_resource_id, | 646 u_plane_resource_id, v_plane_resource_id, |
| 668 a_plane_resource_id, color_space, video_color_space, | 647 a_plane_resource_id, resource_offset, resource_multiplier, |
| 669 resource_offset, resource_multiplier, bits_per_channel); | 648 bits_per_channel); |
| 670 EXPECT_EQ(DrawQuad::YUV_VIDEO_CONTENT, copy_quad->material); | 649 EXPECT_EQ(DrawQuad::YUV_VIDEO_CONTENT, copy_quad->material); |
| 671 EXPECT_EQ(ya_tex_coord_rect, copy_quad->ya_tex_coord_rect); | 650 EXPECT_EQ(ya_tex_coord_rect, copy_quad->ya_tex_coord_rect); |
| 672 EXPECT_EQ(uv_tex_coord_rect, copy_quad->uv_tex_coord_rect); | 651 EXPECT_EQ(uv_tex_coord_rect, copy_quad->uv_tex_coord_rect); |
| 673 EXPECT_EQ(ya_tex_size, copy_quad->ya_tex_size); | 652 EXPECT_EQ(ya_tex_size, copy_quad->ya_tex_size); |
| 674 EXPECT_EQ(uv_tex_size, copy_quad->uv_tex_size); | 653 EXPECT_EQ(uv_tex_size, copy_quad->uv_tex_size); |
| 675 EXPECT_EQ(y_plane_resource_id, copy_quad->y_plane_resource_id()); | 654 EXPECT_EQ(y_plane_resource_id, copy_quad->y_plane_resource_id()); |
| 676 EXPECT_EQ(u_plane_resource_id, copy_quad->u_plane_resource_id()); | 655 EXPECT_EQ(u_plane_resource_id, copy_quad->u_plane_resource_id()); |
| 677 EXPECT_EQ(v_plane_resource_id, copy_quad->v_plane_resource_id()); | 656 EXPECT_EQ(v_plane_resource_id, copy_quad->v_plane_resource_id()); |
| 678 EXPECT_EQ(a_plane_resource_id, copy_quad->a_plane_resource_id()); | 657 EXPECT_EQ(a_plane_resource_id, copy_quad->a_plane_resource_id()); |
| 679 EXPECT_EQ(color_space, copy_quad->color_space); | |
| 680 EXPECT_EQ(resource_offset, copy_quad->resource_offset); | 658 EXPECT_EQ(resource_offset, copy_quad->resource_offset); |
| 681 EXPECT_EQ(resource_multiplier, copy_quad->resource_multiplier); | 659 EXPECT_EQ(resource_multiplier, copy_quad->resource_multiplier); |
| 682 EXPECT_EQ(bits_per_channel, copy_quad->bits_per_channel); | 660 EXPECT_EQ(bits_per_channel, copy_quad->bits_per_channel); |
| 683 } | 661 } |
| 684 | 662 |
| 685 TEST(DrawQuadTest, CopyPictureDrawQuad) { | 663 TEST(DrawQuadTest, CopyPictureDrawQuad) { |
| 686 gfx::Rect opaque_rect(33, 44, 22, 33); | 664 gfx::Rect opaque_rect(33, 44, 22, 33); |
| 687 gfx::Rect visible_rect(40, 50, 30, 20); | 665 gfx::Rect visible_rect(40, 50, 30, 20); |
| 688 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f); | 666 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f); |
| 689 gfx::Size texture_size(85, 32); | 667 gfx::Size texture_size(85, 32); |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 864 gfx::Rect opaque_rect(33, 47, 10, 12); | 842 gfx::Rect opaque_rect(33, 47, 10, 12); |
| 865 gfx::Rect visible_rect(40, 50, 30, 20); | 843 gfx::Rect visible_rect(40, 50, 30, 20); |
| 866 gfx::RectF ya_tex_coord_rect(0.0f, 0.0f, 0.75f, 0.5f); | 844 gfx::RectF ya_tex_coord_rect(0.0f, 0.0f, 0.75f, 0.5f); |
| 867 gfx::RectF uv_tex_coord_rect(0.0f, 0.0f, 0.375f, 0.25f); | 845 gfx::RectF uv_tex_coord_rect(0.0f, 0.0f, 0.375f, 0.25f); |
| 868 gfx::Size ya_tex_size(32, 68); | 846 gfx::Size ya_tex_size(32, 68); |
| 869 gfx::Size uv_tex_size(41, 51); | 847 gfx::Size uv_tex_size(41, 51); |
| 870 ResourceId y_plane_resource_id = 45; | 848 ResourceId y_plane_resource_id = 45; |
| 871 ResourceId u_plane_resource_id = 532; | 849 ResourceId u_plane_resource_id = 532; |
| 872 ResourceId v_plane_resource_id = 4; | 850 ResourceId v_plane_resource_id = 4; |
| 873 ResourceId a_plane_resource_id = 63; | 851 ResourceId a_plane_resource_id = 63; |
| 874 YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::JPEG; | 852 CREATE_SHARED_STATE(); |
| 875 gfx::ColorSpace video_color_space = gfx::ColorSpace::CreateJpeg(); | |
| 876 | 853 |
| 877 CREATE_SHARED_STATE(); | 854 CREATE_QUAD_13_NEW(YUVVideoDrawQuad, opaque_rect, visible_rect, |
| 878 CREATE_QUAD_15_NEW(YUVVideoDrawQuad, opaque_rect, visible_rect, | |
| 879 ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size, | 855 ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size, |
| 880 uv_tex_size, y_plane_resource_id, u_plane_resource_id, | 856 uv_tex_size, y_plane_resource_id, u_plane_resource_id, |
| 881 v_plane_resource_id, a_plane_resource_id, color_space, | 857 v_plane_resource_id, a_plane_resource_id, 0.0, 1.0, 5); |
| 882 video_color_space, 0.0, 1.0, 5); | |
| 883 EXPECT_EQ(DrawQuad::YUV_VIDEO_CONTENT, copy_quad->material); | 858 EXPECT_EQ(DrawQuad::YUV_VIDEO_CONTENT, copy_quad->material); |
| 884 EXPECT_EQ(y_plane_resource_id, quad_new->y_plane_resource_id()); | 859 EXPECT_EQ(y_plane_resource_id, quad_new->y_plane_resource_id()); |
| 885 EXPECT_EQ(u_plane_resource_id, quad_new->u_plane_resource_id()); | 860 EXPECT_EQ(u_plane_resource_id, quad_new->u_plane_resource_id()); |
| 886 EXPECT_EQ(v_plane_resource_id, quad_new->v_plane_resource_id()); | 861 EXPECT_EQ(v_plane_resource_id, quad_new->v_plane_resource_id()); |
| 887 EXPECT_EQ(a_plane_resource_id, quad_new->a_plane_resource_id()); | 862 EXPECT_EQ(a_plane_resource_id, quad_new->a_plane_resource_id()); |
| 888 EXPECT_EQ(color_space, quad_new->color_space); | |
| 889 EXPECT_EQ(4, IterateAndCount(quad_new)); | 863 EXPECT_EQ(4, IterateAndCount(quad_new)); |
| 890 EXPECT_EQ(y_plane_resource_id + 1, quad_new->y_plane_resource_id()); | 864 EXPECT_EQ(y_plane_resource_id + 1, quad_new->y_plane_resource_id()); |
| 891 EXPECT_EQ(u_plane_resource_id + 1, quad_new->u_plane_resource_id()); | 865 EXPECT_EQ(u_plane_resource_id + 1, quad_new->u_plane_resource_id()); |
| 892 EXPECT_EQ(v_plane_resource_id + 1, quad_new->v_plane_resource_id()); | 866 EXPECT_EQ(v_plane_resource_id + 1, quad_new->v_plane_resource_id()); |
| 893 EXPECT_EQ(a_plane_resource_id + 1, quad_new->a_plane_resource_id()); | 867 EXPECT_EQ(a_plane_resource_id + 1, quad_new->a_plane_resource_id()); |
| 894 } | 868 } |
| 895 | 869 |
| 896 // Disabled until picture draw quad is supported for ubercomp: crbug.com/231715 | 870 // Disabled until picture draw quad is supported for ubercomp: crbug.com/231715 |
| 897 TEST_F(DrawQuadIteratorTest, DISABLED_PictureDrawQuad) { | 871 TEST_F(DrawQuadIteratorTest, DISABLED_PictureDrawQuad) { |
| 898 gfx::Rect opaque_rect(33, 44, 22, 33); | 872 gfx::Rect opaque_rect(33, 44, 22, 33); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 987 LOG(ERROR) << "YUVVideoDrawQuad " << sizeof(YUVVideoDrawQuad); | 961 LOG(ERROR) << "YUVVideoDrawQuad " << sizeof(YUVVideoDrawQuad); |
| 988 break; | 962 break; |
| 989 case DrawQuad::INVALID: | 963 case DrawQuad::INVALID: |
| 990 break; | 964 break; |
| 991 } | 965 } |
| 992 } | 966 } |
| 993 } | 967 } |
| 994 | 968 |
| 995 } // namespace | 969 } // namespace |
| 996 } // namespace cc | 970 } // namespace cc |
| OLD | NEW |