Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(456)

Side by Side Diff: cc/quads/draw_quad_unittest.cc

Issue 1131253003: cc: Add support for non-2D texture targets to YUVVideoQuad. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: s/jamesr/sky/ Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/output/shader.cc ('k') | cc/quads/tile_draw_quad.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 SETUP_AND_COPY_QUAD_ALL(Type, quad_all); 306 SETUP_AND_COPY_QUAD_ALL(Type, quad_all);
307 307
308 #define CREATE_QUAD_9_NEW(Type, a, b, c, d, e, f, g, h, i) \ 308 #define CREATE_QUAD_9_NEW(Type, a, b, c, d, e, f, g, h, i) \
309 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \ 309 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \
310 { \ 310 { \
311 QUAD_DATA quad_new->SetNew( \ 311 QUAD_DATA quad_new->SetNew( \
312 shared_state, quad_rect, a, b, c, d, e, f, g, h, i); \ 312 shared_state, quad_rect, a, b, c, d, e, f, g, h, i); \
313 } \ 313 } \
314 SETUP_AND_COPY_QUAD_NEW(Type, quad_new); 314 SETUP_AND_COPY_QUAD_NEW(Type, quad_new);
315 315
316 #define CREATE_QUAD_9_ALL(Type, a, b, c, d, e, f, g, h, i) \ 316 #define CREATE_QUAD_9_ALL(Type, a, b, c, d, e, f, g, h, i) \
317 { \ 317 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \
318 QUAD_DATA quad_all->SetAll(shared_state, \ 318 { \
319 quad_rect, \ 319 QUAD_DATA quad_all->SetAll(shared_state, quad_rect, quad_opaque_rect, \
320 quad_opaque_rect, \ 320 quad_visible_rect, needs_blending, a, b, c, d, \
321 quad_visible_rect, \ 321 e, f, g, h, i); \
322 needs_blending, \ 322 } \
323 a, \
324 b, \
325 c, \
326 d, \
327 e, \
328 f, \
329 g, \
330 h, \
331 i); \
332 } \
333 SETUP_AND_COPY_QUAD_ALL(Type, quad_all); 323 SETUP_AND_COPY_QUAD_ALL(Type, quad_all);
334 324
335 #define CREATE_QUAD_10_NEW(Type, a, b, c, d, e, f, g, h, i, j) \ 325 #define CREATE_QUAD_10_NEW(Type, a, b, c, d, e, f, g, h, i, j) \
336 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \ 326 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \
337 { \ 327 { \
338 QUAD_DATA quad_new->SetNew( \ 328 QUAD_DATA quad_new->SetNew( \
339 shared_state, quad_rect, a, b, c, d, e, f, g, h, i, j); \ 329 shared_state, quad_rect, a, b, c, d, e, f, g, h, i, j); \
340 } \ 330 } \
341 SETUP_AND_COPY_QUAD_NEW(Type, quad_new); 331 SETUP_AND_COPY_QUAD_NEW(Type, quad_new);
342 332
333 #define CREATE_QUAD_11_NEW(Type, a, b, c, d, e, f, g, h, i, j, k) \
334 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \
335 { \
336 QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a, b, c, d, e, f, g, \
337 h, i, j, k); \
338 } \
339 SETUP_AND_COPY_QUAD_NEW(Type, quad_new);
340
343 #define CREATE_QUAD_ALL_RP(Type, a, b, c, d, e, f, g, copy_a) \ 341 #define CREATE_QUAD_ALL_RP(Type, a, b, c, d, e, f, g, copy_a) \
344 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \ 342 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \
345 { \ 343 { \
346 QUAD_DATA quad_all->SetAll(shared_state, \ 344 QUAD_DATA quad_all->SetAll(shared_state, \
347 quad_rect, \ 345 quad_rect, \
348 quad_opaque_rect, \ 346 quad_opaque_rect, \
349 quad_visible_rect, \ 347 quad_visible_rect, \
350 needs_blending, \ 348 needs_blending, \
351 a, \ 349 a, \
352 b, \ 350 b, \
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 EXPECT_EQ(resource_id, copy_quad->resource_id); 631 EXPECT_EQ(resource_id, copy_quad->resource_id);
634 EXPECT_EQ(tex_coord_rect, copy_quad->tex_coord_rect); 632 EXPECT_EQ(tex_coord_rect, copy_quad->tex_coord_rect);
635 EXPECT_EQ(texture_size, copy_quad->texture_size); 633 EXPECT_EQ(texture_size, copy_quad->texture_size);
636 EXPECT_EQ(swizzle_contents, copy_quad->swizzle_contents); 634 EXPECT_EQ(swizzle_contents, copy_quad->swizzle_contents);
637 EXPECT_EQ(nearest_neighbor, copy_quad->nearest_neighbor); 635 EXPECT_EQ(nearest_neighbor, copy_quad->nearest_neighbor);
638 } 636 }
639 637
640 TEST(DrawQuadTest, CopyYUVVideoDrawQuad) { 638 TEST(DrawQuadTest, CopyYUVVideoDrawQuad) {
641 gfx::Rect opaque_rect(33, 47, 10, 12); 639 gfx::Rect opaque_rect(33, 47, 10, 12);
642 gfx::Rect visible_rect(40, 50, 30, 20); 640 gfx::Rect visible_rect(40, 50, 30, 20);
643 gfx::RectF tex_coord_rect(0.0f, 0.0f, 0.75f, 0.5f); 641 gfx::RectF ya_tex_coord_rect(40, 50, 30, 20);
642 gfx::RectF uv_tex_coord_rect(20, 25, 15, 10);
644 gfx::Size ya_tex_size(32, 68); 643 gfx::Size ya_tex_size(32, 68);
645 gfx::Size uv_tex_size(41, 51); 644 gfx::Size uv_tex_size(41, 51);
646 ResourceProvider::ResourceId y_plane_resource_id = 45; 645 ResourceProvider::ResourceId y_plane_resource_id = 45;
647 ResourceProvider::ResourceId u_plane_resource_id = 532; 646 ResourceProvider::ResourceId u_plane_resource_id = 532;
648 ResourceProvider::ResourceId v_plane_resource_id = 4; 647 ResourceProvider::ResourceId v_plane_resource_id = 4;
649 ResourceProvider::ResourceId a_plane_resource_id = 63; 648 ResourceProvider::ResourceId a_plane_resource_id = 63;
650 YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::JPEG; 649 YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::JPEG;
651 CREATE_SHARED_STATE(); 650 CREATE_SHARED_STATE();
652 651
653 CREATE_QUAD_10_NEW(YUVVideoDrawQuad, opaque_rect, visible_rect, 652 CREATE_QUAD_11_NEW(YUVVideoDrawQuad, opaque_rect, visible_rect,
654 tex_coord_rect, ya_tex_size, uv_tex_size, 653 ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size,
655 y_plane_resource_id, u_plane_resource_id, 654 uv_tex_size, y_plane_resource_id, u_plane_resource_id,
656 v_plane_resource_id, a_plane_resource_id, color_space); 655 v_plane_resource_id, a_plane_resource_id, color_space);
657 EXPECT_EQ(DrawQuad::YUV_VIDEO_CONTENT, copy_quad->material); 656 EXPECT_EQ(DrawQuad::YUV_VIDEO_CONTENT, copy_quad->material);
658 EXPECT_EQ(opaque_rect, copy_quad->opaque_rect); 657 EXPECT_EQ(opaque_rect, copy_quad->opaque_rect);
659 EXPECT_EQ(visible_rect, copy_quad->visible_rect); 658 EXPECT_EQ(visible_rect, copy_quad->visible_rect);
660 EXPECT_EQ(tex_coord_rect, copy_quad->tex_coord_rect); 659 EXPECT_EQ(ya_tex_coord_rect, copy_quad->ya_tex_coord_rect);
660 EXPECT_EQ(uv_tex_coord_rect, copy_quad->uv_tex_coord_rect);
661 EXPECT_EQ(ya_tex_size, copy_quad->ya_tex_size); 661 EXPECT_EQ(ya_tex_size, copy_quad->ya_tex_size);
662 EXPECT_EQ(uv_tex_size, copy_quad->uv_tex_size); 662 EXPECT_EQ(uv_tex_size, copy_quad->uv_tex_size);
663 EXPECT_EQ(y_plane_resource_id, copy_quad->y_plane_resource_id); 663 EXPECT_EQ(y_plane_resource_id, copy_quad->y_plane_resource_id);
664 EXPECT_EQ(u_plane_resource_id, copy_quad->u_plane_resource_id); 664 EXPECT_EQ(u_plane_resource_id, copy_quad->u_plane_resource_id);
665 EXPECT_EQ(v_plane_resource_id, copy_quad->v_plane_resource_id); 665 EXPECT_EQ(v_plane_resource_id, copy_quad->v_plane_resource_id);
666 EXPECT_EQ(a_plane_resource_id, copy_quad->a_plane_resource_id); 666 EXPECT_EQ(a_plane_resource_id, copy_quad->a_plane_resource_id);
667 EXPECT_EQ(color_space, copy_quad->color_space); 667 EXPECT_EQ(color_space, copy_quad->color_space);
668 668
669 CREATE_QUAD_8_ALL(YUVVideoDrawQuad, tex_coord_rect, ya_tex_size, uv_tex_size, 669 CREATE_QUAD_9_ALL(YUVVideoDrawQuad, ya_tex_coord_rect, uv_tex_coord_rect,
670 y_plane_resource_id, u_plane_resource_id, 670 ya_tex_size, uv_tex_size, y_plane_resource_id,
671 v_plane_resource_id, a_plane_resource_id, color_space); 671 u_plane_resource_id, v_plane_resource_id,
672 a_plane_resource_id, color_space);
672 EXPECT_EQ(DrawQuad::YUV_VIDEO_CONTENT, copy_quad->material); 673 EXPECT_EQ(DrawQuad::YUV_VIDEO_CONTENT, copy_quad->material);
673 EXPECT_EQ(tex_coord_rect, copy_quad->tex_coord_rect); 674 EXPECT_EQ(ya_tex_coord_rect, copy_quad->ya_tex_coord_rect);
675 EXPECT_EQ(uv_tex_coord_rect, copy_quad->uv_tex_coord_rect);
674 EXPECT_EQ(ya_tex_size, copy_quad->ya_tex_size); 676 EXPECT_EQ(ya_tex_size, copy_quad->ya_tex_size);
675 EXPECT_EQ(uv_tex_size, copy_quad->uv_tex_size); 677 EXPECT_EQ(uv_tex_size, copy_quad->uv_tex_size);
676 EXPECT_EQ(y_plane_resource_id, copy_quad->y_plane_resource_id); 678 EXPECT_EQ(y_plane_resource_id, copy_quad->y_plane_resource_id);
677 EXPECT_EQ(u_plane_resource_id, copy_quad->u_plane_resource_id); 679 EXPECT_EQ(u_plane_resource_id, copy_quad->u_plane_resource_id);
678 EXPECT_EQ(v_plane_resource_id, copy_quad->v_plane_resource_id); 680 EXPECT_EQ(v_plane_resource_id, copy_quad->v_plane_resource_id);
679 EXPECT_EQ(a_plane_resource_id, copy_quad->a_plane_resource_id); 681 EXPECT_EQ(a_plane_resource_id, copy_quad->a_plane_resource_id);
680 EXPECT_EQ(color_space, copy_quad->color_space); 682 EXPECT_EQ(color_space, copy_quad->color_space);
681 } 683 }
682 684
683 TEST(DrawQuadTest, CopyPictureDrawQuad) { 685 TEST(DrawQuadTest, CopyPictureDrawQuad) {
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 swizzle_contents, 896 swizzle_contents,
895 nearest_neighbor); 897 nearest_neighbor);
896 EXPECT_EQ(resource_id, quad_new->resource_id); 898 EXPECT_EQ(resource_id, quad_new->resource_id);
897 EXPECT_EQ(1, IterateAndCount(quad_new)); 899 EXPECT_EQ(1, IterateAndCount(quad_new));
898 EXPECT_EQ(resource_id + 1, quad_new->resource_id); 900 EXPECT_EQ(resource_id + 1, quad_new->resource_id);
899 } 901 }
900 902
901 TEST_F(DrawQuadIteratorTest, YUVVideoDrawQuad) { 903 TEST_F(DrawQuadIteratorTest, YUVVideoDrawQuad) {
902 gfx::Rect opaque_rect(33, 47, 10, 12); 904 gfx::Rect opaque_rect(33, 47, 10, 12);
903 gfx::Rect visible_rect(40, 50, 30, 20); 905 gfx::Rect visible_rect(40, 50, 30, 20);
904 gfx::RectF tex_coord_rect(0.0f, 0.0f, 0.75f, 0.5f); 906 gfx::RectF ya_tex_coord_rect(0.0f, 0.0f, 0.75f, 0.5f);
907 gfx::RectF uv_tex_coord_rect(0.0f, 0.0f, 0.375f, 0.25f);
905 gfx::Size ya_tex_size(32, 68); 908 gfx::Size ya_tex_size(32, 68);
906 gfx::Size uv_tex_size(41, 51); 909 gfx::Size uv_tex_size(41, 51);
907 ResourceProvider::ResourceId y_plane_resource_id = 45; 910 ResourceProvider::ResourceId y_plane_resource_id = 45;
908 ResourceProvider::ResourceId u_plane_resource_id = 532; 911 ResourceProvider::ResourceId u_plane_resource_id = 532;
909 ResourceProvider::ResourceId v_plane_resource_id = 4; 912 ResourceProvider::ResourceId v_plane_resource_id = 4;
910 ResourceProvider::ResourceId a_plane_resource_id = 63; 913 ResourceProvider::ResourceId a_plane_resource_id = 63;
911 YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::JPEG; 914 YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::JPEG;
912 915
913 CREATE_SHARED_STATE(); 916 CREATE_SHARED_STATE();
914 CREATE_QUAD_10_NEW(YUVVideoDrawQuad, opaque_rect, visible_rect, 917 CREATE_QUAD_11_NEW(YUVVideoDrawQuad, opaque_rect, visible_rect,
915 tex_coord_rect, ya_tex_size, uv_tex_size, 918 ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size,
916 y_plane_resource_id, u_plane_resource_id, 919 uv_tex_size, y_plane_resource_id, u_plane_resource_id,
917 v_plane_resource_id, a_plane_resource_id, color_space); 920 v_plane_resource_id, a_plane_resource_id, color_space);
918 EXPECT_EQ(DrawQuad::YUV_VIDEO_CONTENT, copy_quad->material); 921 EXPECT_EQ(DrawQuad::YUV_VIDEO_CONTENT, copy_quad->material);
919 EXPECT_EQ(y_plane_resource_id, quad_new->y_plane_resource_id); 922 EXPECT_EQ(y_plane_resource_id, quad_new->y_plane_resource_id);
920 EXPECT_EQ(u_plane_resource_id, quad_new->u_plane_resource_id); 923 EXPECT_EQ(u_plane_resource_id, quad_new->u_plane_resource_id);
921 EXPECT_EQ(v_plane_resource_id, quad_new->v_plane_resource_id); 924 EXPECT_EQ(v_plane_resource_id, quad_new->v_plane_resource_id);
922 EXPECT_EQ(a_plane_resource_id, quad_new->a_plane_resource_id); 925 EXPECT_EQ(a_plane_resource_id, quad_new->a_plane_resource_id);
923 EXPECT_EQ(color_space, quad_new->color_space); 926 EXPECT_EQ(color_space, quad_new->color_space);
924 EXPECT_EQ(4, IterateAndCount(quad_new)); 927 EXPECT_EQ(4, IterateAndCount(quad_new));
925 EXPECT_EQ(y_plane_resource_id + 1, quad_new->y_plane_resource_id); 928 EXPECT_EQ(y_plane_resource_id + 1, quad_new->y_plane_resource_id);
926 EXPECT_EQ(u_plane_resource_id + 1, quad_new->u_plane_resource_id); 929 EXPECT_EQ(u_plane_resource_id + 1, quad_new->u_plane_resource_id);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 LOG(ERROR) << "YUVVideoDrawQuad " << sizeof(YUVVideoDrawQuad); 1038 LOG(ERROR) << "YUVVideoDrawQuad " << sizeof(YUVVideoDrawQuad);
1036 break; 1039 break;
1037 case DrawQuad::INVALID: 1040 case DrawQuad::INVALID:
1038 break; 1041 break;
1039 } 1042 }
1040 } 1043 }
1041 } 1044 }
1042 1045
1043 } // namespace 1046 } // namespace
1044 } // namespace cc 1047 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/shader.cc ('k') | cc/quads/tile_draw_quad.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698