| 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/render_pass_draw_quad.h" | 11 #include "cc/render_pass_draw_quad.h" |
| 11 #include "cc/solid_color_draw_quad.h" | 12 #include "cc/solid_color_draw_quad.h" |
| 12 #include "cc/stream_video_draw_quad.h" | 13 #include "cc/stream_video_draw_quad.h" |
| 13 #include "cc/test/geometry_test_utils.h" | 14 #include "cc/test/geometry_test_utils.h" |
| 14 #include "cc/texture_draw_quad.h" | 15 #include "cc/texture_draw_quad.h" |
| 15 #include "cc/tile_draw_quad.h" | 16 #include "cc/tile_draw_quad.h" |
| 16 #include "cc/yuv_video_draw_quad.h" | 17 #include "cc/yuv_video_draw_quad.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 18 #include <public/WebTransformationMatrix.h> | 19 #include "ui/gfx/transform.h" |
| 19 | 20 |
| 20 using WebKit::WebTransformationMatrix; | 21 using gfx::Transform; |
| 21 | 22 |
| 22 namespace cc { | 23 namespace cc { |
| 23 namespace { | 24 namespace { |
| 24 | 25 |
| 25 TEST(DrawQuadTest, copySharedQuadState) | 26 TEST(DrawQuadTest, copySharedQuadState) |
| 26 { | 27 { |
| 27 WebTransformationMatrix quadTransform(1, 0.5, 0, 1, 0.5, 0); | 28 Transform quadTransform = MathUtil::createGfxTransform(1, 0.5, 0, 1, 0.5, 0)
; |
| 28 gfx::Rect visibleContentRect(10, 12, 14, 16); | 29 gfx::Rect visibleContentRect(10, 12, 14, 16); |
| 29 gfx::Rect clippedRectInTarget(19, 21, 23, 25); | 30 gfx::Rect clippedRectInTarget(19, 21, 23, 25); |
| 30 gfx::Rect clipRect = clippedRectInTarget; | 31 gfx::Rect clipRect = clippedRectInTarget; |
| 31 bool isClipped = true; | 32 bool isClipped = true; |
| 32 float opacity = 0.25; | 33 float opacity = 0.25; |
| 33 | 34 |
| 34 scoped_ptr<SharedQuadState> state(SharedQuadState::Create()); | 35 scoped_ptr<SharedQuadState> state(SharedQuadState::Create()); |
| 35 state->SetAll(quadTransform, visibleContentRect, clippedRectInTarget, clipRe
ct, isClipped, opacity); | 36 state->SetAll(quadTransform, visibleContentRect, clippedRectInTarget, clipRe
ct, isClipped, opacity); |
| 36 | 37 |
| 37 scoped_ptr<SharedQuadState> copy(state->Copy()); | 38 scoped_ptr<SharedQuadState> copy(state->Copy()); |
| 38 EXPECT_EQ(quadTransform, copy->content_to_target_transform); | 39 EXPECT_EQ(quadTransform, copy->content_to_target_transform); |
| 39 EXPECT_RECT_EQ(visibleContentRect, copy->visible_content_rect); | 40 EXPECT_RECT_EQ(visibleContentRect, copy->visible_content_rect); |
| 40 EXPECT_RECT_EQ(clippedRectInTarget, copy->clipped_rect_in_target); | 41 EXPECT_RECT_EQ(clippedRectInTarget, copy->clipped_rect_in_target); |
| 41 EXPECT_EQ(opacity, copy->opacity); | 42 EXPECT_EQ(opacity, copy->opacity); |
| 42 EXPECT_RECT_EQ(clipRect, copy->clip_rect); | 43 EXPECT_RECT_EQ(clipRect, copy->clip_rect); |
| 43 EXPECT_EQ(isClipped, copy->is_clipped); | 44 EXPECT_EQ(isClipped, copy->is_clipped); |
| 44 } | 45 } |
| 45 | 46 |
| 46 scoped_ptr<SharedQuadState> createSharedQuadState() | 47 scoped_ptr<SharedQuadState> createSharedQuadState() |
| 47 { | 48 { |
| 48 WebTransformationMatrix quadTransform(1, 0.5, 0, 1, 0.5, 0); | 49 Transform quadTransform = MathUtil::createGfxTransform(1, 0.5, 0, 1, 0.5, 0)
; |
| 49 gfx::Rect visibleContentRect(10, 12, 14, 16); | 50 gfx::Rect visibleContentRect(10, 12, 14, 16); |
| 50 gfx::Rect clippedRectInTarget(19, 21, 23, 25); | 51 gfx::Rect clippedRectInTarget(19, 21, 23, 25); |
| 51 gfx::Rect clipRect = clippedRectInTarget; | 52 gfx::Rect clipRect = clippedRectInTarget; |
| 52 bool isClipped = false; | 53 bool isClipped = false; |
| 53 float opacity = 1; | 54 float opacity = 1; |
| 54 | 55 |
| 55 scoped_ptr<SharedQuadState> state(SharedQuadState::Create()); | 56 scoped_ptr<SharedQuadState> state(SharedQuadState::Create()); |
| 56 state->SetAll(quadTransform, visibleContentRect, clippedRectInTarget, clipRe
ct, isClipped, opacity); | 57 state->SetAll(quadTransform, visibleContentRect, clippedRectInTarget, clipRe
ct, isClipped, opacity); |
| 57 return state.Pass(); | 58 return state.Pass(); |
| 58 } | 59 } |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 | 319 |
| 319 CREATE_QUAD_1_ALL(SolidColorDrawQuad, color); | 320 CREATE_QUAD_1_ALL(SolidColorDrawQuad, color); |
| 320 EXPECT_EQ(DrawQuad::SOLID_COLOR, copyQuad->material); | 321 EXPECT_EQ(DrawQuad::SOLID_COLOR, copyQuad->material); |
| 321 EXPECT_EQ(color, copyQuad->color); | 322 EXPECT_EQ(color, copyQuad->color); |
| 322 } | 323 } |
| 323 | 324 |
| 324 TEST(DrawQuadTest, copyStreamVideoDrawQuad) | 325 TEST(DrawQuadTest, copyStreamVideoDrawQuad) |
| 325 { | 326 { |
| 326 gfx::Rect opaqueRect(3, 7, 10, 12); | 327 gfx::Rect opaqueRect(3, 7, 10, 12); |
| 327 unsigned textureId = 64; | 328 unsigned textureId = 64; |
| 328 WebTransformationMatrix matrix(0.5, 1, 0.25, 0.75, 0, 1); | 329 Transform matrix = MathUtil::createGfxTransform(0.5, 1, 0.25, 0.75, 0, 1); |
| 329 CREATE_SHARED_STATE(); | 330 CREATE_SHARED_STATE(); |
| 330 | 331 |
| 331 CREATE_QUAD_3_NEW(StreamVideoDrawQuad, opaqueRect, textureId, matrix); | 332 CREATE_QUAD_3_NEW(StreamVideoDrawQuad, opaqueRect, textureId, matrix); |
| 332 EXPECT_EQ(DrawQuad::STREAM_VIDEO_CONTENT, copyQuad->material); | 333 EXPECT_EQ(DrawQuad::STREAM_VIDEO_CONTENT, copyQuad->material); |
| 333 EXPECT_RECT_EQ(opaqueRect, copyQuad->opaque_rect); | 334 EXPECT_RECT_EQ(opaqueRect, copyQuad->opaque_rect); |
| 334 EXPECT_EQ(textureId, copyQuad->texture_id); | 335 EXPECT_EQ(textureId, copyQuad->texture_id); |
| 335 EXPECT_EQ(matrix, copyQuad->matrix); | 336 EXPECT_EQ(matrix, copyQuad->matrix); |
| 336 | 337 |
| 337 CREATE_QUAD_2_ALL(StreamVideoDrawQuad, textureId, matrix); | 338 CREATE_QUAD_2_ALL(StreamVideoDrawQuad, textureId, matrix); |
| 338 EXPECT_EQ(DrawQuad::STREAM_VIDEO_CONTENT, copyQuad->material); | 339 EXPECT_EQ(DrawQuad::STREAM_VIDEO_CONTENT, copyQuad->material); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 EXPECT_EQ(uPlane.resourceId, copyQuad->u_plane.resourceId); | 444 EXPECT_EQ(uPlane.resourceId, copyQuad->u_plane.resourceId); |
| 444 EXPECT_EQ(uPlane.size, copyQuad->u_plane.size); | 445 EXPECT_EQ(uPlane.size, copyQuad->u_plane.size); |
| 445 EXPECT_EQ(uPlane.format, copyQuad->u_plane.format); | 446 EXPECT_EQ(uPlane.format, copyQuad->u_plane.format); |
| 446 EXPECT_EQ(vPlane.resourceId, copyQuad->v_plane.resourceId); | 447 EXPECT_EQ(vPlane.resourceId, copyQuad->v_plane.resourceId); |
| 447 EXPECT_EQ(vPlane.size, copyQuad->v_plane.size); | 448 EXPECT_EQ(vPlane.size, copyQuad->v_plane.size); |
| 448 EXPECT_EQ(vPlane.format, copyQuad->v_plane.format); | 449 EXPECT_EQ(vPlane.format, copyQuad->v_plane.format); |
| 449 } | 450 } |
| 450 | 451 |
| 451 } // namespace | 452 } // namespace |
| 452 } // namespace cc | 453 } // namespace cc |
| OLD | NEW |