| 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 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 using WebKit::WebTransformationMatrix; | 22 using WebKit::WebTransformationMatrix; |
| 23 | 23 |
| 24 using namespace cc; | 24 using namespace cc; |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 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 gfx::Rect visibleContentRect(10, 12, 14, 16); |
| 32 IntRect clippedRectInTarget(19, 21, 23, 25); | 32 gfx::Rect 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 scoped_ptr<CCSharedQuadState> state(CCSharedQuadState::create(quadTransform,
visibleContentRect, 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 scoped_ptr<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 scoped_ptr<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 gfx::Rect visibleContentRect(10, 12, 14, 16); |
| 53 IntRect clippedRectInTarget(19, 21, 23, 25); | 53 gfx::Rect 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 scoped_ptr<CCSharedQuadState> state(CCSharedQuadState::create(quadTransform,
visibleContentRect, 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.Pass(); | 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) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 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 scoped_ptr<CCSharedQuadState> sharedState(createSharedQuadState()); \ | 81 scoped_ptr<CCSharedQuadState> sharedState(createSharedQuadState()); \ |
| 82 scoped_ptr<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 gfx::Rect quadRect(30, 40, 50, 60); \ |
| 87 IntRect quadVisibleRect(40, 50, 30, 20); \ | 87 gfx::Rect 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 scoped_ptr<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 scoped_ptr<CCDrawQuad> copy(quad->copy(copySharedState.get(), a)); \ | 97 scoped_ptr<CCDrawQuad> copy(quad->copy(copySharedState.get(), a)); \ |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 SkColor color = 0xfabb0011; | 172 SkColor color = 0xfabb0011; |
| 173 int width = 99; | 173 int width = 99; |
| 174 CREATE_SHARED_STATE(); | 174 CREATE_SHARED_STATE(); |
| 175 CREATE_QUAD_2(CCDebugBorderDrawQuad, color, width); | 175 CREATE_QUAD_2(CCDebugBorderDrawQuad, color, width); |
| 176 EXPECT_EQ(color, copyQuad->color()); | 176 EXPECT_EQ(color, copyQuad->color()); |
| 177 EXPECT_EQ(width, copyQuad->width()); | 177 EXPECT_EQ(width, copyQuad->width()); |
| 178 } | 178 } |
| 179 | 179 |
| 180 TEST(CCDrawQuadTest, copyIOSurfaceDrawQuad) | 180 TEST(CCDrawQuadTest, copyIOSurfaceDrawQuad) |
| 181 { | 181 { |
| 182 IntSize size(58, 95); | 182 gfx::Size size(58, 95); |
| 183 unsigned textureId = 72; | 183 unsigned textureId = 72; |
| 184 CCIOSurfaceDrawQuad::Orientation orientation = CCIOSurfaceDrawQuad::Unflippe
d; | 184 CCIOSurfaceDrawQuad::Orientation orientation = CCIOSurfaceDrawQuad::Unflippe
d; |
| 185 | 185 |
| 186 CREATE_SHARED_STATE(); | 186 CREATE_SHARED_STATE(); |
| 187 CREATE_QUAD_3(CCIOSurfaceDrawQuad, size, textureId, orientation); | 187 CREATE_QUAD_3(CCIOSurfaceDrawQuad, size, textureId, orientation); |
| 188 EXPECT_EQ(size, copyQuad->ioSurfaceSize()); | 188 EXPECT_EQ(size, copyQuad->ioSurfaceSize()); |
| 189 EXPECT_EQ(textureId, copyQuad->ioSurfaceTextureId()); | 189 EXPECT_EQ(textureId, copyQuad->ioSurfaceTextureId()); |
| 190 EXPECT_EQ(orientation, copyQuad->orientation()); | 190 EXPECT_EQ(orientation, copyQuad->orientation()); |
| 191 } | 191 } |
| 192 | 192 |
| 193 TEST(CCDrawQuadTest, copyRenderPassDrawQuad) | 193 TEST(CCDrawQuadTest, copyRenderPassDrawQuad) |
| 194 { | 194 { |
| 195 CCRenderPass::Id renderPassId(22, 64); | 195 CCRenderPass::Id renderPassId(22, 64); |
| 196 bool isReplica = true; | 196 bool isReplica = true; |
| 197 CCResourceProvider::ResourceId maskResourceId = 78; | 197 CCResourceProvider::ResourceId maskResourceId = 78; |
| 198 IntRect contentsChangedSinceLastFrame(42, 11, 74, 24); | 198 gfx::Rect contentsChangedSinceLastFrame(42, 11, 74, 24); |
| 199 float maskTexCoordScaleX = 33; | 199 float maskTexCoordScaleX = 33; |
| 200 float maskTexCoordScaleY = 19; | 200 float maskTexCoordScaleY = 19; |
| 201 float maskTexCoordOffsetX = -45; | 201 float maskTexCoordOffsetX = -45; |
| 202 float maskTexCoordOffsetY = -21; | 202 float maskTexCoordOffsetY = -21; |
| 203 | 203 |
| 204 CCRenderPass::Id copiedRenderPassId(235, 11); | 204 CCRenderPass::Id copiedRenderPassId(235, 11); |
| 205 | 205 |
| 206 CREATE_SHARED_STATE(); | 206 CREATE_SHARED_STATE(); |
| 207 CREATE_QUAD_8_1(CCRenderPassDrawQuad, renderPassId, isReplica, maskResourceI
d, contentsChangedSinceLastFrame, maskTexCoordScaleX, maskTexCoordScaleY, maskTe
xCoordOffsetX, maskTexCoordOffsetY, copiedRenderPassId); | 207 CREATE_QUAD_8_1(CCRenderPassDrawQuad, renderPassId, isReplica, maskResourceI
d, contentsChangedSinceLastFrame, maskTexCoordScaleX, maskTexCoordScaleY, maskTe
xCoordOffsetX, maskTexCoordOffsetY, copiedRenderPassId); |
| 208 EXPECT_EQ(copiedRenderPassId, copyQuad->renderPassId()); | 208 EXPECT_EQ(copiedRenderPassId, copyQuad->renderPassId()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 232 CREATE_SHARED_STATE(); | 232 CREATE_SHARED_STATE(); |
| 233 CREATE_QUAD_2(CCStreamVideoDrawQuad, textureId, matrix); | 233 CREATE_QUAD_2(CCStreamVideoDrawQuad, textureId, matrix); |
| 234 EXPECT_EQ(textureId, copyQuad->textureId()); | 234 EXPECT_EQ(textureId, copyQuad->textureId()); |
| 235 EXPECT_EQ(matrix, copyQuad->matrix()); | 235 EXPECT_EQ(matrix, copyQuad->matrix()); |
| 236 } | 236 } |
| 237 | 237 |
| 238 TEST(CCDrawQuadTest, copyTextureDrawQuad) | 238 TEST(CCDrawQuadTest, copyTextureDrawQuad) |
| 239 { | 239 { |
| 240 unsigned resourceId = 82; | 240 unsigned resourceId = 82; |
| 241 bool premultipliedAlpha = true; | 241 bool premultipliedAlpha = true; |
| 242 FloatRect uvRect(0.5, 224, -51, 36); | 242 gfx::RectF uvRect(0.5, 224, -51, 36); |
| 243 bool flipped = true; | 243 bool flipped = true; |
| 244 | 244 |
| 245 CREATE_SHARED_STATE(); | 245 CREATE_SHARED_STATE(); |
| 246 CREATE_QUAD_4(CCTextureDrawQuad, resourceId, premultipliedAlpha, uvRect, fli
pped); | 246 CREATE_QUAD_4(CCTextureDrawQuad, resourceId, premultipliedAlpha, uvRect, fli
pped); |
| 247 EXPECT_EQ(resourceId, copyQuad->resourceId()); | 247 EXPECT_EQ(resourceId, copyQuad->resourceId()); |
| 248 EXPECT_EQ(premultipliedAlpha, copyQuad->premultipliedAlpha()); | 248 EXPECT_EQ(premultipliedAlpha, copyQuad->premultipliedAlpha()); |
| 249 EXPECT_EQ(uvRect, copyQuad->uvRect()); | 249 EXPECT_FLOAT_RECT_EQ(uvRect, copyQuad->uvRect()); |
| 250 EXPECT_EQ(flipped, copyQuad->flipped()); | 250 EXPECT_EQ(flipped, copyQuad->flipped()); |
| 251 } | 251 } |
| 252 | 252 |
| 253 TEST(CCDrawQuadTest, copyTileDrawQuad) | 253 TEST(CCDrawQuadTest, copyTileDrawQuad) |
| 254 { | 254 { |
| 255 IntRect opaqueRect(33, 44, 22, 33); | 255 gfx::Rect opaqueRect(33, 44, 22, 33); |
| 256 unsigned resourceId = 104; | 256 unsigned resourceId = 104; |
| 257 IntPoint textureOffset(-31, 47); | 257 gfx::Point textureOffset(-31, 47); |
| 258 IntSize textureSize(85, 32); | 258 gfx::Size textureSize(85, 32); |
| 259 GLint textureFilter = 82; | 259 GLint textureFilter = 82; |
| 260 bool swizzleContents = true; | 260 bool swizzleContents = true; |
| 261 bool leftEdgeAA = true; | 261 bool leftEdgeAA = true; |
| 262 bool topEdgeAA = true; | 262 bool topEdgeAA = true; |
| 263 bool rightEdgeAA = false; | 263 bool rightEdgeAA = false; |
| 264 bool bottomEdgeAA = true; | 264 bool bottomEdgeAA = true; |
| 265 | 265 |
| 266 CREATE_SHARED_STATE(); | 266 CREATE_SHARED_STATE(); |
| 267 CREATE_QUAD_10(CCTileDrawQuad, opaqueRect, resourceId, textureOffset, textur
eSize, textureFilter, swizzleContents, leftEdgeAA, topEdgeAA, rightEdgeAA, botto
mEdgeAA); | 267 CREATE_QUAD_10(CCTileDrawQuad, opaqueRect, resourceId, textureOffset, textur
eSize, textureFilter, swizzleContents, leftEdgeAA, topEdgeAA, rightEdgeAA, botto
mEdgeAA); |
| 268 EXPECT_RECT_EQ(opaqueRect, copyQuad->opaqueRect()); | 268 EXPECT_RECT_EQ(opaqueRect, copyQuad->opaqueRect()); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 EXPECT_EQ(uPlane.size, copyQuad->uPlane().size); | 305 EXPECT_EQ(uPlane.size, copyQuad->uPlane().size); |
| 306 EXPECT_EQ(uPlane.format, copyQuad->uPlane().format); | 306 EXPECT_EQ(uPlane.format, copyQuad->uPlane().format); |
| 307 EXPECT_EQ(uPlane.visibleSize, copyQuad->uPlane().visibleSize); | 307 EXPECT_EQ(uPlane.visibleSize, copyQuad->uPlane().visibleSize); |
| 308 EXPECT_EQ(vPlane.resourceId, copyQuad->vPlane().resourceId); | 308 EXPECT_EQ(vPlane.resourceId, copyQuad->vPlane().resourceId); |
| 309 EXPECT_EQ(vPlane.size, copyQuad->vPlane().size); | 309 EXPECT_EQ(vPlane.size, copyQuad->vPlane().size); |
| 310 EXPECT_EQ(vPlane.format, copyQuad->vPlane().format); | 310 EXPECT_EQ(vPlane.format, copyQuad->vPlane().format); |
| 311 EXPECT_EQ(vPlane.visibleSize, copyQuad->vPlane().visibleSize); | 311 EXPECT_EQ(vPlane.visibleSize, copyQuad->vPlane().visibleSize); |
| 312 } | 312 } |
| 313 | 313 |
| 314 } // namespace | 314 } // namespace |
| OLD | NEW |