aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar reed <reed@chromium.org>2015-06-08 19:58:07 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-06-08 19:58:07 -0700
commitb3f0ec9f9967da2f80f0d842cb7fd53617b48de3 (patch)
treef00f2095e30e48180a2a3a073be5bf1a1fe3f4c2 /tests
parent86ae0a9e465f157eaa263ef7515e10619946ff83 (diff)
Revert of change SkDraw and all Blitters to use pixmap instead of bitmap (patchset #6 id:100001 of https://codereview.chromium.org/1148793007/)
Reason for revert: speculative revert to try to unblock DEPS roll Original issue's description: > change SkDraw and all Blitters to use pixmap instead of bitmap > > BUG=skia: > > Committed: https://skia.googlesource.com/skia/+/c31af44336f5eb4a50e83e76e51962d46c3ed458 TBR=scroggo@google.com,jvanverth@google.com,reed@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review URL: https://codereview.chromium.org/1164373003
Diffstat (limited to 'tests')
-rw-r--r--tests/DeviceLooperTest.cpp23
-rw-r--r--tests/TextureCompressionTest.cpp69
2 files changed, 61 insertions, 31 deletions
diff --git a/tests/DeviceLooperTest.cpp b/tests/DeviceLooperTest.cpp
index 1a51b58980..5735043074 100644
--- a/tests/DeviceLooperTest.cpp
+++ b/tests/DeviceLooperTest.cpp
@@ -9,8 +9,9 @@
#include "SkRasterClip.h"
#include "Test.h"
-static void make_pm(SkAutoPixmapStorage* pixmap, int w, int h) {
- pixmap->alloc(SkImageInfo::Make(w, h, kAlpha_8_SkColorType, kPremul_SkAlphaType));
+static void make_bm(SkBitmap* bm, int w, int h) {
+ bm->allocPixels(SkImageInfo::Make(w, h, kAlpha_8_SkColorType,
+ kPremul_SkAlphaType));
}
static bool equal(const SkRasterClip& a, const SkRasterClip& b) {
@@ -39,19 +40,19 @@ static const struct {
static void test_simple(skiatest::Reporter* reporter) {
for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) {
- SkAutoPixmapStorage pmap;
- make_pm(&pmap, gRec[i].fDevSize.width(), gRec[i].fDevSize.height());
+ SkBitmap bitmap;
+ make_bm(&bitmap, gRec[i].fDevSize.width(), gRec[i].fDevSize.height());
SkRasterClip rc(gRec[i].fRCBounds);
for (int aa = 0; aa <= 1; ++aa) {
- SkDeviceLooper looper(pmap, rc, gRec[i].fRect, SkToBool(aa));
+ SkDeviceLooper looper(bitmap, rc, gRec[i].fRect, SkToBool(aa));
bool valid = looper.next();
REPORTER_ASSERT(reporter, valid);
if (valid) {
- REPORTER_ASSERT(reporter, looper.getPixmap().width() == pmap.width());
- REPORTER_ASSERT(reporter, looper.getPixmap().height() == pmap.height());
+ REPORTER_ASSERT(reporter, looper.getBitmap().width() == bitmap.width());
+ REPORTER_ASSERT(reporter, looper.getBitmap().height() == bitmap.height());
REPORTER_ASSERT(reporter, equal(looper.getRC(), rc));
REPORTER_ASSERT(reporter, !looper.next());
@@ -61,7 +62,7 @@ static void test_simple(skiatest::Reporter* reporter) {
{
SkIRect r = rc.getBounds();
r.offset(r.width(), 0);
- SkDeviceLooper looper(pmap, rc, r, false);
+ SkDeviceLooper looper(bitmap, rc, r, false);
REPORTER_ASSERT(reporter, !looper.next());
}
}
@@ -108,8 +109,8 @@ static void test_complex(skiatest::Reporter* reporter) {
const int w = gRec[i].fSize.width();
const int h = gRec[i].fSize.height();
- SkAutoPixmapStorage pmap;
- make_pm(&pmap, w, h);
+ SkBitmap bitmap;
+ make_bm(&bitmap, w, h);
const SkIRect rect = SkIRect::MakeWH(w, h);
@@ -124,7 +125,7 @@ static void test_complex(skiatest::Reporter* reporter) {
SkRasterClip rc;
rc.op(rgn, SkRegion::kReplace_Op);
- SkDeviceLooper looper(pmap, rc, rect, gRec[i].fAA);
+ SkDeviceLooper looper(bitmap, rc, rect, gRec[i].fAA);
while (looper.next()) {
REPORTER_ASSERT(reporter, !looper.getRC().isEmpty());
}
diff --git a/tests/TextureCompressionTest.cpp b/tests/TextureCompressionTest.cpp
index ca8da28858..568d4d14b6 100644
--- a/tests/TextureCompressionTest.cpp
+++ b/tests/TextureCompressionTest.cpp
@@ -42,8 +42,10 @@ static bool compresses_a8(SkTextureCompressor::Format fmt) {
* 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 @@ DEF_TEST(CompressAlphaFailDimensions, reporter) {
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 @@ DEF_TEST(CompressAlphaFailDimensions, reporter) {
* 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 @@ DEF_TEST(CompressAlphaFailColorType, reporter) {
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 @@ DEF_TEST(CompressAlphaFailColorType, reporter) {
* 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 @@ DEF_TEST(CompressCheckerboard, reporter) {
REPORTER_ASSERT(reporter, kWidth % 48 == 0);
REPORTER_ASSERT(reporter, kHeight % 48 == 0);
- SkAutoPixmapStorage pixmap;
- pixmap.alloc(SkImageInfo::MakeA8(kWidth, kHeight));
+ bool setInfoSuccess = bitmap.setInfo(info);
+ REPORTER_ASSERT(reporter, setInfoSuccess);
+
+ bitmap.allocPixels(info);
+ bitmap.unlockPixels();
- // Populate the pixels
+ // 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 @@ DEF_TEST(CompressCheckerboard, reporter) {
pixels[x] = 0;
}
}
- pixels += pixmap.rowBytes();
+ pixels += bitmap.rowBytes();
}
}
@@ -152,7 +167,7 @@ DEF_TEST(CompressCheckerboard, reporter) {
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 @@ DEF_TEST(CompressCheckerboard, reporter) {
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 @@ DEF_TEST(CompressCheckerboard, reporter) {
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 @@ DEF_TEST(CompressLATC, reporter) {
const SkTextureCompressor::Format kLATCFormat = SkTextureCompressor::kLATC_Format;
static const int kLATCEncodedBlockSize = 8;
+ SkBitmap bitmap;
static const int kWidth = 8;
static const int kHeight = 8;
+ SkImageInfo info = SkImageInfo::MakeA8(kWidth, kHeight);
+
+ bool setInfoSuccess = bitmap.setInfo(info);
+ REPORTER_ASSERT(reporter, setInfoSuccess);
- SkAutoPixmapStorage pixmap;
- pixmap.alloc(SkImageInfo::MakeA8(kWidth, kHeight));
+ bitmap.allocPixels(info);
+ bitmap.unlockPixels();
int latcDimX, latcDimY;
SkTextureCompressor::GetBlockDimensions(kLATCFormat, &latcDimX, &latcDimY);
@@ -205,13 +226,21 @@ DEF_TEST(CompressLATC, reporter) {
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;