| 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 bool opaque = true; | |
| 32 int id = 3; | 31 int id = 3; |
| 33 | 32 |
| 34 scoped_ptr<SharedQuadState> state(SharedQuadState::create(quadTransform, vis
ibleContentRect, clippedRectInTarget, opacity, opaque)); | 33 scoped_ptr<SharedQuadState> state(SharedQuadState::create(quadTransform, vis
ibleContentRect, clippedRectInTarget, opacity)); |
| 35 state->id = id; | 34 state->id = id; |
| 36 | 35 |
| 37 scoped_ptr<SharedQuadState> copy(state->copy()); | 36 scoped_ptr<SharedQuadState> copy(state->copy()); |
| 38 EXPECT_EQ(id, copy->id); | 37 EXPECT_EQ(id, copy->id); |
| 39 EXPECT_EQ(quadTransform, copy->quadTransform); | 38 EXPECT_EQ(quadTransform, copy->quadTransform); |
| 40 EXPECT_RECT_EQ(visibleContentRect, copy->visibleContentRect); | 39 EXPECT_RECT_EQ(visibleContentRect, copy->visibleContentRect); |
| 41 EXPECT_RECT_EQ(clippedRectInTarget, copy->clippedRectInTarget); | 40 EXPECT_RECT_EQ(clippedRectInTarget, copy->clippedRectInTarget); |
| 42 EXPECT_EQ(opacity, copy->opacity); | 41 EXPECT_EQ(opacity, copy->opacity); |
| 43 EXPECT_EQ(opaque, copy->opaque); | |
| 44 } | 42 } |
| 45 | 43 |
| 46 scoped_ptr<SharedQuadState> createSharedQuadState() | 44 scoped_ptr<SharedQuadState> createSharedQuadState() |
| 47 { | 45 { |
| 48 WebTransformationMatrix quadTransform(1, 0.5, 0, 1, 0.5, 0); | 46 WebTransformationMatrix quadTransform(1, 0.5, 0, 1, 0.5, 0); |
| 49 gfx::Rect visibleContentRect(10, 12, 14, 16); | 47 gfx::Rect visibleContentRect(10, 12, 14, 16); |
| 50 gfx::Rect clippedRectInTarget(19, 21, 23, 25); | 48 gfx::Rect clippedRectInTarget(19, 21, 23, 25); |
| 51 float opacity = 1; | 49 float opacity = 1; |
| 52 bool opaque = false; | |
| 53 int id = 3; | 50 int id = 3; |
| 54 | 51 |
| 55 scoped_ptr<SharedQuadState> state(SharedQuadState::create(quadTransform, vis
ibleContentRect, clippedRectInTarget, opacity, opaque)); | 52 scoped_ptr<SharedQuadState> state(SharedQuadState::create(quadTransform, vis
ibleContentRect, clippedRectInTarget, opacity)); |
| 56 state->id = id; | 53 state->id = id; |
| 57 return state.Pass(); | 54 return state.Pass(); |
| 58 } | 55 } |
| 59 | 56 |
| 60 void compareDrawQuad(DrawQuad* quad, DrawQuad* copy, SharedQuadState* copyShared
State) | 57 void compareDrawQuad(DrawQuad* quad, DrawQuad* copy, SharedQuadState* copyShared
State) |
| 61 { | 58 { |
| 62 EXPECT_EQ(quad->material(), copy->material()); | 59 EXPECT_EQ(quad->material(), copy->material()); |
| 63 EXPECT_EQ(quad->isDebugQuad(), copy->isDebugQuad()); | 60 EXPECT_EQ(quad->isDebugQuad(), copy->isDebugQuad()); |
| 64 EXPECT_RECT_EQ(quad->quadRect(), copy->quadRect()); | 61 EXPECT_RECT_EQ(quad->quadRect(), copy->quadRect()); |
| 65 EXPECT_RECT_EQ(quad->quadVisibleRect(), copy->quadVisibleRect()); | 62 EXPECT_RECT_EQ(quad->quadVisibleRect(), copy->quadVisibleRect()); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 SkColor color = 0xfabb0011; | 160 SkColor color = 0xfabb0011; |
| 164 int width = 99; | 161 int width = 99; |
| 165 CREATE_SHARED_STATE(); | 162 CREATE_SHARED_STATE(); |
| 166 CREATE_QUAD_2(DebugBorderDrawQuad, color, width); | 163 CREATE_QUAD_2(DebugBorderDrawQuad, color, width); |
| 167 EXPECT_EQ(color, copyQuad->color()); | 164 EXPECT_EQ(color, copyQuad->color()); |
| 168 EXPECT_EQ(width, copyQuad->width()); | 165 EXPECT_EQ(width, copyQuad->width()); |
| 169 } | 166 } |
| 170 | 167 |
| 171 TEST(DrawQuadTest, copyIOSurfaceDrawQuad) | 168 TEST(DrawQuadTest, copyIOSurfaceDrawQuad) |
| 172 { | 169 { |
| 170 gfx::Rect opaqueRect(3, 7, 10, 12); |
| 173 gfx::Size size(58, 95); | 171 gfx::Size size(58, 95); |
| 174 unsigned textureId = 72; | 172 unsigned textureId = 72; |
| 175 IOSurfaceDrawQuad::Orientation orientation = IOSurfaceDrawQuad::Unflipped; | 173 IOSurfaceDrawQuad::Orientation orientation = IOSurfaceDrawQuad::Unflipped; |
| 176 | 174 |
| 177 CREATE_SHARED_STATE(); | 175 CREATE_SHARED_STATE(); |
| 178 CREATE_QUAD_3(IOSurfaceDrawQuad, size, textureId, orientation); | 176 CREATE_QUAD_4(IOSurfaceDrawQuad, opaqueRect, size, textureId, orientation); |
| 177 EXPECT_RECT_EQ(opaqueRect, copyQuad->opaqueRect()); |
| 179 EXPECT_EQ(size, copyQuad->ioSurfaceSize()); | 178 EXPECT_EQ(size, copyQuad->ioSurfaceSize()); |
| 180 EXPECT_EQ(textureId, copyQuad->ioSurfaceTextureId()); | 179 EXPECT_EQ(textureId, copyQuad->ioSurfaceTextureId()); |
| 181 EXPECT_EQ(orientation, copyQuad->orientation()); | 180 EXPECT_EQ(orientation, copyQuad->orientation()); |
| 182 } | 181 } |
| 183 | 182 |
| 184 TEST(DrawQuadTest, copyRenderPassDrawQuad) | 183 TEST(DrawQuadTest, copyRenderPassDrawQuad) |
| 185 { | 184 { |
| 186 RenderPass::Id renderPassId(22, 64); | 185 RenderPass::Id renderPassId(22, 64); |
| 187 bool isReplica = true; | 186 bool isReplica = true; |
| 188 ResourceProvider::ResourceId maskResourceId = 78; | 187 ResourceProvider::ResourceId maskResourceId = 78; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 210 { | 209 { |
| 211 SkColor color = 0x49494949; | 210 SkColor color = 0x49494949; |
| 212 | 211 |
| 213 CREATE_SHARED_STATE(); | 212 CREATE_SHARED_STATE(); |
| 214 CREATE_QUAD_1(SolidColorDrawQuad, color); | 213 CREATE_QUAD_1(SolidColorDrawQuad, color); |
| 215 EXPECT_EQ(color, copyQuad->color()); | 214 EXPECT_EQ(color, copyQuad->color()); |
| 216 } | 215 } |
| 217 | 216 |
| 218 TEST(DrawQuadTest, copyStreamVideoDrawQuad) | 217 TEST(DrawQuadTest, copyStreamVideoDrawQuad) |
| 219 { | 218 { |
| 219 gfx::Rect opaqueRect(3, 7, 10, 12); |
| 220 unsigned textureId = 64; | 220 unsigned textureId = 64; |
| 221 WebTransformationMatrix matrix(0.5, 1, 0.25, 0.75, 0, 1); | 221 WebTransformationMatrix matrix(0.5, 1, 0.25, 0.75, 0, 1); |
| 222 | 222 |
| 223 CREATE_SHARED_STATE(); | 223 CREATE_SHARED_STATE(); |
| 224 CREATE_QUAD_2(StreamVideoDrawQuad, textureId, matrix); | 224 CREATE_QUAD_3(StreamVideoDrawQuad, opaqueRect, textureId, matrix); |
| 225 EXPECT_RECT_EQ(opaqueRect, copyQuad->opaqueRect()); |
| 225 EXPECT_EQ(textureId, copyQuad->textureId()); | 226 EXPECT_EQ(textureId, copyQuad->textureId()); |
| 226 EXPECT_EQ(matrix, copyQuad->matrix()); | 227 EXPECT_EQ(matrix, copyQuad->matrix()); |
| 227 } | 228 } |
| 228 | 229 |
| 229 TEST(DrawQuadTest, copyTextureDrawQuad) | 230 TEST(DrawQuadTest, copyTextureDrawQuad) |
| 230 { | 231 { |
| 232 gfx::Rect opaqueRect(3, 7, 10, 12); |
| 231 unsigned resourceId = 82; | 233 unsigned resourceId = 82; |
| 232 bool premultipliedAlpha = true; | 234 bool premultipliedAlpha = true; |
| 233 gfx::RectF uvRect(0.5, 224, -51, 36); | 235 gfx::RectF uvRect(0.5, 224, -51, 36); |
| 234 bool flipped = true; | 236 bool flipped = true; |
| 235 | 237 |
| 236 CREATE_SHARED_STATE(); | 238 CREATE_SHARED_STATE(); |
| 237 CREATE_QUAD_4(TextureDrawQuad, resourceId, premultipliedAlpha, uvRect, flipp
ed); | 239 CREATE_QUAD_5(TextureDrawQuad, opaqueRect, resourceId, premultipliedAlpha, u
vRect, flipped); |
| 240 EXPECT_RECT_EQ(opaqueRect, copyQuad->opaqueRect()); |
| 238 EXPECT_EQ(resourceId, copyQuad->resourceId()); | 241 EXPECT_EQ(resourceId, copyQuad->resourceId()); |
| 239 EXPECT_EQ(premultipliedAlpha, copyQuad->premultipliedAlpha()); | 242 EXPECT_EQ(premultipliedAlpha, copyQuad->premultipliedAlpha()); |
| 240 EXPECT_FLOAT_RECT_EQ(uvRect, copyQuad->uvRect()); | 243 EXPECT_FLOAT_RECT_EQ(uvRect, copyQuad->uvRect()); |
| 241 EXPECT_EQ(flipped, copyQuad->flipped()); | 244 EXPECT_EQ(flipped, copyQuad->flipped()); |
| 242 } | 245 } |
| 243 | 246 |
| 244 TEST(DrawQuadTest, copyTileDrawQuad) | 247 TEST(DrawQuadTest, copyTileDrawQuad) |
| 245 { | 248 { |
| 246 gfx::Rect opaqueRect(33, 44, 22, 33); | 249 gfx::Rect opaqueRect(33, 44, 22, 33); |
| 247 unsigned resourceId = 104; | 250 unsigned resourceId = 104; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 261 EXPECT_EQ(textureSize, copyQuad->textureSize()); | 264 EXPECT_EQ(textureSize, copyQuad->textureSize()); |
| 262 EXPECT_EQ(swizzleContents, copyQuad->swizzleContents()); | 265 EXPECT_EQ(swizzleContents, copyQuad->swizzleContents()); |
| 263 EXPECT_EQ(leftEdgeAA, copyQuad->leftEdgeAA()); | 266 EXPECT_EQ(leftEdgeAA, copyQuad->leftEdgeAA()); |
| 264 EXPECT_EQ(topEdgeAA, copyQuad->topEdgeAA()); | 267 EXPECT_EQ(topEdgeAA, copyQuad->topEdgeAA()); |
| 265 EXPECT_EQ(rightEdgeAA, copyQuad->rightEdgeAA()); | 268 EXPECT_EQ(rightEdgeAA, copyQuad->rightEdgeAA()); |
| 266 EXPECT_EQ(bottomEdgeAA, copyQuad->bottomEdgeAA()); | 269 EXPECT_EQ(bottomEdgeAA, copyQuad->bottomEdgeAA()); |
| 267 } | 270 } |
| 268 | 271 |
| 269 TEST(DrawQuadTest, copyYUVVideoDrawQuad) | 272 TEST(DrawQuadTest, copyYUVVideoDrawQuad) |
| 270 { | 273 { |
| 274 gfx::Rect opaqueRect(3, 7, 10, 12); |
| 271 gfx::SizeF texScale(0.75, 0.5); | 275 gfx::SizeF texScale(0.75, 0.5); |
| 272 VideoLayerImpl::FramePlane yPlane; | 276 VideoLayerImpl::FramePlane yPlane; |
| 273 yPlane.resourceId = 45; | 277 yPlane.resourceId = 45; |
| 274 yPlane.size = gfx::Size(34, 23); | 278 yPlane.size = gfx::Size(34, 23); |
| 275 yPlane.format = 8; | 279 yPlane.format = 8; |
| 276 VideoLayerImpl::FramePlane uPlane; | 280 VideoLayerImpl::FramePlane uPlane; |
| 277 uPlane.resourceId = 532; | 281 uPlane.resourceId = 532; |
| 278 uPlane.size = gfx::Size(134, 16); | 282 uPlane.size = gfx::Size(134, 16); |
| 279 uPlane.format = 2; | 283 uPlane.format = 2; |
| 280 VideoLayerImpl::FramePlane vPlane; | 284 VideoLayerImpl::FramePlane vPlane; |
| 281 vPlane.resourceId = 4; | 285 vPlane.resourceId = 4; |
| 282 vPlane.size = gfx::Size(456, 486); | 286 vPlane.size = gfx::Size(456, 486); |
| 283 vPlane.format = 46; | 287 vPlane.format = 46; |
| 284 | 288 |
| 285 CREATE_SHARED_STATE(); | 289 CREATE_SHARED_STATE(); |
| 286 CREATE_QUAD_4(YUVVideoDrawQuad, texScale, yPlane, uPlane, vPlane); | 290 CREATE_QUAD_5(YUVVideoDrawQuad, opaqueRect, texScale, yPlane, uPlane, vPlane
); |
| 291 EXPECT_RECT_EQ(opaqueRect, copyQuad->opaqueRect()); |
| 287 EXPECT_EQ(texScale, copyQuad->texScale()); | 292 EXPECT_EQ(texScale, copyQuad->texScale()); |
| 288 EXPECT_EQ(yPlane.resourceId, copyQuad->yPlane().resourceId); | 293 EXPECT_EQ(yPlane.resourceId, copyQuad->yPlane().resourceId); |
| 289 EXPECT_EQ(yPlane.size, copyQuad->yPlane().size); | 294 EXPECT_EQ(yPlane.size, copyQuad->yPlane().size); |
| 290 EXPECT_EQ(yPlane.format, copyQuad->yPlane().format); | 295 EXPECT_EQ(yPlane.format, copyQuad->yPlane().format); |
| 291 EXPECT_EQ(uPlane.resourceId, copyQuad->uPlane().resourceId); | 296 EXPECT_EQ(uPlane.resourceId, copyQuad->uPlane().resourceId); |
| 292 EXPECT_EQ(uPlane.size, copyQuad->uPlane().size); | 297 EXPECT_EQ(uPlane.size, copyQuad->uPlane().size); |
| 293 EXPECT_EQ(uPlane.format, copyQuad->uPlane().format); | 298 EXPECT_EQ(uPlane.format, copyQuad->uPlane().format); |
| 294 EXPECT_EQ(vPlane.resourceId, copyQuad->vPlane().resourceId); | 299 EXPECT_EQ(vPlane.resourceId, copyQuad->vPlane().resourceId); |
| 295 EXPECT_EQ(vPlane.size, copyQuad->vPlane().size); | 300 EXPECT_EQ(vPlane.size, copyQuad->vPlane().size); |
| 296 EXPECT_EQ(vPlane.format, copyQuad->vPlane().format); | 301 EXPECT_EQ(vPlane.format, copyQuad->vPlane().format); |
| 297 } | 302 } |
| 298 | 303 |
| 299 } // namespace | 304 } // namespace |
| 300 } // namespace cc | 305 } // namespace cc |
| OLD | NEW |