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/draw_quad.h" | 5 #include "cc/draw_quad.h" |
6 | 6 |
7 #include "cc/checkerboard_draw_quad.h" | 7 #include "cc/checkerboard_draw_quad.h" |
8 #include "cc/debug_border_draw_quad.h" | 8 #include "cc/debug_border_draw_quad.h" |
9 #include "cc/io_surface_draw_quad.h" | 9 #include "cc/io_surface_draw_quad.h" |
10 #include "cc/math_util.h" | 10 #include "cc/math_util.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 { QUAD_DATA \ | 149 { QUAD_DATA \ |
150 quadNew->SetNew(sharedState.get(), quadRect, a, b, c, d, e); } \ | 150 quadNew->SetNew(sharedState.get(), quadRect, a, b, c, d, e); } \ |
151 SETUP_AND_COPY_QUAD_NEW(Type, quadNew); | 151 SETUP_AND_COPY_QUAD_NEW(Type, quadNew); |
152 | 152 |
153 #define CREATE_QUAD_5_ALL(Type, a, b, c, d, e) \ | 153 #define CREATE_QUAD_5_ALL(Type, a, b, c, d, e) \ |
154 scoped_ptr<Type> quadAll(Type::Create()); \ | 154 scoped_ptr<Type> quadAll(Type::Create()); \ |
155 { QUAD_DATA \ | 155 { QUAD_DATA \ |
156 quadAll->SetAll(sharedState.get(), quadRect, quadOpaqueRect, quadVisibleRe
ct, needsBlending, a, b, c, d, e); } \ | 156 quadAll->SetAll(sharedState.get(), quadRect, quadOpaqueRect, quadVisibleRe
ct, needsBlending, a, b, c, d, e); } \ |
157 SETUP_AND_COPY_QUAD_ALL(Type, quadAll); | 157 SETUP_AND_COPY_QUAD_ALL(Type, quadAll); |
158 | 158 |
| 159 #define CREATE_QUAD_5_NEW_1(Type, a, b, c, d, e, copyA) \ |
| 160 scoped_ptr<Type> quadNew(Type::Create()); \ |
| 161 { QUAD_DATA \ |
| 162 quadNew->SetNew(sharedState.get(), quadRect, a, b, c, d, e); } \ |
| 163 SETUP_AND_COPY_QUAD_NEW_1(Type, quadNew, copyA); |
| 164 |
| 165 #define CREATE_QUAD_5_ALL_1(Type, a, b, c, d, e, copyA) \ |
| 166 scoped_ptr<Type> quadAll(Type::Create()); \ |
| 167 { QUAD_DATA \ |
| 168 quadAll->SetAll(sharedState.get(), quadRect, quadOpaqueRect, quadVisibleRe
ct, needsBlending, a, b, c, d, e); } \ |
| 169 SETUP_AND_COPY_QUAD_ALL_1(Type, quadAll, copyA); |
| 170 |
159 #define CREATE_QUAD_6_NEW(Type, a, b, c, d, e, f) \ | 171 #define CREATE_QUAD_6_NEW(Type, a, b, c, d, e, f) \ |
160 scoped_ptr<Type> quadNew(Type::Create()); \ | 172 scoped_ptr<Type> quadNew(Type::Create()); \ |
161 { QUAD_DATA \ | 173 { QUAD_DATA \ |
162 quadNew->SetNew(sharedState.get(), quadRect, a, b, c, d, e, f); } \ | 174 quadNew->SetNew(sharedState.get(), quadRect, a, b, c, d, e, f); } \ |
163 SETUP_AND_COPY_QUAD_NEW(Type, quadNew); | 175 SETUP_AND_COPY_QUAD_NEW(Type, quadNew); |
164 | 176 |
165 #define CREATE_QUAD_6_ALL(Type, a, b, c, d, e, f) \ | 177 #define CREATE_QUAD_6_ALL(Type, a, b, c, d, e, f) \ |
166 scoped_ptr<Type> quadAll(Type::Create()); \ | 178 scoped_ptr<Type> quadAll(Type::Create()); \ |
167 { QUAD_DATA \ | 179 { QUAD_DATA \ |
168 quadAll->SetAll(sharedState.get(), quadRect, quadOpaqueRect, quadVisibleRe
ct, needsBlending, a, b, c, d, e, f); } \ | 180 quadAll->SetAll(sharedState.get(), quadRect, quadOpaqueRect, quadVisibleRe
ct, needsBlending, a, b, c, d, e, f); } \ |
(...skipping 16 matching lines...) Expand all Loading... |
185 { QUAD_DATA \ | 197 { QUAD_DATA \ |
186 quadNew->SetNew(sharedState.get(), quadRect, a, b, c, d, e, f, g, h); } \ | 198 quadNew->SetNew(sharedState.get(), quadRect, a, b, c, d, e, f, g, h); } \ |
187 SETUP_AND_COPY_QUAD_NEW(Type, quadNew); | 199 SETUP_AND_COPY_QUAD_NEW(Type, quadNew); |
188 | 200 |
189 #define CREATE_QUAD_8_ALL(Type, a, b, c, d, e, f, g, h) \ | 201 #define CREATE_QUAD_8_ALL(Type, a, b, c, d, e, f, g, h) \ |
190 scoped_ptr<Type> quadAll(Type::Create()); \ | 202 scoped_ptr<Type> quadAll(Type::Create()); \ |
191 { QUAD_DATA \ | 203 { QUAD_DATA \ |
192 quadAll->SetAll(sharedState.get(), quadRect, quadOpaqueRect, quadVisibleRe
ct, needsBlending, a, b, c, d, e, f, g, h); } \ | 204 quadAll->SetAll(sharedState.get(), quadRect, quadOpaqueRect, quadVisibleRe
ct, needsBlending, a, b, c, d, e, f, g, h); } \ |
193 SETUP_AND_COPY_QUAD_ALL(Type, quadAll); | 205 SETUP_AND_COPY_QUAD_ALL(Type, quadAll); |
194 | 206 |
195 #define CREATE_QUAD_8_NEW_1(Type, a, b, c, d, e, f, g, h, copyA) \ | |
196 scoped_ptr<Type> quadNew(Type::Create()); \ | |
197 { QUAD_DATA \ | |
198 quadNew->SetNew(sharedState.get(), quadRect, a, b, c, d, e, f, g, h); } \ | |
199 SETUP_AND_COPY_QUAD_NEW_1(Type, quadNew, copyA); | |
200 | |
201 #define CREATE_QUAD_8_ALL_1(Type, a, b, c, d, e, f, g, h, copyA) \ | |
202 scoped_ptr<Type> quadAll(Type::Create()); \ | |
203 { QUAD_DATA \ | |
204 quadAll->SetAll(sharedState.get(), quadRect, quadOpaqueRect, quadVisibleRe
ct, needsBlending, a, b, c, d, e, f, g, h); } \ | |
205 SETUP_AND_COPY_QUAD_ALL_1(Type, quadAll, copyA); | |
206 | |
207 #define CREATE_QUAD_9_NEW(Type, a, b, c, d, e, f, g, h, i) \ | 207 #define CREATE_QUAD_9_NEW(Type, a, b, c, d, e, f, g, h, i) \ |
208 scoped_ptr<Type> quadNew(Type::Create()); \ | 208 scoped_ptr<Type> quadNew(Type::Create()); \ |
209 { QUAD_DATA \ | 209 { QUAD_DATA \ |
210 quadNew->SetNew(sharedState.get(), quadRect, a, b, c, d, e, f, g, h, i); }
\ | 210 quadNew->SetNew(sharedState.get(), quadRect, a, b, c, d, e, f, g, h, i); }
\ |
211 SETUP_AND_COPY_QUAD_NEW(Type, quadNew); | 211 SETUP_AND_COPY_QUAD_NEW(Type, quadNew); |
212 | 212 |
213 #define CREATE_QUAD_9_ALL(Type, a, b, c, d, e, f, g, h, i) \ | 213 #define CREATE_QUAD_9_ALL(Type, a, b, c, d, e, f, g, h, i) \ |
214 scoped_ptr<Type> quadAll(Type::Create()); \ | 214 scoped_ptr<Type> quadAll(Type::Create()); \ |
215 { QUAD_DATA \ | 215 { QUAD_DATA \ |
216 quadAll->SetAll(sharedState.get(), quadRect, quadOpaqueRect, quadVisibleRe
ct, needsBlending, a, b, c, d, e, f, g, h, i); } \ | 216 quadAll->SetAll(sharedState.get(), quadRect, quadOpaqueRect, quadVisibleRe
ct, needsBlending, a, b, c, d, e, f, g, h, i); } \ |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 EXPECT_EQ(textureId, copyQuad->io_surface_texture_id); | 268 EXPECT_EQ(textureId, copyQuad->io_surface_texture_id); |
269 EXPECT_EQ(orientation, copyQuad->orientation); | 269 EXPECT_EQ(orientation, copyQuad->orientation); |
270 } | 270 } |
271 | 271 |
272 TEST(DrawQuadTest, copyRenderPassDrawQuad) | 272 TEST(DrawQuadTest, copyRenderPassDrawQuad) |
273 { | 273 { |
274 RenderPass::Id renderPassId(22, 64); | 274 RenderPass::Id renderPassId(22, 64); |
275 bool isReplica = true; | 275 bool isReplica = true; |
276 ResourceProvider::ResourceId maskResourceId = 78; | 276 ResourceProvider::ResourceId maskResourceId = 78; |
277 gfx::Rect contentsChangedSinceLastFrame(42, 11, 74, 24); | 277 gfx::Rect contentsChangedSinceLastFrame(42, 11, 74, 24); |
278 float maskTexCoordScaleX = 33; | 278 gfx::RectF maskUVRect(-45, -21, 33, 19); |
279 float maskTexCoordScaleY = 19; | |
280 float maskTexCoordOffsetX = -45; | |
281 float maskTexCoordOffsetY = -21; | |
282 | 279 |
283 RenderPass::Id copiedRenderPassId(235, 11); | 280 RenderPass::Id copiedRenderPassId(235, 11); |
284 CREATE_SHARED_STATE(); | 281 CREATE_SHARED_STATE(); |
285 | 282 |
286 CREATE_QUAD_8_NEW_1(RenderPassDrawQuad, renderPassId, isReplica, maskResourc
eId, contentsChangedSinceLastFrame, maskTexCoordScaleX, maskTexCoordScaleY, mask
TexCoordOffsetX, maskTexCoordOffsetY, copiedRenderPassId); | 283 CREATE_QUAD_5_NEW_1(RenderPassDrawQuad, renderPassId, isReplica, maskResourc
eId, contentsChangedSinceLastFrame, maskUVRect, copiedRenderPassId); |
287 EXPECT_EQ(DrawQuad::RENDER_PASS, copyQuad->material); | 284 EXPECT_EQ(DrawQuad::RENDER_PASS, copyQuad->material); |
288 EXPECT_EQ(copiedRenderPassId, copyQuad->render_pass_id); | 285 EXPECT_EQ(copiedRenderPassId, copyQuad->render_pass_id); |
289 EXPECT_EQ(isReplica, copyQuad->is_replica); | 286 EXPECT_EQ(isReplica, copyQuad->is_replica); |
290 EXPECT_EQ(maskResourceId, copyQuad->mask_resource_id); | 287 EXPECT_EQ(maskResourceId, copyQuad->mask_resource_id); |
291 EXPECT_RECT_EQ(contentsChangedSinceLastFrame, copyQuad->contents_changed_sin
ce_last_frame); | 288 EXPECT_RECT_EQ(contentsChangedSinceLastFrame, copyQuad->contents_changed_sin
ce_last_frame); |
292 EXPECT_EQ(maskTexCoordScaleX, copyQuad->mask_tex_coord_scale_x); | 289 EXPECT_EQ(maskUVRect.ToString(), copyQuad->mask_uv_rect.ToString()); |
293 EXPECT_EQ(maskTexCoordScaleY, copyQuad->mask_tex_coord_scale_y); | |
294 EXPECT_EQ(maskTexCoordOffsetX, copyQuad->mask_tex_coord_offset_x); | |
295 EXPECT_EQ(maskTexCoordOffsetY, copyQuad->mask_tex_coord_offset_y); | |
296 | 290 |
297 CREATE_QUAD_8_ALL_1(RenderPassDrawQuad, renderPassId, isReplica, maskResourc
eId, contentsChangedSinceLastFrame, maskTexCoordScaleX, maskTexCoordScaleY, mask
TexCoordOffsetX, maskTexCoordOffsetY, copiedRenderPassId); | 291 CREATE_QUAD_5_ALL_1(RenderPassDrawQuad, renderPassId, isReplica, maskResourc
eId, contentsChangedSinceLastFrame, maskUVRect, copiedRenderPassId); |
298 EXPECT_EQ(DrawQuad::RENDER_PASS, copyQuad->material); | 292 EXPECT_EQ(DrawQuad::RENDER_PASS, copyQuad->material); |
299 EXPECT_EQ(copiedRenderPassId, copyQuad->render_pass_id); | 293 EXPECT_EQ(copiedRenderPassId, copyQuad->render_pass_id); |
300 EXPECT_EQ(isReplica, copyQuad->is_replica); | 294 EXPECT_EQ(isReplica, copyQuad->is_replica); |
301 EXPECT_EQ(maskResourceId, copyQuad->mask_resource_id); | 295 EXPECT_EQ(maskResourceId, copyQuad->mask_resource_id); |
302 EXPECT_RECT_EQ(contentsChangedSinceLastFrame, copyQuad->contents_changed_sin
ce_last_frame); | 296 EXPECT_RECT_EQ(contentsChangedSinceLastFrame, copyQuad->contents_changed_sin
ce_last_frame); |
303 EXPECT_EQ(maskTexCoordScaleX, copyQuad->mask_tex_coord_scale_x); | 297 EXPECT_EQ(maskUVRect.ToString(), copyQuad->mask_uv_rect.ToString()); |
304 EXPECT_EQ(maskTexCoordScaleY, copyQuad->mask_tex_coord_scale_y); | |
305 EXPECT_EQ(maskTexCoordOffsetX, copyQuad->mask_tex_coord_offset_x); | |
306 EXPECT_EQ(maskTexCoordOffsetY, copyQuad->mask_tex_coord_offset_y); | |
307 } | 298 } |
308 | 299 |
309 TEST(DrawQuadTest, copySolidColorDrawQuad) | 300 TEST(DrawQuadTest, copySolidColorDrawQuad) |
310 { | 301 { |
311 SkColor color = 0x49494949; | 302 SkColor color = 0x49494949; |
312 CREATE_SHARED_STATE(); | 303 CREATE_SHARED_STATE(); |
313 | 304 |
314 CREATE_QUAD_1_NEW(SolidColorDrawQuad, color); | 305 CREATE_QUAD_1_NEW(SolidColorDrawQuad, color); |
315 EXPECT_EQ(DrawQuad::SOLID_COLOR, copyQuad->material); | 306 EXPECT_EQ(DrawQuad::SOLID_COLOR, copyQuad->material); |
316 EXPECT_EQ(color, copyQuad->color); | 307 EXPECT_EQ(color, copyQuad->color); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 EXPECT_EQ(uPlane.resourceId, copyQuad->u_plane.resourceId); | 433 EXPECT_EQ(uPlane.resourceId, copyQuad->u_plane.resourceId); |
443 EXPECT_EQ(uPlane.size, copyQuad->u_plane.size); | 434 EXPECT_EQ(uPlane.size, copyQuad->u_plane.size); |
444 EXPECT_EQ(uPlane.format, copyQuad->u_plane.format); | 435 EXPECT_EQ(uPlane.format, copyQuad->u_plane.format); |
445 EXPECT_EQ(vPlane.resourceId, copyQuad->v_plane.resourceId); | 436 EXPECT_EQ(vPlane.resourceId, copyQuad->v_plane.resourceId); |
446 EXPECT_EQ(vPlane.size, copyQuad->v_plane.size); | 437 EXPECT_EQ(vPlane.size, copyQuad->v_plane.size); |
447 EXPECT_EQ(vPlane.format, copyQuad->v_plane.format); | 438 EXPECT_EQ(vPlane.format, copyQuad->v_plane.format); |
448 } | 439 } |
449 | 440 |
450 } // namespace | 441 } // namespace |
451 } // namespace cc | 442 } // namespace cc |
OLD | NEW |