Index: tests/TextureCompressionTest.cpp |
diff --git a/tests/TextureCompressionTest.cpp b/tests/TextureCompressionTest.cpp |
index ca8da28858531c3ced26a41aa9c03ec517e8b7e8..568d4d14b6b71ca57091abc954f2f4896265ada3 100644 |
--- a/tests/TextureCompressionTest.cpp |
+++ b/tests/TextureCompressionTest.cpp |
@@ -42,8 +42,10 @@ |
* Make sure that we properly fail when we don't have multiple of four image dimensions. |
*/ |
DEF_TEST(CompressAlphaFailDimensions, reporter) { |
+ SkBitmap bitmap; |
static const int kWidth = 17; |
static const int kHeight = 17; |
+ SkImageInfo info = SkImageInfo::MakeA8(kWidth, kHeight); |
// R11_EAC and LATC are both dimensions of 4, so we need to make sure that we |
// are violating those assumptions. And if we are, then we're also violating the |
@@ -53,16 +55,18 @@ |
REPORTER_ASSERT(reporter, kWidth % 4 != 0); |
REPORTER_ASSERT(reporter, kHeight % 4 != 0); |
- SkAutoPixmapStorage pixmap; |
- pixmap.alloc(SkImageInfo::MakeA8(kWidth, kHeight)); |
- // leaving the pixels uninitialized, as they don't affect the test... |
+ bool setInfoSuccess = bitmap.setInfo(info); |
+ REPORTER_ASSERT(reporter, setInfoSuccess); |
+ |
+ bitmap.allocPixels(info); |
+ bitmap.unlockPixels(); |
for (int i = 0; i < SkTextureCompressor::kFormatCnt; ++i) { |
const SkTextureCompressor::Format fmt = static_cast<SkTextureCompressor::Format>(i); |
if (!compresses_a8(fmt)) { |
continue; |
} |
- SkAutoDataUnref data(SkTextureCompressor::CompressBitmapToFormat(pixmap, fmt)); |
+ SkAutoDataUnref data(SkTextureCompressor::CompressBitmapToFormat(bitmap, fmt)); |
REPORTER_ASSERT(reporter, NULL == data); |
} |
} |
@@ -72,8 +76,10 @@ |
* compressed textures can (currently) only be created from A8 bitmaps. |
*/ |
DEF_TEST(CompressAlphaFailColorType, reporter) { |
+ SkBitmap bitmap; |
static const int kWidth = 12; |
static const int kHeight = 12; |
+ SkImageInfo info = SkImageInfo::MakeN32Premul(kWidth, kHeight); |
// ASTC is at most 12x12, and any dimension divisible by 12 is also divisible |
// by 4, which is the dimensions of R11_EAC and LATC. In the future, we might |
@@ -82,16 +88,18 @@ |
REPORTER_ASSERT(reporter, kWidth % 12 == 0); |
REPORTER_ASSERT(reporter, kHeight % 12 == 0); |
- SkAutoPixmapStorage pixmap; |
- pixmap.alloc(SkImageInfo::MakeN32Premul(kWidth, kHeight)); |
- // leaving the pixels uninitialized, as they don't affect the test... |
+ bool setInfoSuccess = bitmap.setInfo(info); |
+ REPORTER_ASSERT(reporter, setInfoSuccess); |
+ |
+ bitmap.allocPixels(info); |
+ bitmap.unlockPixels(); |
for (int i = 0; i < SkTextureCompressor::kFormatCnt; ++i) { |
const SkTextureCompressor::Format fmt = static_cast<SkTextureCompressor::Format>(i); |
if (!compresses_a8(fmt)) { |
continue; |
} |
- SkAutoDataUnref data(SkTextureCompressor::CompressBitmapToFormat(pixmap, fmt)); |
+ SkAutoDataUnref data(SkTextureCompressor::CompressBitmapToFormat(bitmap, fmt)); |
REPORTER_ASSERT(reporter, NULL == data); |
} |
} |
@@ -101,8 +109,10 @@ |
* then decompress it, you get what you started with. |
*/ |
DEF_TEST(CompressCheckerboard, reporter) { |
+ SkBitmap bitmap; |
static const int kWidth = 48; // We need the number to be divisible by both |
static const int kHeight = 48; // 12 (ASTC) and 16 (ARM NEON R11 EAC). |
+ SkImageInfo info = SkImageInfo::MakeA8(kWidth, kHeight); |
// ASTC is at most 12x12, and any dimension divisible by 12 is also divisible |
// by 4, which is the dimensions of R11_EAC and LATC. In the future, we might |
@@ -113,12 +123,17 @@ |
REPORTER_ASSERT(reporter, kWidth % 48 == 0); |
REPORTER_ASSERT(reporter, kHeight % 48 == 0); |
- SkAutoPixmapStorage pixmap; |
- pixmap.alloc(SkImageInfo::MakeA8(kWidth, kHeight)); |
- |
- // Populate the pixels |
+ bool setInfoSuccess = bitmap.setInfo(info); |
+ REPORTER_ASSERT(reporter, setInfoSuccess); |
+ |
+ bitmap.allocPixels(info); |
+ bitmap.unlockPixels(); |
+ |
+ // Populate bitmap |
{ |
- uint8_t* pixels = reinterpret_cast<uint8_t*>(pixmap.writable_addr()); |
+ SkAutoLockPixels alp(bitmap); |
+ |
+ uint8_t* pixels = reinterpret_cast<uint8_t*>(bitmap.getPixels()); |
REPORTER_ASSERT(reporter, pixels); |
if (NULL == pixels) { |
return; |
@@ -132,7 +147,7 @@ |
pixels[x] = 0; |
} |
} |
- pixels += pixmap.rowBytes(); |
+ pixels += bitmap.rowBytes(); |
} |
} |
@@ -152,7 +167,7 @@ |
continue; |
} |
- SkAutoDataUnref data(SkTextureCompressor::CompressBitmapToFormat(pixmap, fmt)); |
+ SkAutoDataUnref data(SkTextureCompressor::CompressBitmapToFormat(bitmap, fmt)); |
REPORTER_ASSERT(reporter, data); |
if (NULL == data) { |
continue; |
@@ -165,7 +180,8 @@ |
kWidth, kHeight, fmt); |
REPORTER_ASSERT(reporter, decompResult); |
- const uint8_t* pixels = reinterpret_cast<const uint8_t*>(pixmap.addr()); |
+ SkAutoLockPixels alp(bitmap); |
+ uint8_t* pixels = reinterpret_cast<uint8_t*>(bitmap.getPixels()); |
REPORTER_ASSERT(reporter, pixels); |
if (NULL == pixels) { |
continue; |
@@ -173,7 +189,7 @@ |
for (int y = 0; y < kHeight; ++y) { |
for (int x = 0; x < kWidth; ++x) { |
- bool ok = pixels[y*pixmap.rowBytes() + x] == decompBuffer[y*kWidth + x]; |
+ bool ok = pixels[y*bitmap.rowBytes() + x] == decompBuffer[y*kWidth + x]; |
REPORTER_ASSERT(reporter, ok); |
} |
} |
@@ -188,11 +204,16 @@ |
const SkTextureCompressor::Format kLATCFormat = SkTextureCompressor::kLATC_Format; |
static const int kLATCEncodedBlockSize = 8; |
+ SkBitmap bitmap; |
static const int kWidth = 8; |
static const int kHeight = 8; |
- |
- SkAutoPixmapStorage pixmap; |
- pixmap.alloc(SkImageInfo::MakeA8(kWidth, kHeight)); |
+ SkImageInfo info = SkImageInfo::MakeA8(kWidth, kHeight); |
+ |
+ bool setInfoSuccess = bitmap.setInfo(info); |
+ REPORTER_ASSERT(reporter, setInfoSuccess); |
+ |
+ bitmap.allocPixels(info); |
+ bitmap.unlockPixels(); |
int latcDimX, latcDimY; |
SkTextureCompressor::GetBlockDimensions(kLATCFormat, &latcDimX, &latcDimY); |
@@ -205,13 +226,21 @@ |
REPORTER_ASSERT(reporter, (kSizeToBe % kLATCEncodedBlockSize) == 0); |
for (int lum = 0; lum < 256; ++lum) { |
- uint8_t* pixels = reinterpret_cast<uint8_t*>(pixmap.writable_addr()); |
+ bitmap.lockPixels(); |
+ uint8_t* pixels = reinterpret_cast<uint8_t*>(bitmap.getPixels()); |
+ REPORTER_ASSERT(reporter, pixels); |
+ if (NULL == pixels) { |
+ bitmap.unlockPixels(); |
+ continue; |
+ } |
+ |
for (int i = 0; i < kWidth*kHeight; ++i) { |
pixels[i] = lum; |
} |
+ bitmap.unlockPixels(); |
SkAutoDataUnref latcData( |
- SkTextureCompressor::CompressBitmapToFormat(pixmap, kLATCFormat)); |
+ SkTextureCompressor::CompressBitmapToFormat(bitmap, kLATCFormat)); |
REPORTER_ASSERT(reporter, latcData); |
if (NULL == latcData) { |
continue; |