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 "base/compiler_specific.h" |
11 #include "cc/base/math_util.h" | 11 #include "cc/base/math_util.h" |
12 #include "cc/output/filter_operations.h" | 12 #include "cc/output/filter_operations.h" |
13 #include "cc/quads/checkerboard_draw_quad.h" | 13 #include "cc/quads/checkerboard_draw_quad.h" |
14 #include "cc/quads/debug_border_draw_quad.h" | 14 #include "cc/quads/debug_border_draw_quad.h" |
15 #include "cc/quads/io_surface_draw_quad.h" | 15 #include "cc/quads/io_surface_draw_quad.h" |
16 #include "cc/quads/picture_draw_quad.h" | 16 #include "cc/quads/picture_draw_quad.h" |
| 17 #include "cc/quads/render_pass.h" |
17 #include "cc/quads/render_pass_draw_quad.h" | 18 #include "cc/quads/render_pass_draw_quad.h" |
18 #include "cc/quads/solid_color_draw_quad.h" | 19 #include "cc/quads/solid_color_draw_quad.h" |
19 #include "cc/quads/stream_video_draw_quad.h" | 20 #include "cc/quads/stream_video_draw_quad.h" |
20 #include "cc/quads/surface_draw_quad.h" | 21 #include "cc/quads/surface_draw_quad.h" |
21 #include "cc/quads/texture_draw_quad.h" | 22 #include "cc/quads/texture_draw_quad.h" |
22 #include "cc/quads/tile_draw_quad.h" | 23 #include "cc/quads/tile_draw_quad.h" |
23 #include "cc/quads/yuv_video_draw_quad.h" | 24 #include "cc/quads/yuv_video_draw_quad.h" |
24 #include "cc/resources/picture_pile_impl.h" | 25 #include "cc/resources/picture_pile_impl.h" |
25 #include "cc/test/geometry_test_utils.h" | 26 #include "cc/test/geometry_test_utils.h" |
26 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 26 matching lines...) Expand all Loading... |
53 scoped_ptr<SharedQuadState> copy(new SharedQuadState); | 54 scoped_ptr<SharedQuadState> copy(new SharedQuadState); |
54 copy->CopyFrom(state.get()); | 55 copy->CopyFrom(state.get()); |
55 EXPECT_EQ(quad_transform, copy->content_to_target_transform); | 56 EXPECT_EQ(quad_transform, copy->content_to_target_transform); |
56 EXPECT_RECT_EQ(visible_content_rect, copy->visible_content_rect); | 57 EXPECT_RECT_EQ(visible_content_rect, copy->visible_content_rect); |
57 EXPECT_EQ(opacity, copy->opacity); | 58 EXPECT_EQ(opacity, copy->opacity); |
58 EXPECT_RECT_EQ(clip_rect, copy->clip_rect); | 59 EXPECT_RECT_EQ(clip_rect, copy->clip_rect); |
59 EXPECT_EQ(is_clipped, copy->is_clipped); | 60 EXPECT_EQ(is_clipped, copy->is_clipped); |
60 EXPECT_EQ(blend_mode, copy->blend_mode); | 61 EXPECT_EQ(blend_mode, copy->blend_mode); |
61 } | 62 } |
62 | 63 |
63 scoped_ptr<SharedQuadState> CreateSharedQuadState() { | 64 SharedQuadState* CreateSharedQuadState(RenderPass* render_pass) { |
64 gfx::Transform quad_transform = gfx::Transform(1.0, 0.0, 0.5, 1.0, 0.5, 0.0); | 65 gfx::Transform quad_transform = gfx::Transform(1.0, 0.0, 0.5, 1.0, 0.5, 0.0); |
65 gfx::Size content_bounds(26, 28); | 66 gfx::Size content_bounds(26, 28); |
66 gfx::Rect visible_content_rect(10, 12, 14, 16); | 67 gfx::Rect visible_content_rect(10, 12, 14, 16); |
67 gfx::Rect clip_rect(19, 21, 23, 25); | 68 gfx::Rect clip_rect(19, 21, 23, 25); |
68 bool is_clipped = false; | 69 bool is_clipped = false; |
69 float opacity = 1.f; | 70 float opacity = 1.f; |
70 int sorting_context_id = 65536; | 71 int sorting_context_id = 65536; |
71 SkXfermode::Mode blend_mode = SkXfermode::kSrcOver_Mode; | 72 SkXfermode::Mode blend_mode = SkXfermode::kSrcOver_Mode; |
72 | 73 |
73 scoped_ptr<SharedQuadState> state(new SharedQuadState); | 74 SharedQuadState* state = render_pass->CreateAndAppendSharedQuadState(); |
74 state->SetAll(quad_transform, | 75 state->SetAll(quad_transform, |
75 content_bounds, | 76 content_bounds, |
76 visible_content_rect, | 77 visible_content_rect, |
77 clip_rect, | 78 clip_rect, |
78 is_clipped, | 79 is_clipped, |
79 opacity, | 80 opacity, |
80 blend_mode, | 81 blend_mode, |
81 sorting_context_id); | 82 sorting_context_id); |
82 return state.Pass(); | 83 return state; |
83 } | 84 } |
84 | 85 |
85 void CompareDrawQuad(DrawQuad* quad, | 86 void CompareDrawQuad(DrawQuad* quad, |
86 DrawQuad* copy, | 87 DrawQuad* copy, |
87 SharedQuadState* copy_shared_state) { | 88 SharedQuadState* copy_shared_state) { |
88 EXPECT_EQ(quad->material, copy->material); | 89 EXPECT_EQ(quad->material, copy->material); |
89 EXPECT_RECT_EQ(quad->rect, copy->rect); | 90 EXPECT_RECT_EQ(quad->rect, copy->rect); |
90 EXPECT_RECT_EQ(quad->visible_rect, copy->visible_rect); | 91 EXPECT_RECT_EQ(quad->visible_rect, copy->visible_rect); |
91 EXPECT_RECT_EQ(quad->opaque_rect, copy->opaque_rect); | 92 EXPECT_RECT_EQ(quad->opaque_rect, copy->opaque_rect); |
92 EXPECT_EQ(quad->needs_blending, copy->needs_blending); | 93 EXPECT_EQ(quad->needs_blending, copy->needs_blending); |
93 EXPECT_EQ(copy_shared_state, copy->shared_quad_state); | 94 EXPECT_EQ(copy_shared_state, copy->shared_quad_state); |
94 } | 95 } |
95 | 96 |
96 #define CREATE_SHARED_STATE() \ | 97 #define CREATE_SHARED_STATE() \ |
97 scoped_ptr<SharedQuadState> shared_state(CreateSharedQuadState()); \ | 98 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); \ |
98 scoped_ptr<SharedQuadState> copy_shared_state(new SharedQuadState); \ | 99 SharedQuadState* shared_state(CreateSharedQuadState(render_pass.get())); \ |
99 copy_shared_state->CopyFrom(shared_state.get()); | 100 SharedQuadState* copy_shared_state = \ |
| 101 render_pass->CreateAndAppendSharedQuadState(); \ |
| 102 copy_shared_state->CopyFrom(shared_state); |
100 | 103 |
101 #define QUAD_DATA \ | 104 #define QUAD_DATA \ |
102 gfx::Rect quad_rect(30, 40, 50, 60); \ | 105 gfx::Rect quad_rect(30, 40, 50, 60); \ |
103 gfx::Rect quad_visible_rect(40, 50, 30, 20); \ | 106 gfx::Rect quad_visible_rect(40, 50, 30, 20); \ |
104 gfx::Rect ALLOW_UNUSED quad_opaque_rect(60, 55, 10, 10); \ | 107 gfx::Rect ALLOW_UNUSED quad_opaque_rect(60, 55, 10, 10); \ |
105 bool ALLOW_UNUSED needs_blending = true; | 108 bool ALLOW_UNUSED needs_blending = true; |
106 | 109 |
107 #define SETUP_AND_COPY_QUAD_NEW(Type, quad) \ | 110 #define SETUP_AND_COPY_QUAD_NEW(Type, quad) \ |
108 scoped_ptr<DrawQuad> copy_new(quad_new->Copy(copy_shared_state.get())); \ | 111 DrawQuad* copy_new = \ |
109 CompareDrawQuad(quad_new.get(), copy_new.get(), copy_shared_state.get()); \ | 112 render_pass->CopyFromAndAppendDrawQuad(quad_new, copy_shared_state); \ |
110 const Type* ALLOW_UNUSED copy_quad = Type::MaterialCast(copy_new.get()); | 113 CompareDrawQuad(quad_new, copy_new, copy_shared_state); \ |
111 | 114 const Type* ALLOW_UNUSED copy_quad = Type::MaterialCast(copy_new); |
112 #define SETUP_AND_COPY_QUAD_ALL(Type, quad) \ | 115 |
113 scoped_ptr<DrawQuad> copy_all(quad_all->Copy(copy_shared_state.get())); \ | 116 #define SETUP_AND_COPY_QUAD_ALL(Type, quad) \ |
114 CompareDrawQuad(quad_all.get(), copy_all.get(), copy_shared_state.get()); \ | 117 DrawQuad* copy_all = \ |
115 copy_quad = Type::MaterialCast(copy_all.get()); | 118 render_pass->CopyFromAndAppendDrawQuad(quad_all, copy_shared_state); \ |
116 | 119 CompareDrawQuad(quad_all, copy_all, copy_shared_state); \ |
117 #define SETUP_AND_COPY_QUAD_NEW_1(Type, quad, a) \ | 120 copy_quad = Type::MaterialCast(copy_all); |
118 scoped_ptr<DrawQuad> copy_new(quad_new->Copy(copy_shared_state.get(), a)); \ | 121 |
119 CompareDrawQuad(quad_new.get(), copy_new.get(), copy_shared_state.get()); \ | 122 #define SETUP_AND_COPY_QUAD_NEW_RP(Type, quad, a) \ |
120 const Type* ALLOW_UNUSED copy_quad = Type::MaterialCast(copy_new.get()); | 123 DrawQuad* copy_new = render_pass->CopyFromAndAppendRenderPassDrawQuad( \ |
121 | 124 quad_new, copy_shared_state, a); \ |
122 #define SETUP_AND_COPY_QUAD_ALL_1(Type, quad, a) \ | 125 CompareDrawQuad(quad_new, copy_new, copy_shared_state); \ |
123 scoped_ptr<DrawQuad> copy_all(quad_all->Copy(copy_shared_state.get(), a)); \ | 126 const Type* ALLOW_UNUSED copy_quad = Type::MaterialCast(copy_new); |
124 CompareDrawQuad(quad_all.get(), copy_all.get(), copy_shared_state.get()); \ | 127 |
125 copy_quad = Type::MaterialCast(copy_all.get()); | 128 #define SETUP_AND_COPY_QUAD_ALL_RP(Type, quad, a) \ |
126 | 129 DrawQuad* copy_all = render_pass->CopyFromAndAppendRenderPassDrawQuad( \ |
127 #define CREATE_QUAD_1_NEW(Type, a) \ | 130 quad_all, copy_shared_state, a); \ |
128 scoped_ptr<Type> quad_new(Type::Create()); \ | 131 CompareDrawQuad(quad_all, copy_all, copy_shared_state); \ |
129 { \ | 132 copy_quad = Type::MaterialCast(copy_all); |
130 QUAD_DATA \ | 133 |
131 quad_new->SetNew(shared_state.get(), quad_rect, a); \ | 134 #define CREATE_QUAD_1_NEW(Type, a) \ |
132 } \ | 135 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \ |
133 SETUP_AND_COPY_QUAD_NEW(Type, quad_new); | 136 { QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a); } \ |
134 | 137 SETUP_AND_COPY_QUAD_NEW(Type, quad_new); |
135 #define CREATE_QUAD_1_ALL(Type, a) \ | 138 |
136 scoped_ptr<Type> quad_all(Type::Create()); \ | 139 #define CREATE_QUAD_1_ALL(Type, a) \ |
137 { \ | 140 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \ |
138 QUAD_DATA \ | 141 { \ |
139 quad_all->SetAll(shared_state.get(), quad_rect, quad_opaque_rect, \ | 142 QUAD_DATA quad_all->SetAll(shared_state, \ |
140 quad_visible_rect, needs_blending, a); \ | 143 quad_rect, \ |
141 } \ | 144 quad_opaque_rect, \ |
142 SETUP_AND_COPY_QUAD_ALL(Type, quad_all); | 145 quad_visible_rect, \ |
143 | 146 needs_blending, \ |
144 #define CREATE_QUAD_2_NEW(Type, a, b) \ | 147 a); \ |
145 scoped_ptr<Type> quad_new(Type::Create()); \ | 148 } \ |
146 { \ | 149 SETUP_AND_COPY_QUAD_ALL(Type, quad_all); |
147 QUAD_DATA \ | 150 |
148 quad_new->SetNew(shared_state.get(), quad_rect, a, b); \ | 151 #define CREATE_QUAD_2_NEW(Type, a, b) \ |
149 } \ | 152 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \ |
150 SETUP_AND_COPY_QUAD_NEW(Type, quad_new); | 153 { QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a, b); } \ |
151 | 154 SETUP_AND_COPY_QUAD_NEW(Type, quad_new); |
152 #define CREATE_QUAD_2_ALL(Type, a, b) \ | 155 |
153 scoped_ptr<Type> quad_all(Type::Create()); \ | 156 #define CREATE_QUAD_2_ALL(Type, a, b) \ |
154 { \ | 157 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \ |
155 QUAD_DATA \ | 158 { \ |
156 quad_all->SetAll(shared_state.get(), quad_rect, quad_opaque_rect, \ | 159 QUAD_DATA quad_all->SetAll(shared_state, \ |
157 quad_visible_rect, needs_blending, a, b); \ | 160 quad_rect, \ |
158 } \ | 161 quad_opaque_rect, \ |
159 SETUP_AND_COPY_QUAD_ALL(Type, quad_all); | 162 quad_visible_rect, \ |
160 | 163 needs_blending, \ |
161 #define CREATE_QUAD_3_NEW(Type, a, b, c) \ | 164 a, \ |
162 scoped_ptr<Type> quad_new(Type::Create()); \ | 165 b); \ |
163 { \ | 166 } \ |
164 QUAD_DATA \ | 167 SETUP_AND_COPY_QUAD_ALL(Type, quad_all); |
165 quad_new->SetNew(shared_state.get(), quad_rect, a, b, c); \ | 168 |
166 } \ | 169 #define CREATE_QUAD_3_NEW(Type, a, b, c) \ |
167 SETUP_AND_COPY_QUAD_NEW(Type, quad_new); | 170 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \ |
168 | 171 { QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a, b, c); } \ |
169 #define CREATE_QUAD_3_ALL(Type, a, b, c) \ | 172 SETUP_AND_COPY_QUAD_NEW(Type, quad_new); |
170 scoped_ptr<Type> quad_all(Type::Create()); \ | 173 |
171 { \ | 174 #define CREATE_QUAD_3_ALL(Type, a, b, c) \ |
172 QUAD_DATA \ | 175 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \ |
173 quad_all->SetAll(shared_state.get(), quad_rect, quad_opaque_rect, \ | 176 { \ |
174 quad_visible_rect, needs_blending, a, b, c); \ | 177 QUAD_DATA quad_all->SetAll(shared_state, \ |
175 } \ | 178 quad_rect, \ |
176 SETUP_AND_COPY_QUAD_ALL(Type, quad_all); | 179 quad_opaque_rect, \ |
177 | 180 quad_visible_rect, \ |
178 #define CREATE_QUAD_4_NEW(Type, a, b, c, d) \ | 181 needs_blending, \ |
179 scoped_ptr<Type> quad_new(Type::Create()); \ | 182 a, \ |
180 { \ | 183 b, \ |
181 QUAD_DATA \ | 184 c); \ |
182 quad_new->SetNew(shared_state.get(), quad_rect, a, b, c, d); \ | 185 } \ |
183 } \ | 186 SETUP_AND_COPY_QUAD_ALL(Type, quad_all); |
184 SETUP_AND_COPY_QUAD_NEW(Type, quad_new); | 187 |
185 | 188 #define CREATE_QUAD_4_NEW(Type, a, b, c, d) \ |
186 #define CREATE_QUAD_4_ALL(Type, a, b, c, d) \ | 189 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \ |
187 scoped_ptr<Type> quad_all(Type::Create()); \ | 190 { QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a, b, c, d); } \ |
188 { \ | 191 SETUP_AND_COPY_QUAD_NEW(Type, quad_new); |
189 QUAD_DATA \ | 192 |
190 quad_all->SetAll(shared_state.get(), quad_rect, quad_opaque_rect, \ | 193 #define CREATE_QUAD_4_ALL(Type, a, b, c, d) \ |
191 quad_visible_rect, needs_blending, a, b, c, d); \ | 194 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \ |
192 } \ | 195 { \ |
193 SETUP_AND_COPY_QUAD_ALL(Type, quad_all); | 196 QUAD_DATA quad_all->SetAll(shared_state, \ |
194 | 197 quad_rect, \ |
195 #define CREATE_QUAD_5_NEW(Type, a, b, c, d, e) \ | 198 quad_opaque_rect, \ |
196 scoped_ptr<Type> quad_new(Type::Create()); \ | 199 quad_visible_rect, \ |
197 { \ | 200 needs_blending, \ |
198 QUAD_DATA \ | 201 a, \ |
199 quad_new->SetNew(shared_state.get(), quad_rect, a, b, c, d, e); \ | 202 b, \ |
200 } \ | 203 c, \ |
201 SETUP_AND_COPY_QUAD_NEW(Type, quad_new); | 204 d); \ |
202 | 205 } \ |
203 #define CREATE_QUAD_5_ALL(Type, a, b, c, d, e) \ | 206 SETUP_AND_COPY_QUAD_ALL(Type, quad_all); |
204 scoped_ptr<Type> quad_all(Type::Create()); \ | 207 |
205 { \ | 208 #define CREATE_QUAD_5_NEW(Type, a, b, c, d, e) \ |
206 QUAD_DATA \ | 209 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \ |
207 quad_all->SetAll(shared_state.get(), quad_rect, quad_opaque_rect, \ | 210 { QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a, b, c, d, e); } \ |
208 quad_visible_rect, needs_blending, a, b, c, d, e); \ | 211 SETUP_AND_COPY_QUAD_NEW(Type, quad_new); |
209 } \ | 212 |
210 SETUP_AND_COPY_QUAD_ALL(Type, quad_all); | 213 #define CREATE_QUAD_5_ALL(Type, a, b, c, d, e) \ |
211 | 214 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \ |
212 #define CREATE_QUAD_5_NEW_1(Type, a, b, c, d, e, copy_a) \ | 215 { \ |
213 scoped_ptr<Type> quad_new(Type::Create()); \ | 216 QUAD_DATA quad_all->SetAll(shared_state, \ |
214 { \ | 217 quad_rect, \ |
215 QUAD_DATA \ | 218 quad_opaque_rect, \ |
216 quad_new->SetNew(shared_state.get(), quad_rect, a, b, c, d, e); \ | 219 quad_visible_rect, \ |
217 } \ | 220 needs_blending, \ |
218 SETUP_AND_COPY_QUAD_NEW_1(Type, quad_new, copy_a); | 221 a, \ |
219 | 222 b, \ |
220 #define CREATE_QUAD_5_ALL_1(Type, a, b, c, d, e, copy_a) \ | 223 c, \ |
221 scoped_ptr<Type> quad_all(Type::Create()); \ | 224 d, \ |
222 { \ | 225 e); \ |
223 QUAD_DATA \ | 226 } \ |
224 quad_all->SetAll(shared_state.get(), quad_rect, quad_opaque_rect, \ | 227 SETUP_AND_COPY_QUAD_ALL(Type, quad_all); |
225 quad_visible_rect, needs_blending, a, b, c, d, e); \ | 228 |
226 } \ | 229 #define CREATE_QUAD_5_NEW_RP(Type, a, b, c, d, e, copy_a) \ |
227 SETUP_AND_COPY_QUAD_ALL_1(Type, quad_all, copy_a); | 230 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \ |
228 | 231 { QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a, b, c, d, e); } \ |
229 #define CREATE_QUAD_6_NEW(Type, a, b, c, d, e, f) \ | 232 SETUP_AND_COPY_QUAD_NEW_RP(Type, quad_new, copy_a); |
230 scoped_ptr<Type> quad_new(Type::Create()); \ | 233 |
231 { \ | 234 #define CREATE_QUAD_5_ALL_RP(Type, a, b, c, d, e, copy_a) \ |
232 QUAD_DATA \ | 235 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \ |
233 quad_new->SetNew(shared_state.get(), quad_rect, a, b, c, d, e, f); \ | 236 { \ |
234 } \ | 237 QUAD_DATA quad_all->SetAll(shared_state, \ |
235 SETUP_AND_COPY_QUAD_NEW(Type, quad_new); | 238 quad_rect, \ |
236 | 239 quad_opaque_rect, \ |
237 #define CREATE_QUAD_6_ALL(Type, a, b, c, d, e, f) \ | 240 quad_visible_rect, \ |
238 scoped_ptr<Type> quad_all(Type::Create()); \ | 241 needs_blending, \ |
239 { \ | 242 a, \ |
240 QUAD_DATA \ | 243 b, \ |
241 quad_all->SetAll(shared_state.get(), quad_rect, quad_opaque_rect, \ | 244 c, \ |
242 quad_visible_rect, needs_blending, a, b, c, d, e, f); \ | 245 d, \ |
243 } \ | 246 e); \ |
244 SETUP_AND_COPY_QUAD_ALL(Type, quad_all); | 247 } \ |
245 | 248 SETUP_AND_COPY_QUAD_ALL_RP(Type, quad_all, copy_a); |
246 #define CREATE_QUAD_7_NEW(Type, a, b, c, d, e, f, g) \ | 249 |
247 scoped_ptr<Type> quad_new(Type::Create()); \ | 250 #define CREATE_QUAD_6_NEW(Type, a, b, c, d, e, f) \ |
248 { \ | 251 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \ |
249 QUAD_DATA \ | 252 { QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a, b, c, d, e, f); } \ |
250 quad_new->SetNew(shared_state.get(), quad_rect, a, b, c, d, e, f, g); \ | 253 SETUP_AND_COPY_QUAD_NEW(Type, quad_new); |
251 } \ | 254 |
252 SETUP_AND_COPY_QUAD_NEW(Type, quad_new); | 255 #define CREATE_QUAD_6_ALL(Type, a, b, c, d, e, f) \ |
253 | 256 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \ |
254 #define CREATE_QUAD_7_ALL(Type, a, b, c, d, e, f, g) \ | 257 { \ |
255 scoped_ptr<Type> quad_all(Type::Create()); \ | 258 QUAD_DATA quad_all->SetAll(shared_state, \ |
256 { \ | 259 quad_rect, \ |
257 QUAD_DATA \ | 260 quad_opaque_rect, \ |
258 quad_all->SetAll(shared_state.get(), quad_rect, quad_opaque_rect, \ | 261 quad_visible_rect, \ |
259 quad_visible_rect, needs_blending, \ | 262 needs_blending, \ |
260 a, b, c, d, e, f, g); \ | 263 a, \ |
261 } \ | 264 b, \ |
262 SETUP_AND_COPY_QUAD_ALL(Type, quad_all); | 265 c, \ |
263 | 266 d, \ |
264 #define CREATE_QUAD_7_NEW_1(Type, a, b, c, d, e, f, g, copy_a) \ | 267 e, \ |
265 scoped_ptr<Type> quad_new(Type::Create()); \ | 268 f); \ |
266 { \ | 269 } \ |
267 QUAD_DATA \ | 270 SETUP_AND_COPY_QUAD_ALL(Type, quad_all); |
268 quad_new->SetNew(shared_state.get(), quad_rect, a, b, c, d, e, f, g); \ | 271 |
269 } \ | 272 #define CREATE_QUAD_7_NEW(Type, a, b, c, d, e, f, g) \ |
270 SETUP_AND_COPY_QUAD_NEW_1(Type, quad_new, copy_a); | 273 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \ |
271 | 274 { \ |
272 #define CREATE_QUAD_7_ALL_1(Type, a, b, c, d, e, f, g, copy_a) \ | 275 QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a, b, c, d, e, f, g); \ |
273 scoped_ptr<Type> quad_all(Type::Create()); \ | 276 } \ |
274 { \ | 277 SETUP_AND_COPY_QUAD_NEW(Type, quad_new); |
275 QUAD_DATA \ | 278 |
276 quad_all->SetAll(shared_state.get(), quad_rect, quad_opaque_rect, \ | 279 #define CREATE_QUAD_7_ALL(Type, a, b, c, d, e, f, g) \ |
277 quad_visible_rect, needs_blending, \ | 280 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \ |
278 a, b, c, d, e, f, g); \ | 281 { \ |
279 } \ | 282 QUAD_DATA quad_all->SetAll(shared_state, \ |
280 SETUP_AND_COPY_QUAD_ALL_1(Type, quad_all, copy_a); | 283 quad_rect, \ |
281 | 284 quad_opaque_rect, \ |
282 #define CREATE_QUAD_8_NEW(Type, a, b, c, d, e, f, g, h) \ | 285 quad_visible_rect, \ |
283 scoped_ptr<Type> quad_new(Type::Create()); \ | 286 needs_blending, \ |
284 { \ | 287 a, \ |
285 QUAD_DATA \ | 288 b, \ |
286 quad_new->SetNew(shared_state.get(), quad_rect, a, b, c, d, e, f, g, h); \ | 289 c, \ |
287 } \ | 290 d, \ |
288 SETUP_AND_COPY_QUAD_NEW(Type, quad_new); | 291 e, \ |
289 | 292 f, \ |
290 #define CREATE_QUAD_8_ALL(Type, a, b, c, d, e, f, g, h) \ | 293 g); \ |
291 scoped_ptr<Type> quad_all(Type::Create()); \ | 294 } \ |
292 { \ | 295 SETUP_AND_COPY_QUAD_ALL(Type, quad_all); |
293 QUAD_DATA \ | 296 |
294 quad_all->SetAll(shared_state.get(), quad_rect, quad_opaque_rect, \ | 297 #define CREATE_QUAD_7_NEW_RP(Type, a, b, c, d, e, f, g, copy_a) \ |
295 quad_visible_rect, needs_blending, \ | 298 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \ |
296 a, b, c, d, e, f, g, h); \ | 299 { \ |
297 } \ | 300 QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a, b, c, d, e, f, g); \ |
298 SETUP_AND_COPY_QUAD_ALL(Type, quad_all); | 301 } \ |
299 | 302 SETUP_AND_COPY_QUAD_NEW_RP(Type, quad_new, copy_a); |
300 #define CREATE_QUAD_8_NEW_1(Type, a, b, c, d, e, f, g, h, copy_a) \ | 303 |
301 scoped_ptr<Type> quad_new(Type::Create()); \ | 304 #define CREATE_QUAD_7_ALL_RP(Type, a, b, c, d, e, f, g, copy_a) \ |
302 { \ | 305 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \ |
303 QUAD_DATA \ | 306 { \ |
304 quad_new->SetNew(shared_state.get(), quad_rect, a, b, c, d, e, f, g, h); \ | 307 QUAD_DATA quad_all->SetAll(shared_state, \ |
305 } \ | 308 quad_rect, \ |
306 SETUP_AND_COPY_QUAD_NEW_1(Type, quad_new, copy_a); | 309 quad_opaque_rect, \ |
307 | 310 quad_visible_rect, \ |
308 #define CREATE_QUAD_8_ALL_1(Type, a, b, c, d, e, f, g, h, copy_a) \ | 311 needs_blending, \ |
309 scoped_ptr<Type> quad_all(Type::Create()); \ | 312 a, \ |
310 { \ | 313 b, \ |
311 QUAD_DATA \ | 314 c, \ |
312 quad_all->SetAll(shared_state.get(), quad_rect, quad_opaque_rect, \ | 315 d, \ |
313 quad_visible_rect, needs_blending, \ | 316 e, \ |
314 a, b, c, d, e, f, g, h); \ | 317 f, \ |
315 } \ | 318 g); \ |
316 SETUP_AND_COPY_QUAD_ALL_1(Type, quad_all, copy_a); | 319 } \ |
317 | 320 SETUP_AND_COPY_QUAD_ALL_RP(Type, quad_all, copy_a); |
318 #define CREATE_QUAD_9_NEW(Type, a, b, c, d, e, f, g, h, i) \ | 321 |
319 scoped_ptr<Type> quad_new(Type::Create()); \ | 322 #define CREATE_QUAD_8_NEW(Type, a, b, c, d, e, f, g, h) \ |
320 { \ | 323 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \ |
321 QUAD_DATA \ | 324 { \ |
322 quad_new->SetNew(shared_state.get(), quad_rect, \ | 325 QUAD_DATA quad_new->SetNew( \ |
323 a, b, c, d, e, f, g, h, i); \ | 326 shared_state, quad_rect, a, b, c, d, e, f, g, h); \ |
324 } \ | 327 } \ |
325 SETUP_AND_COPY_QUAD_NEW(Type, quad_new); | 328 SETUP_AND_COPY_QUAD_NEW(Type, quad_new); |
| 329 |
| 330 #define CREATE_QUAD_8_ALL(Type, a, b, c, d, e, f, g, h) \ |
| 331 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \ |
| 332 { \ |
| 333 QUAD_DATA quad_all->SetAll(shared_state, \ |
| 334 quad_rect, \ |
| 335 quad_opaque_rect, \ |
| 336 quad_visible_rect, \ |
| 337 needs_blending, \ |
| 338 a, \ |
| 339 b, \ |
| 340 c, \ |
| 341 d, \ |
| 342 e, \ |
| 343 f, \ |
| 344 g, \ |
| 345 h); \ |
| 346 } \ |
| 347 SETUP_AND_COPY_QUAD_ALL(Type, quad_all); |
| 348 |
| 349 #define CREATE_QUAD_8_NEW_RP(Type, a, b, c, d, e, f, g, h, copy_a) \ |
| 350 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \ |
| 351 { \ |
| 352 QUAD_DATA quad_new->SetNew( \ |
| 353 shared_state, quad_rect, a, b, c, d, e, f, g, h); \ |
| 354 } \ |
| 355 SETUP_AND_COPY_QUAD_NEW_RP(Type, quad_new, copy_a); |
| 356 |
| 357 #define CREATE_QUAD_8_ALL_RP(Type, a, b, c, d, e, f, g, h, copy_a) \ |
| 358 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \ |
| 359 { \ |
| 360 QUAD_DATA quad_all->SetAll(shared_state, \ |
| 361 quad_rect, \ |
| 362 quad_opaque_rect, \ |
| 363 quad_visible_rect, \ |
| 364 needs_blending, \ |
| 365 a, \ |
| 366 b, \ |
| 367 c, \ |
| 368 d, \ |
| 369 e, \ |
| 370 f, \ |
| 371 g, \ |
| 372 h); \ |
| 373 } \ |
| 374 SETUP_AND_COPY_QUAD_ALL_RP(Type, quad_all, copy_a); |
| 375 |
| 376 #define CREATE_QUAD_9_NEW(Type, a, b, c, d, e, f, g, h, i) \ |
| 377 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \ |
| 378 { \ |
| 379 QUAD_DATA quad_new->SetNew( \ |
| 380 shared_state, quad_rect, a, b, c, d, e, f, g, h, i); \ |
| 381 } \ |
| 382 SETUP_AND_COPY_QUAD_NEW(Type, quad_new); |
326 | 383 |
327 #define CREATE_QUAD_9_ALL(Type, a, b, c, d, e, f, g, h, i) \ | 384 #define CREATE_QUAD_9_ALL(Type, a, b, c, d, e, f, g, h, i) \ |
328 scoped_ptr<Type> quad_all(Type::Create()); \ | 385 { \ |
329 { \ | 386 QUAD_DATA quad_all->SetAll(shared_state, \ |
330 QUAD_DATA \ | 387 quad_rect, \ |
331 quad_all->SetAll(shared_state.get(), quad_rect, quad_opaque_rect, \ | 388 quad_opaque_rect, \ |
332 quad_visible_rect, needs_blending, \ | 389 quad_visible_rect, \ |
333 a, b, c, d, e, f, g, h, i); \ | 390 needs_blending, \ |
334 } \ | 391 a, \ |
335 SETUP_AND_COPY_QUAD_ALL(Type, quad_all); | 392 b, \ |
| 393 c, \ |
| 394 d, \ |
| 395 e, \ |
| 396 f, \ |
| 397 g, \ |
| 398 h, \ |
| 399 i); \ |
| 400 } \ |
| 401 SETUP_AND_COPY_QUAD_ALL(Type, quad_all); |
336 | 402 |
337 TEST(DrawQuadTest, CopyCheckerboardDrawQuad) { | 403 TEST(DrawQuadTest, CopyCheckerboardDrawQuad) { |
338 gfx::Rect visible_rect(40, 50, 30, 20); | 404 gfx::Rect visible_rect(40, 50, 30, 20); |
339 SkColor color = 0xfabb0011; | 405 SkColor color = 0xfabb0011; |
340 CREATE_SHARED_STATE(); | 406 CREATE_SHARED_STATE(); |
341 | 407 |
342 CREATE_QUAD_2_NEW(CheckerboardDrawQuad, visible_rect, color); | 408 CREATE_QUAD_2_NEW(CheckerboardDrawQuad, visible_rect, color); |
343 EXPECT_EQ(DrawQuad::CHECKERBOARD, copy_quad->material); | 409 EXPECT_EQ(DrawQuad::CHECKERBOARD, copy_quad->material); |
344 EXPECT_RECT_EQ(visible_rect, copy_quad->visible_rect); | 410 EXPECT_RECT_EQ(visible_rect, copy_quad->visible_rect); |
345 EXPECT_EQ(color, copy_quad->color); | 411 EXPECT_EQ(color, copy_quad->color); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 gfx::RectF mask_u_v_rect(-45.f, -21.f, 33.f, 19.f); | 470 gfx::RectF mask_u_v_rect(-45.f, -21.f, 33.f, 19.f); |
405 FilterOperations filters; | 471 FilterOperations filters; |
406 filters.Append(FilterOperation::CreateBlurFilter(1.f)); | 472 filters.Append(FilterOperation::CreateBlurFilter(1.f)); |
407 FilterOperations background_filters; | 473 FilterOperations background_filters; |
408 background_filters.Append( | 474 background_filters.Append( |
409 FilterOperation::CreateGrayscaleFilter(1.f)); | 475 FilterOperation::CreateGrayscaleFilter(1.f)); |
410 | 476 |
411 RenderPass::Id copied_render_pass_id(235, 11); | 477 RenderPass::Id copied_render_pass_id(235, 11); |
412 CREATE_SHARED_STATE(); | 478 CREATE_SHARED_STATE(); |
413 | 479 |
414 CREATE_QUAD_8_NEW_1(RenderPassDrawQuad, | 480 CREATE_QUAD_8_NEW_RP(RenderPassDrawQuad, |
415 visible_rect, | 481 visible_rect, |
416 render_pass_id, | 482 render_pass_id, |
417 is_replica, | 483 is_replica, |
418 mask_resource_id, | 484 mask_resource_id, |
419 contents_changed_since_last_frame, | 485 contents_changed_since_last_frame, |
420 mask_u_v_rect, | 486 mask_u_v_rect, |
421 filters, | 487 filters, |
422 background_filters, | 488 background_filters, |
423 copied_render_pass_id); | 489 copied_render_pass_id); |
424 EXPECT_EQ(DrawQuad::RENDER_PASS, copy_quad->material); | 490 EXPECT_EQ(DrawQuad::RENDER_PASS, copy_quad->material); |
425 EXPECT_RECT_EQ(visible_rect, copy_quad->visible_rect); | 491 EXPECT_RECT_EQ(visible_rect, copy_quad->visible_rect); |
426 EXPECT_EQ(copied_render_pass_id, copy_quad->render_pass_id); | 492 EXPECT_EQ(copied_render_pass_id, copy_quad->render_pass_id); |
427 EXPECT_EQ(is_replica, copy_quad->is_replica); | 493 EXPECT_EQ(is_replica, copy_quad->is_replica); |
428 EXPECT_EQ(mask_resource_id, copy_quad->mask_resource_id); | 494 EXPECT_EQ(mask_resource_id, copy_quad->mask_resource_id); |
429 EXPECT_RECT_EQ(contents_changed_since_last_frame, | 495 EXPECT_RECT_EQ(contents_changed_since_last_frame, |
430 copy_quad->contents_changed_since_last_frame); | 496 copy_quad->contents_changed_since_last_frame); |
431 EXPECT_EQ(mask_u_v_rect.ToString(), copy_quad->mask_uv_rect.ToString()); | 497 EXPECT_EQ(mask_u_v_rect.ToString(), copy_quad->mask_uv_rect.ToString()); |
432 EXPECT_EQ(filters, copy_quad->filters); | 498 EXPECT_EQ(filters, copy_quad->filters); |
433 EXPECT_EQ(background_filters, copy_quad->background_filters); | 499 EXPECT_EQ(background_filters, copy_quad->background_filters); |
434 | 500 |
435 CREATE_QUAD_7_ALL_1(RenderPassDrawQuad, | 501 CREATE_QUAD_7_ALL_RP(RenderPassDrawQuad, |
436 render_pass_id, | 502 render_pass_id, |
437 is_replica, | 503 is_replica, |
438 mask_resource_id, | 504 mask_resource_id, |
439 contents_changed_since_last_frame, | 505 contents_changed_since_last_frame, |
440 mask_u_v_rect, | 506 mask_u_v_rect, |
441 filters, | 507 filters, |
442 background_filters, | 508 background_filters, |
443 copied_render_pass_id); | 509 copied_render_pass_id); |
444 EXPECT_EQ(DrawQuad::RENDER_PASS, copy_quad->material); | 510 EXPECT_EQ(DrawQuad::RENDER_PASS, copy_quad->material); |
445 EXPECT_EQ(copied_render_pass_id, copy_quad->render_pass_id); | 511 EXPECT_EQ(copied_render_pass_id, copy_quad->render_pass_id); |
446 EXPECT_EQ(is_replica, copy_quad->is_replica); | 512 EXPECT_EQ(is_replica, copy_quad->is_replica); |
447 EXPECT_EQ(mask_resource_id, copy_quad->mask_resource_id); | 513 EXPECT_EQ(mask_resource_id, copy_quad->mask_resource_id); |
448 EXPECT_RECT_EQ(contents_changed_since_last_frame, | 514 EXPECT_RECT_EQ(contents_changed_since_last_frame, |
449 copy_quad->contents_changed_since_last_frame); | 515 copy_quad->contents_changed_since_last_frame); |
450 EXPECT_EQ(mask_u_v_rect.ToString(), copy_quad->mask_uv_rect.ToString()); | 516 EXPECT_EQ(mask_u_v_rect.ToString(), copy_quad->mask_uv_rect.ToString()); |
451 EXPECT_EQ(filters, copy_quad->filters); | 517 EXPECT_EQ(filters, copy_quad->filters); |
452 EXPECT_EQ(background_filters, copy_quad->background_filters); | 518 EXPECT_EQ(background_filters, copy_quad->background_filters); |
453 } | 519 } |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 private: | 768 private: |
703 int num_resources_; | 769 int num_resources_; |
704 }; | 770 }; |
705 | 771 |
706 TEST_F(DrawQuadIteratorTest, CheckerboardDrawQuad) { | 772 TEST_F(DrawQuadIteratorTest, CheckerboardDrawQuad) { |
707 gfx::Rect visible_rect(40, 50, 30, 20); | 773 gfx::Rect visible_rect(40, 50, 30, 20); |
708 SkColor color = 0xfabb0011; | 774 SkColor color = 0xfabb0011; |
709 | 775 |
710 CREATE_SHARED_STATE(); | 776 CREATE_SHARED_STATE(); |
711 CREATE_QUAD_2_NEW(CheckerboardDrawQuad, visible_rect, color); | 777 CREATE_QUAD_2_NEW(CheckerboardDrawQuad, visible_rect, color); |
712 EXPECT_EQ(0, IterateAndCount(quad_new.get())); | 778 EXPECT_EQ(0, IterateAndCount(quad_new)); |
713 } | 779 } |
714 | 780 |
715 TEST_F(DrawQuadIteratorTest, DebugBorderDrawQuad) { | 781 TEST_F(DrawQuadIteratorTest, DebugBorderDrawQuad) { |
716 gfx::Rect visible_rect(40, 50, 30, 20); | 782 gfx::Rect visible_rect(40, 50, 30, 20); |
717 SkColor color = 0xfabb0011; | 783 SkColor color = 0xfabb0011; |
718 int width = 99; | 784 int width = 99; |
719 | 785 |
720 CREATE_SHARED_STATE(); | 786 CREATE_SHARED_STATE(); |
721 CREATE_QUAD_3_NEW(DebugBorderDrawQuad, visible_rect, color, width); | 787 CREATE_QUAD_3_NEW(DebugBorderDrawQuad, visible_rect, color, width); |
722 EXPECT_EQ(0, IterateAndCount(quad_new.get())); | 788 EXPECT_EQ(0, IterateAndCount(quad_new)); |
723 } | 789 } |
724 | 790 |
725 TEST_F(DrawQuadIteratorTest, IOSurfaceDrawQuad) { | 791 TEST_F(DrawQuadIteratorTest, IOSurfaceDrawQuad) { |
726 gfx::Rect opaque_rect(33, 47, 10, 12); | 792 gfx::Rect opaque_rect(33, 47, 10, 12); |
727 gfx::Rect visible_rect(40, 50, 30, 20); | 793 gfx::Rect visible_rect(40, 50, 30, 20); |
728 gfx::Size size(58, 95); | 794 gfx::Size size(58, 95); |
729 ResourceProvider::ResourceId resource_id = 72; | 795 ResourceProvider::ResourceId resource_id = 72; |
730 IOSurfaceDrawQuad::Orientation orientation = IOSurfaceDrawQuad::UNFLIPPED; | 796 IOSurfaceDrawQuad::Orientation orientation = IOSurfaceDrawQuad::UNFLIPPED; |
731 | 797 |
732 CREATE_SHARED_STATE(); | 798 CREATE_SHARED_STATE(); |
733 CREATE_QUAD_5_NEW(IOSurfaceDrawQuad, | 799 CREATE_QUAD_5_NEW(IOSurfaceDrawQuad, |
734 opaque_rect, | 800 opaque_rect, |
735 visible_rect, | 801 visible_rect, |
736 size, | 802 size, |
737 resource_id, | 803 resource_id, |
738 orientation); | 804 orientation); |
739 EXPECT_EQ(resource_id, quad_new->io_surface_resource_id); | 805 EXPECT_EQ(resource_id, quad_new->io_surface_resource_id); |
740 EXPECT_EQ(1, IterateAndCount(quad_new.get())); | 806 EXPECT_EQ(1, IterateAndCount(quad_new)); |
741 EXPECT_EQ(resource_id + 1, quad_new->io_surface_resource_id); | 807 EXPECT_EQ(resource_id + 1, quad_new->io_surface_resource_id); |
742 } | 808 } |
743 | 809 |
744 TEST_F(DrawQuadIteratorTest, RenderPassDrawQuad) { | 810 TEST_F(DrawQuadIteratorTest, RenderPassDrawQuad) { |
745 gfx::Rect visible_rect(40, 50, 30, 20); | 811 gfx::Rect visible_rect(40, 50, 30, 20); |
746 RenderPass::Id render_pass_id(22, 64); | 812 RenderPass::Id render_pass_id(22, 64); |
747 bool is_replica = true; | 813 bool is_replica = true; |
748 ResourceProvider::ResourceId mask_resource_id = 78; | 814 ResourceProvider::ResourceId mask_resource_id = 78; |
749 gfx::Rect contents_changed_since_last_frame(42, 11, 74, 24); | 815 gfx::Rect contents_changed_since_last_frame(42, 11, 74, 24); |
750 gfx::RectF mask_u_v_rect(-45.f, -21.f, 33.f, 19.f); | 816 gfx::RectF mask_u_v_rect(-45.f, -21.f, 33.f, 19.f); |
751 FilterOperations filters; | 817 FilterOperations filters; |
752 filters.Append(FilterOperation::CreateBlurFilter(1.f)); | 818 filters.Append(FilterOperation::CreateBlurFilter(1.f)); |
753 FilterOperations background_filters; | 819 FilterOperations background_filters; |
754 background_filters.Append( | 820 background_filters.Append( |
755 FilterOperation::CreateGrayscaleFilter(1.f)); | 821 FilterOperation::CreateGrayscaleFilter(1.f)); |
756 | 822 |
757 RenderPass::Id copied_render_pass_id(235, 11); | 823 RenderPass::Id copied_render_pass_id(235, 11); |
758 | 824 |
759 CREATE_SHARED_STATE(); | 825 CREATE_SHARED_STATE(); |
760 CREATE_QUAD_8_NEW_1(RenderPassDrawQuad, | 826 CREATE_QUAD_8_NEW_RP(RenderPassDrawQuad, |
761 visible_rect, | 827 visible_rect, |
762 render_pass_id, | 828 render_pass_id, |
763 is_replica, | 829 is_replica, |
764 mask_resource_id, | 830 mask_resource_id, |
765 contents_changed_since_last_frame, | 831 contents_changed_since_last_frame, |
766 mask_u_v_rect, | 832 mask_u_v_rect, |
767 filters, | 833 filters, |
768 background_filters, | 834 background_filters, |
769 copied_render_pass_id); | 835 copied_render_pass_id); |
770 EXPECT_EQ(mask_resource_id, quad_new->mask_resource_id); | 836 EXPECT_EQ(mask_resource_id, quad_new->mask_resource_id); |
771 EXPECT_EQ(1, IterateAndCount(quad_new.get())); | 837 EXPECT_EQ(1, IterateAndCount(quad_new)); |
772 EXPECT_EQ(mask_resource_id + 1, quad_new->mask_resource_id); | 838 EXPECT_EQ(mask_resource_id + 1, quad_new->mask_resource_id); |
773 quad_new->mask_resource_id = 0; | 839 quad_new->mask_resource_id = 0; |
774 EXPECT_EQ(0, IterateAndCount(quad_new.get())); | 840 EXPECT_EQ(0, IterateAndCount(quad_new)); |
775 EXPECT_EQ(0u, quad_new->mask_resource_id); | 841 EXPECT_EQ(0u, quad_new->mask_resource_id); |
776 } | 842 } |
777 | 843 |
778 TEST_F(DrawQuadIteratorTest, SolidColorDrawQuad) { | 844 TEST_F(DrawQuadIteratorTest, SolidColorDrawQuad) { |
779 gfx::Rect visible_rect(40, 50, 30, 20); | 845 gfx::Rect visible_rect(40, 50, 30, 20); |
780 SkColor color = 0x49494949; | 846 SkColor color = 0x49494949; |
781 bool force_anti_aliasing_off = false; | 847 bool force_anti_aliasing_off = false; |
782 | 848 |
783 CREATE_SHARED_STATE(); | 849 CREATE_SHARED_STATE(); |
784 CREATE_QUAD_3_NEW( | 850 CREATE_QUAD_3_NEW( |
785 SolidColorDrawQuad, visible_rect, color, force_anti_aliasing_off); | 851 SolidColorDrawQuad, visible_rect, color, force_anti_aliasing_off); |
786 EXPECT_EQ(0, IterateAndCount(quad_new.get())); | 852 EXPECT_EQ(0, IterateAndCount(quad_new)); |
787 } | 853 } |
788 | 854 |
789 TEST_F(DrawQuadIteratorTest, StreamVideoDrawQuad) { | 855 TEST_F(DrawQuadIteratorTest, StreamVideoDrawQuad) { |
790 gfx::Rect opaque_rect(33, 47, 10, 12); | 856 gfx::Rect opaque_rect(33, 47, 10, 12); |
791 gfx::Rect visible_rect(40, 50, 30, 20); | 857 gfx::Rect visible_rect(40, 50, 30, 20); |
792 ResourceProvider::ResourceId resource_id = 64; | 858 ResourceProvider::ResourceId resource_id = 64; |
793 gfx::Transform matrix = gfx::Transform(0.5, 0.25, 1, 0.75, 0, 1); | 859 gfx::Transform matrix = gfx::Transform(0.5, 0.25, 1, 0.75, 0, 1); |
794 | 860 |
795 CREATE_SHARED_STATE(); | 861 CREATE_SHARED_STATE(); |
796 CREATE_QUAD_4_NEW( | 862 CREATE_QUAD_4_NEW( |
797 StreamVideoDrawQuad, opaque_rect, visible_rect, resource_id, matrix); | 863 StreamVideoDrawQuad, opaque_rect, visible_rect, resource_id, matrix); |
798 EXPECT_EQ(resource_id, quad_new->resource_id); | 864 EXPECT_EQ(resource_id, quad_new->resource_id); |
799 EXPECT_EQ(1, IterateAndCount(quad_new.get())); | 865 EXPECT_EQ(1, IterateAndCount(quad_new)); |
800 EXPECT_EQ(resource_id + 1, quad_new->resource_id); | 866 EXPECT_EQ(resource_id + 1, quad_new->resource_id); |
801 } | 867 } |
802 | 868 |
803 TEST_F(DrawQuadIteratorTest, SurfaceDrawQuad) { | 869 TEST_F(DrawQuadIteratorTest, SurfaceDrawQuad) { |
804 gfx::Rect visible_rect(40, 50, 30, 20); | 870 gfx::Rect visible_rect(40, 50, 30, 20); |
805 SurfaceId surface_id(4321); | 871 SurfaceId surface_id(4321); |
806 | 872 |
807 CREATE_SHARED_STATE(); | 873 CREATE_SHARED_STATE(); |
808 CREATE_QUAD_2_NEW(SurfaceDrawQuad, visible_rect, surface_id); | 874 CREATE_QUAD_2_NEW(SurfaceDrawQuad, visible_rect, surface_id); |
809 EXPECT_EQ(0, IterateAndCount(quad_new.get())); | 875 EXPECT_EQ(0, IterateAndCount(quad_new)); |
810 } | 876 } |
811 | 877 |
812 TEST_F(DrawQuadIteratorTest, TextureDrawQuad) { | 878 TEST_F(DrawQuadIteratorTest, TextureDrawQuad) { |
813 gfx::Rect opaque_rect(33, 47, 10, 12); | 879 gfx::Rect opaque_rect(33, 47, 10, 12); |
814 gfx::Rect visible_rect(40, 50, 30, 20); | 880 gfx::Rect visible_rect(40, 50, 30, 20); |
815 unsigned resource_id = 82; | 881 unsigned resource_id = 82; |
816 bool premultiplied_alpha = true; | 882 bool premultiplied_alpha = true; |
817 gfx::PointF uv_top_left(0.5f, 224.f); | 883 gfx::PointF uv_top_left(0.5f, 224.f); |
818 gfx::PointF uv_bottom_right(51.5f, 260.f); | 884 gfx::PointF uv_bottom_right(51.5f, 260.f); |
819 const float vertex_opacity[] = { 1.0f, 1.0f, 1.0f, 1.0f }; | 885 const float vertex_opacity[] = { 1.0f, 1.0f, 1.0f, 1.0f }; |
820 bool flipped = true; | 886 bool flipped = true; |
821 | 887 |
822 CREATE_SHARED_STATE(); | 888 CREATE_SHARED_STATE(); |
823 CREATE_QUAD_9_NEW(TextureDrawQuad, | 889 CREATE_QUAD_9_NEW(TextureDrawQuad, |
824 opaque_rect, | 890 opaque_rect, |
825 visible_rect, | 891 visible_rect, |
826 resource_id, | 892 resource_id, |
827 premultiplied_alpha, | 893 premultiplied_alpha, |
828 uv_top_left, | 894 uv_top_left, |
829 uv_bottom_right, | 895 uv_bottom_right, |
830 SK_ColorTRANSPARENT, | 896 SK_ColorTRANSPARENT, |
831 vertex_opacity, | 897 vertex_opacity, |
832 flipped); | 898 flipped); |
833 EXPECT_EQ(resource_id, quad_new->resource_id); | 899 EXPECT_EQ(resource_id, quad_new->resource_id); |
834 EXPECT_EQ(1, IterateAndCount(quad_new.get())); | 900 EXPECT_EQ(1, IterateAndCount(quad_new)); |
835 EXPECT_EQ(resource_id + 1, quad_new->resource_id); | 901 EXPECT_EQ(resource_id + 1, quad_new->resource_id); |
836 } | 902 } |
837 | 903 |
838 TEST_F(DrawQuadIteratorTest, TileDrawQuad) { | 904 TEST_F(DrawQuadIteratorTest, TileDrawQuad) { |
839 gfx::Rect opaque_rect(33, 44, 22, 33); | 905 gfx::Rect opaque_rect(33, 44, 22, 33); |
840 gfx::Rect visible_rect(40, 50, 30, 20); | 906 gfx::Rect visible_rect(40, 50, 30, 20); |
841 unsigned resource_id = 104; | 907 unsigned resource_id = 104; |
842 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f); | 908 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f); |
843 gfx::Size texture_size(85, 32); | 909 gfx::Size texture_size(85, 32); |
844 bool swizzle_contents = true; | 910 bool swizzle_contents = true; |
845 | 911 |
846 CREATE_SHARED_STATE(); | 912 CREATE_SHARED_STATE(); |
847 CREATE_QUAD_6_NEW(TileDrawQuad, | 913 CREATE_QUAD_6_NEW(TileDrawQuad, |
848 opaque_rect, | 914 opaque_rect, |
849 visible_rect, | 915 visible_rect, |
850 resource_id, | 916 resource_id, |
851 tex_coord_rect, | 917 tex_coord_rect, |
852 texture_size, | 918 texture_size, |
853 swizzle_contents); | 919 swizzle_contents); |
854 EXPECT_EQ(resource_id, quad_new->resource_id); | 920 EXPECT_EQ(resource_id, quad_new->resource_id); |
855 EXPECT_EQ(1, IterateAndCount(quad_new.get())); | 921 EXPECT_EQ(1, IterateAndCount(quad_new)); |
856 EXPECT_EQ(resource_id + 1, quad_new->resource_id); | 922 EXPECT_EQ(resource_id + 1, quad_new->resource_id); |
857 } | 923 } |
858 | 924 |
859 TEST_F(DrawQuadIteratorTest, YUVVideoDrawQuad) { | 925 TEST_F(DrawQuadIteratorTest, YUVVideoDrawQuad) { |
860 gfx::Rect opaque_rect(33, 47, 10, 12); | 926 gfx::Rect opaque_rect(33, 47, 10, 12); |
861 gfx::Rect visible_rect(40, 50, 30, 20); | 927 gfx::Rect visible_rect(40, 50, 30, 20); |
862 gfx::RectF tex_coord_rect(0.0f, 0.0f, 0.75f, 0.5f); | 928 gfx::RectF tex_coord_rect(0.0f, 0.0f, 0.75f, 0.5f); |
863 ResourceProvider::ResourceId y_plane_resource_id = 45; | 929 ResourceProvider::ResourceId y_plane_resource_id = 45; |
864 ResourceProvider::ResourceId u_plane_resource_id = 532; | 930 ResourceProvider::ResourceId u_plane_resource_id = 532; |
865 ResourceProvider::ResourceId v_plane_resource_id = 4; | 931 ResourceProvider::ResourceId v_plane_resource_id = 4; |
866 ResourceProvider::ResourceId a_plane_resource_id = 63; | 932 ResourceProvider::ResourceId a_plane_resource_id = 63; |
867 YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::REC_601_JPEG; | 933 YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::REC_601_JPEG; |
868 | 934 |
869 CREATE_SHARED_STATE(); | 935 CREATE_SHARED_STATE(); |
870 CREATE_QUAD_8_NEW(YUVVideoDrawQuad, | 936 CREATE_QUAD_8_NEW(YUVVideoDrawQuad, |
871 opaque_rect, | 937 opaque_rect, |
872 visible_rect, | 938 visible_rect, |
873 tex_coord_rect, | 939 tex_coord_rect, |
874 y_plane_resource_id, | 940 y_plane_resource_id, |
875 u_plane_resource_id, | 941 u_plane_resource_id, |
876 v_plane_resource_id, | 942 v_plane_resource_id, |
877 a_plane_resource_id, | 943 a_plane_resource_id, |
878 color_space); | 944 color_space); |
879 EXPECT_EQ(DrawQuad::YUV_VIDEO_CONTENT, copy_quad->material); | 945 EXPECT_EQ(DrawQuad::YUV_VIDEO_CONTENT, copy_quad->material); |
880 EXPECT_EQ(y_plane_resource_id, quad_new->y_plane_resource_id); | 946 EXPECT_EQ(y_plane_resource_id, quad_new->y_plane_resource_id); |
881 EXPECT_EQ(u_plane_resource_id, quad_new->u_plane_resource_id); | 947 EXPECT_EQ(u_plane_resource_id, quad_new->u_plane_resource_id); |
882 EXPECT_EQ(v_plane_resource_id, quad_new->v_plane_resource_id); | 948 EXPECT_EQ(v_plane_resource_id, quad_new->v_plane_resource_id); |
883 EXPECT_EQ(a_plane_resource_id, quad_new->a_plane_resource_id); | 949 EXPECT_EQ(a_plane_resource_id, quad_new->a_plane_resource_id); |
884 EXPECT_EQ(color_space, quad_new->color_space); | 950 EXPECT_EQ(color_space, quad_new->color_space); |
885 EXPECT_EQ(4, IterateAndCount(quad_new.get())); | 951 EXPECT_EQ(4, IterateAndCount(quad_new)); |
886 EXPECT_EQ(y_plane_resource_id + 1, quad_new->y_plane_resource_id); | 952 EXPECT_EQ(y_plane_resource_id + 1, quad_new->y_plane_resource_id); |
887 EXPECT_EQ(u_plane_resource_id + 1, quad_new->u_plane_resource_id); | 953 EXPECT_EQ(u_plane_resource_id + 1, quad_new->u_plane_resource_id); |
888 EXPECT_EQ(v_plane_resource_id + 1, quad_new->v_plane_resource_id); | 954 EXPECT_EQ(v_plane_resource_id + 1, quad_new->v_plane_resource_id); |
889 EXPECT_EQ(a_plane_resource_id + 1, quad_new->a_plane_resource_id); | 955 EXPECT_EQ(a_plane_resource_id + 1, quad_new->a_plane_resource_id); |
890 } | 956 } |
891 | 957 |
892 // Disabled until picture draw quad is supported for ubercomp: crbug.com/231715 | 958 // Disabled until picture draw quad is supported for ubercomp: crbug.com/231715 |
893 TEST_F(DrawQuadIteratorTest, DISABLED_PictureDrawQuad) { | 959 TEST_F(DrawQuadIteratorTest, DISABLED_PictureDrawQuad) { |
894 gfx::Rect opaque_rect(33, 44, 22, 33); | 960 gfx::Rect opaque_rect(33, 44, 22, 33); |
895 gfx::Rect visible_rect(40, 50, 30, 20); | 961 gfx::Rect visible_rect(40, 50, 30, 20); |
896 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f); | 962 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f); |
897 gfx::Size texture_size(85, 32); | 963 gfx::Size texture_size(85, 32); |
898 ResourceFormat texture_format = RGBA_8888; | 964 ResourceFormat texture_format = RGBA_8888; |
899 gfx::Rect content_rect(30, 40, 20, 30); | 965 gfx::Rect content_rect(30, 40, 20, 30); |
900 float contents_scale = 3.141592f; | 966 float contents_scale = 3.141592f; |
901 scoped_refptr<PicturePileImpl> picture_pile = PicturePileImpl::Create(); | 967 scoped_refptr<PicturePileImpl> picture_pile = PicturePileImpl::Create(); |
902 | 968 |
903 CREATE_SHARED_STATE(); | 969 CREATE_SHARED_STATE(); |
904 CREATE_QUAD_8_NEW(PictureDrawQuad, | 970 CREATE_QUAD_8_NEW(PictureDrawQuad, |
905 opaque_rect, | 971 opaque_rect, |
906 visible_rect, | 972 visible_rect, |
907 tex_coord_rect, | 973 tex_coord_rect, |
908 texture_size, | 974 texture_size, |
909 texture_format, | 975 texture_format, |
910 content_rect, | 976 content_rect, |
911 contents_scale, | 977 contents_scale, |
912 picture_pile); | 978 picture_pile); |
913 EXPECT_EQ(0, IterateAndCount(quad_new.get())); | 979 EXPECT_EQ(0, IterateAndCount(quad_new)); |
914 } | 980 } |
915 | 981 |
916 } // namespace | 982 } // namespace |
917 } // namespace cc | 983 } // namespace cc |
OLD | NEW |