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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "cc/base/math_util.h" | 8 #include "cc/base/math_util.h" |
9 #include "cc/quads/checkerboard_draw_quad.h" | 9 #include "cc/quads/checkerboard_draw_quad.h" |
10 #include "cc/quads/debug_border_draw_quad.h" | 10 #include "cc/quads/debug_border_draw_quad.h" |
11 #include "cc/quads/io_surface_draw_quad.h" | 11 #include "cc/quads/io_surface_draw_quad.h" |
| 12 #include "cc/quads/picture_draw_quad.h" |
12 #include "cc/quads/render_pass_draw_quad.h" | 13 #include "cc/quads/render_pass_draw_quad.h" |
13 #include "cc/quads/solid_color_draw_quad.h" | 14 #include "cc/quads/solid_color_draw_quad.h" |
14 #include "cc/quads/stream_video_draw_quad.h" | 15 #include "cc/quads/stream_video_draw_quad.h" |
15 #include "cc/quads/texture_draw_quad.h" | 16 #include "cc/quads/texture_draw_quad.h" |
16 #include "cc/quads/tile_draw_quad.h" | 17 #include "cc/quads/tile_draw_quad.h" |
17 #include "cc/quads/yuv_video_draw_quad.h" | 18 #include "cc/quads/yuv_video_draw_quad.h" |
| 19 #include "cc/resources/picture_pile_impl.h" |
18 #include "cc/test/geometry_test_utils.h" | 20 #include "cc/test/geometry_test_utils.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
20 #include "third_party/WebKit/Source/Platform/chromium/public/WebFilterOperations
.h" | 22 #include "third_party/WebKit/Source/Platform/chromium/public/WebFilterOperations
.h" |
21 #include "third_party/skia/include/effects/SkBlurImageFilter.h" | 23 #include "third_party/skia/include/effects/SkBlurImageFilter.h" |
22 #include "ui/gfx/transform.h" | 24 #include "ui/gfx/transform.h" |
23 | 25 |
24 namespace cc { | 26 namespace cc { |
25 namespace { | 27 namespace { |
26 | 28 |
27 TEST(DrawQuadTest, CopySharedQuadState) { | 29 TEST(DrawQuadTest, CopySharedQuadState) { |
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 EXPECT_EQ(y_plane.size, copy_quad->y_plane.size); | 650 EXPECT_EQ(y_plane.size, copy_quad->y_plane.size); |
649 EXPECT_EQ(y_plane.format, copy_quad->y_plane.format); | 651 EXPECT_EQ(y_plane.format, copy_quad->y_plane.format); |
650 EXPECT_EQ(u_plane.resource_id, copy_quad->u_plane.resource_id); | 652 EXPECT_EQ(u_plane.resource_id, copy_quad->u_plane.resource_id); |
651 EXPECT_EQ(u_plane.size, copy_quad->u_plane.size); | 653 EXPECT_EQ(u_plane.size, copy_quad->u_plane.size); |
652 EXPECT_EQ(u_plane.format, copy_quad->u_plane.format); | 654 EXPECT_EQ(u_plane.format, copy_quad->u_plane.format); |
653 EXPECT_EQ(v_plane.resource_id, copy_quad->v_plane.resource_id); | 655 EXPECT_EQ(v_plane.resource_id, copy_quad->v_plane.resource_id); |
654 EXPECT_EQ(v_plane.size, copy_quad->v_plane.size); | 656 EXPECT_EQ(v_plane.size, copy_quad->v_plane.size); |
655 EXPECT_EQ(v_plane.format, copy_quad->v_plane.format); | 657 EXPECT_EQ(v_plane.format, copy_quad->v_plane.format); |
656 } | 658 } |
657 | 659 |
| 660 TEST(DrawQuadTest, CopyPictureDrawQuad) { |
| 661 gfx::Rect opaque_rect(33, 44, 22, 33); |
| 662 unsigned resource_id = 104; |
| 663 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f); |
| 664 gfx::Size texture_size(85, 32); |
| 665 bool swizzle_contents = true; |
| 666 gfx::Rect content_rect(30, 40, 20, 30); |
| 667 float contents_scale = 3.141592f; |
| 668 scoped_refptr<PicturePileImpl> picture_pile = PicturePileImpl::Create(false); |
| 669 CREATE_SHARED_STATE(); |
| 670 |
| 671 CREATE_QUAD_7_NEW(PictureDrawQuad, |
| 672 opaque_rect, |
| 673 tex_coord_rect, |
| 674 texture_size, |
| 675 swizzle_contents, |
| 676 content_rect, |
| 677 contents_scale, |
| 678 picture_pile); |
| 679 EXPECT_EQ(DrawQuad::PICTURE_CONTENT, copy_quad->material); |
| 680 EXPECT_RECT_EQ(opaque_rect, copy_quad->opaque_rect); |
| 681 EXPECT_EQ(tex_coord_rect, copy_quad->tex_coord_rect); |
| 682 EXPECT_EQ(texture_size, copy_quad->texture_size); |
| 683 EXPECT_EQ(swizzle_contents, copy_quad->swizzle_contents); |
| 684 EXPECT_RECT_EQ(content_rect, copy_quad->content_rect); |
| 685 EXPECT_EQ(contents_scale, copy_quad->contents_scale); |
| 686 EXPECT_EQ(picture_pile, copy_quad->picture_pile); |
| 687 |
| 688 CREATE_QUAD_6_ALL(PictureDrawQuad, |
| 689 tex_coord_rect, |
| 690 texture_size, |
| 691 swizzle_contents, |
| 692 content_rect, |
| 693 contents_scale, |
| 694 picture_pile); |
| 695 EXPECT_EQ(DrawQuad::PICTURE_CONTENT, copy_quad->material); |
| 696 EXPECT_EQ(tex_coord_rect, copy_quad->tex_coord_rect); |
| 697 EXPECT_EQ(texture_size, copy_quad->texture_size); |
| 698 EXPECT_EQ(swizzle_contents, copy_quad->swizzle_contents); |
| 699 EXPECT_RECT_EQ(content_rect, copy_quad->content_rect); |
| 700 EXPECT_EQ(contents_scale, copy_quad->contents_scale); |
| 701 EXPECT_EQ(picture_pile, copy_quad->picture_pile); |
| 702 } |
| 703 |
658 class DrawQuadIteratorTest : public testing::Test { | 704 class DrawQuadIteratorTest : public testing::Test { |
659 protected: | 705 protected: |
660 ResourceProvider::ResourceId IncrementResourceId( | 706 ResourceProvider::ResourceId IncrementResourceId( |
661 ResourceProvider::ResourceId id) { | 707 ResourceProvider::ResourceId id) { |
662 ++num_resources_; | 708 ++num_resources_; |
663 return id + 1; | 709 return id + 1; |
664 } | 710 } |
665 | 711 |
666 int IterateAndCount(DrawQuad* quad) { | 712 int IterateAndCount(DrawQuad* quad) { |
667 num_resources_ = 0; | 713 num_resources_ = 0; |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
817 EXPECT_EQ(DrawQuad::YUV_VIDEO_CONTENT, copy_quad->material); | 863 EXPECT_EQ(DrawQuad::YUV_VIDEO_CONTENT, copy_quad->material); |
818 EXPECT_EQ(y_plane.resource_id, quad_new->y_plane.resource_id); | 864 EXPECT_EQ(y_plane.resource_id, quad_new->y_plane.resource_id); |
819 EXPECT_EQ(u_plane.resource_id, quad_new->u_plane.resource_id); | 865 EXPECT_EQ(u_plane.resource_id, quad_new->u_plane.resource_id); |
820 EXPECT_EQ(v_plane.resource_id, quad_new->v_plane.resource_id); | 866 EXPECT_EQ(v_plane.resource_id, quad_new->v_plane.resource_id); |
821 EXPECT_EQ(3, IterateAndCount(quad_new.get())); | 867 EXPECT_EQ(3, IterateAndCount(quad_new.get())); |
822 EXPECT_EQ(y_plane.resource_id + 1, quad_new->y_plane.resource_id); | 868 EXPECT_EQ(y_plane.resource_id + 1, quad_new->y_plane.resource_id); |
823 EXPECT_EQ(u_plane.resource_id + 1, quad_new->u_plane.resource_id); | 869 EXPECT_EQ(u_plane.resource_id + 1, quad_new->u_plane.resource_id); |
824 EXPECT_EQ(v_plane.resource_id + 1, quad_new->v_plane.resource_id); | 870 EXPECT_EQ(v_plane.resource_id + 1, quad_new->v_plane.resource_id); |
825 } | 871 } |
826 | 872 |
| 873 TEST_F(DrawQuadIteratorTest, PictureDrawQuad) { |
| 874 gfx::Rect opaque_rect(33, 44, 22, 33); |
| 875 unsigned resource_id = 104; |
| 876 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f); |
| 877 gfx::Size texture_size(85, 32); |
| 878 bool swizzle_contents = true; |
| 879 gfx::Rect content_rect(30, 40, 20, 30); |
| 880 float contents_scale = 3.141592f; |
| 881 scoped_refptr<PicturePileImpl> picture_pile = PicturePileImpl::Create(false); |
| 882 |
| 883 CREATE_SHARED_STATE(); |
| 884 CREATE_QUAD_7_NEW(PictureDrawQuad, |
| 885 opaque_rect, |
| 886 tex_coord_rect, |
| 887 texture_size, |
| 888 swizzle_contents, |
| 889 content_rect, |
| 890 contents_scale, |
| 891 picture_pile); |
| 892 EXPECT_EQ(0, IterateAndCount(quad_new.get())); |
| 893 } |
| 894 |
827 } // namespace | 895 } // namespace |
828 } // namespace cc | 896 } // namespace cc |
OLD | NEW |