| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "cc/checkerboard_draw_quad.h" | 8 #include "cc/checkerboard_draw_quad.h" |
| 9 #include "cc/debug_border_draw_quad.h" | 9 #include "cc/debug_border_draw_quad.h" |
| 10 #include "cc/io_surface_draw_quad.h" | 10 #include "cc/io_surface_draw_quad.h" |
| 11 #include "cc/math_util.h" | 11 #include "cc/math_util.h" |
| 12 #include "cc/render_pass_draw_quad.h" | 12 #include "cc/render_pass_draw_quad.h" |
| 13 #include "cc/solid_color_draw_quad.h" | 13 #include "cc/solid_color_draw_quad.h" |
| 14 #include "cc/stream_video_draw_quad.h" | 14 #include "cc/stream_video_draw_quad.h" |
| 15 #include "cc/test/geometry_test_utils.h" | 15 #include "cc/test/geometry_test_utils.h" |
| 16 #include "cc/texture_draw_quad.h" | 16 #include "cc/texture_draw_quad.h" |
| 17 #include "cc/tile_draw_quad.h" | 17 #include "cc/tile_draw_quad.h" |
| 18 #include "cc/yuv_video_draw_quad.h" | 18 #include "cc/yuv_video_draw_quad.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 20 #include "third_party/WebKit/Source/Platform/chromium/public/WebFilterOperations
.h" | 20 #include "third_party/WebKit/Source/Platform/chromium/public/WebFilterOperations
.h" |
| 21 #include "third_party/skia/include/effects/SkBlurImageFilter.h" | 21 #include "third_party/skia/include/effects/SkBlurImageFilter.h" |
| 22 #include "ui/gfx/transform.h" | 22 #include "ui/gfx/transform.h" |
| 23 | 23 |
| 24 namespace cc { | 24 namespace cc { |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 TEST(DrawQuadTest, copySharedQuadState) | 27 TEST(DrawQuadTest, copySharedQuadState) |
| 28 { | 28 { |
| 29 gfx::Transform quadTransform = gfx::Transform(1.0, 0.0, 0.5, 1.0, 0.5, 0.0); | 29 gfx::Transform quadTransform = gfx::Transform(1.0, 0.0, 0.5, 1.0, 0.5, 0.0); |
| 30 gfx::Size contentBounds(26, 28); |
| 30 gfx::Rect visibleContentRect(10, 12, 14, 16); | 31 gfx::Rect visibleContentRect(10, 12, 14, 16); |
| 31 gfx::Rect clipRect(19, 21, 23, 25); | 32 gfx::Rect clipRect(19, 21, 23, 25); |
| 32 bool isClipped = true; | 33 bool isClipped = true; |
| 33 float opacity = 0.25; | 34 float opacity = 0.25; |
| 34 | 35 |
| 35 scoped_ptr<SharedQuadState> state(SharedQuadState::Create()); | 36 scoped_ptr<SharedQuadState> state(SharedQuadState::Create()); |
| 36 state->SetAll(quadTransform, visibleContentRect, clipRect, isClipped, opacit
y); | 37 state->SetAll(quadTransform, contentBounds, visibleContentRect, clipRect, |
| 38 isClipped, opacity); |
| 37 | 39 |
| 38 scoped_ptr<SharedQuadState> copy(state->Copy()); | 40 scoped_ptr<SharedQuadState> copy(state->Copy()); |
| 39 EXPECT_EQ(quadTransform, copy->content_to_target_transform); | 41 EXPECT_EQ(quadTransform, copy->content_to_target_transform); |
| 40 EXPECT_RECT_EQ(visibleContentRect, copy->visible_content_rect); | 42 EXPECT_RECT_EQ(visibleContentRect, copy->visible_content_rect); |
| 41 EXPECT_EQ(opacity, copy->opacity); | 43 EXPECT_EQ(opacity, copy->opacity); |
| 42 EXPECT_RECT_EQ(clipRect, copy->clip_rect); | 44 EXPECT_RECT_EQ(clipRect, copy->clip_rect); |
| 43 EXPECT_EQ(isClipped, copy->is_clipped); | 45 EXPECT_EQ(isClipped, copy->is_clipped); |
| 44 } | 46 } |
| 45 | 47 |
| 46 scoped_ptr<SharedQuadState> createSharedQuadState() | 48 scoped_ptr<SharedQuadState> createSharedQuadState() |
| 47 { | 49 { |
| 48 gfx::Transform quadTransform = gfx::Transform(1.0, 0.0, 0.5, 1.0, 0.5, 0.0); | 50 gfx::Transform quadTransform = gfx::Transform(1.0, 0.0, 0.5, 1.0, 0.5, 0.0); |
| 51 gfx::Size contentBounds(26, 28); |
| 49 gfx::Rect visibleContentRect(10, 12, 14, 16); | 52 gfx::Rect visibleContentRect(10, 12, 14, 16); |
| 50 gfx::Rect clipRect(19, 21, 23, 25); | 53 gfx::Rect clipRect(19, 21, 23, 25); |
| 51 bool isClipped = false; | 54 bool isClipped = false; |
| 52 float opacity = 1; | 55 float opacity = 1; |
| 53 | 56 |
| 54 scoped_ptr<SharedQuadState> state(SharedQuadState::Create()); | 57 scoped_ptr<SharedQuadState> state(SharedQuadState::Create()); |
| 55 state->SetAll(quadTransform, visibleContentRect, clipRect, isClipped, opacit
y); | 58 state->SetAll(quadTransform, contentBounds, visibleContentRect, clipRect, |
| 59 isClipped, opacity); |
| 56 return state.Pass(); | 60 return state.Pass(); |
| 57 } | 61 } |
| 58 | 62 |
| 59 void compareDrawQuad(DrawQuad* quad, DrawQuad* copy, SharedQuadState* copyShared
State) | 63 void compareDrawQuad(DrawQuad* quad, DrawQuad* copy, SharedQuadState* copyShared
State) |
| 60 { | 64 { |
| 61 EXPECT_EQ(quad->material, copy->material); | 65 EXPECT_EQ(quad->material, copy->material); |
| 62 EXPECT_RECT_EQ(quad->rect, copy->rect); | 66 EXPECT_RECT_EQ(quad->rect, copy->rect); |
| 63 EXPECT_RECT_EQ(quad->visible_rect, copy->visible_rect); | 67 EXPECT_RECT_EQ(quad->visible_rect, copy->visible_rect); |
| 64 EXPECT_RECT_EQ(quad->opaque_rect, copy->opaque_rect); | 68 EXPECT_RECT_EQ(quad->opaque_rect, copy->opaque_rect); |
| 65 EXPECT_EQ(quad->needs_blending, copy->needs_blending); | 69 EXPECT_EQ(quad->needs_blending, copy->needs_blending); |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 } | 458 } |
| 455 } | 459 } |
| 456 | 460 |
| 457 TEST(DrawQuadTest, copyTileDrawQuad) | 461 TEST(DrawQuadTest, copyTileDrawQuad) |
| 458 { | 462 { |
| 459 gfx::Rect opaqueRect(33, 44, 22, 33); | 463 gfx::Rect opaqueRect(33, 44, 22, 33); |
| 460 unsigned resourceId = 104; | 464 unsigned resourceId = 104; |
| 461 gfx::RectF texCoordRect(31, 12, 54, 20); | 465 gfx::RectF texCoordRect(31, 12, 54, 20); |
| 462 gfx::Size textureSize(85, 32); | 466 gfx::Size textureSize(85, 32); |
| 463 bool swizzleContents = true; | 467 bool swizzleContents = true; |
| 464 bool leftEdgeAA = true; | |
| 465 bool topEdgeAA = true; | |
| 466 bool rightEdgeAA = false; | |
| 467 bool bottomEdgeAA = true; | |
| 468 CREATE_SHARED_STATE(); | 468 CREATE_SHARED_STATE(); |
| 469 | 469 |
| 470 CREATE_QUAD_9_NEW(TileDrawQuad, opaqueRect, resourceId, texCoordRect, textur
eSize, swizzleContents, leftEdgeAA, topEdgeAA, rightEdgeAA, bottomEdgeAA); | 470 CREATE_QUAD_5_NEW(TileDrawQuad, opaqueRect, resourceId, texCoordRect, textur
eSize, swizzleContents); |
| 471 EXPECT_EQ(DrawQuad::TILED_CONTENT, copyQuad->material); | 471 EXPECT_EQ(DrawQuad::TILED_CONTENT, copyQuad->material); |
| 472 EXPECT_RECT_EQ(opaqueRect, copyQuad->opaque_rect); | 472 EXPECT_RECT_EQ(opaqueRect, copyQuad->opaque_rect); |
| 473 EXPECT_EQ(resourceId, copyQuad->resource_id); | 473 EXPECT_EQ(resourceId, copyQuad->resource_id); |
| 474 EXPECT_EQ(texCoordRect, copyQuad->tex_coord_rect); | 474 EXPECT_EQ(texCoordRect, copyQuad->tex_coord_rect); |
| 475 EXPECT_EQ(textureSize, copyQuad->texture_size); | 475 EXPECT_EQ(textureSize, copyQuad->texture_size); |
| 476 EXPECT_EQ(swizzleContents, copyQuad->swizzle_contents); | 476 EXPECT_EQ(swizzleContents, copyQuad->swizzle_contents); |
| 477 EXPECT_EQ(leftEdgeAA, copyQuad->left_edge_aa); | |
| 478 EXPECT_EQ(topEdgeAA, copyQuad->top_edge_aa); | |
| 479 EXPECT_EQ(rightEdgeAA, copyQuad->right_edge_aa); | |
| 480 EXPECT_EQ(bottomEdgeAA, copyQuad->bottom_edge_aa); | |
| 481 | 477 |
| 482 CREATE_QUAD_8_ALL(TileDrawQuad, resourceId, texCoordRect, textureSize, swizz
leContents, leftEdgeAA, topEdgeAA, rightEdgeAA, bottomEdgeAA); | 478 CREATE_QUAD_4_ALL(TileDrawQuad, resourceId, texCoordRect, textureSize, swizz
leContents); |
| 483 EXPECT_EQ(DrawQuad::TILED_CONTENT, copyQuad->material); | 479 EXPECT_EQ(DrawQuad::TILED_CONTENT, copyQuad->material); |
| 484 EXPECT_EQ(resourceId, copyQuad->resource_id); | 480 EXPECT_EQ(resourceId, copyQuad->resource_id); |
| 485 EXPECT_EQ(texCoordRect, copyQuad->tex_coord_rect); | 481 EXPECT_EQ(texCoordRect, copyQuad->tex_coord_rect); |
| 486 EXPECT_EQ(textureSize, copyQuad->texture_size); | 482 EXPECT_EQ(textureSize, copyQuad->texture_size); |
| 487 EXPECT_EQ(swizzleContents, copyQuad->swizzle_contents); | 483 EXPECT_EQ(swizzleContents, copyQuad->swizzle_contents); |
| 488 EXPECT_EQ(leftEdgeAA, copyQuad->left_edge_aa); | |
| 489 EXPECT_EQ(topEdgeAA, copyQuad->top_edge_aa); | |
| 490 EXPECT_EQ(rightEdgeAA, copyQuad->right_edge_aa); | |
| 491 EXPECT_EQ(bottomEdgeAA, copyQuad->bottom_edge_aa); | |
| 492 } | 484 } |
| 493 | 485 |
| 494 TEST(DrawQuadTest, copyYUVVideoDrawQuad) | 486 TEST(DrawQuadTest, copyYUVVideoDrawQuad) |
| 495 { | 487 { |
| 496 gfx::Rect opaqueRect(3, 7, 10, 12); | 488 gfx::Rect opaqueRect(3, 7, 10, 12); |
| 497 gfx::SizeF texScale(0.75, 0.5); | 489 gfx::SizeF texScale(0.75, 0.5); |
| 498 VideoLayerImpl::FramePlane yPlane; | 490 VideoLayerImpl::FramePlane yPlane; |
| 499 yPlane.resourceId = 45; | 491 yPlane.resourceId = 45; |
| 500 yPlane.size = gfx::Size(34, 23); | 492 yPlane.size = gfx::Size(34, 23); |
| 501 yPlane.format = 8; | 493 yPlane.format = 8; |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 EXPECT_EQ(1, IterateAndCount(quadNew.get())); | 633 EXPECT_EQ(1, IterateAndCount(quadNew.get())); |
| 642 EXPECT_EQ(resourceId + 1, quadNew->resource_id); | 634 EXPECT_EQ(resourceId + 1, quadNew->resource_id); |
| 643 } | 635 } |
| 644 | 636 |
| 645 TEST_F(DrawQuadIteratorTest, TileDrawQuad) { | 637 TEST_F(DrawQuadIteratorTest, TileDrawQuad) { |
| 646 gfx::Rect opaqueRect(33, 44, 22, 33); | 638 gfx::Rect opaqueRect(33, 44, 22, 33); |
| 647 unsigned resourceId = 104; | 639 unsigned resourceId = 104; |
| 648 gfx::RectF texCoordRect(31, 12, 54, 20); | 640 gfx::RectF texCoordRect(31, 12, 54, 20); |
| 649 gfx::Size textureSize(85, 32); | 641 gfx::Size textureSize(85, 32); |
| 650 bool swizzleContents = true; | 642 bool swizzleContents = true; |
| 651 bool leftEdgeAA = true; | |
| 652 bool topEdgeAA = true; | |
| 653 bool rightEdgeAA = false; | |
| 654 bool bottomEdgeAA = true; | |
| 655 | 643 |
| 656 CREATE_SHARED_STATE(); | 644 CREATE_SHARED_STATE(); |
| 657 CREATE_QUAD_9_NEW(TileDrawQuad, opaqueRect, resourceId, texCoordRect, textureS
ize, swizzleContents, leftEdgeAA, topEdgeAA, rightEdgeAA, bottomEdgeAA); | 645 CREATE_QUAD_5_NEW(TileDrawQuad, opaqueRect, resourceId, texCoordRect, textureS
ize, swizzleContents); |
| 658 EXPECT_EQ(resourceId, quadNew->resource_id); | 646 EXPECT_EQ(resourceId, quadNew->resource_id); |
| 659 EXPECT_EQ(1, IterateAndCount(quadNew.get())); | 647 EXPECT_EQ(1, IterateAndCount(quadNew.get())); |
| 660 EXPECT_EQ(resourceId + 1, quadNew->resource_id); | 648 EXPECT_EQ(resourceId + 1, quadNew->resource_id); |
| 661 } | 649 } |
| 662 | 650 |
| 663 TEST_F(DrawQuadIteratorTest, YUVVideoDrawQuad) { | 651 TEST_F(DrawQuadIteratorTest, YUVVideoDrawQuad) { |
| 664 gfx::Rect opaqueRect(3, 7, 10, 12); | 652 gfx::Rect opaqueRect(3, 7, 10, 12); |
| 665 gfx::SizeF texScale(0.75, 0.5); | 653 gfx::SizeF texScale(0.75, 0.5); |
| 666 VideoLayerImpl::FramePlane yPlane; | 654 VideoLayerImpl::FramePlane yPlane; |
| 667 yPlane.resourceId = 45; | 655 yPlane.resourceId = 45; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 684 EXPECT_EQ(vPlane.resourceId, quadNew->v_plane.resourceId); | 672 EXPECT_EQ(vPlane.resourceId, quadNew->v_plane.resourceId); |
| 685 EXPECT_EQ(3, IterateAndCount(quadNew.get())); | 673 EXPECT_EQ(3, IterateAndCount(quadNew.get())); |
| 686 EXPECT_EQ(yPlane.resourceId + 1, quadNew->y_plane.resourceId); | 674 EXPECT_EQ(yPlane.resourceId + 1, quadNew->y_plane.resourceId); |
| 687 EXPECT_EQ(uPlane.resourceId + 1, quadNew->u_plane.resourceId); | 675 EXPECT_EQ(uPlane.resourceId + 1, quadNew->u_plane.resourceId); |
| 688 EXPECT_EQ(vPlane.resourceId + 1, quadNew->v_plane.resourceId); | 676 EXPECT_EQ(vPlane.resourceId + 1, quadNew->v_plane.resourceId); |
| 689 } | 677 } |
| 690 | 678 |
| 691 | 679 |
| 692 } // namespace | 680 } // namespace |
| 693 } // namespace cc | 681 } // namespace cc |
| OLD | NEW |