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