| 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 float opacity = 0.25; | 31 float opacity = 0.25; |
| 31 | 32 |
| 32 scoped_ptr<SharedQuadState> state(SharedQuadState::Create()); | 33 scoped_ptr<SharedQuadState> state(SharedQuadState::Create()); |
| 33 state->SetAll(quadTransform, visibleContentRect, clippedRectInTarget, opacit
y); | 34 state->SetAll(quadTransform, visibleContentRect, clippedRectInTarget, opacit
y); |
| 34 | 35 |
| 35 scoped_ptr<SharedQuadState> copy(state->Copy()); | 36 scoped_ptr<SharedQuadState> copy(state->Copy()); |
| 36 EXPECT_EQ(quadTransform, copy->content_to_target_transform); | 37 EXPECT_EQ(quadTransform, copy->content_to_target_transform); |
| 37 EXPECT_RECT_EQ(visibleContentRect, copy->visible_content_rect); | 38 EXPECT_RECT_EQ(visibleContentRect, copy->visible_content_rect); |
| 38 EXPECT_RECT_EQ(clippedRectInTarget, copy->clipped_rect_in_target); | 39 EXPECT_RECT_EQ(clippedRectInTarget, copy->clipped_rect_in_target); |
| 39 EXPECT_EQ(opacity, copy->opacity); | 40 EXPECT_EQ(opacity, copy->opacity); |
| 40 } | 41 } |
| 41 | 42 |
| 42 scoped_ptr<SharedQuadState> createSharedQuadState() | 43 scoped_ptr<SharedQuadState> createSharedQuadState() |
| 43 { | 44 { |
| 44 WebTransformationMatrix quadTransform(1, 0.5, 0, 1, 0.5, 0); | 45 Transform quadTransform = MathUtil::createGfxTransform(1, 0.5, 0, 1, 0.5, 0)
; |
| 45 gfx::Rect visibleContentRect(10, 12, 14, 16); | 46 gfx::Rect visibleContentRect(10, 12, 14, 16); |
| 46 gfx::Rect clippedRectInTarget(19, 21, 23, 25); | 47 gfx::Rect clippedRectInTarget(19, 21, 23, 25); |
| 47 float opacity = 1; | 48 float opacity = 1; |
| 48 | 49 |
| 49 scoped_ptr<SharedQuadState> state(SharedQuadState::Create()); | 50 scoped_ptr<SharedQuadState> state(SharedQuadState::Create()); |
| 50 state->SetAll(quadTransform, visibleContentRect, clippedRectInTarget, opacit
y); | 51 state->SetAll(quadTransform, visibleContentRect, clippedRectInTarget, opacit
y); |
| 51 return state.Pass(); | 52 return state.Pass(); |
| 52 } | 53 } |
| 53 | 54 |
| 54 void compareDrawQuad(DrawQuad* quad, DrawQuad* copy, SharedQuadState* copyShared
State) | 55 void compareDrawQuad(DrawQuad* quad, DrawQuad* copy, SharedQuadState* copyShared
State) |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 | 313 |
| 313 CREATE_QUAD_1_ALL(SolidColorDrawQuad, color); | 314 CREATE_QUAD_1_ALL(SolidColorDrawQuad, color); |
| 314 EXPECT_EQ(DrawQuad::SOLID_COLOR, copyQuad->material); | 315 EXPECT_EQ(DrawQuad::SOLID_COLOR, copyQuad->material); |
| 315 EXPECT_EQ(color, copyQuad->color); | 316 EXPECT_EQ(color, copyQuad->color); |
| 316 } | 317 } |
| 317 | 318 |
| 318 TEST(DrawQuadTest, copyStreamVideoDrawQuad) | 319 TEST(DrawQuadTest, copyStreamVideoDrawQuad) |
| 319 { | 320 { |
| 320 gfx::Rect opaqueRect(3, 7, 10, 12); | 321 gfx::Rect opaqueRect(3, 7, 10, 12); |
| 321 unsigned textureId = 64; | 322 unsigned textureId = 64; |
| 322 WebTransformationMatrix matrix(0.5, 1, 0.25, 0.75, 0, 1); | 323 Transform matrix = MathUtil::createGfxTransform(0.5, 1, 0.25, 0.75, 0, 1); |
| 323 CREATE_SHARED_STATE(); | 324 CREATE_SHARED_STATE(); |
| 324 | 325 |
| 325 CREATE_QUAD_3_NEW(StreamVideoDrawQuad, opaqueRect, textureId, matrix); | 326 CREATE_QUAD_3_NEW(StreamVideoDrawQuad, opaqueRect, textureId, matrix); |
| 326 EXPECT_EQ(DrawQuad::STREAM_VIDEO_CONTENT, copyQuad->material); | 327 EXPECT_EQ(DrawQuad::STREAM_VIDEO_CONTENT, copyQuad->material); |
| 327 EXPECT_RECT_EQ(opaqueRect, copyQuad->opaque_rect); | 328 EXPECT_RECT_EQ(opaqueRect, copyQuad->opaque_rect); |
| 328 EXPECT_EQ(textureId, copyQuad->texture_id); | 329 EXPECT_EQ(textureId, copyQuad->texture_id); |
| 329 EXPECT_EQ(matrix, copyQuad->matrix); | 330 EXPECT_EQ(matrix, copyQuad->matrix); |
| 330 | 331 |
| 331 CREATE_QUAD_2_ALL(StreamVideoDrawQuad, textureId, matrix); | 332 CREATE_QUAD_2_ALL(StreamVideoDrawQuad, textureId, matrix); |
| 332 EXPECT_EQ(DrawQuad::STREAM_VIDEO_CONTENT, copyQuad->material); | 333 EXPECT_EQ(DrawQuad::STREAM_VIDEO_CONTENT, copyQuad->material); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 EXPECT_EQ(uPlane.resourceId, copyQuad->u_plane.resourceId); | 438 EXPECT_EQ(uPlane.resourceId, copyQuad->u_plane.resourceId); |
| 438 EXPECT_EQ(uPlane.size, copyQuad->u_plane.size); | 439 EXPECT_EQ(uPlane.size, copyQuad->u_plane.size); |
| 439 EXPECT_EQ(uPlane.format, copyQuad->u_plane.format); | 440 EXPECT_EQ(uPlane.format, copyQuad->u_plane.format); |
| 440 EXPECT_EQ(vPlane.resourceId, copyQuad->v_plane.resourceId); | 441 EXPECT_EQ(vPlane.resourceId, copyQuad->v_plane.resourceId); |
| 441 EXPECT_EQ(vPlane.size, copyQuad->v_plane.size); | 442 EXPECT_EQ(vPlane.size, copyQuad->v_plane.size); |
| 442 EXPECT_EQ(vPlane.format, copyQuad->v_plane.format); | 443 EXPECT_EQ(vPlane.format, copyQuad->v_plane.format); |
| 443 } | 444 } |
| 444 | 445 |
| 445 } // namespace | 446 } // namespace |
| 446 } // namespace cc | 447 } // namespace cc |
| OLD | NEW |