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 "base/compiler_specific.h" | |
11 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
12 #include "cc/quads/checkerboard_draw_quad.h" | 11 #include "cc/quads/checkerboard_draw_quad.h" |
13 #include "cc/quads/debug_border_draw_quad.h" | 12 #include "cc/quads/debug_border_draw_quad.h" |
14 #include "cc/quads/io_surface_draw_quad.h" | 13 #include "cc/quads/io_surface_draw_quad.h" |
15 #include "cc/quads/picture_draw_quad.h" | 14 #include "cc/quads/picture_draw_quad.h" |
16 #include "cc/quads/render_pass_draw_quad.h" | 15 #include "cc/quads/render_pass_draw_quad.h" |
17 #include "cc/quads/solid_color_draw_quad.h" | 16 #include "cc/quads/solid_color_draw_quad.h" |
18 #include "cc/quads/stream_video_draw_quad.h" | 17 #include "cc/quads/stream_video_draw_quad.h" |
19 #include "cc/quads/texture_draw_quad.h" | 18 #include "cc/quads/texture_draw_quad.h" |
20 #include "cc/quads/tile_draw_quad.h" | 19 #include "cc/quads/tile_draw_quad.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 EXPECT_EQ(copy_shared_state, copy->shared_quad_state); | 81 EXPECT_EQ(copy_shared_state, copy->shared_quad_state); |
83 } | 82 } |
84 | 83 |
85 #define CREATE_SHARED_STATE() \ | 84 #define CREATE_SHARED_STATE() \ |
86 scoped_ptr<SharedQuadState> shared_state(CreateSharedQuadState()); \ | 85 scoped_ptr<SharedQuadState> shared_state(CreateSharedQuadState()); \ |
87 scoped_ptr<SharedQuadState> copy_shared_state(shared_state->Copy()); \ | 86 scoped_ptr<SharedQuadState> copy_shared_state(shared_state->Copy()); \ |
88 | 87 |
89 #define QUAD_DATA \ | 88 #define QUAD_DATA \ |
90 gfx::Rect quad_rect(30, 40, 50, 60); \ | 89 gfx::Rect quad_rect(30, 40, 50, 60); \ |
91 gfx::Rect quad_visible_rect(40, 50, 30, 20); \ | 90 gfx::Rect quad_visible_rect(40, 50, 30, 20); \ |
92 gfx::Rect ALLOW_UNUSED quad_opaque_rect(60, 55, 10, 10); \ | 91 gfx::Rect quad_opaque_rect(60, 55, 10, 10); \ |
93 bool ALLOW_UNUSED needs_blending = true; | 92 bool needs_blending = true; |
94 | 93 |
95 #define SETUP_AND_COPY_QUAD_NEW(Type, quad) \ | 94 #define SETUP_AND_COPY_QUAD_NEW(Type, quad) \ |
96 scoped_ptr<DrawQuad> copy_new(quad_new->Copy(copy_shared_state.get())); \ | 95 scoped_ptr<DrawQuad> copy_new(quad_new->Copy(copy_shared_state.get())); \ |
97 CompareDrawQuad(quad_new.get(), copy_new.get(), copy_shared_state.get()); \ | 96 CompareDrawQuad(quad_new.get(), copy_new.get(), copy_shared_state.get()); \ |
98 const Type* ALLOW_UNUSED copy_quad = Type::MaterialCast(copy_new.get()); | 97 const Type* copy_quad = Type::MaterialCast(copy_new.get()); |
99 | 98 |
100 #define SETUP_AND_COPY_QUAD_ALL(Type, quad) \ | 99 #define SETUP_AND_COPY_QUAD_ALL(Type, quad) \ |
101 scoped_ptr<DrawQuad> copy_all(quad_all->Copy(copy_shared_state.get())); \ | 100 scoped_ptr<DrawQuad> copy_all(quad_all->Copy(copy_shared_state.get())); \ |
102 CompareDrawQuad(quad_all.get(), copy_all.get(), copy_shared_state.get()); \ | 101 CompareDrawQuad(quad_all.get(), copy_all.get(), copy_shared_state.get()); \ |
103 copy_quad = Type::MaterialCast(copy_all.get()); | 102 copy_quad = Type::MaterialCast(copy_all.get()); |
104 | 103 |
105 #define SETUP_AND_COPY_QUAD_NEW_1(Type, quad, a) \ | 104 #define SETUP_AND_COPY_QUAD_NEW_1(Type, quad, a) \ |
106 scoped_ptr<DrawQuad> copy_new(quad_new->Copy(copy_shared_state.get(), a)); \ | 105 scoped_ptr<DrawQuad> copy_new(quad_new->Copy(copy_shared_state.get(), a)); \ |
107 CompareDrawQuad(quad_new.get(), copy_new.get(), copy_shared_state.get()); \ | 106 CompareDrawQuad(quad_new.get(), copy_new.get(), copy_shared_state.get()); \ |
108 const Type* ALLOW_UNUSED copy_quad = Type::MaterialCast(copy_new.get()); | 107 const Type* copy_quad = Type::MaterialCast(copy_new.get()); |
109 | 108 |
110 #define SETUP_AND_COPY_QUAD_ALL_1(Type, quad, a) \ | 109 #define SETUP_AND_COPY_QUAD_ALL_1(Type, quad, a) \ |
111 scoped_ptr<DrawQuad> copy_all(quad_all->Copy(copy_shared_state.get(), a)); \ | 110 scoped_ptr<DrawQuad> copy_all(quad_all->Copy(copy_shared_state.get(), a)); \ |
112 CompareDrawQuad(quad_all.get(), copy_all.get(), copy_shared_state.get()); \ | 111 CompareDrawQuad(quad_all.get(), copy_all.get(), copy_shared_state.get()); \ |
113 copy_quad = Type::MaterialCast(copy_all.get()); | 112 copy_quad = Type::MaterialCast(copy_all.get()); |
114 | 113 |
115 #define CREATE_QUAD_1_NEW(Type, a) \ | 114 #define CREATE_QUAD_1_NEW(Type, a) \ |
116 scoped_ptr<Type> quad_new(Type::Create()); \ | 115 scoped_ptr<Type> quad_new(Type::Create()); \ |
117 { \ | 116 { \ |
118 QUAD_DATA \ | 117 QUAD_DATA \ |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 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); |
656 EXPECT_EQ(u_plane.size, copy_quad->u_plane.size); | 655 EXPECT_EQ(u_plane.size, copy_quad->u_plane.size); |
657 EXPECT_EQ(u_plane.format, copy_quad->u_plane.format); | 656 EXPECT_EQ(u_plane.format, copy_quad->u_plane.format); |
658 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); |
659 EXPECT_EQ(v_plane.size, copy_quad->v_plane.size); | 658 EXPECT_EQ(v_plane.size, copy_quad->v_plane.size); |
660 EXPECT_EQ(v_plane.format, copy_quad->v_plane.format); | 659 EXPECT_EQ(v_plane.format, copy_quad->v_plane.format); |
661 } | 660 } |
662 | 661 |
663 TEST(DrawQuadTest, CopyPictureDrawQuad) { | 662 TEST(DrawQuadTest, CopyPictureDrawQuad) { |
664 gfx::Rect opaque_rect(33, 44, 22, 33); | 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); | 665 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f); |
666 gfx::Size texture_size(85, 32); | 666 gfx::Size texture_size(85, 32); |
667 bool swizzle_contents = true; | 667 bool swizzle_contents = true; |
668 gfx::Rect content_rect(30, 40, 20, 30); | 668 gfx::Rect content_rect(30, 40, 20, 30); |
669 float contents_scale = 3.141592f; | 669 float contents_scale = 3.141592f; |
670 scoped_refptr<PicturePileImpl> picture_pile = PicturePileImpl::Create(false); | 670 scoped_refptr<PicturePileImpl> picture_pile = PicturePileImpl::Create(false); |
671 CREATE_SHARED_STATE(); | 671 CREATE_SHARED_STATE(); |
672 | 672 |
673 CREATE_QUAD_7_NEW(PictureDrawQuad, | 673 CREATE_QUAD_7_NEW(PictureDrawQuad, |
674 opaque_rect, | 674 opaque_rect, |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 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); |
868 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); |
869 EXPECT_EQ(3, IterateAndCount(quad_new.get())); | 869 EXPECT_EQ(3, IterateAndCount(quad_new.get())); |
870 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); |
871 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); |
872 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); |
873 } | 873 } |
874 | 874 |
875 TEST_F(DrawQuadIteratorTest, PictureDrawQuad) { | 875 TEST_F(DrawQuadIteratorTest, PictureDrawQuad) { |
876 gfx::Rect opaque_rect(33, 44, 22, 33); | 876 gfx::Rect opaque_rect(33, 44, 22, 33); |
| 877 unsigned resource_id = 104; |
877 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f); | 878 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f); |
878 gfx::Size texture_size(85, 32); | 879 gfx::Size texture_size(85, 32); |
879 bool swizzle_contents = true; | 880 bool swizzle_contents = true; |
880 gfx::Rect content_rect(30, 40, 20, 30); | 881 gfx::Rect content_rect(30, 40, 20, 30); |
881 float contents_scale = 3.141592f; | 882 float contents_scale = 3.141592f; |
882 scoped_refptr<PicturePileImpl> picture_pile = PicturePileImpl::Create(false); | 883 scoped_refptr<PicturePileImpl> picture_pile = PicturePileImpl::Create(false); |
883 | 884 |
884 CREATE_SHARED_STATE(); | 885 CREATE_SHARED_STATE(); |
885 CREATE_QUAD_7_NEW(PictureDrawQuad, | 886 CREATE_QUAD_7_NEW(PictureDrawQuad, |
886 opaque_rect, | 887 opaque_rect, |
887 tex_coord_rect, | 888 tex_coord_rect, |
888 texture_size, | 889 texture_size, |
889 swizzle_contents, | 890 swizzle_contents, |
890 content_rect, | 891 content_rect, |
891 contents_scale, | 892 contents_scale, |
892 picture_pile); | 893 picture_pile); |
893 EXPECT_EQ(0, IterateAndCount(quad_new.get())); | 894 EXPECT_EQ(0, IterateAndCount(quad_new.get())); |
894 } | 895 } |
895 | 896 |
896 } // namespace | 897 } // namespace |
897 } // namespace cc | 898 } // namespace cc |
OLD | NEW |