| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkBitmap.h" | 8 #include "SkBitmap.h" |
| 9 #include "SkRect.h" | 9 #include "SkRect.h" |
| 10 #include "Test.h" | 10 #include "Test.h" |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 int subW = 2; | 380 int subW = 2; |
| 381 int subH = 2; | 381 int subH = 2; |
| 382 | 382 |
| 383 // Create bitmap to act as source for copies and subsets. | 383 // Create bitmap to act as source for copies and subsets. |
| 384 SkBitmap src, subset; | 384 SkBitmap src, subset; |
| 385 SkColorTable* ct = NULL; | 385 SkColorTable* ct = NULL; |
| 386 if (kIndex_8_SkColorType == src.colorType()) { | 386 if (kIndex_8_SkColorType == src.colorType()) { |
| 387 ct = init_ctable(kPremul_SkAlphaType); | 387 ct = init_ctable(kPremul_SkAlphaType); |
| 388 } | 388 } |
| 389 | 389 |
| 390 int localSubW; |
| 390 if (isExtracted[copyCase]) { // A larger image to extract from. | 391 if (isExtracted[copyCase]) { // A larger image to extract from. |
| 391 src.allocPixels(SkImageInfo::Make(2 * subW + 1, subH, | 392 localSubW = 2 * subW + 1; |
| 392 gPairs[i].fColorType, | |
| 393 kPremul_SkAlphaType)); | |
| 394 } else { // Tests expect a 2x2 bitmap, so make smaller. | 393 } else { // Tests expect a 2x2 bitmap, so make smaller. |
| 395 src.allocPixels(SkImageInfo::Make(subW, subH, | 394 localSubW = subW; |
| 396 gPairs[i].fColorType, | 395 } |
| 397 kPremul_SkAlphaType)); | 396 // could fail if we pass kIndex_8 for the colortype |
| 397 if (src.tryAllocPixels(SkImageInfo::Make(localSubW, subH, gPairs[i].
fColorType, |
| 398 kPremul_SkAlphaType))) { |
| 399 // failure is fine, as we will notice later on |
| 398 } | 400 } |
| 399 SkSafeUnref(ct); | 401 SkSafeUnref(ct); |
| 400 | 402 |
| 401 // Either copy src or extract into 'subset', which is used | 403 // Either copy src or extract into 'subset', which is used |
| 402 // for subsequent calls to copyPixelsTo/From. | 404 // for subsequent calls to copyPixelsTo/From. |
| 403 bool srcReady = false; | 405 bool srcReady = false; |
| 404 // Test relies on older behavior that extractSubset will fail on | 406 // Test relies on older behavior that extractSubset will fail on |
| 405 // kUnknown_SkColorType | 407 // kUnknown_SkColorType |
| 406 if (kUnknown_SkColorType != src.colorType() && | 408 if (kUnknown_SkColorType != src.colorType() && |
| 407 isExtracted[copyCase]) { | 409 isExtracted[copyCase]) { |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 REPORTER_ASSERT(reporter, check_4x4_pixel(dstC, sx, sy))
; | 630 REPORTER_ASSERT(reporter, check_4x4_pixel(dstC, sx, sy))
; |
| 629 } else { | 631 } else { |
| 630 REPORTER_ASSERT(reporter, 0 == dstC); | 632 REPORTER_ASSERT(reporter, 0 == dstC); |
| 631 } | 633 } |
| 632 } | 634 } |
| 633 } | 635 } |
| 634 } | 636 } |
| 635 } | 637 } |
| 636 } | 638 } |
| 637 | 639 |
| OLD | NEW |