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

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

Issue 789433003: [cc] Add nearest neighbor filtering for PictureLayer. (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/quads/content_draw_quad_base.cc ('k') | cc/quads/picture_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 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 EXPECT_EQ(nearest_neighbor, copy_quad->nearest_neighbor); 593 EXPECT_EQ(nearest_neighbor, copy_quad->nearest_neighbor);
594 } 594 }
595 595
596 TEST(DrawQuadTest, CopyTileDrawQuad) { 596 TEST(DrawQuadTest, CopyTileDrawQuad) {
597 gfx::Rect opaque_rect(33, 44, 22, 33); 597 gfx::Rect opaque_rect(33, 44, 22, 33);
598 gfx::Rect visible_rect(40, 50, 30, 20); 598 gfx::Rect visible_rect(40, 50, 30, 20);
599 unsigned resource_id = 104; 599 unsigned resource_id = 104;
600 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);
601 gfx::Size texture_size(85, 32); 601 gfx::Size texture_size(85, 32);
602 bool swizzle_contents = true; 602 bool swizzle_contents = true;
603 bool nearest_neighbor = true;
603 CREATE_SHARED_STATE(); 604 CREATE_SHARED_STATE();
604 605
605 CREATE_QUAD_6_NEW(TileDrawQuad, 606 CREATE_QUAD_7_NEW(TileDrawQuad,
606 opaque_rect, 607 opaque_rect,
607 visible_rect, 608 visible_rect,
608 resource_id, 609 resource_id,
609 tex_coord_rect, 610 tex_coord_rect,
610 texture_size, 611 texture_size,
611 swizzle_contents); 612 swizzle_contents,
613 nearest_neighbor);
612 EXPECT_EQ(DrawQuad::TILED_CONTENT, copy_quad->material); 614 EXPECT_EQ(DrawQuad::TILED_CONTENT, copy_quad->material);
613 EXPECT_EQ(opaque_rect, copy_quad->opaque_rect); 615 EXPECT_EQ(opaque_rect, copy_quad->opaque_rect);
614 EXPECT_EQ(visible_rect, copy_quad->visible_rect); 616 EXPECT_EQ(visible_rect, copy_quad->visible_rect);
615 EXPECT_EQ(resource_id, copy_quad->resource_id); 617 EXPECT_EQ(resource_id, copy_quad->resource_id);
616 EXPECT_EQ(tex_coord_rect, copy_quad->tex_coord_rect); 618 EXPECT_EQ(tex_coord_rect, copy_quad->tex_coord_rect);
617 EXPECT_EQ(texture_size, copy_quad->texture_size); 619 EXPECT_EQ(texture_size, copy_quad->texture_size);
618 EXPECT_EQ(swizzle_contents, copy_quad->swizzle_contents); 620 EXPECT_EQ(swizzle_contents, copy_quad->swizzle_contents);
621 EXPECT_EQ(nearest_neighbor, copy_quad->nearest_neighbor);
619 622
620 CREATE_QUAD_4_ALL(TileDrawQuad, 623 CREATE_QUAD_5_ALL(TileDrawQuad,
621 resource_id, 624 resource_id,
622 tex_coord_rect, 625 tex_coord_rect,
623 texture_size, 626 texture_size,
624 swizzle_contents); 627 swizzle_contents,
628 nearest_neighbor);
625 EXPECT_EQ(DrawQuad::TILED_CONTENT, copy_quad->material); 629 EXPECT_EQ(DrawQuad::TILED_CONTENT, copy_quad->material);
626 EXPECT_EQ(resource_id, copy_quad->resource_id); 630 EXPECT_EQ(resource_id, copy_quad->resource_id);
627 EXPECT_EQ(tex_coord_rect, copy_quad->tex_coord_rect); 631 EXPECT_EQ(tex_coord_rect, copy_quad->tex_coord_rect);
628 EXPECT_EQ(texture_size, copy_quad->texture_size); 632 EXPECT_EQ(texture_size, copy_quad->texture_size);
629 EXPECT_EQ(swizzle_contents, copy_quad->swizzle_contents); 633 EXPECT_EQ(swizzle_contents, copy_quad->swizzle_contents);
634 EXPECT_EQ(nearest_neighbor, copy_quad->nearest_neighbor);
630 } 635 }
631 636
632 TEST(DrawQuadTest, CopyYUVVideoDrawQuad) { 637 TEST(DrawQuadTest, CopyYUVVideoDrawQuad) {
633 gfx::Rect opaque_rect(33, 47, 10, 12); 638 gfx::Rect opaque_rect(33, 47, 10, 12);
634 gfx::Rect visible_rect(40, 50, 30, 20); 639 gfx::Rect visible_rect(40, 50, 30, 20);
635 gfx::RectF tex_coord_rect(0.0f, 0.0f, 0.75f, 0.5f); 640 gfx::RectF tex_coord_rect(0.0f, 0.0f, 0.75f, 0.5f);
636 ResourceProvider::ResourceId y_plane_resource_id = 45; 641 ResourceProvider::ResourceId y_plane_resource_id = 45;
637 ResourceProvider::ResourceId u_plane_resource_id = 532; 642 ResourceProvider::ResourceId u_plane_resource_id = 532;
638 ResourceProvider::ResourceId v_plane_resource_id = 4; 643 ResourceProvider::ResourceId v_plane_resource_id = 4;
639 ResourceProvider::ResourceId a_plane_resource_id = 63; 644 ResourceProvider::ResourceId a_plane_resource_id = 63;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 EXPECT_EQ(v_plane_resource_id, copy_quad->v_plane_resource_id); 678 EXPECT_EQ(v_plane_resource_id, copy_quad->v_plane_resource_id);
674 EXPECT_EQ(a_plane_resource_id, copy_quad->a_plane_resource_id); 679 EXPECT_EQ(a_plane_resource_id, copy_quad->a_plane_resource_id);
675 EXPECT_EQ(color_space, copy_quad->color_space); 680 EXPECT_EQ(color_space, copy_quad->color_space);
676 } 681 }
677 682
678 TEST(DrawQuadTest, CopyPictureDrawQuad) { 683 TEST(DrawQuadTest, CopyPictureDrawQuad) {
679 gfx::Rect opaque_rect(33, 44, 22, 33); 684 gfx::Rect opaque_rect(33, 44, 22, 33);
680 gfx::Rect visible_rect(40, 50, 30, 20); 685 gfx::Rect visible_rect(40, 50, 30, 20);
681 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f); 686 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f);
682 gfx::Size texture_size(85, 32); 687 gfx::Size texture_size(85, 32);
688 bool nearest_neighbor = true;
683 ResourceFormat texture_format = RGBA_8888; 689 ResourceFormat texture_format = RGBA_8888;
684 gfx::Rect content_rect(30, 40, 20, 30); 690 gfx::Rect content_rect(30, 40, 20, 30);
685 float contents_scale = 3.141592f; 691 float contents_scale = 3.141592f;
686 scoped_refptr<RasterSource> raster_source = PicturePileImpl::Create(); 692 scoped_refptr<RasterSource> raster_source = PicturePileImpl::Create();
687 CREATE_SHARED_STATE(); 693 CREATE_SHARED_STATE();
688 694
689 CREATE_QUAD_8_NEW(PictureDrawQuad, opaque_rect, visible_rect, tex_coord_rect, 695 CREATE_QUAD_9_NEW(PictureDrawQuad, opaque_rect, visible_rect, tex_coord_rect,
690 texture_size, texture_format, content_rect, contents_scale, 696 texture_size, nearest_neighbor, texture_format,
691 raster_source); 697 content_rect, contents_scale, raster_source);
692 EXPECT_EQ(DrawQuad::PICTURE_CONTENT, copy_quad->material); 698 EXPECT_EQ(DrawQuad::PICTURE_CONTENT, copy_quad->material);
693 EXPECT_EQ(opaque_rect, copy_quad->opaque_rect); 699 EXPECT_EQ(opaque_rect, copy_quad->opaque_rect);
694 EXPECT_EQ(visible_rect, copy_quad->visible_rect); 700 EXPECT_EQ(visible_rect, copy_quad->visible_rect);
695 EXPECT_EQ(tex_coord_rect, copy_quad->tex_coord_rect); 701 EXPECT_EQ(tex_coord_rect, copy_quad->tex_coord_rect);
696 EXPECT_EQ(texture_size, copy_quad->texture_size); 702 EXPECT_EQ(texture_size, copy_quad->texture_size);
703 EXPECT_EQ(nearest_neighbor, copy_quad->nearest_neighbor);
697 EXPECT_EQ(texture_format, copy_quad->texture_format); 704 EXPECT_EQ(texture_format, copy_quad->texture_format);
698 EXPECT_EQ(content_rect, copy_quad->content_rect); 705 EXPECT_EQ(content_rect, copy_quad->content_rect);
699 EXPECT_EQ(contents_scale, copy_quad->contents_scale); 706 EXPECT_EQ(contents_scale, copy_quad->contents_scale);
700 EXPECT_EQ(raster_source, copy_quad->raster_source); 707 EXPECT_EQ(raster_source, copy_quad->raster_source);
701 708
702 CREATE_QUAD_6_ALL(PictureDrawQuad, tex_coord_rect, texture_size, 709 CREATE_QUAD_7_ALL(PictureDrawQuad, tex_coord_rect, texture_size,
703 texture_format, content_rect, contents_scale, 710 nearest_neighbor, texture_format, content_rect,
704 raster_source); 711 contents_scale, raster_source);
705 EXPECT_EQ(DrawQuad::PICTURE_CONTENT, copy_quad->material); 712 EXPECT_EQ(DrawQuad::PICTURE_CONTENT, copy_quad->material);
706 EXPECT_EQ(tex_coord_rect, copy_quad->tex_coord_rect); 713 EXPECT_EQ(tex_coord_rect, copy_quad->tex_coord_rect);
707 EXPECT_EQ(texture_size, copy_quad->texture_size); 714 EXPECT_EQ(texture_size, copy_quad->texture_size);
715 EXPECT_EQ(nearest_neighbor, copy_quad->nearest_neighbor);
708 EXPECT_EQ(texture_format, copy_quad->texture_format); 716 EXPECT_EQ(texture_format, copy_quad->texture_format);
709 EXPECT_EQ(content_rect, copy_quad->content_rect); 717 EXPECT_EQ(content_rect, copy_quad->content_rect);
710 EXPECT_EQ(contents_scale, copy_quad->contents_scale); 718 EXPECT_EQ(contents_scale, copy_quad->contents_scale);
711 EXPECT_EQ(raster_source, copy_quad->raster_source); 719 EXPECT_EQ(raster_source, copy_quad->raster_source);
712 } 720 }
713 721
714 class DrawQuadIteratorTest : public testing::Test { 722 class DrawQuadIteratorTest : public testing::Test {
715 protected: 723 protected:
716 ResourceProvider::ResourceId IncrementResourceId( 724 ResourceProvider::ResourceId IncrementResourceId(
717 ResourceProvider::ResourceId id) { 725 ResourceProvider::ResourceId id) {
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 EXPECT_EQ(resource_id + 1, quad_new->resource_id); 872 EXPECT_EQ(resource_id + 1, quad_new->resource_id);
865 } 873 }
866 874
867 TEST_F(DrawQuadIteratorTest, TileDrawQuad) { 875 TEST_F(DrawQuadIteratorTest, TileDrawQuad) {
868 gfx::Rect opaque_rect(33, 44, 22, 33); 876 gfx::Rect opaque_rect(33, 44, 22, 33);
869 gfx::Rect visible_rect(40, 50, 30, 20); 877 gfx::Rect visible_rect(40, 50, 30, 20);
870 unsigned resource_id = 104; 878 unsigned resource_id = 104;
871 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f); 879 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f);
872 gfx::Size texture_size(85, 32); 880 gfx::Size texture_size(85, 32);
873 bool swizzle_contents = true; 881 bool swizzle_contents = true;
882 bool nearest_neighbor = true;
874 883
875 CREATE_SHARED_STATE(); 884 CREATE_SHARED_STATE();
876 CREATE_QUAD_6_NEW(TileDrawQuad, 885 CREATE_QUAD_7_NEW(TileDrawQuad,
877 opaque_rect, 886 opaque_rect,
878 visible_rect, 887 visible_rect,
879 resource_id, 888 resource_id,
880 tex_coord_rect, 889 tex_coord_rect,
881 texture_size, 890 texture_size,
882 swizzle_contents); 891 swizzle_contents,
892 nearest_neighbor);
883 EXPECT_EQ(resource_id, quad_new->resource_id); 893 EXPECT_EQ(resource_id, quad_new->resource_id);
884 EXPECT_EQ(1, IterateAndCount(quad_new)); 894 EXPECT_EQ(1, IterateAndCount(quad_new));
885 EXPECT_EQ(resource_id + 1, quad_new->resource_id); 895 EXPECT_EQ(resource_id + 1, quad_new->resource_id);
886 } 896 }
887 897
888 TEST_F(DrawQuadIteratorTest, YUVVideoDrawQuad) { 898 TEST_F(DrawQuadIteratorTest, YUVVideoDrawQuad) {
889 gfx::Rect opaque_rect(33, 47, 10, 12); 899 gfx::Rect opaque_rect(33, 47, 10, 12);
890 gfx::Rect visible_rect(40, 50, 30, 20); 900 gfx::Rect visible_rect(40, 50, 30, 20);
891 gfx::RectF tex_coord_rect(0.0f, 0.0f, 0.75f, 0.5f); 901 gfx::RectF tex_coord_rect(0.0f, 0.0f, 0.75f, 0.5f);
892 ResourceProvider::ResourceId y_plane_resource_id = 45; 902 ResourceProvider::ResourceId y_plane_resource_id = 45;
(...skipping 24 matching lines...) Expand all
917 EXPECT_EQ(v_plane_resource_id + 1, quad_new->v_plane_resource_id); 927 EXPECT_EQ(v_plane_resource_id + 1, quad_new->v_plane_resource_id);
918 EXPECT_EQ(a_plane_resource_id + 1, quad_new->a_plane_resource_id); 928 EXPECT_EQ(a_plane_resource_id + 1, quad_new->a_plane_resource_id);
919 } 929 }
920 930
921 // Disabled until picture draw quad is supported for ubercomp: crbug.com/231715 931 // Disabled until picture draw quad is supported for ubercomp: crbug.com/231715
922 TEST_F(DrawQuadIteratorTest, DISABLED_PictureDrawQuad) { 932 TEST_F(DrawQuadIteratorTest, DISABLED_PictureDrawQuad) {
923 gfx::Rect opaque_rect(33, 44, 22, 33); 933 gfx::Rect opaque_rect(33, 44, 22, 33);
924 gfx::Rect visible_rect(40, 50, 30, 20); 934 gfx::Rect visible_rect(40, 50, 30, 20);
925 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f); 935 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f);
926 gfx::Size texture_size(85, 32); 936 gfx::Size texture_size(85, 32);
937 bool nearest_neighbor = true;
927 ResourceFormat texture_format = RGBA_8888; 938 ResourceFormat texture_format = RGBA_8888;
928 gfx::Rect content_rect(30, 40, 20, 30); 939 gfx::Rect content_rect(30, 40, 20, 30);
929 float contents_scale = 3.141592f; 940 float contents_scale = 3.141592f;
930 scoped_refptr<PicturePileImpl> raster_source = PicturePileImpl::Create(); 941 scoped_refptr<PicturePileImpl> raster_source = PicturePileImpl::Create();
931 942
932 CREATE_SHARED_STATE(); 943 CREATE_SHARED_STATE();
933 CREATE_QUAD_8_NEW(PictureDrawQuad, opaque_rect, visible_rect, tex_coord_rect, 944 CREATE_QUAD_9_NEW(PictureDrawQuad, opaque_rect, visible_rect, tex_coord_rect,
934 texture_size, texture_format, content_rect, contents_scale, 945 texture_size, nearest_neighbor, texture_format,
935 raster_source); 946 content_rect, contents_scale, raster_source);
936 EXPECT_EQ(0, IterateAndCount(quad_new)); 947 EXPECT_EQ(0, IterateAndCount(quad_new));
937 } 948 }
938 949
939 TEST(DrawQuadTest, LargestQuadType) { 950 TEST(DrawQuadTest, LargestQuadType) {
940 size_t largest = 0; 951 size_t largest = 0;
941 952
942 for (int i = 0; i <= DrawQuad::MATERIAL_LAST; ++i) { 953 for (int i = 0; i <= DrawQuad::MATERIAL_LAST; ++i) {
943 switch (static_cast<DrawQuad::Material>(i)) { 954 switch (static_cast<DrawQuad::Material>(i)) {
944 case DrawQuad::CHECKERBOARD: 955 case DrawQuad::CHECKERBOARD:
945 largest = std::max(largest, sizeof(CheckerboardDrawQuad)); 956 largest = std::max(largest, sizeof(CheckerboardDrawQuad));
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 LOG(ERROR) << "YUVVideoDrawQuad " << sizeof(YUVVideoDrawQuad); 1033 LOG(ERROR) << "YUVVideoDrawQuad " << sizeof(YUVVideoDrawQuad);
1023 break; 1034 break;
1024 case DrawQuad::INVALID: 1035 case DrawQuad::INVALID:
1025 break; 1036 break;
1026 } 1037 }
1027 } 1038 }
1028 } 1039 }
1029 1040
1030 } // namespace 1041 } // namespace
1031 } // namespace cc 1042 } // namespace cc
OLDNEW
« no previous file with comments | « cc/quads/content_draw_quad_base.cc ('k') | cc/quads/picture_draw_quad.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698