Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <limits> | 5 #include <limits> |
| 6 | 6 |
| 7 #include "base/memory/scoped_vector.h" | 7 #include "base/memory/scoped_vector.h" |
| 8 #include "cc/animation/transform_operations.h" | 8 #include "cc/animation/transform_operations.h" |
| 9 #include "cc/test/geometry_test_utils.h" | 9 #include "cc/test/geometry_test_utils.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 ScopedVector<TransformOperations> operations; | 140 ScopedVector<TransformOperations> operations; |
| 141 GetIdentityOperations(&operations); | 141 GetIdentityOperations(&operations); |
| 142 | 142 |
| 143 for (size_t i = 0; i < operations.size(); ++i) { | 143 for (size_t i = 0; i < operations.size(); ++i) { |
| 144 for (size_t j = 0; j < operations.size(); ++j) | 144 for (size_t j = 0; j < operations.size(); ++j) |
| 145 EXPECT_TRUE(operations[i]->MatchesTypes(*operations[j])); | 145 EXPECT_TRUE(operations[i]->MatchesTypes(*operations[j])); |
| 146 } | 146 } |
| 147 } | 147 } |
| 148 | 148 |
| 149 TEST(TransformOperationTest, ApplyTranslate) { | 149 TEST(TransformOperationTest, ApplyTranslate) { |
| 150 double x = 1; | 150 SkMScalar x = 1; |
| 151 double y = 2; | 151 SkMScalar y = 2; |
| 152 double z = 3; | 152 SkMScalar z = 3; |
| 153 TransformOperations operations; | 153 TransformOperations operations; |
| 154 operations.AppendTranslate(x, y, z); | 154 operations.AppendTranslate(x, y, z); |
| 155 gfx::Transform expected; | 155 gfx::Transform expected; |
| 156 expected.Translate3d(x, y, z); | 156 expected.Translate3d(x, y, z); |
| 157 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, operations.Apply()); | 157 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, operations.Apply()); |
| 158 } | 158 } |
| 159 | 159 |
| 160 TEST(TransformOperationTest, ApplyRotate) { | 160 TEST(TransformOperationTest, ApplyRotate) { |
| 161 double x = 1; | 161 SkMScalar x = 1; |
| 162 double y = 2; | 162 SkMScalar y = 2; |
| 163 double z = 3; | 163 SkMScalar z = 3; |
| 164 double degrees = 80; | 164 SkMScalar degrees = 80; |
| 165 TransformOperations operations; | 165 TransformOperations operations; |
| 166 operations.AppendRotate(x, y, z, degrees); | 166 operations.AppendRotate(x, y, z, degrees); |
| 167 gfx::Transform expected; | 167 gfx::Transform expected; |
| 168 expected.RotateAbout(gfx::Vector3dF(x, y, z), degrees); | 168 expected.RotateAbout(gfx::Vector3dF(x, y, z), degrees); |
| 169 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, operations.Apply()); | 169 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, operations.Apply()); |
| 170 } | 170 } |
| 171 | 171 |
| 172 TEST(TransformOperationTest, ApplyScale) { | 172 TEST(TransformOperationTest, ApplyScale) { |
| 173 double x = 1; | 173 SkMScalar x = 1; |
| 174 double y = 2; | 174 SkMScalar y = 2; |
| 175 double z = 3; | 175 SkMScalar z = 3; |
| 176 TransformOperations operations; | 176 TransformOperations operations; |
| 177 operations.AppendScale(x, y, z); | 177 operations.AppendScale(x, y, z); |
| 178 gfx::Transform expected; | 178 gfx::Transform expected; |
| 179 expected.Scale3d(x, y, z); | 179 expected.Scale3d(x, y, z); |
| 180 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, operations.Apply()); | 180 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, operations.Apply()); |
| 181 } | 181 } |
| 182 | 182 |
| 183 TEST(TransformOperationTest, ApplySkew) { | 183 TEST(TransformOperationTest, ApplySkew) { |
| 184 double x = 1; | 184 SkMScalar x = 1; |
| 185 double y = 2; | 185 SkMScalar y = 2; |
| 186 TransformOperations operations; | 186 TransformOperations operations; |
| 187 operations.AppendSkew(x, y); | 187 operations.AppendSkew(x, y); |
| 188 gfx::Transform expected; | 188 gfx::Transform expected; |
| 189 expected.SkewX(x); | 189 expected.SkewX(x); |
| 190 expected.SkewY(y); | 190 expected.SkewY(y); |
| 191 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, operations.Apply()); | 191 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, operations.Apply()); |
| 192 } | 192 } |
| 193 | 193 |
| 194 TEST(TransformOperationTest, ApplyPerspective) { | 194 TEST(TransformOperationTest, ApplyPerspective) { |
| 195 double depth = 800; | 195 SkMScalar depth = 800; |
| 196 TransformOperations operations; | 196 TransformOperations operations; |
| 197 operations.AppendPerspective(depth); | 197 operations.AppendPerspective(depth); |
| 198 gfx::Transform expected; | 198 gfx::Transform expected; |
| 199 expected.ApplyPerspectiveDepth(depth); | 199 expected.ApplyPerspectiveDepth(depth); |
| 200 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, operations.Apply()); | 200 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, operations.Apply()); |
| 201 } | 201 } |
| 202 | 202 |
| 203 TEST(TransformOperationTest, ApplyMatrix) { | 203 TEST(TransformOperationTest, ApplyMatrix) { |
| 204 double dx = 1; | 204 SkMScalar dx = 1; |
| 205 double dy = 2; | 205 SkMScalar dy = 2; |
| 206 double dz = 3; | 206 SkMScalar dz = 3; |
| 207 gfx::Transform expected_matrix; | 207 gfx::Transform expected_matrix; |
| 208 expected_matrix.Translate3d(dx, dy, dz); | 208 expected_matrix.Translate3d(dx, dy, dz); |
| 209 TransformOperations matrix_transform; | 209 TransformOperations matrix_transform; |
| 210 matrix_transform.AppendMatrix(expected_matrix); | 210 matrix_transform.AppendMatrix(expected_matrix); |
| 211 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_matrix, matrix_transform.Apply()); | 211 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_matrix, matrix_transform.Apply()); |
| 212 } | 212 } |
| 213 | 213 |
| 214 TEST(TransformOperationTest, ApplyOrder) { | 214 TEST(TransformOperationTest, ApplyOrder) { |
| 215 double sx = 2; | 215 SkMScalar sx = 2; |
| 216 double sy = 4; | 216 SkMScalar sy = 4; |
| 217 double sz = 8; | 217 SkMScalar sz = 8; |
| 218 | 218 |
| 219 double dx = 1; | 219 SkMScalar dx = 1; |
| 220 double dy = 2; | 220 SkMScalar dy = 2; |
| 221 double dz = 3; | 221 SkMScalar dz = 3; |
| 222 | 222 |
| 223 TransformOperations operations; | 223 TransformOperations operations; |
| 224 operations.AppendScale(sx, sy, sz); | 224 operations.AppendScale(sx, sy, sz); |
| 225 operations.AppendTranslate(dx, dy, dz); | 225 operations.AppendTranslate(dx, dy, dz); |
| 226 | 226 |
| 227 gfx::Transform expected_scale_matrix; | 227 gfx::Transform expected_scale_matrix; |
| 228 expected_scale_matrix.Scale3d(sx, sy, sz); | 228 expected_scale_matrix.Scale3d(sx, sy, sz); |
| 229 | 229 |
| 230 gfx::Transform expected_translate_matrix; | 230 gfx::Transform expected_translate_matrix; |
| 231 expected_translate_matrix.Translate3d(dx, dy, dz); | 231 expected_translate_matrix.Translate3d(dx, dy, dz); |
| 232 | 232 |
| 233 gfx::Transform expected_combined_matrix = expected_scale_matrix; | 233 gfx::Transform expected_combined_matrix = expected_scale_matrix; |
| 234 expected_combined_matrix.PreconcatTransform(expected_translate_matrix); | 234 expected_combined_matrix.PreconcatTransform(expected_translate_matrix); |
| 235 | 235 |
| 236 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_combined_matrix, operations.Apply()); | 236 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_combined_matrix, operations.Apply()); |
| 237 } | 237 } |
| 238 | 238 |
| 239 TEST(TransformOperationTest, BlendOrder) { | 239 TEST(TransformOperationTest, BlendOrder) { |
| 240 double sx1 = 2; | 240 SkMScalar sx1 = 2; |
| 241 double sy1 = 4; | 241 SkMScalar sy1 = 4; |
| 242 double sz1 = 8; | 242 SkMScalar sz1 = 8; |
| 243 | 243 |
| 244 double dx1 = 1; | 244 SkMScalar dx1 = 1; |
| 245 double dy1 = 2; | 245 SkMScalar dy1 = 2; |
| 246 double dz1 = 3; | 246 SkMScalar dz1 = 3; |
| 247 | 247 |
| 248 double sx2 = 4; | 248 SkMScalar sx2 = 4; |
| 249 double sy2 = 8; | 249 SkMScalar sy2 = 8; |
| 250 double sz2 = 16; | 250 SkMScalar sz2 = 16; |
| 251 | 251 |
| 252 double dx2 = 10; | 252 SkMScalar dx2 = 10; |
| 253 double dy2 = 20; | 253 SkMScalar dy2 = 20; |
| 254 double dz2 = 30; | 254 SkMScalar dz2 = 30; |
| 255 | 255 |
| 256 TransformOperations operations_from; | 256 TransformOperations operations_from; |
| 257 operations_from.AppendScale(sx1, sy1, sz1); | 257 operations_from.AppendScale(sx1, sy1, sz1); |
| 258 operations_from.AppendTranslate(dx1, dy1, dz1); | 258 operations_from.AppendTranslate(dx1, dy1, dz1); |
| 259 | 259 |
| 260 TransformOperations operations_to; | 260 TransformOperations operations_to; |
| 261 operations_to.AppendScale(sx2, sy2, sz2); | 261 operations_to.AppendScale(sx2, sy2, sz2); |
| 262 operations_to.AppendTranslate(dx2, dy2, dz2); | 262 operations_to.AppendTranslate(dx2, dy2, dz2); |
| 263 | 263 |
| 264 gfx::Transform scale_from; | 264 gfx::Transform scale_from; |
| 265 scale_from.Scale3d(sx1, sy1, sz1); | 265 scale_from.Scale3d(sx1, sy1, sz1); |
| 266 gfx::Transform translate_from; | 266 gfx::Transform translate_from; |
| 267 translate_from.Translate3d(dx1, dy1, dz1); | 267 translate_from.Translate3d(dx1, dy1, dz1); |
| 268 | 268 |
| 269 gfx::Transform scale_to; | 269 gfx::Transform scale_to; |
| 270 scale_to.Scale3d(sx2, sy2, sz2); | 270 scale_to.Scale3d(sx2, sy2, sz2); |
| 271 gfx::Transform translate_to; | 271 gfx::Transform translate_to; |
| 272 translate_to.Translate3d(dx2, dy2, dz2); | 272 translate_to.Translate3d(dx2, dy2, dz2); |
| 273 | 273 |
| 274 double progress = 0.25; | 274 SkMScalar progress = 0.25; |
|
danakj
2013/09/09 17:57:45
double?
| |
| 275 | 275 |
| 276 gfx::Transform blended_scale = scale_to; | 276 gfx::Transform blended_scale = scale_to; |
| 277 blended_scale.Blend(scale_from, progress); | 277 blended_scale.Blend(scale_from, progress); |
| 278 | 278 |
| 279 gfx::Transform blended_translate = translate_to; | 279 gfx::Transform blended_translate = translate_to; |
| 280 blended_translate.Blend(translate_from, progress); | 280 blended_translate.Blend(translate_from, progress); |
| 281 | 281 |
| 282 gfx::Transform expected = blended_scale; | 282 gfx::Transform expected = blended_scale; |
| 283 expected.PreconcatTransform(blended_translate); | 283 expected.PreconcatTransform(blended_translate); |
| 284 | 284 |
| 285 EXPECT_TRANSFORMATION_MATRIX_EQ( | 285 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 286 expected, operations_to.Blend(operations_from, progress)); | 286 expected, operations_to.Blend(operations_from, progress)); |
| 287 } | 287 } |
| 288 | 288 |
| 289 static void CheckProgress(double progress, | 289 static void CheckProgress(SkMScalar progress, |
|
danakj
2013/09/09 17:57:45
double?
| |
| 290 const gfx::Transform& from_matrix, | 290 const gfx::Transform& from_matrix, |
| 291 const gfx::Transform& to_matrix, | 291 const gfx::Transform& to_matrix, |
| 292 const TransformOperations& from_transform, | 292 const TransformOperations& from_transform, |
| 293 const TransformOperations& to_transform) { | 293 const TransformOperations& to_transform) { |
| 294 gfx::Transform expected_matrix = to_matrix; | 294 gfx::Transform expected_matrix = to_matrix; |
| 295 expected_matrix.Blend(from_matrix, progress); | 295 expected_matrix.Blend(from_matrix, progress); |
| 296 EXPECT_TRANSFORMATION_MATRIX_EQ( | 296 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 297 expected_matrix, to_transform.Blend(from_transform, progress)); | 297 expected_matrix, to_transform.Blend(from_transform, progress)); |
| 298 } | 298 } |
| 299 | 299 |
| 300 TEST(TransformOperationTest, BlendProgress) { | 300 TEST(TransformOperationTest, BlendProgress) { |
| 301 double sx = 2; | 301 SkMScalar sx = 2; |
| 302 double sy = 4; | 302 SkMScalar sy = 4; |
| 303 double sz = 8; | 303 SkMScalar sz = 8; |
| 304 TransformOperations operations_from; | 304 TransformOperations operations_from; |
| 305 operations_from.AppendScale(sx, sy, sz); | 305 operations_from.AppendScale(sx, sy, sz); |
| 306 | 306 |
| 307 gfx::Transform matrix_from; | 307 gfx::Transform matrix_from; |
| 308 matrix_from.Scale3d(sx, sy, sz); | 308 matrix_from.Scale3d(sx, sy, sz); |
| 309 | 309 |
| 310 sx = 4; | 310 sx = 4; |
| 311 sy = 8; | 311 sy = 8; |
| 312 sz = 16; | 312 sz = 16; |
| 313 TransformOperations operations_to; | 313 TransformOperations operations_to; |
| 314 operations_to.AppendScale(sx, sy, sz); | 314 operations_to.AppendScale(sx, sy, sz); |
| 315 | 315 |
| 316 gfx::Transform matrix_to; | 316 gfx::Transform matrix_to; |
| 317 matrix_to.Scale3d(sx, sy, sz); | 317 matrix_to.Scale3d(sx, sy, sz); |
| 318 | 318 |
| 319 CheckProgress(-1, matrix_from, matrix_to, operations_from, operations_to); | 319 CheckProgress(-1, matrix_from, matrix_to, operations_from, operations_to); |
| 320 CheckProgress(0, matrix_from, matrix_to, operations_from, operations_to); | 320 CheckProgress(0, matrix_from, matrix_to, operations_from, operations_to); |
| 321 CheckProgress(0.25, matrix_from, matrix_to, operations_from, operations_to); | 321 CheckProgress(0.25, matrix_from, matrix_to, operations_from, operations_to); |
| 322 CheckProgress(0.5, matrix_from, matrix_to, operations_from, operations_to); | 322 CheckProgress(0.5, matrix_from, matrix_to, operations_from, operations_to); |
| 323 CheckProgress(1, matrix_from, matrix_to, operations_from, operations_to); | 323 CheckProgress(1, matrix_from, matrix_to, operations_from, operations_to); |
| 324 CheckProgress(2, matrix_from, matrix_to, operations_from, operations_to); | 324 CheckProgress(2, matrix_from, matrix_to, operations_from, operations_to); |
| 325 } | 325 } |
| 326 | 326 |
| 327 TEST(TransformOperationTest, BlendWhenTypesDoNotMatch) { | 327 TEST(TransformOperationTest, BlendWhenTypesDoNotMatch) { |
| 328 double sx1 = 2; | 328 SkMScalar sx1 = 2; |
| 329 double sy1 = 4; | 329 SkMScalar sy1 = 4; |
| 330 double sz1 = 8; | 330 SkMScalar sz1 = 8; |
| 331 | 331 |
| 332 double dx1 = 1; | 332 SkMScalar dx1 = 1; |
| 333 double dy1 = 2; | 333 SkMScalar dy1 = 2; |
| 334 double dz1 = 3; | 334 SkMScalar dz1 = 3; |
| 335 | 335 |
| 336 double sx2 = 4; | 336 SkMScalar sx2 = 4; |
| 337 double sy2 = 8; | 337 SkMScalar sy2 = 8; |
| 338 double sz2 = 16; | 338 SkMScalar sz2 = 16; |
| 339 | 339 |
| 340 double dx2 = 10; | 340 SkMScalar dx2 = 10; |
| 341 double dy2 = 20; | 341 SkMScalar dy2 = 20; |
| 342 double dz2 = 30; | 342 SkMScalar dz2 = 30; |
| 343 | 343 |
| 344 TransformOperations operations_from; | 344 TransformOperations operations_from; |
| 345 operations_from.AppendScale(sx1, sy1, sz1); | 345 operations_from.AppendScale(sx1, sy1, sz1); |
| 346 operations_from.AppendTranslate(dx1, dy1, dz1); | 346 operations_from.AppendTranslate(dx1, dy1, dz1); |
| 347 | 347 |
| 348 TransformOperations operations_to; | 348 TransformOperations operations_to; |
| 349 operations_to.AppendTranslate(dx2, dy2, dz2); | 349 operations_to.AppendTranslate(dx2, dy2, dz2); |
| 350 operations_to.AppendScale(sx2, sy2, sz2); | 350 operations_to.AppendScale(sx2, sy2, sz2); |
| 351 | 351 |
| 352 gfx::Transform from; | 352 gfx::Transform from; |
| 353 from.Scale3d(sx1, sy1, sz1); | 353 from.Scale3d(sx1, sy1, sz1); |
| 354 from.Translate3d(dx1, dy1, dz1); | 354 from.Translate3d(dx1, dy1, dz1); |
| 355 | 355 |
| 356 gfx::Transform to; | 356 gfx::Transform to; |
| 357 to.Translate3d(dx2, dy2, dz2); | 357 to.Translate3d(dx2, dy2, dz2); |
| 358 to.Scale3d(sx2, sy2, sz2); | 358 to.Scale3d(sx2, sy2, sz2); |
| 359 | 359 |
| 360 double progress = 0.25; | 360 SkMScalar progress = 0.25; |
|
danakj
2013/09/09 17:57:45
double for all these?
| |
| 361 | 361 |
| 362 gfx::Transform expected = to; | 362 gfx::Transform expected = to; |
| 363 expected.Blend(from, progress); | 363 expected.Blend(from, progress); |
| 364 | 364 |
| 365 EXPECT_TRANSFORMATION_MATRIX_EQ( | 365 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 366 expected, operations_to.Blend(operations_from, progress)); | 366 expected, operations_to.Blend(operations_from, progress)); |
| 367 } | 367 } |
| 368 | 368 |
| 369 TEST(TransformOperationTest, LargeRotationsWithSameAxis) { | 369 TEST(TransformOperationTest, LargeRotationsWithSameAxis) { |
| 370 TransformOperations operations_from; | 370 TransformOperations operations_from; |
| 371 operations_from.AppendRotate(0, 0, 1, 0); | 371 operations_from.AppendRotate(0, 0, 1, 0); |
| 372 | 372 |
| 373 TransformOperations operations_to; | 373 TransformOperations operations_to; |
| 374 operations_to.AppendRotate(0, 0, 2, 360); | 374 operations_to.AppendRotate(0, 0, 2, 360); |
| 375 | 375 |
| 376 double progress = 0.5; | 376 SkMScalar progress = 0.5; |
| 377 | 377 |
| 378 gfx::Transform expected; | 378 gfx::Transform expected; |
| 379 expected.RotateAbout(gfx::Vector3dF(0, 0, 1), 180); | 379 expected.RotateAbout(gfx::Vector3dF(0, 0, 1), 180); |
| 380 | 380 |
| 381 EXPECT_TRANSFORMATION_MATRIX_EQ( | 381 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 382 expected, operations_to.Blend(operations_from, progress)); | 382 expected, operations_to.Blend(operations_from, progress)); |
| 383 } | 383 } |
| 384 | 384 |
| 385 TEST(TransformOperationTest, LargeRotationsWithSameAxisInDifferentDirection) { | 385 TEST(TransformOperationTest, LargeRotationsWithSameAxisInDifferentDirection) { |
| 386 TransformOperations operations_from; | 386 TransformOperations operations_from; |
| 387 operations_from.AppendRotate(0, 0, 1, 180); | 387 operations_from.AppendRotate(0, 0, 1, 180); |
| 388 | 388 |
| 389 TransformOperations operations_to; | 389 TransformOperations operations_to; |
| 390 operations_to.AppendRotate(0, 0, -1, 180); | 390 operations_to.AppendRotate(0, 0, -1, 180); |
| 391 | 391 |
| 392 double progress = 0.5; | 392 SkMScalar progress = 0.5; |
| 393 | 393 |
| 394 gfx::Transform expected; | 394 gfx::Transform expected; |
| 395 | 395 |
| 396 EXPECT_TRANSFORMATION_MATRIX_EQ( | 396 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 397 expected, operations_to.Blend(operations_from, progress)); | 397 expected, operations_to.Blend(operations_from, progress)); |
| 398 } | 398 } |
| 399 | 399 |
| 400 TEST(TransformOperationTest, LargeRotationsWithDifferentAxes) { | 400 TEST(TransformOperationTest, LargeRotationsWithDifferentAxes) { |
| 401 TransformOperations operations_from; | 401 TransformOperations operations_from; |
| 402 operations_from.AppendRotate(0, 0, 1, 175); | 402 operations_from.AppendRotate(0, 0, 1, 175); |
| 403 | 403 |
| 404 TransformOperations operations_to; | 404 TransformOperations operations_to; |
| 405 operations_to.AppendRotate(0, 1, 0, 175); | 405 operations_to.AppendRotate(0, 1, 0, 175); |
| 406 | 406 |
| 407 double progress = 0.5; | 407 SkMScalar progress = 0.5; |
| 408 gfx::Transform matrix_from; | 408 gfx::Transform matrix_from; |
| 409 matrix_from.RotateAbout(gfx::Vector3dF(0, 0, 1), 175); | 409 matrix_from.RotateAbout(gfx::Vector3dF(0, 0, 1), 175); |
| 410 | 410 |
| 411 gfx::Transform matrix_to; | 411 gfx::Transform matrix_to; |
| 412 matrix_to.RotateAbout(gfx::Vector3dF(0, 1, 0), 175); | 412 matrix_to.RotateAbout(gfx::Vector3dF(0, 1, 0), 175); |
| 413 | 413 |
| 414 gfx::Transform expected = matrix_to; | 414 gfx::Transform expected = matrix_to; |
| 415 expected.Blend(matrix_from, progress); | 415 expected.Blend(matrix_from, progress); |
| 416 | 416 |
| 417 EXPECT_TRANSFORMATION_MATRIX_EQ( | 417 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 418 expected, operations_to.Blend(operations_from, progress)); | 418 expected, operations_to.Blend(operations_from, progress)); |
| 419 } | 419 } |
| 420 | 420 |
| 421 TEST(TransformOperationTest, BlendRotationFromIdentity) { | 421 TEST(TransformOperationTest, BlendRotationFromIdentity) { |
| 422 ScopedVector<TransformOperations> identity_operations; | 422 ScopedVector<TransformOperations> identity_operations; |
| 423 GetIdentityOperations(&identity_operations); | 423 GetIdentityOperations(&identity_operations); |
| 424 | 424 |
| 425 for (size_t i = 0; i < identity_operations.size(); ++i) { | 425 for (size_t i = 0; i < identity_operations.size(); ++i) { |
| 426 TransformOperations operations; | 426 TransformOperations operations; |
| 427 operations.AppendRotate(0, 0, 1, 360); | 427 operations.AppendRotate(0, 0, 1, 360); |
| 428 | 428 |
| 429 double progress = 0.5; | 429 SkMScalar progress = 0.5; |
| 430 | 430 |
| 431 gfx::Transform expected; | 431 gfx::Transform expected; |
| 432 expected.RotateAbout(gfx::Vector3dF(0, 0, 1), 180); | 432 expected.RotateAbout(gfx::Vector3dF(0, 0, 1), 180); |
| 433 | 433 |
| 434 EXPECT_TRANSFORMATION_MATRIX_EQ( | 434 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 435 expected, operations.Blend(*identity_operations[i], progress)); | 435 expected, operations.Blend(*identity_operations[i], progress)); |
| 436 | 436 |
| 437 progress = -0.5; | 437 progress = -0.5; |
| 438 | 438 |
| 439 expected.MakeIdentity(); | 439 expected.MakeIdentity(); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 453 } | 453 } |
| 454 | 454 |
| 455 TEST(TransformOperationTest, BlendTranslationFromIdentity) { | 455 TEST(TransformOperationTest, BlendTranslationFromIdentity) { |
| 456 ScopedVector<TransformOperations> identity_operations; | 456 ScopedVector<TransformOperations> identity_operations; |
| 457 GetIdentityOperations(&identity_operations); | 457 GetIdentityOperations(&identity_operations); |
| 458 | 458 |
| 459 for (size_t i = 0; i < identity_operations.size(); ++i) { | 459 for (size_t i = 0; i < identity_operations.size(); ++i) { |
| 460 TransformOperations operations; | 460 TransformOperations operations; |
| 461 operations.AppendTranslate(2, 2, 2); | 461 operations.AppendTranslate(2, 2, 2); |
| 462 | 462 |
| 463 double progress = 0.5; | 463 SkMScalar progress = 0.5; |
| 464 | 464 |
| 465 gfx::Transform expected; | 465 gfx::Transform expected; |
| 466 expected.Translate3d(1, 1, 1); | 466 expected.Translate3d(1, 1, 1); |
| 467 | 467 |
| 468 EXPECT_TRANSFORMATION_MATRIX_EQ( | 468 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 469 expected, operations.Blend(*identity_operations[i], progress)); | 469 expected, operations.Blend(*identity_operations[i], progress)); |
| 470 | 470 |
| 471 progress = -0.5; | 471 progress = -0.5; |
| 472 | 472 |
| 473 expected.MakeIdentity(); | 473 expected.MakeIdentity(); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 487 } | 487 } |
| 488 | 488 |
| 489 TEST(TransformOperationTest, BlendScaleFromIdentity) { | 489 TEST(TransformOperationTest, BlendScaleFromIdentity) { |
| 490 ScopedVector<TransformOperations> identity_operations; | 490 ScopedVector<TransformOperations> identity_operations; |
| 491 GetIdentityOperations(&identity_operations); | 491 GetIdentityOperations(&identity_operations); |
| 492 | 492 |
| 493 for (size_t i = 0; i < identity_operations.size(); ++i) { | 493 for (size_t i = 0; i < identity_operations.size(); ++i) { |
| 494 TransformOperations operations; | 494 TransformOperations operations; |
| 495 operations.AppendScale(3, 3, 3); | 495 operations.AppendScale(3, 3, 3); |
| 496 | 496 |
| 497 double progress = 0.5; | 497 SkMScalar progress = 0.5; |
| 498 | 498 |
| 499 gfx::Transform expected; | 499 gfx::Transform expected; |
| 500 expected.Scale3d(2, 2, 2); | 500 expected.Scale3d(2, 2, 2); |
| 501 | 501 |
| 502 EXPECT_TRANSFORMATION_MATRIX_EQ( | 502 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 503 expected, operations.Blend(*identity_operations[i], progress)); | 503 expected, operations.Blend(*identity_operations[i], progress)); |
| 504 | 504 |
| 505 progress = -0.5; | 505 progress = -0.5; |
| 506 | 506 |
| 507 expected.MakeIdentity(); | 507 expected.MakeIdentity(); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 521 } | 521 } |
| 522 | 522 |
| 523 TEST(TransformOperationTest, BlendSkewFromIdentity) { | 523 TEST(TransformOperationTest, BlendSkewFromIdentity) { |
| 524 ScopedVector<TransformOperations> identity_operations; | 524 ScopedVector<TransformOperations> identity_operations; |
| 525 GetIdentityOperations(&identity_operations); | 525 GetIdentityOperations(&identity_operations); |
| 526 | 526 |
| 527 for (size_t i = 0; i < identity_operations.size(); ++i) { | 527 for (size_t i = 0; i < identity_operations.size(); ++i) { |
| 528 TransformOperations operations; | 528 TransformOperations operations; |
| 529 operations.AppendSkew(2, 2); | 529 operations.AppendSkew(2, 2); |
| 530 | 530 |
| 531 double progress = 0.5; | 531 SkMScalar progress = 0.5; |
| 532 | 532 |
| 533 gfx::Transform expected; | 533 gfx::Transform expected; |
| 534 expected.SkewX(1); | 534 expected.SkewX(1); |
| 535 expected.SkewY(1); | 535 expected.SkewY(1); |
| 536 | 536 |
| 537 EXPECT_TRANSFORMATION_MATRIX_EQ( | 537 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 538 expected, operations.Blend(*identity_operations[i], progress)); | 538 expected, operations.Blend(*identity_operations[i], progress)); |
| 539 | 539 |
| 540 progress = -0.5; | 540 progress = -0.5; |
| 541 | 541 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 558 } | 558 } |
| 559 | 559 |
| 560 TEST(TransformOperationTest, BlendPerspectiveFromIdentity) { | 560 TEST(TransformOperationTest, BlendPerspectiveFromIdentity) { |
| 561 ScopedVector<TransformOperations> identity_operations; | 561 ScopedVector<TransformOperations> identity_operations; |
| 562 GetIdentityOperations(&identity_operations); | 562 GetIdentityOperations(&identity_operations); |
| 563 | 563 |
| 564 for (size_t i = 0; i < identity_operations.size(); ++i) { | 564 for (size_t i = 0; i < identity_operations.size(); ++i) { |
| 565 TransformOperations operations; | 565 TransformOperations operations; |
| 566 operations.AppendPerspective(1000); | 566 operations.AppendPerspective(1000); |
| 567 | 567 |
| 568 double progress = 0.5; | 568 SkMScalar progress = 0.5; |
| 569 | 569 |
| 570 gfx::Transform expected; | 570 gfx::Transform expected; |
| 571 expected.ApplyPerspectiveDepth( | 571 expected.ApplyPerspectiveDepth(500 + |
| 572 500 + 0.5 * std::numeric_limits<double>::max()); | 572 0.5 * std::numeric_limits<SkMScalar>::max()); |
| 573 | 573 |
| 574 EXPECT_TRANSFORMATION_MATRIX_EQ( | 574 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 575 expected, operations.Blend(*identity_operations[i], progress)); | 575 expected, operations.Blend(*identity_operations[i], progress)); |
| 576 } | 576 } |
| 577 } | 577 } |
| 578 | 578 |
| 579 TEST(TransformOperationTest, BlendRotationToIdentity) { | 579 TEST(TransformOperationTest, BlendRotationToIdentity) { |
| 580 ScopedVector<TransformOperations> identity_operations; | 580 ScopedVector<TransformOperations> identity_operations; |
| 581 GetIdentityOperations(&identity_operations); | 581 GetIdentityOperations(&identity_operations); |
| 582 | 582 |
| 583 for (size_t i = 0; i < identity_operations.size(); ++i) { | 583 for (size_t i = 0; i < identity_operations.size(); ++i) { |
| 584 TransformOperations operations; | 584 TransformOperations operations; |
| 585 operations.AppendRotate(0, 0, 1, 360); | 585 operations.AppendRotate(0, 0, 1, 360); |
| 586 | 586 |
| 587 double progress = 0.5; | 587 SkMScalar progress = 0.5; |
| 588 | 588 |
| 589 gfx::Transform expected; | 589 gfx::Transform expected; |
| 590 expected.RotateAbout(gfx::Vector3dF(0, 0, 1), 180); | 590 expected.RotateAbout(gfx::Vector3dF(0, 0, 1), 180); |
| 591 | 591 |
| 592 EXPECT_TRANSFORMATION_MATRIX_EQ( | 592 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 593 expected, identity_operations[i]->Blend(operations, progress)); | 593 expected, identity_operations[i]->Blend(operations, progress)); |
| 594 } | 594 } |
| 595 } | 595 } |
| 596 | 596 |
| 597 TEST(TransformOperationTest, BlendTranslationToIdentity) { | 597 TEST(TransformOperationTest, BlendTranslationToIdentity) { |
| 598 ScopedVector<TransformOperations> identity_operations; | 598 ScopedVector<TransformOperations> identity_operations; |
| 599 GetIdentityOperations(&identity_operations); | 599 GetIdentityOperations(&identity_operations); |
| 600 | 600 |
| 601 for (size_t i = 0; i < identity_operations.size(); ++i) { | 601 for (size_t i = 0; i < identity_operations.size(); ++i) { |
| 602 TransformOperations operations; | 602 TransformOperations operations; |
| 603 operations.AppendTranslate(2, 2, 2); | 603 operations.AppendTranslate(2, 2, 2); |
| 604 | 604 |
| 605 double progress = 0.5; | 605 SkMScalar progress = 0.5; |
|
danakj
2013/09/09 17:57:45
It's a bit off that these are 0.5 and not 0.5f or
enne (OOO)
2013/09/10 22:32:32
Changed all progress to float literals to avoid na
| |
| 606 | 606 |
| 607 gfx::Transform expected; | 607 gfx::Transform expected; |
| 608 expected.Translate3d(1, 1, 1); | 608 expected.Translate3d(1, 1, 1); |
| 609 | 609 |
| 610 EXPECT_TRANSFORMATION_MATRIX_EQ( | 610 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 611 expected, identity_operations[i]->Blend(operations, progress)); | 611 expected, identity_operations[i]->Blend(operations, progress)); |
| 612 } | 612 } |
| 613 } | 613 } |
| 614 | 614 |
| 615 TEST(TransformOperationTest, BlendScaleToIdentity) { | 615 TEST(TransformOperationTest, BlendScaleToIdentity) { |
| 616 ScopedVector<TransformOperations> identity_operations; | 616 ScopedVector<TransformOperations> identity_operations; |
| 617 GetIdentityOperations(&identity_operations); | 617 GetIdentityOperations(&identity_operations); |
| 618 | 618 |
| 619 for (size_t i = 0; i < identity_operations.size(); ++i) { | 619 for (size_t i = 0; i < identity_operations.size(); ++i) { |
| 620 TransformOperations operations; | 620 TransformOperations operations; |
| 621 operations.AppendScale(3, 3, 3); | 621 operations.AppendScale(3, 3, 3); |
| 622 | 622 |
| 623 double progress = 0.5; | 623 SkMScalar progress = 0.5; |
| 624 | 624 |
| 625 gfx::Transform expected; | 625 gfx::Transform expected; |
| 626 expected.Scale3d(2, 2, 2); | 626 expected.Scale3d(2, 2, 2); |
| 627 | 627 |
| 628 EXPECT_TRANSFORMATION_MATRIX_EQ( | 628 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 629 expected, identity_operations[i]->Blend(operations, progress)); | 629 expected, identity_operations[i]->Blend(operations, progress)); |
| 630 } | 630 } |
| 631 } | 631 } |
| 632 | 632 |
| 633 TEST(TransformOperationTest, BlendSkewToIdentity) { | 633 TEST(TransformOperationTest, BlendSkewToIdentity) { |
| 634 ScopedVector<TransformOperations> identity_operations; | 634 ScopedVector<TransformOperations> identity_operations; |
| 635 GetIdentityOperations(&identity_operations); | 635 GetIdentityOperations(&identity_operations); |
| 636 | 636 |
| 637 for (size_t i = 0; i < identity_operations.size(); ++i) { | 637 for (size_t i = 0; i < identity_operations.size(); ++i) { |
| 638 TransformOperations operations; | 638 TransformOperations operations; |
| 639 operations.AppendSkew(2, 2); | 639 operations.AppendSkew(2, 2); |
| 640 | 640 |
| 641 double progress = 0.5; | 641 SkMScalar progress = 0.5; |
| 642 | 642 |
| 643 gfx::Transform expected; | 643 gfx::Transform expected; |
| 644 expected.SkewX(1); | 644 expected.SkewX(1); |
| 645 expected.SkewY(1); | 645 expected.SkewY(1); |
| 646 | 646 |
| 647 EXPECT_TRANSFORMATION_MATRIX_EQ( | 647 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 648 expected, identity_operations[i]->Blend(operations, progress)); | 648 expected, identity_operations[i]->Blend(operations, progress)); |
| 649 } | 649 } |
| 650 } | 650 } |
| 651 | 651 |
| 652 TEST(TransformOperationTest, BlendPerspectiveToIdentity) { | 652 TEST(TransformOperationTest, BlendPerspectiveToIdentity) { |
| 653 ScopedVector<TransformOperations> identity_operations; | 653 ScopedVector<TransformOperations> identity_operations; |
| 654 GetIdentityOperations(&identity_operations); | 654 GetIdentityOperations(&identity_operations); |
| 655 | 655 |
| 656 for (size_t i = 0; i < identity_operations.size(); ++i) { | 656 for (size_t i = 0; i < identity_operations.size(); ++i) { |
| 657 TransformOperations operations; | 657 TransformOperations operations; |
| 658 operations.AppendPerspective(1000); | 658 operations.AppendPerspective(1000); |
| 659 | 659 |
| 660 double progress = 0.5; | 660 SkMScalar progress = 0.5; |
| 661 | 661 |
| 662 gfx::Transform expected; | 662 gfx::Transform expected; |
| 663 expected.ApplyPerspectiveDepth( | 663 expected.ApplyPerspectiveDepth(500 + |
| 664 500 + 0.5 * std::numeric_limits<double>::max()); | 664 0.5 * std::numeric_limits<SkMScalar>::max()); |
| 665 | 665 |
| 666 EXPECT_TRANSFORMATION_MATRIX_EQ( | 666 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 667 expected, identity_operations[i]->Blend(operations, progress)); | 667 expected, identity_operations[i]->Blend(operations, progress)); |
| 668 } | 668 } |
| 669 } | 669 } |
| 670 | 670 |
| 671 TEST(TransformOperationTest, ExtrapolatePerspectiveBlending) { | 671 TEST(TransformOperationTest, ExtrapolatePerspectiveBlending) { |
| 672 TransformOperations operations1; | 672 TransformOperations operations1; |
| 673 operations1.AppendPerspective(1000); | 673 operations1.AppendPerspective(1000); |
| 674 | 674 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 713 operations_from.AppendScale(2.0, 4.0, 8.0); | 713 operations_from.AppendScale(2.0, 4.0, 8.0); |
| 714 operations_from.AppendTranslate(1.0, 2.0, 3.0); | 714 operations_from.AppendTranslate(1.0, 2.0, 3.0); |
| 715 | 715 |
| 716 TransformOperations operations_to; | 716 TransformOperations operations_to; |
| 717 operations_to.AppendTranslate(10.0, 20.0, 30.0); | 717 operations_to.AppendTranslate(10.0, 20.0, 30.0); |
| 718 operations_to.AppendScale(4.0, 8.0, 16.0); | 718 operations_to.AppendScale(4.0, 8.0, 16.0); |
| 719 | 719 |
| 720 gfx::BoxF box(1.f, 1.f, 1.f); | 720 gfx::BoxF box(1.f, 1.f, 1.f); |
| 721 gfx::BoxF bounds; | 721 gfx::BoxF bounds; |
| 722 | 722 |
| 723 double min_progress = 0.0; | 723 SkMScalar min_progress = 0.0; |
|
danakj
2013/09/09 17:57:45
more doubles?
| |
| 724 double max_progress = 1.0; | 724 SkMScalar max_progress = 1.0; |
| 725 | 725 |
| 726 EXPECT_FALSE(operations_to.BlendedBoundsForBox( | 726 EXPECT_FALSE(operations_to.BlendedBoundsForBox( |
| 727 box, operations_from, min_progress, max_progress, &bounds)); | 727 box, operations_from, min_progress, max_progress, &bounds)); |
| 728 } | 728 } |
| 729 | 729 |
| 730 TEST(TransformOperationTest, BlendedBoundsForIdentity) { | 730 TEST(TransformOperationTest, BlendedBoundsForIdentity) { |
| 731 TransformOperations operations_from; | 731 TransformOperations operations_from; |
| 732 operations_from.AppendIdentity(); | 732 operations_from.AppendIdentity(); |
| 733 TransformOperations operations_to; | 733 TransformOperations operations_to; |
| 734 operations_to.AppendIdentity(); | 734 operations_to.AppendIdentity(); |
| 735 | 735 |
| 736 gfx::BoxF box(1.f, 2.f, 3.f); | 736 gfx::BoxF box(1.f, 2.f, 3.f); |
| 737 gfx::BoxF bounds; | 737 gfx::BoxF bounds; |
| 738 | 738 |
| 739 double min_progress = 0.0; | 739 SkMScalar min_progress = 0.0; |
| 740 double max_progress = 1.0; | 740 SkMScalar max_progress = 1.0; |
| 741 | 741 |
| 742 EXPECT_TRUE(operations_to.BlendedBoundsForBox( | 742 EXPECT_TRUE(operations_to.BlendedBoundsForBox( |
| 743 box, operations_from, min_progress, max_progress, &bounds)); | 743 box, operations_from, min_progress, max_progress, &bounds)); |
| 744 EXPECT_EQ(box.ToString(), bounds.ToString()); | 744 EXPECT_EQ(box.ToString(), bounds.ToString()); |
| 745 } | 745 } |
| 746 | 746 |
| 747 TEST(TransformOperationTest, BlendedBoundsForTranslate) { | 747 TEST(TransformOperationTest, BlendedBoundsForTranslate) { |
| 748 TransformOperations operations_from; | 748 TransformOperations operations_from; |
| 749 operations_from.AppendTranslate(3.0, -4.0, 2.0); | 749 operations_from.AppendTranslate(3.0, -4.0, 2.0); |
| 750 TransformOperations operations_to; | 750 TransformOperations operations_to; |
| 751 operations_to.AppendTranslate(7.0, 4.0, -2.0); | 751 operations_to.AppendTranslate(7.0, 4.0, -2.0); |
| 752 | 752 |
| 753 gfx::BoxF box(1.f, 2.f, 3.f, 4.f, 4.f, 4.f); | 753 gfx::BoxF box(1.f, 2.f, 3.f, 4.f, 4.f, 4.f); |
| 754 gfx::BoxF bounds; | 754 gfx::BoxF bounds; |
| 755 | 755 |
| 756 double min_progress = -0.5; | 756 SkMScalar min_progress = -0.5; |
| 757 double max_progress = 1.5; | 757 SkMScalar max_progress = 1.5; |
| 758 EXPECT_TRUE(operations_to.BlendedBoundsForBox( | 758 EXPECT_TRUE(operations_to.BlendedBoundsForBox( |
| 759 box, operations_from, min_progress, max_progress, &bounds)); | 759 box, operations_from, min_progress, max_progress, &bounds)); |
| 760 EXPECT_EQ(gfx::BoxF(2.f, -6.f, -1.f, 12.f, 20.f, 12.f).ToString(), | 760 EXPECT_EQ(gfx::BoxF(2.f, -6.f, -1.f, 12.f, 20.f, 12.f).ToString(), |
| 761 bounds.ToString()); | 761 bounds.ToString()); |
| 762 | 762 |
| 763 min_progress = 0.0; | 763 min_progress = 0.0; |
| 764 max_progress = 1.0; | 764 max_progress = 1.0; |
| 765 EXPECT_TRUE(operations_to.BlendedBoundsForBox( | 765 EXPECT_TRUE(operations_to.BlendedBoundsForBox( |
| 766 box, operations_from, min_progress, max_progress, &bounds)); | 766 box, operations_from, min_progress, max_progress, &bounds)); |
| 767 EXPECT_EQ(gfx::BoxF(4.f, -2.f, 1.f, 8.f, 12.f, 8.f).ToString(), | 767 EXPECT_EQ(gfx::BoxF(4.f, -2.f, 1.f, 8.f, 12.f, 8.f).ToString(), |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 781 | 781 |
| 782 TEST(TransformOperationTest, BlendedBoundsForScale) { | 782 TEST(TransformOperationTest, BlendedBoundsForScale) { |
| 783 TransformOperations operations_from; | 783 TransformOperations operations_from; |
| 784 operations_from.AppendScale(3.0, 0.5, 2.0); | 784 operations_from.AppendScale(3.0, 0.5, 2.0); |
| 785 TransformOperations operations_to; | 785 TransformOperations operations_to; |
| 786 operations_to.AppendScale(7.0, 4.0, -2.0); | 786 operations_to.AppendScale(7.0, 4.0, -2.0); |
| 787 | 787 |
| 788 gfx::BoxF box(1.f, 2.f, 3.f, 4.f, 4.f, 4.f); | 788 gfx::BoxF box(1.f, 2.f, 3.f, 4.f, 4.f, 4.f); |
| 789 gfx::BoxF bounds; | 789 gfx::BoxF bounds; |
| 790 | 790 |
| 791 double min_progress = -0.5; | 791 SkMScalar min_progress = -0.5; |
| 792 double max_progress = 1.5; | 792 SkMScalar max_progress = 1.5; |
| 793 EXPECT_TRUE(operations_to.BlendedBoundsForBox( | 793 EXPECT_TRUE(operations_to.BlendedBoundsForBox( |
| 794 box, operations_from, min_progress, max_progress, &bounds)); | 794 box, operations_from, min_progress, max_progress, &bounds)); |
| 795 EXPECT_EQ(gfx::BoxF(1.f, -7.5f, -28.f, 44.f, 42.f, 56.f).ToString(), | 795 EXPECT_EQ(gfx::BoxF(1.f, -7.5f, -28.f, 44.f, 42.f, 56.f).ToString(), |
| 796 bounds.ToString()); | 796 bounds.ToString()); |
| 797 | 797 |
| 798 min_progress = 0.0; | 798 min_progress = 0.0; |
| 799 max_progress = 1.0; | 799 max_progress = 1.0; |
| 800 EXPECT_TRUE(operations_to.BlendedBoundsForBox( | 800 EXPECT_TRUE(operations_to.BlendedBoundsForBox( |
| 801 box, operations_from, min_progress, max_progress, &bounds)); | 801 box, operations_from, min_progress, max_progress, &bounds)); |
| 802 EXPECT_EQ(gfx::BoxF(3.f, 1.f, -14.f, 32.f, 23.f, 28.f).ToString(), | 802 EXPECT_EQ(gfx::BoxF(3.f, 1.f, -14.f, 32.f, 23.f, 28.f).ToString(), |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 816 | 816 |
| 817 TEST(TransformOperationTest, BlendedBoundsWithZeroScale) { | 817 TEST(TransformOperationTest, BlendedBoundsWithZeroScale) { |
| 818 TransformOperations zero_scale; | 818 TransformOperations zero_scale; |
| 819 zero_scale.AppendScale(0.0, 0.0, 0.0); | 819 zero_scale.AppendScale(0.0, 0.0, 0.0); |
| 820 TransformOperations non_zero_scale; | 820 TransformOperations non_zero_scale; |
| 821 non_zero_scale.AppendScale(2.0, -4.0, 5.0); | 821 non_zero_scale.AppendScale(2.0, -4.0, 5.0); |
| 822 | 822 |
| 823 gfx::BoxF box(1.f, 2.f, 3.f, 4.f, 4.f, 4.f); | 823 gfx::BoxF box(1.f, 2.f, 3.f, 4.f, 4.f, 4.f); |
| 824 gfx::BoxF bounds; | 824 gfx::BoxF bounds; |
| 825 | 825 |
| 826 double min_progress = 0.0; | 826 SkMScalar min_progress = 0.0; |
| 827 double max_progress = 1.0; | 827 SkMScalar max_progress = 1.0; |
| 828 EXPECT_TRUE(zero_scale.BlendedBoundsForBox( | 828 EXPECT_TRUE(zero_scale.BlendedBoundsForBox( |
| 829 box, non_zero_scale, min_progress, max_progress, &bounds)); | 829 box, non_zero_scale, min_progress, max_progress, &bounds)); |
| 830 EXPECT_EQ(gfx::BoxF(0.f, -24.f, 0.f, 10.f, 24.f, 35.f).ToString(), | 830 EXPECT_EQ(gfx::BoxF(0.f, -24.f, 0.f, 10.f, 24.f, 35.f).ToString(), |
| 831 bounds.ToString()); | 831 bounds.ToString()); |
| 832 | 832 |
| 833 EXPECT_TRUE(non_zero_scale.BlendedBoundsForBox( | 833 EXPECT_TRUE(non_zero_scale.BlendedBoundsForBox( |
| 834 box, zero_scale, min_progress, max_progress, &bounds)); | 834 box, zero_scale, min_progress, max_progress, &bounds)); |
| 835 EXPECT_EQ(gfx::BoxF(0.f, -24.f, 0.f, 10.f, 24.f, 35.f).ToString(), | 835 EXPECT_EQ(gfx::BoxF(0.f, -24.f, 0.f, 10.f, 24.f, 35.f).ToString(), |
| 836 bounds.ToString()); | 836 bounds.ToString()); |
| 837 | 837 |
| 838 EXPECT_TRUE(zero_scale.BlendedBoundsForBox( | 838 EXPECT_TRUE(zero_scale.BlendedBoundsForBox( |
| 839 box, zero_scale, min_progress, max_progress, &bounds)); | 839 box, zero_scale, min_progress, max_progress, &bounds)); |
| 840 EXPECT_EQ(gfx::BoxF().ToString(), bounds.ToString()); | 840 EXPECT_EQ(gfx::BoxF().ToString(), bounds.ToString()); |
| 841 } | 841 } |
| 842 | 842 |
| 843 TEST(TransformOperationTest, BlendedBoundsForSequence) { | 843 TEST(TransformOperationTest, BlendedBoundsForSequence) { |
| 844 TransformOperations operations_from; | 844 TransformOperations operations_from; |
| 845 operations_from.AppendTranslate(2.0, 4.0, -1.0); | 845 operations_from.AppendTranslate(2.0, 4.0, -1.0); |
| 846 operations_from.AppendScale(-1.0, 2.0, 3.0); | 846 operations_from.AppendScale(-1.0, 2.0, 3.0); |
| 847 operations_from.AppendTranslate(1.0, -5.0, 1.0); | 847 operations_from.AppendTranslate(1.0, -5.0, 1.0); |
| 848 TransformOperations operations_to; | 848 TransformOperations operations_to; |
| 849 operations_to.AppendTranslate(6.0, -2.0, 3.0); | 849 operations_to.AppendTranslate(6.0, -2.0, 3.0); |
| 850 operations_to.AppendScale(-3.0, -2.0, 5.0); | 850 operations_to.AppendScale(-3.0, -2.0, 5.0); |
| 851 operations_to.AppendTranslate(13.0, -1.0, 5.0); | 851 operations_to.AppendTranslate(13.0, -1.0, 5.0); |
| 852 | 852 |
| 853 gfx::BoxF box(1.f, 2.f, 3.f, 4.f, 4.f, 4.f); | 853 gfx::BoxF box(1.f, 2.f, 3.f, 4.f, 4.f, 4.f); |
| 854 gfx::BoxF bounds; | 854 gfx::BoxF bounds; |
| 855 | 855 |
| 856 double min_progress = -0.5; | 856 SkMScalar min_progress = -0.5; |
| 857 double max_progress = 1.5; | 857 SkMScalar max_progress = 1.5; |
| 858 EXPECT_TRUE(operations_to.BlendedBoundsForBox( | 858 EXPECT_TRUE(operations_to.BlendedBoundsForBox( |
| 859 box, operations_from, min_progress, max_progress, &bounds)); | 859 box, operations_from, min_progress, max_progress, &bounds)); |
| 860 EXPECT_EQ(gfx::BoxF(-57.f, -59.f, -1.f, 76.f, 112.f, 80.f).ToString(), | 860 EXPECT_EQ(gfx::BoxF(-57.f, -59.f, -1.f, 76.f, 112.f, 80.f).ToString(), |
| 861 bounds.ToString()); | 861 bounds.ToString()); |
| 862 | 862 |
| 863 min_progress = 0.0; | 863 min_progress = 0.0; |
| 864 max_progress = 1.0; | 864 max_progress = 1.0; |
| 865 EXPECT_TRUE(operations_to.BlendedBoundsForBox( | 865 EXPECT_TRUE(operations_to.BlendedBoundsForBox( |
| 866 box, operations_from, min_progress, max_progress, &bounds)); | 866 box, operations_from, min_progress, max_progress, &bounds)); |
| 867 EXPECT_EQ(gfx::BoxF(-32.f, -25.f, 7.f, 42.f, 44.f, 48.f).ToString(), | 867 EXPECT_EQ(gfx::BoxF(-32.f, -25.f, 7.f, 42.f, 44.f, 48.f).ToString(), |
| 868 bounds.ToString()); | 868 bounds.ToString()); |
| 869 | 869 |
| 870 TransformOperations identity; | 870 TransformOperations identity; |
| 871 EXPECT_TRUE(operations_to.BlendedBoundsForBox( | 871 EXPECT_TRUE(operations_to.BlendedBoundsForBox( |
| 872 box, identity, min_progress, max_progress, &bounds)); | 872 box, identity, min_progress, max_progress, &bounds)); |
| 873 EXPECT_EQ(gfx::BoxF(-33.f, -13.f, 3.f, 57.f, 19.f, 52.f).ToString(), | 873 EXPECT_EQ(gfx::BoxF(-33.f, -13.f, 3.f, 57.f, 19.f, 52.f).ToString(), |
| 874 bounds.ToString()); | 874 bounds.ToString()); |
| 875 | 875 |
| 876 EXPECT_TRUE(identity.BlendedBoundsForBox( | 876 EXPECT_TRUE(identity.BlendedBoundsForBox( |
| 877 box, operations_from, min_progress, max_progress, &bounds)); | 877 box, operations_from, min_progress, max_progress, &bounds)); |
| 878 EXPECT_EQ(gfx::BoxF(-7.f, -3.f, 2.f, 15.f, 23.f, 20.f).ToString(), | 878 EXPECT_EQ(gfx::BoxF(-7.f, -3.f, 2.f, 15.f, 23.f, 20.f).ToString(), |
| 879 bounds.ToString()); | 879 bounds.ToString()); |
| 880 } | 880 } |
| 881 | 881 |
| 882 } // namespace | 882 } // namespace |
| 883 } // namespace cc | 883 } // namespace cc |
| OLD | NEW |