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