OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "Test.h" | 8 #include "Test.h" |
9 #include "TestClassDef.h" | 9 #include "TestClassDef.h" |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 // Test copying to/from external buffer. | 336 // Test copying to/from external buffer. |
337 // Note: the tests below have hard-coded values --- | 337 // Note: the tests below have hard-coded values --- |
338 // Please take care if modifying. | 338 // Please take care if modifying. |
339 | 339 |
340 // Tests for getSafeSize64(). | 340 // Tests for getSafeSize64(). |
341 // Test with a very large configuration without pixel buffer | 341 // Test with a very large configuration without pixel buffer |
342 // attached. | 342 // attached. |
343 SkBitmap tstSafeSize; | 343 SkBitmap tstSafeSize; |
344 tstSafeSize.setConfig(gPairs[i].fConfig, 100000000U, | 344 tstSafeSize.setConfig(gPairs[i].fConfig, 100000000U, |
345 100000000U); | 345 100000000U); |
346 int64_t safeSize = tstSafeSize.computeSafeSize64(); | 346 Sk64 safeSize = tstSafeSize.getSafeSize64(); |
347 if (safeSize < 0) { | 347 if (safeSize.isNeg()) { |
348 SkString str; | 348 SkString str; |
349 str.printf("getSafeSize64() negative: %s", | 349 str.printf("getSafeSize64() negative: %s", |
350 getSkConfigName(tstSafeSize)); | 350 getSkConfigName(tstSafeSize)); |
351 reporter->reportFailed(str); | 351 reporter->reportFailed(str); |
352 } | 352 } |
353 bool sizeFail = false; | 353 bool sizeFail = false; |
354 // Compare against hand-computed values. | 354 // Compare against hand-computed values. |
355 switch (gPairs[i].fConfig) { | 355 switch (gPairs[i].fConfig) { |
356 case SkBitmap::kNo_Config: | 356 case SkBitmap::kNo_Config: |
357 break; | 357 break; |
358 | 358 |
359 case SkBitmap::kA8_Config: | 359 case SkBitmap::kA8_Config: |
360 case SkBitmap::kIndex8_Config: | 360 case SkBitmap::kIndex8_Config: |
361 if (safeSize != 0x2386F26FC10000LL) { | 361 if (safeSize.as64() != 0x2386F26FC10000LL) { |
362 sizeFail = true; | 362 sizeFail = true; |
363 } | 363 } |
364 break; | 364 break; |
365 | 365 |
366 case SkBitmap::kRGB_565_Config: | 366 case SkBitmap::kRGB_565_Config: |
367 case SkBitmap::kARGB_4444_Config: | 367 case SkBitmap::kARGB_4444_Config: |
368 if (safeSize != 0x470DE4DF820000LL) { | 368 if (safeSize.as64() != 0x470DE4DF820000LL) { |
369 sizeFail = true; | 369 sizeFail = true; |
370 } | 370 } |
371 break; | 371 break; |
372 | 372 |
373 case SkBitmap::kARGB_8888_Config: | 373 case SkBitmap::kARGB_8888_Config: |
374 if (safeSize != 0x8E1BC9BF040000LL) { | 374 if (safeSize.as64() != 0x8E1BC9BF040000LL) { |
375 sizeFail = true; | 375 sizeFail = true; |
376 } | 376 } |
377 break; | 377 break; |
378 | 378 |
379 default: | 379 default: |
380 break; | 380 break; |
381 } | 381 } |
382 if (sizeFail) { | 382 if (sizeFail) { |
383 SkString str; | 383 SkString str; |
384 str.printf("computeSafeSize64() wrong size: %s", | 384 str.printf("getSafeSize64() wrong size: %s", |
385 getSkConfigName(tstSafeSize)); | 385 getSkConfigName(tstSafeSize)); |
386 reporter->reportFailed(str); | 386 reporter->reportFailed(str); |
387 } | 387 } |
388 | 388 |
389 int subW = 2; | 389 int subW = 2; |
390 int subH = 2; | 390 int subH = 2; |
391 | 391 |
392 // Create bitmap to act as source for copies and subsets. | 392 // Create bitmap to act as source for copies and subsets. |
393 SkBitmap src, subset; | 393 SkBitmap src, subset; |
394 SkColorTable* ct = NULL; | 394 SkColorTable* ct = NULL; |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 // for the transfer. | 544 // for the transfer. |
545 REPORTER_ASSERT(reporter, | 545 REPORTER_ASSERT(reporter, |
546 subset.copyPixelsFrom(buf, 1, subset.rowBytes()) == | 546 subset.copyPixelsFrom(buf, 1, subset.rowBytes()) == |
547 false); | 547 false); |
548 | 548 |
549 #endif | 549 #endif |
550 } | 550 } |
551 } // for (size_t copyCase ... | 551 } // for (size_t copyCase ... |
552 } | 552 } |
553 } | 553 } |
OLD | NEW |