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