| 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" |
| 11 #include "cc/render_pass_draw_quad.h" | 11 #include "cc/render_pass_draw_quad.h" |
| 12 #include "cc/solid_color_draw_quad.h" | 12 #include "cc/solid_color_draw_quad.h" |
| 13 #include "cc/stream_video_draw_quad.h" | 13 #include "cc/stream_video_draw_quad.h" |
| 14 #include "cc/test/geometry_test_utils.h" | 14 #include "cc/test/geometry_test_utils.h" |
| 15 #include "cc/texture_draw_quad.h" | 15 #include "cc/texture_draw_quad.h" |
| 16 #include "cc/tile_draw_quad.h" | 16 #include "cc/tile_draw_quad.h" |
| 17 #include "cc/yuv_video_draw_quad.h" | 17 #include "cc/yuv_video_draw_quad.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 #include "third_party/WebKit/Source/Platform/chromium/public/WebFilterOperations
.h" |
| 20 #include "third_party/skia/include/effects/SkBlurImageFilter.h" |
| 19 #include "ui/gfx/transform.h" | 21 #include "ui/gfx/transform.h" |
| 20 | 22 |
| 21 namespace cc { | 23 namespace cc { |
| 22 namespace { | 24 namespace { |
| 23 | 25 |
| 24 TEST(DrawQuadTest, copySharedQuadState) | 26 TEST(DrawQuadTest, copySharedQuadState) |
| 25 { | 27 { |
| 26 gfx::Transform quadTransform = MathUtil::createGfxTransform(1, 0.5, 0, 1, 0.
5, 0); | 28 gfx::Transform quadTransform = MathUtil::createGfxTransform(1, 0.5, 0, 1, 0.
5, 0); |
| 27 gfx::Rect visibleContentRect(10, 12, 14, 16); | 29 gfx::Rect visibleContentRect(10, 12, 14, 16); |
| 28 gfx::Rect clippedRectInTarget(19, 21, 23, 25); | 30 gfx::Rect clippedRectInTarget(19, 21, 23, 25); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 { QUAD_DATA \ | 199 { QUAD_DATA \ |
| 198 quadNew->SetNew(sharedState.get(), quadRect, a, b, c, d, e, f, g, h); } \ | 200 quadNew->SetNew(sharedState.get(), quadRect, a, b, c, d, e, f, g, h); } \ |
| 199 SETUP_AND_COPY_QUAD_NEW(Type, quadNew); | 201 SETUP_AND_COPY_QUAD_NEW(Type, quadNew); |
| 200 | 202 |
| 201 #define CREATE_QUAD_8_ALL(Type, a, b, c, d, e, f, g, h) \ | 203 #define CREATE_QUAD_8_ALL(Type, a, b, c, d, e, f, g, h) \ |
| 202 scoped_ptr<Type> quadAll(Type::Create()); \ | 204 scoped_ptr<Type> quadAll(Type::Create()); \ |
| 203 { QUAD_DATA \ | 205 { QUAD_DATA \ |
| 204 quadAll->SetAll(sharedState.get(), quadRect, quadOpaqueRect, quadVisibleRe
ct, needsBlending, a, b, c, d, e, f, g, h); } \ | 206 quadAll->SetAll(sharedState.get(), quadRect, quadOpaqueRect, quadVisibleRe
ct, needsBlending, a, b, c, d, e, f, g, h); } \ |
| 205 SETUP_AND_COPY_QUAD_ALL(Type, quadAll); | 207 SETUP_AND_COPY_QUAD_ALL(Type, quadAll); |
| 206 | 208 |
| 209 #define CREATE_QUAD_8_NEW_1(Type, a, b, c, d, e, f, g, h, copyA) \ |
| 210 scoped_ptr<Type> quadNew(Type::Create()); \ |
| 211 { QUAD_DATA \ |
| 212 quadNew->SetNew(sharedState.get(), quadRect, a, b, c, d, e, f, g, h); } \ |
| 213 SETUP_AND_COPY_QUAD_NEW_1(Type, quadNew, copyA); |
| 214 |
| 215 #define CREATE_QUAD_8_ALL_1(Type, a, b, c, d, e, f, g, h, copyA) \ |
| 216 scoped_ptr<Type> quadAll(Type::Create()); \ |
| 217 { QUAD_DATA \ |
| 218 quadAll->SetAll(sharedState.get(), quadRect, quadOpaqueRect, quadVisibleRe
ct, needsBlending, a, b, c, d, e, f, g, h); } \ |
| 219 SETUP_AND_COPY_QUAD_ALL_1(Type, quadAll, copyA); |
| 220 |
| 207 #define CREATE_QUAD_9_NEW(Type, a, b, c, d, e, f, g, h, i) \ | 221 #define CREATE_QUAD_9_NEW(Type, a, b, c, d, e, f, g, h, i) \ |
| 208 scoped_ptr<Type> quadNew(Type::Create()); \ | 222 scoped_ptr<Type> quadNew(Type::Create()); \ |
| 209 { QUAD_DATA \ | 223 { QUAD_DATA \ |
| 210 quadNew->SetNew(sharedState.get(), quadRect, a, b, c, d, e, f, g, h, i); }
\ | 224 quadNew->SetNew(sharedState.get(), quadRect, a, b, c, d, e, f, g, h, i); }
\ |
| 211 SETUP_AND_COPY_QUAD_NEW(Type, quadNew); | 225 SETUP_AND_COPY_QUAD_NEW(Type, quadNew); |
| 212 | 226 |
| 213 #define CREATE_QUAD_9_ALL(Type, a, b, c, d, e, f, g, h, i) \ | 227 #define CREATE_QUAD_9_ALL(Type, a, b, c, d, e, f, g, h, i) \ |
| 214 scoped_ptr<Type> quadAll(Type::Create()); \ | 228 scoped_ptr<Type> quadAll(Type::Create()); \ |
| 215 { QUAD_DATA \ | 229 { QUAD_DATA \ |
| 216 quadAll->SetAll(sharedState.get(), quadRect, quadOpaqueRect, quadVisibleRe
ct, needsBlending, a, b, c, d, e, f, g, h, i); } \ | 230 quadAll->SetAll(sharedState.get(), quadRect, quadOpaqueRect, quadVisibleRe
ct, needsBlending, a, b, c, d, e, f, g, h, i); } \ |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 EXPECT_EQ(orientation, copyQuad->orientation); | 283 EXPECT_EQ(orientation, copyQuad->orientation); |
| 270 } | 284 } |
| 271 | 285 |
| 272 TEST(DrawQuadTest, copyRenderPassDrawQuad) | 286 TEST(DrawQuadTest, copyRenderPassDrawQuad) |
| 273 { | 287 { |
| 274 RenderPass::Id renderPassId(22, 64); | 288 RenderPass::Id renderPassId(22, 64); |
| 275 bool isReplica = true; | 289 bool isReplica = true; |
| 276 ResourceProvider::ResourceId maskResourceId = 78; | 290 ResourceProvider::ResourceId maskResourceId = 78; |
| 277 gfx::Rect contentsChangedSinceLastFrame(42, 11, 74, 24); | 291 gfx::Rect contentsChangedSinceLastFrame(42, 11, 74, 24); |
| 278 gfx::RectF maskUVRect(-45, -21, 33, 19); | 292 gfx::RectF maskUVRect(-45, -21, 33, 19); |
| 293 WebKit::WebFilterOperations filters; |
| 294 filters.append(WebKit::WebFilterOperation::createBlurFilter(1.f)); |
| 295 WebKit::WebFilterOperations background_filters; |
| 296 background_filters.append( |
| 297 WebKit::WebFilterOperation::createGrayscaleFilter(1.f)); |
| 298 skia::RefPtr<SkImageFilter> filter = skia::AdoptRef( |
| 299 new SkBlurImageFilter(SK_Scalar1, SK_Scalar1)); |
| 279 | 300 |
| 280 RenderPass::Id copiedRenderPassId(235, 11); | 301 RenderPass::Id copiedRenderPassId(235, 11); |
| 281 CREATE_SHARED_STATE(); | 302 CREATE_SHARED_STATE(); |
| 282 | 303 |
| 283 CREATE_QUAD_5_NEW_1(RenderPassDrawQuad, renderPassId, isReplica, maskResourc
eId, contentsChangedSinceLastFrame, maskUVRect, copiedRenderPassId); | 304 CREATE_QUAD_8_NEW_1(RenderPassDrawQuad, renderPassId, isReplica, maskResourc
eId, contentsChangedSinceLastFrame, maskUVRect, filters, filter, background_filt
ers, copiedRenderPassId); |
| 284 EXPECT_EQ(DrawQuad::RENDER_PASS, copyQuad->material); | 305 EXPECT_EQ(DrawQuad::RENDER_PASS, copyQuad->material); |
| 285 EXPECT_EQ(copiedRenderPassId, copyQuad->render_pass_id); | 306 EXPECT_EQ(copiedRenderPassId, copyQuad->render_pass_id); |
| 286 EXPECT_EQ(isReplica, copyQuad->is_replica); | 307 EXPECT_EQ(isReplica, copyQuad->is_replica); |
| 287 EXPECT_EQ(maskResourceId, copyQuad->mask_resource_id); | 308 EXPECT_EQ(maskResourceId, copyQuad->mask_resource_id); |
| 288 EXPECT_RECT_EQ(contentsChangedSinceLastFrame, copyQuad->contents_changed_sin
ce_last_frame); | 309 EXPECT_RECT_EQ(contentsChangedSinceLastFrame, copyQuad->contents_changed_sin
ce_last_frame); |
| 289 EXPECT_EQ(maskUVRect.ToString(), copyQuad->mask_uv_rect.ToString()); | 310 EXPECT_EQ(maskUVRect.ToString(), copyQuad->mask_uv_rect.ToString()); |
| 311 EXPECT_EQ(filters, copyQuad->filters); |
| 312 EXPECT_EQ(filter, copyQuad->filter); |
| 313 EXPECT_EQ(background_filters, copyQuad->background_filters); |
| 290 | 314 |
| 291 CREATE_QUAD_5_ALL_1(RenderPassDrawQuad, renderPassId, isReplica, maskResourc
eId, contentsChangedSinceLastFrame, maskUVRect, copiedRenderPassId); | 315 CREATE_QUAD_8_ALL_1(RenderPassDrawQuad, renderPassId, isReplica, maskResourc
eId, contentsChangedSinceLastFrame, maskUVRect, filters, filter, background_filt
ers, copiedRenderPassId); |
| 292 EXPECT_EQ(DrawQuad::RENDER_PASS, copyQuad->material); | 316 EXPECT_EQ(DrawQuad::RENDER_PASS, copyQuad->material); |
| 293 EXPECT_EQ(copiedRenderPassId, copyQuad->render_pass_id); | 317 EXPECT_EQ(copiedRenderPassId, copyQuad->render_pass_id); |
| 294 EXPECT_EQ(isReplica, copyQuad->is_replica); | 318 EXPECT_EQ(isReplica, copyQuad->is_replica); |
| 295 EXPECT_EQ(maskResourceId, copyQuad->mask_resource_id); | 319 EXPECT_EQ(maskResourceId, copyQuad->mask_resource_id); |
| 296 EXPECT_RECT_EQ(contentsChangedSinceLastFrame, copyQuad->contents_changed_sin
ce_last_frame); | 320 EXPECT_RECT_EQ(contentsChangedSinceLastFrame, copyQuad->contents_changed_sin
ce_last_frame); |
| 297 EXPECT_EQ(maskUVRect.ToString(), copyQuad->mask_uv_rect.ToString()); | 321 EXPECT_EQ(maskUVRect.ToString(), copyQuad->mask_uv_rect.ToString()); |
| 322 EXPECT_EQ(filters, copyQuad->filters); |
| 323 EXPECT_EQ(filter, copyQuad->filter); |
| 324 EXPECT_EQ(background_filters, copyQuad->background_filters); |
| 298 } | 325 } |
| 299 | 326 |
| 300 TEST(DrawQuadTest, copySolidColorDrawQuad) | 327 TEST(DrawQuadTest, copySolidColorDrawQuad) |
| 301 { | 328 { |
| 302 SkColor color = 0x49494949; | 329 SkColor color = 0x49494949; |
| 303 CREATE_SHARED_STATE(); | 330 CREATE_SHARED_STATE(); |
| 304 | 331 |
| 305 CREATE_QUAD_1_NEW(SolidColorDrawQuad, color); | 332 CREATE_QUAD_1_NEW(SolidColorDrawQuad, color); |
| 306 EXPECT_EQ(DrawQuad::SOLID_COLOR, copyQuad->material); | 333 EXPECT_EQ(DrawQuad::SOLID_COLOR, copyQuad->material); |
| 307 EXPECT_EQ(color, copyQuad->color); | 334 EXPECT_EQ(color, copyQuad->color); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 EXPECT_EQ(uPlane.resourceId, copyQuad->u_plane.resourceId); | 463 EXPECT_EQ(uPlane.resourceId, copyQuad->u_plane.resourceId); |
| 437 EXPECT_EQ(uPlane.size, copyQuad->u_plane.size); | 464 EXPECT_EQ(uPlane.size, copyQuad->u_plane.size); |
| 438 EXPECT_EQ(uPlane.format, copyQuad->u_plane.format); | 465 EXPECT_EQ(uPlane.format, copyQuad->u_plane.format); |
| 439 EXPECT_EQ(vPlane.resourceId, copyQuad->v_plane.resourceId); | 466 EXPECT_EQ(vPlane.resourceId, copyQuad->v_plane.resourceId); |
| 440 EXPECT_EQ(vPlane.size, copyQuad->v_plane.size); | 467 EXPECT_EQ(vPlane.size, copyQuad->v_plane.size); |
| 441 EXPECT_EQ(vPlane.format, copyQuad->v_plane.format); | 468 EXPECT_EQ(vPlane.format, copyQuad->v_plane.format); |
| 442 } | 469 } |
| 443 | 470 |
| 444 } // namespace | 471 } // namespace |
| 445 } // namespace cc | 472 } // namespace cc |
| OLD | NEW |