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/render_pass_draw_quad.h" | 10 #include "cc/render_pass_draw_quad.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 namespace cc { | 22 namespace cc { |
23 namespace { | 23 namespace { |
24 | 24 |
25 TEST(DrawQuadTest, copySharedQuadState) | 25 TEST(DrawQuadTest, copySharedQuadState) |
26 { | 26 { |
27 WebTransformationMatrix quadTransform(1, 0.5, 0, 1, 0.5, 0); | 27 WebTransformationMatrix quadTransform(1, 0.5, 0, 1, 0.5, 0); |
28 gfx::Rect visibleContentRect(10, 12, 14, 16); | 28 gfx::Rect visibleContentRect(10, 12, 14, 16); |
29 gfx::Rect clippedRectInTarget(19, 21, 23, 25); | 29 gfx::Rect clippedRectInTarget(19, 21, 23, 25); |
30 float opacity = 0.25; | 30 float opacity = 0.25; |
31 int id = 3; | |
32 | 31 |
33 scoped_ptr<SharedQuadState> state(SharedQuadState::create(quadTransform, vis
ibleContentRect, clippedRectInTarget, opacity)); | 32 scoped_ptr<SharedQuadState> state(SharedQuadState::Create()); |
34 state->id = id; | 33 state->SetAll(quadTransform, visibleContentRect, clippedRectInTarget, opacit
y); |
35 | 34 |
36 scoped_ptr<SharedQuadState> copy(state->copy()); | 35 scoped_ptr<SharedQuadState> copy(state->Copy()); |
37 EXPECT_EQ(id, copy->id); | 36 EXPECT_EQ(quadTransform, copy->content_to_target_transform); |
38 EXPECT_EQ(quadTransform, copy->quadTransform); | 37 EXPECT_RECT_EQ(visibleContentRect, copy->visible_content_rect); |
39 EXPECT_RECT_EQ(visibleContentRect, copy->visibleContentRect); | 38 EXPECT_RECT_EQ(clippedRectInTarget, copy->clipped_rect_in_target); |
40 EXPECT_RECT_EQ(clippedRectInTarget, copy->clippedRectInTarget); | |
41 EXPECT_EQ(opacity, copy->opacity); | 39 EXPECT_EQ(opacity, copy->opacity); |
42 } | 40 } |
43 | 41 |
44 scoped_ptr<SharedQuadState> createSharedQuadState() | 42 scoped_ptr<SharedQuadState> createSharedQuadState() |
45 { | 43 { |
46 WebTransformationMatrix quadTransform(1, 0.5, 0, 1, 0.5, 0); | 44 WebTransformationMatrix quadTransform(1, 0.5, 0, 1, 0.5, 0); |
47 gfx::Rect visibleContentRect(10, 12, 14, 16); | 45 gfx::Rect visibleContentRect(10, 12, 14, 16); |
48 gfx::Rect clippedRectInTarget(19, 21, 23, 25); | 46 gfx::Rect clippedRectInTarget(19, 21, 23, 25); |
49 float opacity = 1; | 47 float opacity = 1; |
50 int id = 3; | |
51 | 48 |
52 scoped_ptr<SharedQuadState> state(SharedQuadState::create(quadTransform, vis
ibleContentRect, clippedRectInTarget, opacity)); | 49 scoped_ptr<SharedQuadState> state(SharedQuadState::Create()); |
53 state->id = id; | 50 state->SetAll(quadTransform, visibleContentRect, clippedRectInTarget, opacit
y); |
54 return state.Pass(); | 51 return state.Pass(); |
55 } | 52 } |
56 | 53 |
57 void compareDrawQuad(DrawQuad* quad, DrawQuad* copy, SharedQuadState* copyShared
State) | 54 void compareDrawQuad(DrawQuad* quad, DrawQuad* copy, SharedQuadState* copyShared
State) |
58 { | 55 { |
59 EXPECT_EQ(quad->material, copy->material); | 56 EXPECT_EQ(quad->material, copy->material); |
60 EXPECT_RECT_EQ(quad->rect, copy->rect); | 57 EXPECT_RECT_EQ(quad->rect, copy->rect); |
61 EXPECT_RECT_EQ(quad->visible_rect, copy->visible_rect); | 58 EXPECT_RECT_EQ(quad->visible_rect, copy->visible_rect); |
62 EXPECT_RECT_EQ(quad->opaque_rect, copy->opaque_rect); | 59 EXPECT_RECT_EQ(quad->opaque_rect, copy->opaque_rect); |
63 EXPECT_EQ(quad->needs_blending, copy->needs_blending); | 60 EXPECT_EQ(quad->needs_blending, copy->needs_blending); |
64 EXPECT_EQ(copySharedState, copy->shared_quad_state); | 61 EXPECT_EQ(copySharedState, copy->shared_quad_state); |
65 } | 62 } |
66 | 63 |
67 #define CREATE_SHARED_STATE() \ | 64 #define CREATE_SHARED_STATE() \ |
68 scoped_ptr<SharedQuadState> sharedState(createSharedQuadState()); \ | 65 scoped_ptr<SharedQuadState> sharedState(createSharedQuadState()); \ |
69 scoped_ptr<SharedQuadState> copySharedState(sharedState->copy()); \ | 66 scoped_ptr<SharedQuadState> copySharedState(sharedState->Copy()); \ |
70 copySharedState->id = 5; | |
71 | 67 |
72 #define QUAD_DATA \ | 68 #define QUAD_DATA \ |
73 gfx::Rect quadRect(30, 40, 50, 60); \ | 69 gfx::Rect quadRect(30, 40, 50, 60); \ |
74 gfx::Rect quadVisibleRect(40, 50, 30, 20); \ | 70 gfx::Rect quadVisibleRect(40, 50, 30, 20); \ |
75 gfx::Rect quadOpaqueRect(60, 55, 10, 10); \ | 71 gfx::Rect quadOpaqueRect(60, 55, 10, 10); \ |
76 bool needsBlending = true; | 72 bool needsBlending = true; |
77 | 73 |
78 #define SETUP_AND_COPY_QUAD_NEW(Type, quad) \ | 74 #define SETUP_AND_COPY_QUAD_NEW(Type, quad) \ |
79 scoped_ptr<DrawQuad> copyNew(quadNew->Copy(copySharedState.get())); \ | 75 scoped_ptr<DrawQuad> copyNew(quadNew->Copy(copySharedState.get())); \ |
80 compareDrawQuad(quadNew.get(), copyNew.get(), copySharedState.get()); \ | 76 compareDrawQuad(quadNew.get(), copyNew.get(), copySharedState.get()); \ |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 EXPECT_EQ(uPlane.resourceId, copyQuad->u_plane.resourceId); | 437 EXPECT_EQ(uPlane.resourceId, copyQuad->u_plane.resourceId); |
442 EXPECT_EQ(uPlane.size, copyQuad->u_plane.size); | 438 EXPECT_EQ(uPlane.size, copyQuad->u_plane.size); |
443 EXPECT_EQ(uPlane.format, copyQuad->u_plane.format); | 439 EXPECT_EQ(uPlane.format, copyQuad->u_plane.format); |
444 EXPECT_EQ(vPlane.resourceId, copyQuad->v_plane.resourceId); | 440 EXPECT_EQ(vPlane.resourceId, copyQuad->v_plane.resourceId); |
445 EXPECT_EQ(vPlane.size, copyQuad->v_plane.size); | 441 EXPECT_EQ(vPlane.size, copyQuad->v_plane.size); |
446 EXPECT_EQ(vPlane.format, copyQuad->v_plane.format); | 442 EXPECT_EQ(vPlane.format, copyQuad->v_plane.format); |
447 } | 443 } |
448 | 444 |
449 } // namespace | 445 } // namespace |
450 } // namespace cc | 446 } // namespace cc |
OLD | NEW |