| 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "CCDrawQuad.h" | 7 #include "CCDrawQuad.h" |
| 8 | 8 |
| 9 #include "CCCheckerboardDrawQuad.h" | 9 #include "CCCheckerboardDrawQuad.h" |
| 10 #include "CCDebugBorderDrawQuad.h" | 10 #include "CCDebugBorderDrawQuad.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 TEST(CCDrawQuadTest, copySharedQuadState) | 28 TEST(CCDrawQuadTest, copySharedQuadState) |
| 29 { | 29 { |
| 30 WebTransformationMatrix quadTransform(1, 0.5, 0, 1, 0.5, 0); | 30 WebTransformationMatrix quadTransform(1, 0.5, 0, 1, 0.5, 0); |
| 31 IntRect visibleContentRect(10, 12, 14, 16); | 31 IntRect visibleContentRect(10, 12, 14, 16); |
| 32 IntRect clippedRectInTarget(19, 21, 23, 25); | 32 IntRect clippedRectInTarget(19, 21, 23, 25); |
| 33 float opacity = 0.25; | 33 float opacity = 0.25; |
| 34 bool opaque = true; | 34 bool opaque = true; |
| 35 int id = 3; | 35 int id = 3; |
| 36 | 36 |
| 37 OwnPtr<CCSharedQuadState> state(CCSharedQuadState::create(quadTransform, vis
ibleContentRect, clippedRectInTarget, opacity, opaque)); | 37 scoped_ptr<CCSharedQuadState> state(CCSharedQuadState::create(quadTransform,
visibleContentRect, clippedRectInTarget, opacity, opaque)); |
| 38 state->id = id; | 38 state->id = id; |
| 39 | 39 |
| 40 OwnPtr<CCSharedQuadState> copy(state->copy()); | 40 scoped_ptr<CCSharedQuadState> copy(state->copy()); |
| 41 EXPECT_EQ(id, copy->id); | 41 EXPECT_EQ(id, copy->id); |
| 42 EXPECT_EQ(quadTransform, copy->quadTransform); | 42 EXPECT_EQ(quadTransform, copy->quadTransform); |
| 43 EXPECT_RECT_EQ(visibleContentRect, copy->visibleContentRect); | 43 EXPECT_RECT_EQ(visibleContentRect, copy->visibleContentRect); |
| 44 EXPECT_RECT_EQ(clippedRectInTarget, copy->clippedRectInTarget); | 44 EXPECT_RECT_EQ(clippedRectInTarget, copy->clippedRectInTarget); |
| 45 EXPECT_EQ(opacity, copy->opacity); | 45 EXPECT_EQ(opacity, copy->opacity); |
| 46 EXPECT_EQ(opaque, copy->opaque); | 46 EXPECT_EQ(opaque, copy->opaque); |
| 47 } | 47 } |
| 48 | 48 |
| 49 PassOwnPtr<CCSharedQuadState> createSharedQuadState() | 49 scoped_ptr<CCSharedQuadState> createSharedQuadState() |
| 50 { | 50 { |
| 51 WebTransformationMatrix quadTransform(1, 0.5, 0, 1, 0.5, 0); | 51 WebTransformationMatrix quadTransform(1, 0.5, 0, 1, 0.5, 0); |
| 52 IntRect visibleContentRect(10, 12, 14, 16); | 52 IntRect visibleContentRect(10, 12, 14, 16); |
| 53 IntRect clippedRectInTarget(19, 21, 23, 25); | 53 IntRect clippedRectInTarget(19, 21, 23, 25); |
| 54 float opacity = 1; | 54 float opacity = 1; |
| 55 bool opaque = false; | 55 bool opaque = false; |
| 56 int id = 3; | 56 int id = 3; |
| 57 | 57 |
| 58 OwnPtr<CCSharedQuadState> state(CCSharedQuadState::create(quadTransform, vis
ibleContentRect, clippedRectInTarget, opacity, opaque)); | 58 scoped_ptr<CCSharedQuadState> state(CCSharedQuadState::create(quadTransform,
visibleContentRect, clippedRectInTarget, opacity, opaque)); |
| 59 state->id = id; | 59 state->id = id; |
| 60 return state.release(); | 60 return state.Pass(); |
| 61 } | 61 } |
| 62 | 62 |
| 63 void compareDrawQuad(CCDrawQuad* quad, CCDrawQuad* copy, CCSharedQuadState* copy
SharedState) | 63 void compareDrawQuad(CCDrawQuad* quad, CCDrawQuad* copy, CCSharedQuadState* copy
SharedState) |
| 64 { | 64 { |
| 65 EXPECT_EQ(quad->size(), copy->size()); | 65 EXPECT_EQ(quad->size(), copy->size()); |
| 66 EXPECT_EQ(quad->material(), copy->material()); | 66 EXPECT_EQ(quad->material(), copy->material()); |
| 67 EXPECT_EQ(quad->isDebugQuad(), copy->isDebugQuad()); | 67 EXPECT_EQ(quad->isDebugQuad(), copy->isDebugQuad()); |
| 68 EXPECT_RECT_EQ(quad->quadRect(), copy->quadRect()); | 68 EXPECT_RECT_EQ(quad->quadRect(), copy->quadRect()); |
| 69 EXPECT_RECT_EQ(quad->quadVisibleRect(), copy->quadVisibleRect()); | 69 EXPECT_RECT_EQ(quad->quadVisibleRect(), copy->quadVisibleRect()); |
| 70 EXPECT_EQ(quad->opaqueRect(), copy->opaqueRect()); | 70 EXPECT_EQ(quad->opaqueRect(), copy->opaqueRect()); |
| 71 EXPECT_EQ(quad->needsBlending(), copy->needsBlending()); | 71 EXPECT_EQ(quad->needsBlending(), copy->needsBlending()); |
| 72 | 72 |
| 73 EXPECT_EQ(copySharedState, copy->sharedQuadState()); | 73 EXPECT_EQ(copySharedState, copy->sharedQuadState()); |
| 74 EXPECT_EQ(copySharedState->id, copy->sharedQuadStateId()); | 74 EXPECT_EQ(copySharedState->id, copy->sharedQuadStateId()); |
| 75 | 75 |
| 76 EXPECT_EQ(quad->sharedQuadStateId(), quad->sharedQuadState()->id); | 76 EXPECT_EQ(quad->sharedQuadStateId(), quad->sharedQuadState()->id); |
| 77 EXPECT_EQ(copy->sharedQuadStateId(), copy->sharedQuadState()->id); | 77 EXPECT_EQ(copy->sharedQuadStateId(), copy->sharedQuadState()->id); |
| 78 } | 78 } |
| 79 | 79 |
| 80 #define CREATE_SHARED_STATE() \ | 80 #define CREATE_SHARED_STATE() \ |
| 81 OwnPtr<CCSharedQuadState> sharedState(createSharedQuadState()); \ | 81 scoped_ptr<CCSharedQuadState> sharedState(createSharedQuadState()); \ |
| 82 OwnPtr<CCSharedQuadState> copySharedState(sharedState->copy()); \ | 82 scoped_ptr<CCSharedQuadState> copySharedState(sharedState->copy()); \ |
| 83 copySharedState->id = 5; | 83 copySharedState->id = 5; |
| 84 | 84 |
| 85 #define QUAD_DATA \ | 85 #define QUAD_DATA \ |
| 86 IntRect quadRect(30, 40, 50, 60); \ | 86 IntRect quadRect(30, 40, 50, 60); \ |
| 87 IntRect quadVisibleRect(40, 50, 30, 20); \ | 87 IntRect quadVisibleRect(40, 50, 30, 20); \ |
| 88 | 88 |
| 89 #define SETUP_AND_COPY_QUAD(Type, quad) \ | 89 #define SETUP_AND_COPY_QUAD(Type, quad) \ |
| 90 quad->setQuadVisibleRect(quadVisibleRect); \ | 90 quad->setQuadVisibleRect(quadVisibleRect); \ |
| 91 OwnPtr<CCDrawQuad> copy(quad->copy(copySharedState.get())); \ | 91 scoped_ptr<CCDrawQuad> copy(quad->copy(copySharedState.get())); \ |
| 92 compareDrawQuad(quad.get(), copy.get(), copySharedState.get()); \ | 92 compareDrawQuad(quad.get(), copy.get(), copySharedState.get()); \ |
| 93 const Type* copyQuad = Type::materialCast(copy.get()); | 93 const Type* copyQuad = Type::materialCast(copy.get()); |
| 94 | 94 |
| 95 #define SETUP_AND_COPY_QUAD_1(Type, quad, a) \ | 95 #define SETUP_AND_COPY_QUAD_1(Type, quad, a) \ |
| 96 quad->setQuadVisibleRect(quadVisibleRect); \ | 96 quad->setQuadVisibleRect(quadVisibleRect); \ |
| 97 OwnPtr<CCDrawQuad> copy(quad->copy(copySharedState.get(), a)); \ | 97 scoped_ptr<CCDrawQuad> copy(quad->copy(copySharedState.get(), a)); \ |
| 98 compareDrawQuad(quad.get(), copy.get(), copySharedState.get()); \ | 98 compareDrawQuad(quad.get(), copy.get(), copySharedState.get()); \ |
| 99 const Type* copyQuad = Type::materialCast(copy.get()); | 99 const Type* copyQuad = Type::materialCast(copy.get()); |
| 100 | 100 |
| 101 #define CREATE_QUAD_0(Type) \ | 101 #define CREATE_QUAD_0(Type) \ |
| 102 QUAD_DATA \ | 102 QUAD_DATA \ |
| 103 OwnPtr<Type> quad(Type::create(sharedState.get(), quadRect)); \ | 103 scoped_ptr<Type> quad(Type::create(sharedState.get(), quadRect)); \ |
| 104 SETUP_AND_COPY_QUAD(Type, quad); \ | 104 SETUP_AND_COPY_QUAD(Type, quad); \ |
| 105 UNUSED_PARAM(copyQuad); | 105 UNUSED_PARAM(copyQuad); |
| 106 | 106 |
| 107 #define CREATE_QUAD_1(Type, a) \ | 107 #define CREATE_QUAD_1(Type, a) \ |
| 108 QUAD_DATA \ | 108 QUAD_DATA \ |
| 109 OwnPtr<Type> quad(Type::create(sharedState.get(), quadRect, a)); \ | 109 scoped_ptr<Type> quad(Type::create(sharedState.get(), quadRect, a)); \ |
| 110 SETUP_AND_COPY_QUAD(Type, quad); | 110 SETUP_AND_COPY_QUAD(Type, quad); |
| 111 | 111 |
| 112 #define CREATE_QUAD_2(Type, a, b) \ | 112 #define CREATE_QUAD_2(Type, a, b) \ |
| 113 QUAD_DATA \ | 113 QUAD_DATA \ |
| 114 OwnPtr<Type> quad(Type::create(sharedState.get(), quadRect, a, b)); \ | 114 scoped_ptr<Type> quad(Type::create(sharedState.get(), quadRect, a, b)); \ |
| 115 SETUP_AND_COPY_QUAD(Type, quad); | 115 SETUP_AND_COPY_QUAD(Type, quad); |
| 116 | 116 |
| 117 #define CREATE_QUAD_3(Type, a, b, c) \ | 117 #define CREATE_QUAD_3(Type, a, b, c) \ |
| 118 QUAD_DATA \ | 118 QUAD_DATA \ |
| 119 OwnPtr<Type> quad(Type::create(sharedState.get(), quadRect, a, b, c)); \ | 119 scoped_ptr<Type> quad(Type::create(sharedState.get(), quadRect, a, b, c)); \ |
| 120 SETUP_AND_COPY_QUAD(Type, quad); | 120 SETUP_AND_COPY_QUAD(Type, quad); |
| 121 | 121 |
| 122 #define CREATE_QUAD_4(Type, a, b, c, d) \ | 122 #define CREATE_QUAD_4(Type, a, b, c, d) \ |
| 123 QUAD_DATA \ | 123 QUAD_DATA \ |
| 124 OwnPtr<Type> quad(Type::create(sharedState.get(), quadRect, a, b, c, d)); \ | 124 scoped_ptr<Type> quad(Type::create(sharedState.get(), quadRect, a, b, c, d))
; \ |
| 125 SETUP_AND_COPY_QUAD(Type, quad); | 125 SETUP_AND_COPY_QUAD(Type, quad); |
| 126 | 126 |
| 127 #define CREATE_QUAD_5(Type, a, b, c, d, e) \ | 127 #define CREATE_QUAD_5(Type, a, b, c, d, e) \ |
| 128 QUAD_DATA \ | 128 QUAD_DATA \ |
| 129 OwnPtr<Type> quad(Type::create(sharedState.get(), quadRect, a, b, c, d, e));
\ | 129 scoped_ptr<Type> quad(Type::create(sharedState.get(), quadRect, a, b, c, d,
e)); \ |
| 130 SETUP_AND_COPY_QUAD(Type, quad); | 130 SETUP_AND_COPY_QUAD(Type, quad); |
| 131 | 131 |
| 132 #define CREATE_QUAD_6(Type, a, b, c, d, e, f) \ | 132 #define CREATE_QUAD_6(Type, a, b, c, d, e, f) \ |
| 133 QUAD_DATA \ | 133 QUAD_DATA \ |
| 134 OwnPtr<Type> quad(Type::create(sharedState.get(), quadRect, a, b, c, d, e, f
)); \ | 134 scoped_ptr<Type> quad(Type::create(sharedState.get(), quadRect, a, b, c, d,
e, f)); \ |
| 135 SETUP_AND_COPY_QUAD(Type, quad); | 135 SETUP_AND_COPY_QUAD(Type, quad); |
| 136 | 136 |
| 137 #define CREATE_QUAD_7(Type, a, b, c, d, e, f, g) \ | 137 #define CREATE_QUAD_7(Type, a, b, c, d, e, f, g) \ |
| 138 QUAD_DATA \ | 138 QUAD_DATA \ |
| 139 OwnPtr<Type> quad(Type::create(sharedState.get(), quadRect, a, b, c, d, e, f
, g)); \ | 139 scoped_ptr<Type> quad(Type::create(sharedState.get(), quadRect, a, b, c, d,
e, f, g)); \ |
| 140 SETUP_AND_COPY_QUAD(Type, quad); | 140 SETUP_AND_COPY_QUAD(Type, quad); |
| 141 | 141 |
| 142 #define CREATE_QUAD_8(Type, a, b, c, d, e, f, g, h) \ | 142 #define CREATE_QUAD_8(Type, a, b, c, d, e, f, g, h) \ |
| 143 QUAD_DATA \ | 143 QUAD_DATA \ |
| 144 OwnPtr<Type> quad(Type::create(sharedState.get(), quadRect, a, b, c, d, e, f
, g, h)); \ | 144 scoped_ptr<Type> quad(Type::create(sharedState.get(), quadRect, a, b, c, d,
e, f, g, h)); \ |
| 145 SETUP_AND_COPY_QUAD(Type, quad); | 145 SETUP_AND_COPY_QUAD(Type, quad); |
| 146 | 146 |
| 147 #define CREATE_QUAD_8_1(Type, a, b, c, d, e, f, g, h, copyA) \ | 147 #define CREATE_QUAD_8_1(Type, a, b, c, d, e, f, g, h, copyA) \ |
| 148 QUAD_DATA \ | 148 QUAD_DATA \ |
| 149 OwnPtr<Type> quad(Type::create(sharedState.get(), quadRect, a, b, c, d, e, f
, g, h)); \ | 149 scoped_ptr<Type> quad(Type::create(sharedState.get(), quadRect, a, b, c, d,
e, f, g, h)); \ |
| 150 SETUP_AND_COPY_QUAD_1(Type, quad, copyA); | 150 SETUP_AND_COPY_QUAD_1(Type, quad, copyA); |
| 151 | 151 |
| 152 #define CREATE_QUAD_9(Type, a, b, c, d, e, f, g, h, i) \ | 152 #define CREATE_QUAD_9(Type, a, b, c, d, e, f, g, h, i) \ |
| 153 QUAD_DATA \ | 153 QUAD_DATA \ |
| 154 OwnPtr<Type> quad(Type::create(sharedState.get(), quadRect, a, b, c, d, e, f
, g, h, i)); \ | 154 scoped_ptr<Type> quad(Type::create(sharedState.get(), quadRect, a, b, c, d,
e, f, g, h, i)); \ |
| 155 SETUP_AND_COPY_QUAD(Type, quad); | 155 SETUP_AND_COPY_QUAD(Type, quad); |
| 156 | 156 |
| 157 #define CREATE_QUAD_10(Type, a, b, c, d, e, f, g, h, i, j) \ | 157 #define CREATE_QUAD_10(Type, a, b, c, d, e, f, g, h, i, j) \ |
| 158 QUAD_DATA \ | 158 QUAD_DATA \ |
| 159 OwnPtr<Type> quad(Type::create(sharedState.get(), quadRect, a, b, c, d, e, f
, g, h, i, j)); \ | 159 scoped_ptr<Type> quad(Type::create(sharedState.get(), quadRect, a, b, c, d,
e, f, g, h, i, j)); \ |
| 160 SETUP_AND_COPY_QUAD(Type, quad); | 160 SETUP_AND_COPY_QUAD(Type, quad); |
| 161 | 161 |
| 162 TEST(CCDrawQuadTest, copyCheckerboardDrawQuad) | 162 TEST(CCDrawQuadTest, copyCheckerboardDrawQuad) |
| 163 { | 163 { |
| 164 CREATE_SHARED_STATE(); | 164 CREATE_SHARED_STATE(); |
| 165 CREATE_QUAD_0(CCCheckerboardDrawQuad); | 165 CREATE_QUAD_0(CCCheckerboardDrawQuad); |
| 166 } | 166 } |
| 167 | 167 |
| 168 TEST(CCDrawQuadTest, copyDebugBorderDrawQuad) | 168 TEST(CCDrawQuadTest, copyDebugBorderDrawQuad) |
| 169 { | 169 { |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 EXPECT_EQ(uPlane.size, copyQuad->uPlane().size); | 303 EXPECT_EQ(uPlane.size, copyQuad->uPlane().size); |
| 304 EXPECT_EQ(uPlane.format, copyQuad->uPlane().format); | 304 EXPECT_EQ(uPlane.format, copyQuad->uPlane().format); |
| 305 EXPECT_EQ(uPlane.visibleSize, copyQuad->uPlane().visibleSize); | 305 EXPECT_EQ(uPlane.visibleSize, copyQuad->uPlane().visibleSize); |
| 306 EXPECT_EQ(vPlane.resourceId, copyQuad->vPlane().resourceId); | 306 EXPECT_EQ(vPlane.resourceId, copyQuad->vPlane().resourceId); |
| 307 EXPECT_EQ(vPlane.size, copyQuad->vPlane().size); | 307 EXPECT_EQ(vPlane.size, copyQuad->vPlane().size); |
| 308 EXPECT_EQ(vPlane.format, copyQuad->vPlane().format); | 308 EXPECT_EQ(vPlane.format, copyQuad->vPlane().format); |
| 309 EXPECT_EQ(vPlane.visibleSize, copyQuad->vPlane().visibleSize); | 309 EXPECT_EQ(vPlane.visibleSize, copyQuad->vPlane().visibleSize); |
| 310 } | 310 } |
| 311 | 311 |
| 312 } // namespace | 312 } // namespace |
| OLD | NEW |