| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 EXPECT_EQ(copySharedState, copy->shared_quad_state); | 64 EXPECT_EQ(copySharedState, copy->shared_quad_state); |
| 65 } | 65 } |
| 66 | 66 |
| 67 #define CREATE_SHARED_STATE() \ | 67 #define CREATE_SHARED_STATE() \ |
| 68 scoped_ptr<SharedQuadState> sharedState(createSharedQuadState()); \ | 68 scoped_ptr<SharedQuadState> sharedState(createSharedQuadState()); \ |
| 69 scoped_ptr<SharedQuadState> copySharedState(sharedState->copy()); \ | 69 scoped_ptr<SharedQuadState> copySharedState(sharedState->copy()); \ |
| 70 copySharedState->id = 5; | 70 copySharedState->id = 5; |
| 71 | 71 |
| 72 #define QUAD_DATA \ | 72 #define QUAD_DATA \ |
| 73 gfx::Rect quadRect(30, 40, 50, 60); \ | 73 gfx::Rect quadRect(30, 40, 50, 60); \ |
| 74 gfx::Rect quadVisibleRect(40, 50, 30, 20); | 74 gfx::Rect quadVisibleRect(40, 50, 30, 20); \ |
| 75 gfx::Rect quadOpaqueRect(60, 55, 10, 10); \ |
| 76 bool needsBlending = true; |
| 75 | 77 |
| 76 #define SETUP_AND_COPY_QUAD(Type, quad) \ | 78 #define SETUP_AND_COPY_QUAD_NEW(Type, quad) \ |
| 77 quad->visible_rect = quadVisibleRect; \ | 79 scoped_ptr<DrawQuad> copyNew(quadNew->Copy(copySharedState.get())); \ |
| 78 scoped_ptr<DrawQuad> copy(quad->Copy(copySharedState.get())); \ | 80 compareDrawQuad(quadNew.get(), copyNew.get(), copySharedState.get()); \ |
| 79 compareDrawQuad(quad.get(), copy.get(), copySharedState.get()); \ | 81 const Type* copyQuad = Type::MaterialCast(copyNew.get()); |
| 80 const Type* copyQuad = Type::materialCast(copy.get()); | |
| 81 | 82 |
| 82 #define SETUP_AND_COPY_QUAD_1(Type, quad, a) \ | 83 #define SETUP_AND_COPY_QUAD_ALL(Type, quad) \ |
| 83 quad->visible_rect = quadVisibleRect; \ | 84 scoped_ptr<DrawQuad> copyAll(quadAll->Copy(copySharedState.get())); \ |
| 84 scoped_ptr<DrawQuad> copy(quad->copy(copySharedState.get(), a)); \ | 85 compareDrawQuad(quadAll.get(), copyAll.get(), copySharedState.get()); \ |
| 85 compareDrawQuad(quad.get(), copy.get(), copySharedState.get()); \ | 86 copyQuad = Type::MaterialCast(copyAll.get()); |
| 86 const Type* copyQuad = Type::materialCast(copy.get()); | |
| 87 | 87 |
| 88 #define CREATE_QUAD_0(Type) \ | 88 #define SETUP_AND_COPY_QUAD_NEW_1(Type, quad, a) \ |
| 89 QUAD_DATA \ | 89 scoped_ptr<DrawQuad> copyNew(quadNew->Copy(copySharedState.get(), a)); \ |
| 90 scoped_ptr<Type> quad(Type::create(sharedState.get(), quadRect)); \ | 90 compareDrawQuad(quadNew.get(), copyNew.get(), copySharedState.get()); \ |
| 91 SETUP_AND_COPY_QUAD(Type, quad); \ | 91 const Type* copyQuad = Type::MaterialCast(copyNew.get()); |
| 92 UNUSED_PARAM(copyQuad); | |
| 93 | 92 |
| 94 #define CREATE_QUAD_1(Type, a) \ | 93 #define SETUP_AND_COPY_QUAD_ALL_1(Type, quad, a) \ |
| 95 QUAD_DATA \ | 94 scoped_ptr<DrawQuad> copyAll(quadAll->Copy(copySharedState.get(), a)); \ |
| 96 scoped_ptr<Type> quad(Type::create(sharedState.get(), quadRect, a)); \ | 95 compareDrawQuad(quadAll.get(), copyAll.get(), copySharedState.get()); \ |
| 97 SETUP_AND_COPY_QUAD(Type, quad); | 96 copyQuad = Type::MaterialCast(copyAll.get()); |
| 98 | 97 |
| 99 #define CREATE_QUAD_2(Type, a, b) \ | 98 #define CREATE_QUAD_1_NEW(Type, a) \ |
| 100 QUAD_DATA \ | 99 scoped_ptr<Type> quadNew(Type::Create()); \ |
| 101 scoped_ptr<Type> quad(Type::create(sharedState.get(), quadRect, a, b)); \ | 100 { QUAD_DATA \ |
| 102 SETUP_AND_COPY_QUAD(Type, quad); | 101 quadNew->SetNew(sharedState.get(), quadRect, a); } \ |
| 102 SETUP_AND_COPY_QUAD_NEW(Type, quadNew); |
| 103 | 103 |
| 104 #define CREATE_QUAD_3(Type, a, b, c) \ | 104 #define CREATE_QUAD_1_ALL(Type, a) \ |
| 105 QUAD_DATA \ | 105 scoped_ptr<Type> quadAll(Type::Create()); \ |
| 106 scoped_ptr<Type> quad(Type::create(sharedState.get(), quadRect, a, b, c)); \ | 106 { QUAD_DATA \ |
| 107 SETUP_AND_COPY_QUAD(Type, quad); | 107 quadAll->SetAll(sharedState.get(), quadRect, quadOpaqueRect, quadVisibleRe
ct, needsBlending, a); } \ |
| 108 SETUP_AND_COPY_QUAD_ALL(Type, quadAll); |
| 108 | 109 |
| 109 #define CREATE_QUAD_4(Type, a, b, c, d) \ | 110 #define CREATE_QUAD_2_NEW(Type, a, b) \ |
| 110 QUAD_DATA \ | 111 scoped_ptr<Type> quadNew(Type::Create()); \ |
| 111 scoped_ptr<Type> quad(Type::create(sharedState.get(), quadRect, a, b, c, d))
; \ | 112 { QUAD_DATA \ |
| 112 SETUP_AND_COPY_QUAD(Type, quad); | 113 quadNew->SetNew(sharedState.get(), quadRect, a, b); } \ |
| 114 SETUP_AND_COPY_QUAD_NEW(Type, quadNew); |
| 113 | 115 |
| 114 #define CREATE_QUAD_5(Type, a, b, c, d, e) \ | 116 #define CREATE_QUAD_2_ALL(Type, a, b) \ |
| 115 QUAD_DATA \ | 117 scoped_ptr<Type> quadAll(Type::Create()); \ |
| 116 scoped_ptr<Type> quad(Type::create(sharedState.get(), quadRect, a, b, c, d,
e)); \ | 118 { QUAD_DATA \ |
| 117 SETUP_AND_COPY_QUAD(Type, quad); | 119 quadAll->SetAll(sharedState.get(), quadRect, quadOpaqueRect, quadVisibleRe
ct, needsBlending, a, b); } \ |
| 120 SETUP_AND_COPY_QUAD_ALL(Type, quadAll); |
| 118 | 121 |
| 119 #define CREATE_QUAD_6(Type, a, b, c, d, e, f) \ | 122 #define CREATE_QUAD_3_NEW(Type, a, b, c) \ |
| 120 QUAD_DATA \ | 123 scoped_ptr<Type> quadNew(Type::Create()); \ |
| 121 scoped_ptr<Type> quad(Type::create(sharedState.get(), quadRect, a, b, c, d,
e, f)); \ | 124 { QUAD_DATA \ |
| 122 SETUP_AND_COPY_QUAD(Type, quad); | 125 quadNew->SetNew(sharedState.get(), quadRect, a, b, c); } \ |
| 126 SETUP_AND_COPY_QUAD_NEW(Type, quadNew); |
| 123 | 127 |
| 124 #define CREATE_QUAD_7(Type, a, b, c, d, e, f, g) \ | 128 #define CREATE_QUAD_3_ALL(Type, a, b, c) \ |
| 125 QUAD_DATA \ | 129 scoped_ptr<Type> quadAll(Type::Create()); \ |
| 126 scoped_ptr<Type> quad(Type::create(sharedState.get(), quadRect, a, b, c, d,
e, f, g)); \ | 130 { QUAD_DATA \ |
| 127 SETUP_AND_COPY_QUAD(Type, quad); | 131 quadAll->SetAll(sharedState.get(), quadRect, quadOpaqueRect, quadVisibleRe
ct, needsBlending, a, b, c); } \ |
| 132 SETUP_AND_COPY_QUAD_ALL(Type, quadAll); |
| 128 | 133 |
| 129 #define CREATE_QUAD_8(Type, a, b, c, d, e, f, g, h) \ | 134 #define CREATE_QUAD_4_NEW(Type, a, b, c, d) \ |
| 130 QUAD_DATA \ | 135 scoped_ptr<Type> quadNew(Type::Create()); \ |
| 131 scoped_ptr<Type> quad(Type::create(sharedState.get(), quadRect, a, b, c, d,
e, f, g, h)); \ | 136 { QUAD_DATA \ |
| 132 SETUP_AND_COPY_QUAD(Type, quad); | 137 quadNew->SetNew(sharedState.get(), quadRect, a, b, c, d); } \ |
| 138 SETUP_AND_COPY_QUAD_NEW(Type, quadNew); |
| 133 | 139 |
| 134 #define CREATE_QUAD_8_1(Type, a, b, c, d, e, f, g, h, copyA) \ | 140 #define CREATE_QUAD_4_ALL(Type, a, b, c, d) \ |
| 135 QUAD_DATA \ | 141 scoped_ptr<Type> quadAll(Type::Create()); \ |
| 136 scoped_ptr<Type> quad(Type::create(sharedState.get(), quadRect, a, b, c, d,
e, f, g, h)); \ | 142 { QUAD_DATA \ |
| 137 SETUP_AND_COPY_QUAD_1(Type, quad, copyA); | 143 quadAll->SetAll(sharedState.get(), quadRect, quadOpaqueRect, quadVisibleRe
ct, needsBlending, a, b, c, d); } \ |
| 144 SETUP_AND_COPY_QUAD_ALL(Type, quadAll); |
| 138 | 145 |
| 139 #define CREATE_QUAD_9(Type, a, b, c, d, e, f, g, h, i) \ | 146 #define CREATE_QUAD_5_NEW(Type, a, b, c, d, e) \ |
| 140 QUAD_DATA \ | 147 scoped_ptr<Type> quadNew(Type::Create()); \ |
| 141 scoped_ptr<Type> quad(Type::create(sharedState.get(), quadRect, a, b, c, d,
e, f, g, h, i)); \ | 148 { QUAD_DATA \ |
| 142 SETUP_AND_COPY_QUAD(Type, quad); | 149 quadNew->SetNew(sharedState.get(), quadRect, a, b, c, d, e); } \ |
| 150 SETUP_AND_COPY_QUAD_NEW(Type, quadNew); |
| 151 |
| 152 #define CREATE_QUAD_5_ALL(Type, a, b, c, d, e) \ |
| 153 scoped_ptr<Type> quadAll(Type::Create()); \ |
| 154 { QUAD_DATA \ |
| 155 quadAll->SetAll(sharedState.get(), quadRect, quadOpaqueRect, quadVisibleRe
ct, needsBlending, a, b, c, d, e); } \ |
| 156 SETUP_AND_COPY_QUAD_ALL(Type, quadAll); |
| 157 |
| 158 #define CREATE_QUAD_6_NEW(Type, a, b, c, d, e, f) \ |
| 159 scoped_ptr<Type> quadNew(Type::Create()); \ |
| 160 { QUAD_DATA \ |
| 161 quadNew->SetNew(sharedState.get(), quadRect, a, b, c, d, e, f); } \ |
| 162 SETUP_AND_COPY_QUAD_NEW(Type, quadNew); |
| 163 |
| 164 #define CREATE_QUAD_6_ALL(Type, a, b, c, d, e, f) \ |
| 165 scoped_ptr<Type> quadAll(Type::Create()); \ |
| 166 { QUAD_DATA \ |
| 167 quadAll->SetAll(sharedState.get(), quadRect, quadOpaqueRect, quadVisibleRe
ct, needsBlending, a, b, c, d, e, f); } \ |
| 168 SETUP_AND_COPY_QUAD_ALL(Type, quadAll); |
| 169 |
| 170 #define CREATE_QUAD_7_NEW(Type, a, b, c, d, e, f, g) \ |
| 171 scoped_ptr<Type> quadNew(Type::Create()); \ |
| 172 { QUAD_DATA \ |
| 173 quadNew->SetNew(sharedState.get(), quadRect, a, b, c, d, e, f, g); } \ |
| 174 SETUP_AND_COPY_QUAD_NEW(Type, quadNew); |
| 175 |
| 176 #define CREATE_QUAD_7_ALL(Type, a, b, c, d, e, f, g) \ |
| 177 scoped_ptr<Type> quadAll(Type::Create()); \ |
| 178 { QUAD_DATA \ |
| 179 quadAll->SetAll(sharedState.get(), quadRect, quadOpaqueRect, quadVisibleRe
ct, needsBlending, a, b, c, d, e, f, g); } \ |
| 180 SETUP_AND_COPY_QUAD_ALL(Type, quadAll); |
| 181 |
| 182 #define CREATE_QUAD_8_NEW(Type, a, b, c, d, e, f, g, h) \ |
| 183 scoped_ptr<Type> quadNew(Type::Create()); \ |
| 184 { QUAD_DATA \ |
| 185 quadNew->SetNew(sharedState.get(), quadRect, a, b, c, d, e, f, g, h); } \ |
| 186 SETUP_AND_COPY_QUAD_NEW(Type, quadNew); |
| 187 |
| 188 #define CREATE_QUAD_8_ALL(Type, a, b, c, d, e, f, g, h) \ |
| 189 scoped_ptr<Type> quadAll(Type::Create()); \ |
| 190 { QUAD_DATA \ |
| 191 quadAll->SetAll(sharedState.get(), quadRect, quadOpaqueRect, quadVisibleRe
ct, needsBlending, a, b, c, d, e, f, g, h); } \ |
| 192 SETUP_AND_COPY_QUAD_ALL(Type, quadAll); |
| 193 |
| 194 #define CREATE_QUAD_8_NEW_1(Type, a, b, c, d, e, f, g, h, copyA) \ |
| 195 scoped_ptr<Type> quadNew(Type::Create()); \ |
| 196 { QUAD_DATA \ |
| 197 quadNew->SetNew(sharedState.get(), quadRect, a, b, c, d, e, f, g, h); } \ |
| 198 SETUP_AND_COPY_QUAD_NEW_1(Type, quadNew, copyA); |
| 199 |
| 200 #define CREATE_QUAD_8_ALL_1(Type, a, b, c, d, e, f, g, h, copyA) \ |
| 201 scoped_ptr<Type> quadAll(Type::Create()); \ |
| 202 { QUAD_DATA \ |
| 203 quadAll->SetAll(sharedState.get(), quadRect, quadOpaqueRect, quadVisibleRe
ct, needsBlending, a, b, c, d, e, f, g, h); } \ |
| 204 SETUP_AND_COPY_QUAD_ALL_1(Type, quadAll, copyA); |
| 205 |
| 206 #define CREATE_QUAD_9_NEW(Type, a, b, c, d, e, f, g, h, i) \ |
| 207 scoped_ptr<Type> quadNew(Type::Create()); \ |
| 208 { QUAD_DATA \ |
| 209 quadNew->SetNew(sharedState.get(), quadRect, a, b, c, d, e, f, g, h, i); }
\ |
| 210 SETUP_AND_COPY_QUAD_NEW(Type, quadNew); |
| 211 |
| 212 #define CREATE_QUAD_9_ALL(Type, a, b, c, d, e, f, g, h, i) \ |
| 213 scoped_ptr<Type> quadAll(Type::Create()); \ |
| 214 { QUAD_DATA \ |
| 215 quadAll->SetAll(sharedState.get(), quadRect, quadOpaqueRect, quadVisibleRe
ct, needsBlending, a, b, c, d, e, f, g, h, i); } \ |
| 216 SETUP_AND_COPY_QUAD_ALL(Type, quadAll); |
| 143 | 217 |
| 144 TEST(DrawQuadTest, copyCheckerboardDrawQuad) | 218 TEST(DrawQuadTest, copyCheckerboardDrawQuad) |
| 145 { | 219 { |
| 146 SkColor color = 0xfabb0011; | 220 SkColor color = 0xfabb0011; |
| 147 CREATE_SHARED_STATE(); | 221 CREATE_SHARED_STATE(); |
| 148 CREATE_QUAD_1(CheckerboardDrawQuad, color); | 222 |
| 149 EXPECT_EQ(color, copyQuad->color()); | 223 CREATE_QUAD_1_NEW(CheckerboardDrawQuad, color); |
| 224 EXPECT_EQ(DrawQuad::CHECKERBOARD, copyQuad->material); |
| 225 EXPECT_EQ(color, copyQuad->color); |
| 226 |
| 227 CREATE_QUAD_1_ALL(CheckerboardDrawQuad, color); |
| 228 EXPECT_EQ(DrawQuad::CHECKERBOARD, copyQuad->material); |
| 229 EXPECT_EQ(color, copyQuad->color); |
| 150 } | 230 } |
| 151 | 231 |
| 152 TEST(DrawQuadTest, copyDebugBorderDrawQuad) | 232 TEST(DrawQuadTest, copyDebugBorderDrawQuad) |
| 153 { | 233 { |
| 154 SkColor color = 0xfabb0011; | 234 SkColor color = 0xfabb0011; |
| 155 int width = 99; | 235 int width = 99; |
| 156 CREATE_SHARED_STATE(); | 236 CREATE_SHARED_STATE(); |
| 157 CREATE_QUAD_2(DebugBorderDrawQuad, color, width); | 237 |
| 158 EXPECT_EQ(color, copyQuad->color()); | 238 CREATE_QUAD_2_NEW(DebugBorderDrawQuad, color, width); |
| 159 EXPECT_EQ(width, copyQuad->width()); | 239 EXPECT_EQ(DrawQuad::DEBUG_BORDER, copyQuad->material); |
| 240 EXPECT_EQ(color, copyQuad->color); |
| 241 EXPECT_EQ(width, copyQuad->width); |
| 242 |
| 243 CREATE_QUAD_2_ALL(DebugBorderDrawQuad, color, width); |
| 244 EXPECT_EQ(DrawQuad::DEBUG_BORDER, copyQuad->material); |
| 245 EXPECT_EQ(color, copyQuad->color); |
| 246 EXPECT_EQ(width, copyQuad->width); |
| 160 } | 247 } |
| 161 | 248 |
| 162 TEST(DrawQuadTest, copyIOSurfaceDrawQuad) | 249 TEST(DrawQuadTest, copyIOSurfaceDrawQuad) |
| 163 { | 250 { |
| 164 gfx::Rect opaqueRect(3, 7, 10, 12); | 251 gfx::Rect opaqueRect(3, 7, 10, 12); |
| 165 gfx::Size size(58, 95); | 252 gfx::Size size(58, 95); |
| 166 unsigned textureId = 72; | 253 unsigned textureId = 72; |
| 167 IOSurfaceDrawQuad::Orientation orientation = IOSurfaceDrawQuad::Unflipped; | 254 IOSurfaceDrawQuad::Orientation orientation = IOSurfaceDrawQuad::UNFLIPPED; |
| 255 CREATE_SHARED_STATE(); |
| 168 | 256 |
| 169 CREATE_SHARED_STATE(); | 257 CREATE_QUAD_4_NEW(IOSurfaceDrawQuad, opaqueRect, size, textureId, orientatio
n); |
| 170 CREATE_QUAD_4(IOSurfaceDrawQuad, opaqueRect, size, textureId, orientation); | 258 EXPECT_EQ(DrawQuad::IO_SURFACE_CONTENT, copyQuad->material); |
| 171 EXPECT_RECT_EQ(opaqueRect, copyQuad->opaque_rect); | 259 EXPECT_RECT_EQ(opaqueRect, copyQuad->opaque_rect); |
| 172 EXPECT_EQ(size, copyQuad->ioSurfaceSize()); | 260 EXPECT_EQ(size, copyQuad->io_surface_size); |
| 173 EXPECT_EQ(textureId, copyQuad->ioSurfaceTextureId()); | 261 EXPECT_EQ(textureId, copyQuad->io_surface_texture_id); |
| 174 EXPECT_EQ(orientation, copyQuad->orientation()); | 262 EXPECT_EQ(orientation, copyQuad->orientation); |
| 263 |
| 264 CREATE_QUAD_3_ALL(IOSurfaceDrawQuad, size, textureId, orientation); |
| 265 EXPECT_EQ(DrawQuad::IO_SURFACE_CONTENT, copyQuad->material); |
| 266 EXPECT_EQ(size, copyQuad->io_surface_size); |
| 267 EXPECT_EQ(textureId, copyQuad->io_surface_texture_id); |
| 268 EXPECT_EQ(orientation, copyQuad->orientation); |
| 175 } | 269 } |
| 176 | 270 |
| 177 TEST(DrawQuadTest, copyRenderPassDrawQuad) | 271 TEST(DrawQuadTest, copyRenderPassDrawQuad) |
| 178 { | 272 { |
| 179 RenderPass::Id renderPassId(22, 64); | 273 RenderPass::Id renderPassId(22, 64); |
| 180 bool isReplica = true; | 274 bool isReplica = true; |
| 181 ResourceProvider::ResourceId maskResourceId = 78; | 275 ResourceProvider::ResourceId maskResourceId = 78; |
| 182 gfx::Rect contentsChangedSinceLastFrame(42, 11, 74, 24); | 276 gfx::Rect contentsChangedSinceLastFrame(42, 11, 74, 24); |
| 183 float maskTexCoordScaleX = 33; | 277 float maskTexCoordScaleX = 33; |
| 184 float maskTexCoordScaleY = 19; | 278 float maskTexCoordScaleY = 19; |
| 185 float maskTexCoordOffsetX = -45; | 279 float maskTexCoordOffsetX = -45; |
| 186 float maskTexCoordOffsetY = -21; | 280 float maskTexCoordOffsetY = -21; |
| 187 | 281 |
| 188 RenderPass::Id copiedRenderPassId(235, 11); | 282 RenderPass::Id copiedRenderPassId(235, 11); |
| 283 CREATE_SHARED_STATE(); |
| 189 | 284 |
| 190 CREATE_SHARED_STATE(); | 285 CREATE_QUAD_8_NEW_1(RenderPassDrawQuad, renderPassId, isReplica, maskResourc
eId, contentsChangedSinceLastFrame, maskTexCoordScaleX, maskTexCoordScaleY, mask
TexCoordOffsetX, maskTexCoordOffsetY, copiedRenderPassId); |
| 191 CREATE_QUAD_8_1(RenderPassDrawQuad, renderPassId, isReplica, maskResourceId,
contentsChangedSinceLastFrame, maskTexCoordScaleX, maskTexCoordScaleY, maskTexC
oordOffsetX, maskTexCoordOffsetY, copiedRenderPassId); | 286 EXPECT_EQ(DrawQuad::RENDER_PASS, copyQuad->material); |
| 192 EXPECT_EQ(copiedRenderPassId, copyQuad->renderPassId()); | 287 EXPECT_EQ(copiedRenderPassId, copyQuad->render_pass_id); |
| 193 EXPECT_EQ(isReplica, copyQuad->isReplica()); | 288 EXPECT_EQ(isReplica, copyQuad->is_replica); |
| 194 EXPECT_EQ(maskResourceId, copyQuad->maskResourceId()); | 289 EXPECT_EQ(maskResourceId, copyQuad->mask_resource_id); |
| 195 EXPECT_RECT_EQ(contentsChangedSinceLastFrame, copyQuad->contentsChangedSince
LastFrame()); | 290 EXPECT_RECT_EQ(contentsChangedSinceLastFrame, copyQuad->contents_changed_sin
ce_last_frame); |
| 196 EXPECT_EQ(maskTexCoordScaleX, copyQuad->maskTexCoordScaleX()); | 291 EXPECT_EQ(maskTexCoordScaleX, copyQuad->mask_tex_coord_scale_x); |
| 197 EXPECT_EQ(maskTexCoordScaleY, copyQuad->maskTexCoordScaleY()); | 292 EXPECT_EQ(maskTexCoordScaleY, copyQuad->mask_tex_coord_scale_y); |
| 198 EXPECT_EQ(maskTexCoordOffsetX, copyQuad->maskTexCoordOffsetX()); | 293 EXPECT_EQ(maskTexCoordOffsetX, copyQuad->mask_tex_coord_offset_x); |
| 199 EXPECT_EQ(maskTexCoordOffsetY, copyQuad->maskTexCoordOffsetY()); | 294 EXPECT_EQ(maskTexCoordOffsetY, copyQuad->mask_tex_coord_offset_y); |
| 295 |
| 296 CREATE_QUAD_8_ALL_1(RenderPassDrawQuad, renderPassId, isReplica, maskResourc
eId, contentsChangedSinceLastFrame, maskTexCoordScaleX, maskTexCoordScaleY, mask
TexCoordOffsetX, maskTexCoordOffsetY, copiedRenderPassId); |
| 297 EXPECT_EQ(DrawQuad::RENDER_PASS, copyQuad->material); |
| 298 EXPECT_EQ(copiedRenderPassId, copyQuad->render_pass_id); |
| 299 EXPECT_EQ(isReplica, copyQuad->is_replica); |
| 300 EXPECT_EQ(maskResourceId, copyQuad->mask_resource_id); |
| 301 EXPECT_RECT_EQ(contentsChangedSinceLastFrame, copyQuad->contents_changed_sin
ce_last_frame); |
| 302 EXPECT_EQ(maskTexCoordScaleX, copyQuad->mask_tex_coord_scale_x); |
| 303 EXPECT_EQ(maskTexCoordScaleY, copyQuad->mask_tex_coord_scale_y); |
| 304 EXPECT_EQ(maskTexCoordOffsetX, copyQuad->mask_tex_coord_offset_x); |
| 305 EXPECT_EQ(maskTexCoordOffsetY, copyQuad->mask_tex_coord_offset_y); |
| 200 } | 306 } |
| 201 | 307 |
| 202 TEST(DrawQuadTest, copySolidColorDrawQuad) | 308 TEST(DrawQuadTest, copySolidColorDrawQuad) |
| 203 { | 309 { |
| 204 SkColor color = 0x49494949; | 310 SkColor color = 0x49494949; |
| 311 CREATE_SHARED_STATE(); |
| 205 | 312 |
| 206 CREATE_SHARED_STATE(); | 313 CREATE_QUAD_1_NEW(SolidColorDrawQuad, color); |
| 207 CREATE_QUAD_1(SolidColorDrawQuad, color); | 314 EXPECT_EQ(DrawQuad::SOLID_COLOR, copyQuad->material); |
| 208 EXPECT_EQ(color, copyQuad->color()); | 315 EXPECT_EQ(color, copyQuad->color); |
| 316 |
| 317 CREATE_QUAD_1_ALL(SolidColorDrawQuad, color); |
| 318 EXPECT_EQ(DrawQuad::SOLID_COLOR, copyQuad->material); |
| 319 EXPECT_EQ(color, copyQuad->color); |
| 209 } | 320 } |
| 210 | 321 |
| 211 TEST(DrawQuadTest, copyStreamVideoDrawQuad) | 322 TEST(DrawQuadTest, copyStreamVideoDrawQuad) |
| 212 { | 323 { |
| 213 gfx::Rect opaqueRect(3, 7, 10, 12); | 324 gfx::Rect opaqueRect(3, 7, 10, 12); |
| 214 unsigned textureId = 64; | 325 unsigned textureId = 64; |
| 215 WebTransformationMatrix matrix(0.5, 1, 0.25, 0.75, 0, 1); | 326 WebTransformationMatrix matrix(0.5, 1, 0.25, 0.75, 0, 1); |
| 327 CREATE_SHARED_STATE(); |
| 216 | 328 |
| 217 CREATE_SHARED_STATE(); | 329 CREATE_QUAD_3_NEW(StreamVideoDrawQuad, opaqueRect, textureId, matrix); |
| 218 CREATE_QUAD_3(StreamVideoDrawQuad, opaqueRect, textureId, matrix); | 330 EXPECT_EQ(DrawQuad::STREAM_VIDEO_CONTENT, copyQuad->material); |
| 219 EXPECT_RECT_EQ(opaqueRect, copyQuad->opaque_rect); | 331 EXPECT_RECT_EQ(opaqueRect, copyQuad->opaque_rect); |
| 220 EXPECT_EQ(textureId, copyQuad->textureId()); | 332 EXPECT_EQ(textureId, copyQuad->texture_id); |
| 221 EXPECT_EQ(matrix, copyQuad->matrix()); | 333 EXPECT_EQ(matrix, copyQuad->matrix); |
| 334 |
| 335 CREATE_QUAD_2_ALL(StreamVideoDrawQuad, textureId, matrix); |
| 336 EXPECT_EQ(DrawQuad::STREAM_VIDEO_CONTENT, copyQuad->material); |
| 337 EXPECT_EQ(textureId, copyQuad->texture_id); |
| 338 EXPECT_EQ(matrix, copyQuad->matrix); |
| 222 } | 339 } |
| 223 | 340 |
| 224 TEST(DrawQuadTest, copyTextureDrawQuad) | 341 TEST(DrawQuadTest, copyTextureDrawQuad) |
| 225 { | 342 { |
| 226 gfx::Rect opaqueRect(3, 7, 10, 12); | 343 gfx::Rect opaqueRect(3, 7, 10, 12); |
| 227 unsigned resourceId = 82; | 344 unsigned resourceId = 82; |
| 228 bool premultipliedAlpha = true; | 345 bool premultipliedAlpha = true; |
| 229 gfx::RectF uvRect(0.5, 224, -51, 36); | 346 gfx::RectF uvRect(0.5, 224, -51, 36); |
| 230 bool flipped = true; | 347 bool flipped = true; |
| 348 CREATE_SHARED_STATE(); |
| 231 | 349 |
| 232 CREATE_SHARED_STATE(); | 350 CREATE_QUAD_5_NEW(TextureDrawQuad, opaqueRect, resourceId, premultipliedAlph
a, uvRect, flipped); |
| 233 CREATE_QUAD_5(TextureDrawQuad, opaqueRect, resourceId, premultipliedAlpha, u
vRect, flipped); | 351 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, copyQuad->material); |
| 234 EXPECT_RECT_EQ(opaqueRect, copyQuad->opaque_rect); | 352 EXPECT_RECT_EQ(opaqueRect, copyQuad->opaque_rect); |
| 235 EXPECT_EQ(resourceId, copyQuad->resourceId()); | 353 EXPECT_EQ(resourceId, copyQuad->resource_id); |
| 236 EXPECT_EQ(premultipliedAlpha, copyQuad->premultipliedAlpha()); | 354 EXPECT_EQ(premultipliedAlpha, copyQuad->premultiplied_alpha); |
| 237 EXPECT_FLOAT_RECT_EQ(uvRect, copyQuad->uvRect()); | 355 EXPECT_FLOAT_RECT_EQ(uvRect, copyQuad->uv_rect); |
| 238 EXPECT_EQ(flipped, copyQuad->flipped()); | 356 EXPECT_EQ(flipped, copyQuad->flipped); |
| 357 |
| 358 CREATE_QUAD_4_ALL(TextureDrawQuad, resourceId, premultipliedAlpha, uvRect, f
lipped); |
| 359 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, copyQuad->material); |
| 360 EXPECT_EQ(resourceId, copyQuad->resource_id); |
| 361 EXPECT_EQ(premultipliedAlpha, copyQuad->premultiplied_alpha); |
| 362 EXPECT_FLOAT_RECT_EQ(uvRect, copyQuad->uv_rect); |
| 363 EXPECT_EQ(flipped, copyQuad->flipped); |
| 239 } | 364 } |
| 240 | 365 |
| 241 TEST(DrawQuadTest, copyTileDrawQuad) | 366 TEST(DrawQuadTest, copyTileDrawQuad) |
| 242 { | 367 { |
| 243 gfx::Rect opaqueRect(33, 44, 22, 33); | 368 gfx::Rect opaqueRect(33, 44, 22, 33); |
| 244 unsigned resourceId = 104; | 369 unsigned resourceId = 104; |
| 245 gfx::RectF texCoordRect(31, 12, 54, 20); | 370 gfx::RectF texCoordRect(31, 12, 54, 20); |
| 246 gfx::Size textureSize(85, 32); | 371 gfx::Size textureSize(85, 32); |
| 247 bool swizzleContents = true; | 372 bool swizzleContents = true; |
| 248 bool leftEdgeAA = true; | 373 bool leftEdgeAA = true; |
| 249 bool topEdgeAA = true; | 374 bool topEdgeAA = true; |
| 250 bool rightEdgeAA = false; | 375 bool rightEdgeAA = false; |
| 251 bool bottomEdgeAA = true; | 376 bool bottomEdgeAA = true; |
| 377 CREATE_SHARED_STATE(); |
| 252 | 378 |
| 253 CREATE_SHARED_STATE(); | 379 CREATE_QUAD_9_NEW(TileDrawQuad, opaqueRect, resourceId, texCoordRect, textur
eSize, swizzleContents, leftEdgeAA, topEdgeAA, rightEdgeAA, bottomEdgeAA); |
| 254 CREATE_QUAD_9(TileDrawQuad, opaqueRect, resourceId, texCoordRect, textureSiz
e, swizzleContents, leftEdgeAA, topEdgeAA, rightEdgeAA, bottomEdgeAA); | 380 EXPECT_EQ(DrawQuad::TILED_CONTENT, copyQuad->material); |
| 255 EXPECT_RECT_EQ(opaqueRect, copyQuad->opaque_rect); | 381 EXPECT_RECT_EQ(opaqueRect, copyQuad->opaque_rect); |
| 256 EXPECT_EQ(resourceId, copyQuad->resourceId()); | 382 EXPECT_EQ(resourceId, copyQuad->resource_id); |
| 257 EXPECT_EQ(texCoordRect, copyQuad->texCoordRect()); | 383 EXPECT_EQ(texCoordRect, copyQuad->tex_coord_rect); |
| 258 EXPECT_EQ(textureSize, copyQuad->textureSize()); | 384 EXPECT_EQ(textureSize, copyQuad->texture_size); |
| 259 EXPECT_EQ(swizzleContents, copyQuad->swizzleContents()); | 385 EXPECT_EQ(swizzleContents, copyQuad->swizzle_contents); |
| 260 EXPECT_EQ(leftEdgeAA, copyQuad->leftEdgeAA()); | 386 EXPECT_EQ(leftEdgeAA, copyQuad->left_edge_aa); |
| 261 EXPECT_EQ(topEdgeAA, copyQuad->topEdgeAA()); | 387 EXPECT_EQ(topEdgeAA, copyQuad->top_edge_aa); |
| 262 EXPECT_EQ(rightEdgeAA, copyQuad->rightEdgeAA()); | 388 EXPECT_EQ(rightEdgeAA, copyQuad->right_edge_aa); |
| 263 EXPECT_EQ(bottomEdgeAA, copyQuad->bottomEdgeAA()); | 389 EXPECT_EQ(bottomEdgeAA, copyQuad->bottom_edge_aa); |
| 390 |
| 391 CREATE_QUAD_8_ALL(TileDrawQuad, resourceId, texCoordRect, textureSize, swizz
leContents, leftEdgeAA, topEdgeAA, rightEdgeAA, bottomEdgeAA); |
| 392 EXPECT_EQ(DrawQuad::TILED_CONTENT, copyQuad->material); |
| 393 EXPECT_EQ(resourceId, copyQuad->resource_id); |
| 394 EXPECT_EQ(texCoordRect, copyQuad->tex_coord_rect); |
| 395 EXPECT_EQ(textureSize, copyQuad->texture_size); |
| 396 EXPECT_EQ(swizzleContents, copyQuad->swizzle_contents); |
| 397 EXPECT_EQ(leftEdgeAA, copyQuad->left_edge_aa); |
| 398 EXPECT_EQ(topEdgeAA, copyQuad->top_edge_aa); |
| 399 EXPECT_EQ(rightEdgeAA, copyQuad->right_edge_aa); |
| 400 EXPECT_EQ(bottomEdgeAA, copyQuad->bottom_edge_aa); |
| 264 } | 401 } |
| 265 | 402 |
| 266 TEST(DrawQuadTest, copyYUVVideoDrawQuad) | 403 TEST(DrawQuadTest, copyYUVVideoDrawQuad) |
| 267 { | 404 { |
| 268 gfx::Rect opaqueRect(3, 7, 10, 12); | 405 gfx::Rect opaqueRect(3, 7, 10, 12); |
| 269 gfx::SizeF texScale(0.75, 0.5); | 406 gfx::SizeF texScale(0.75, 0.5); |
| 270 VideoLayerImpl::FramePlane yPlane; | 407 VideoLayerImpl::FramePlane yPlane; |
| 271 yPlane.resourceId = 45; | 408 yPlane.resourceId = 45; |
| 272 yPlane.size = gfx::Size(34, 23); | 409 yPlane.size = gfx::Size(34, 23); |
| 273 yPlane.format = 8; | 410 yPlane.format = 8; |
| 274 VideoLayerImpl::FramePlane uPlane; | 411 VideoLayerImpl::FramePlane uPlane; |
| 275 uPlane.resourceId = 532; | 412 uPlane.resourceId = 532; |
| 276 uPlane.size = gfx::Size(134, 16); | 413 uPlane.size = gfx::Size(134, 16); |
| 277 uPlane.format = 2; | 414 uPlane.format = 2; |
| 278 VideoLayerImpl::FramePlane vPlane; | 415 VideoLayerImpl::FramePlane vPlane; |
| 279 vPlane.resourceId = 4; | 416 vPlane.resourceId = 4; |
| 280 vPlane.size = gfx::Size(456, 486); | 417 vPlane.size = gfx::Size(456, 486); |
| 281 vPlane.format = 46; | 418 vPlane.format = 46; |
| 419 CREATE_SHARED_STATE(); |
| 282 | 420 |
| 283 CREATE_SHARED_STATE(); | 421 CREATE_QUAD_5_NEW(YUVVideoDrawQuad, opaqueRect, texScale, yPlane, uPlane, vP
lane); |
| 284 CREATE_QUAD_5(YUVVideoDrawQuad, opaqueRect, texScale, yPlane, uPlane, vPlane
); | 422 EXPECT_EQ(DrawQuad::YUV_VIDEO_CONTENT, copyQuad->material); |
| 285 EXPECT_RECT_EQ(opaqueRect, copyQuad->opaque_rect); | 423 EXPECT_RECT_EQ(opaqueRect, copyQuad->opaque_rect); |
| 286 EXPECT_EQ(texScale, copyQuad->texScale()); | 424 EXPECT_EQ(texScale, copyQuad->tex_scale); |
| 287 EXPECT_EQ(yPlane.resourceId, copyQuad->yPlane().resourceId); | 425 EXPECT_EQ(yPlane.resourceId, copyQuad->y_plane.resourceId); |
| 288 EXPECT_EQ(yPlane.size, copyQuad->yPlane().size); | 426 EXPECT_EQ(yPlane.size, copyQuad->y_plane.size); |
| 289 EXPECT_EQ(yPlane.format, copyQuad->yPlane().format); | 427 EXPECT_EQ(yPlane.format, copyQuad->y_plane.format); |
| 290 EXPECT_EQ(uPlane.resourceId, copyQuad->uPlane().resourceId); | 428 EXPECT_EQ(uPlane.resourceId, copyQuad->u_plane.resourceId); |
| 291 EXPECT_EQ(uPlane.size, copyQuad->uPlane().size); | 429 EXPECT_EQ(uPlane.size, copyQuad->u_plane.size); |
| 292 EXPECT_EQ(uPlane.format, copyQuad->uPlane().format); | 430 EXPECT_EQ(uPlane.format, copyQuad->u_plane.format); |
| 293 EXPECT_EQ(vPlane.resourceId, copyQuad->vPlane().resourceId); | 431 EXPECT_EQ(vPlane.resourceId, copyQuad->v_plane.resourceId); |
| 294 EXPECT_EQ(vPlane.size, copyQuad->vPlane().size); | 432 EXPECT_EQ(vPlane.size, copyQuad->v_plane.size); |
| 295 EXPECT_EQ(vPlane.format, copyQuad->vPlane().format); | 433 EXPECT_EQ(vPlane.format, copyQuad->v_plane.format); |
| 434 |
| 435 CREATE_QUAD_4_ALL(YUVVideoDrawQuad, texScale, yPlane, uPlane, vPlane); |
| 436 EXPECT_EQ(DrawQuad::YUV_VIDEO_CONTENT, copyQuad->material); |
| 437 EXPECT_EQ(texScale, copyQuad->tex_scale); |
| 438 EXPECT_EQ(yPlane.resourceId, copyQuad->y_plane.resourceId); |
| 439 EXPECT_EQ(yPlane.size, copyQuad->y_plane.size); |
| 440 EXPECT_EQ(yPlane.format, copyQuad->y_plane.format); |
| 441 EXPECT_EQ(uPlane.resourceId, copyQuad->u_plane.resourceId); |
| 442 EXPECT_EQ(uPlane.size, copyQuad->u_plane.size); |
| 443 EXPECT_EQ(uPlane.format, copyQuad->u_plane.format); |
| 444 EXPECT_EQ(vPlane.resourceId, copyQuad->v_plane.resourceId); |
| 445 EXPECT_EQ(vPlane.size, copyQuad->v_plane.size); |
| 446 EXPECT_EQ(vPlane.format, copyQuad->v_plane.format); |
| 296 } | 447 } |
| 297 | 448 |
| 298 } // namespace | 449 } // namespace |
| 299 } // namespace cc | 450 } // namespace cc |
| OLD | NEW |