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

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

Issue 558083002: [cc] Add nearest neighbor filtering for TextureLayer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync and rebase Created 6 years 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/renderer_pixeltest.cc ('k') | cc/quads/texture_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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 c, \ 325 c, \
326 d, \ 326 d, \
327 e, \ 327 e, \
328 f, \ 328 f, \
329 g, \ 329 g, \
330 h, \ 330 h, \
331 i); \ 331 i); \
332 } \ 332 } \
333 SETUP_AND_COPY_QUAD_ALL(Type, quad_all); 333 SETUP_AND_COPY_QUAD_ALL(Type, quad_all);
334 334
335 #define CREATE_QUAD_10_NEW(Type, a, b, c, d, e, f, g, h, i, j) \
336 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \
337 { \
338 QUAD_DATA quad_new->SetNew( \
339 shared_state, quad_rect, a, b, c, d, e, f, g, h, i, j); \
340 } \
341 SETUP_AND_COPY_QUAD_NEW(Type, quad_new);
342
335 #define CREATE_QUAD_ALL_RP(Type, a, b, c, d, e, f, g, copy_a) \ 343 #define CREATE_QUAD_ALL_RP(Type, a, b, c, d, e, f, g, copy_a) \
336 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \ 344 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \
337 { \ 345 { \
338 QUAD_DATA quad_all->SetAll(shared_state, \ 346 QUAD_DATA quad_all->SetAll(shared_state, \
339 quad_rect, \ 347 quad_rect, \
340 quad_opaque_rect, \ 348 quad_opaque_rect, \
341 quad_visible_rect, \ 349 quad_visible_rect, \
342 needs_blending, \ 350 needs_blending, \
343 a, \ 351 a, \
344 b, \ 352 b, \
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 542
535 TEST(DrawQuadTest, CopyTextureDrawQuad) { 543 TEST(DrawQuadTest, CopyTextureDrawQuad) {
536 gfx::Rect opaque_rect(33, 47, 10, 12); 544 gfx::Rect opaque_rect(33, 47, 10, 12);
537 gfx::Rect visible_rect(40, 50, 30, 20); 545 gfx::Rect visible_rect(40, 50, 30, 20);
538 unsigned resource_id = 82; 546 unsigned resource_id = 82;
539 bool premultiplied_alpha = true; 547 bool premultiplied_alpha = true;
540 gfx::PointF uv_top_left(0.5f, 224.f); 548 gfx::PointF uv_top_left(0.5f, 224.f);
541 gfx::PointF uv_bottom_right(51.5f, 260.f); 549 gfx::PointF uv_bottom_right(51.5f, 260.f);
542 const float vertex_opacity[] = { 1.0f, 1.0f, 1.0f, 1.0f }; 550 const float vertex_opacity[] = { 1.0f, 1.0f, 1.0f, 1.0f };
543 bool flipped = true; 551 bool flipped = true;
552 bool nearest_neighbor = true;
544 CREATE_SHARED_STATE(); 553 CREATE_SHARED_STATE();
545 554
546 CREATE_QUAD_9_NEW(TextureDrawQuad, 555 CREATE_QUAD_10_NEW(TextureDrawQuad,
547 opaque_rect, 556 opaque_rect,
548 visible_rect, 557 visible_rect,
549 resource_id, 558 resource_id,
550 premultiplied_alpha, 559 premultiplied_alpha,
551 uv_top_left, 560 uv_top_left,
552 uv_bottom_right, 561 uv_bottom_right,
553 SK_ColorTRANSPARENT, 562 SK_ColorTRANSPARENT,
554 vertex_opacity, 563 vertex_opacity,
555 flipped); 564 flipped,
565 nearest_neighbor);
556 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, copy_quad->material); 566 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, copy_quad->material);
557 EXPECT_RECT_EQ(visible_rect, copy_quad->visible_rect); 567 EXPECT_RECT_EQ(visible_rect, copy_quad->visible_rect);
558 EXPECT_RECT_EQ(opaque_rect, copy_quad->opaque_rect); 568 EXPECT_RECT_EQ(opaque_rect, copy_quad->opaque_rect);
559 EXPECT_EQ(resource_id, copy_quad->resource_id); 569 EXPECT_EQ(resource_id, copy_quad->resource_id);
560 EXPECT_EQ(premultiplied_alpha, copy_quad->premultiplied_alpha); 570 EXPECT_EQ(premultiplied_alpha, copy_quad->premultiplied_alpha);
561 EXPECT_EQ(uv_top_left, copy_quad->uv_top_left); 571 EXPECT_EQ(uv_top_left, copy_quad->uv_top_left);
562 EXPECT_EQ(uv_bottom_right, copy_quad->uv_bottom_right); 572 EXPECT_EQ(uv_bottom_right, copy_quad->uv_bottom_right);
563 EXPECT_FLOAT_ARRAY_EQ(vertex_opacity, copy_quad->vertex_opacity, 4); 573 EXPECT_FLOAT_ARRAY_EQ(vertex_opacity, copy_quad->vertex_opacity, 4);
564 EXPECT_EQ(flipped, copy_quad->flipped); 574 EXPECT_EQ(flipped, copy_quad->flipped);
575 EXPECT_EQ(nearest_neighbor, copy_quad->nearest_neighbor);
565 576
566 CREATE_QUAD_7_ALL(TextureDrawQuad, 577 CREATE_QUAD_8_ALL(TextureDrawQuad,
567 resource_id, 578 resource_id,
568 premultiplied_alpha, 579 premultiplied_alpha,
569 uv_top_left, 580 uv_top_left,
570 uv_bottom_right, 581 uv_bottom_right,
571 SK_ColorTRANSPARENT, 582 SK_ColorTRANSPARENT,
572 vertex_opacity, 583 vertex_opacity,
573 flipped); 584 flipped,
585 nearest_neighbor);
574 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, copy_quad->material); 586 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, copy_quad->material);
575 EXPECT_EQ(resource_id, copy_quad->resource_id); 587 EXPECT_EQ(resource_id, copy_quad->resource_id);
576 EXPECT_EQ(premultiplied_alpha, copy_quad->premultiplied_alpha); 588 EXPECT_EQ(premultiplied_alpha, copy_quad->premultiplied_alpha);
577 EXPECT_EQ(uv_top_left, copy_quad->uv_top_left); 589 EXPECT_EQ(uv_top_left, copy_quad->uv_top_left);
578 EXPECT_EQ(uv_bottom_right, copy_quad->uv_bottom_right); 590 EXPECT_EQ(uv_bottom_right, copy_quad->uv_bottom_right);
579 EXPECT_FLOAT_ARRAY_EQ(vertex_opacity, copy_quad->vertex_opacity, 4); 591 EXPECT_FLOAT_ARRAY_EQ(vertex_opacity, copy_quad->vertex_opacity, 4);
580 EXPECT_EQ(flipped, copy_quad->flipped); 592 EXPECT_EQ(flipped, copy_quad->flipped);
593 EXPECT_EQ(nearest_neighbor, copy_quad->nearest_neighbor);
581 } 594 }
582 595
583 TEST(DrawQuadTest, CopyTileDrawQuad) { 596 TEST(DrawQuadTest, CopyTileDrawQuad) {
584 gfx::Rect opaque_rect(33, 44, 22, 33); 597 gfx::Rect opaque_rect(33, 44, 22, 33);
585 gfx::Rect visible_rect(40, 50, 30, 20); 598 gfx::Rect visible_rect(40, 50, 30, 20);
586 unsigned resource_id = 104; 599 unsigned resource_id = 104;
587 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f); 600 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f);
588 gfx::Size texture_size(85, 32); 601 gfx::Size texture_size(85, 32);
589 bool swizzle_contents = true; 602 bool swizzle_contents = true;
590 CREATE_SHARED_STATE(); 603 CREATE_SHARED_STATE();
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 838
826 TEST_F(DrawQuadIteratorTest, TextureDrawQuad) { 839 TEST_F(DrawQuadIteratorTest, TextureDrawQuad) {
827 gfx::Rect opaque_rect(33, 47, 10, 12); 840 gfx::Rect opaque_rect(33, 47, 10, 12);
828 gfx::Rect visible_rect(40, 50, 30, 20); 841 gfx::Rect visible_rect(40, 50, 30, 20);
829 unsigned resource_id = 82; 842 unsigned resource_id = 82;
830 bool premultiplied_alpha = true; 843 bool premultiplied_alpha = true;
831 gfx::PointF uv_top_left(0.5f, 224.f); 844 gfx::PointF uv_top_left(0.5f, 224.f);
832 gfx::PointF uv_bottom_right(51.5f, 260.f); 845 gfx::PointF uv_bottom_right(51.5f, 260.f);
833 const float vertex_opacity[] = { 1.0f, 1.0f, 1.0f, 1.0f }; 846 const float vertex_opacity[] = { 1.0f, 1.0f, 1.0f, 1.0f };
834 bool flipped = true; 847 bool flipped = true;
848 bool nearest_neighbor = true;
835 849
836 CREATE_SHARED_STATE(); 850 CREATE_SHARED_STATE();
837 CREATE_QUAD_9_NEW(TextureDrawQuad, 851 CREATE_QUAD_10_NEW(TextureDrawQuad,
838 opaque_rect, 852 opaque_rect,
839 visible_rect, 853 visible_rect,
840 resource_id, 854 resource_id,
841 premultiplied_alpha, 855 premultiplied_alpha,
842 uv_top_left, 856 uv_top_left,
843 uv_bottom_right, 857 uv_bottom_right,
844 SK_ColorTRANSPARENT, 858 SK_ColorTRANSPARENT,
845 vertex_opacity, 859 vertex_opacity,
846 flipped); 860 flipped,
861 nearest_neighbor);
847 EXPECT_EQ(resource_id, quad_new->resource_id); 862 EXPECT_EQ(resource_id, quad_new->resource_id);
848 EXPECT_EQ(1, IterateAndCount(quad_new)); 863 EXPECT_EQ(1, IterateAndCount(quad_new));
849 EXPECT_EQ(resource_id + 1, quad_new->resource_id); 864 EXPECT_EQ(resource_id + 1, quad_new->resource_id);
850 } 865 }
851 866
852 TEST_F(DrawQuadIteratorTest, TileDrawQuad) { 867 TEST_F(DrawQuadIteratorTest, TileDrawQuad) {
853 gfx::Rect opaque_rect(33, 44, 22, 33); 868 gfx::Rect opaque_rect(33, 44, 22, 33);
854 gfx::Rect visible_rect(40, 50, 30, 20); 869 gfx::Rect visible_rect(40, 50, 30, 20);
855 unsigned resource_id = 104; 870 unsigned resource_id = 104;
856 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f); 871 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f);
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 LOG(ERROR) << "YUVVideoDrawQuad " << sizeof(YUVVideoDrawQuad); 1022 LOG(ERROR) << "YUVVideoDrawQuad " << sizeof(YUVVideoDrawQuad);
1008 break; 1023 break;
1009 case DrawQuad::INVALID: 1024 case DrawQuad::INVALID:
1010 break; 1025 break;
1011 } 1026 }
1012 } 1027 }
1013 } 1028 }
1014 1029
1015 } // namespace 1030 } // namespace
1016 } // namespace cc 1031 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/renderer_pixeltest.cc ('k') | cc/quads/texture_draw_quad.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698