зеркало из https://github.com/mozilla/moz-skia.git
remove deprecated use of bitmap config from tests
BUG=skia: R=halcanary@google.com, reed@google.com Author: reed@chromium.org Review URL: https://codereview.chromium.org/184233003 git-svn-id: http://skia.googlecode.com/svn/trunk@13666 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
Родитель
f1f66c0c86
Коммит
8ef51b975c
|
@ -4,6 +4,7 @@
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "SkBitmap.h"
|
#include "SkBitmap.h"
|
||||||
#include "SkRect.h"
|
#include "SkRect.h"
|
||||||
#include "Test.h"
|
#include "Test.h"
|
||||||
|
@ -12,7 +13,7 @@ static const char* boolStr(bool value) {
|
||||||
return value ? "true" : "false";
|
return value ? "true" : "false";
|
||||||
}
|
}
|
||||||
|
|
||||||
// these are in the same order as the SkBitmap::Config enum
|
// these are in the same order as the SkColorType enum
|
||||||
static const char* gColorTypeName[] = {
|
static const char* gColorTypeName[] = {
|
||||||
"None", "A8", "565", "4444", "RGBA", "BGRA", "Index8"
|
"None", "A8", "565", "4444", "RGBA", "BGRA", "Index8"
|
||||||
};
|
};
|
||||||
|
@ -89,17 +90,15 @@ static uint32_t getPixel(int x, int y, const SkBitmap& bm) {
|
||||||
SkAutoLockPixels lock(bm);
|
SkAutoLockPixels lock(bm);
|
||||||
const void* rawAddr = bm.getAddr(x,y);
|
const void* rawAddr = bm.getAddr(x,y);
|
||||||
|
|
||||||
switch (bm.config()) {
|
switch (bm.bytesPerPixel()) {
|
||||||
case SkBitmap::kARGB_8888_Config:
|
case 4:
|
||||||
memcpy(&val, rawAddr, sizeof(uint32_t));
|
memcpy(&val, rawAddr, sizeof(uint32_t));
|
||||||
break;
|
break;
|
||||||
case SkBitmap::kARGB_4444_Config:
|
case 2:
|
||||||
case SkBitmap::kRGB_565_Config:
|
|
||||||
memcpy(&val16, rawAddr, sizeof(uint16_t));
|
memcpy(&val16, rawAddr, sizeof(uint16_t));
|
||||||
val = val16;
|
val = val16;
|
||||||
break;
|
break;
|
||||||
case SkBitmap::kA8_Config:
|
case 1:
|
||||||
case SkBitmap::kIndex8_Config:
|
|
||||||
memcpy(&val8, rawAddr, sizeof(uint8_t));
|
memcpy(&val8, rawAddr, sizeof(uint8_t));
|
||||||
val = val8;
|
val = val8;
|
||||||
break;
|
break;
|
||||||
|
@ -118,17 +117,15 @@ static void setPixel(int x, int y, uint32_t val, SkBitmap& bm) {
|
||||||
SkAutoLockPixels lock(bm);
|
SkAutoLockPixels lock(bm);
|
||||||
void* rawAddr = bm.getAddr(x,y);
|
void* rawAddr = bm.getAddr(x,y);
|
||||||
|
|
||||||
switch (bm.config()) {
|
switch (bm.bytesPerPixel()) {
|
||||||
case SkBitmap::kARGB_8888_Config:
|
case 4:
|
||||||
memcpy(rawAddr, &val, sizeof(uint32_t));
|
memcpy(rawAddr, &val, sizeof(uint32_t));
|
||||||
break;
|
break;
|
||||||
case SkBitmap::kARGB_4444_Config:
|
case 2:
|
||||||
case SkBitmap::kRGB_565_Config:
|
|
||||||
val16 = val & 0xFFFF;
|
val16 = val & 0xFFFF;
|
||||||
memcpy(rawAddr, &val16, sizeof(uint16_t));
|
memcpy(rawAddr, &val16, sizeof(uint16_t));
|
||||||
break;
|
break;
|
||||||
case SkBitmap::kA8_Config:
|
case 1:
|
||||||
case SkBitmap::kIndex8_Config:
|
|
||||||
val8 = val & 0xFF;
|
val8 = val & 0xFF;
|
||||||
memcpy(rawAddr, &val8, sizeof(uint8_t));
|
memcpy(rawAddr, &val8, sizeof(uint8_t));
|
||||||
break;
|
break;
|
||||||
|
@ -138,20 +135,6 @@ static void setPixel(int x, int y, uint32_t val, SkBitmap& bm) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Utility to return string containing name of each format, to
|
|
||||||
// simplify diagnostic output.
|
|
||||||
static const char* getSkConfigName(const SkBitmap& bm) {
|
|
||||||
switch (bm.config()) {
|
|
||||||
case SkBitmap::kNo_Config: return "SkBitmap::kNo_Config";
|
|
||||||
case SkBitmap::kA8_Config: return "SkBitmap::kA8_Config";
|
|
||||||
case SkBitmap::kIndex8_Config: return "SkBitmap::kIndex8_Config";
|
|
||||||
case SkBitmap::kRGB_565_Config: return "SkBitmap::kRGB_565_Config";
|
|
||||||
case SkBitmap::kARGB_4444_Config: return "SkBitmap::kARGB_4444_Config";
|
|
||||||
case SkBitmap::kARGB_8888_Config: return "SkBitmap::kARGB_8888_Config";
|
|
||||||
default: return "Unknown SkBitmap configuration.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Helper struct to contain pixel locations, while avoiding need for STL.
|
// Helper struct to contain pixel locations, while avoiding need for STL.
|
||||||
struct Coordinates {
|
struct Coordinates {
|
||||||
|
|
||||||
|
@ -188,7 +171,8 @@ static void reportCopyVerification(const SkBitmap& bm1, const SkBitmap& bm2,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!success) {
|
if (!success) {
|
||||||
ERRORF(reporter, "%s [config = %s]", msg, getSkConfigName(bm1));
|
ERRORF(reporter, "%s [colortype = %s]", msg,
|
||||||
|
gColorTypeName[bm1.colorType()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,7 +301,7 @@ DEF_TEST(BitmapCopy, reporter) {
|
||||||
REPORTER_ASSERT(reporter, srcPremul.height() == dst.height());
|
REPORTER_ASSERT(reporter, srcPremul.height() == dst.height());
|
||||||
REPORTER_ASSERT(reporter, dst.colorType() == gPairs[j].fColorType);
|
REPORTER_ASSERT(reporter, dst.colorType() == gPairs[j].fColorType);
|
||||||
test_isOpaque(reporter, srcOpaque, srcPremul, dst.colorType());
|
test_isOpaque(reporter, srcOpaque, srcPremul, dst.colorType());
|
||||||
if (srcPremul.config() == dst.config()) {
|
if (srcPremul.colorType() == dst.colorType()) {
|
||||||
SkAutoLockPixels srcLock(srcPremul);
|
SkAutoLockPixels srcLock(srcPremul);
|
||||||
SkAutoLockPixels dstLock(dst);
|
SkAutoLockPixels dstLock(dst);
|
||||||
REPORTER_ASSERT(reporter, srcPremul.readyToDraw());
|
REPORTER_ASSERT(reporter, srcPremul.readyToDraw());
|
||||||
|
@ -333,7 +317,7 @@ DEF_TEST(BitmapCopy, reporter) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// dst should be unchanged from its initial state
|
// dst should be unchanged from its initial state
|
||||||
REPORTER_ASSERT(reporter, dst.config() == SkBitmap::kNo_Config);
|
REPORTER_ASSERT(reporter, dst.colorType() == kUnknown_SkColorType);
|
||||||
REPORTER_ASSERT(reporter, dst.width() == 0);
|
REPORTER_ASSERT(reporter, dst.width() == 0);
|
||||||
REPORTER_ASSERT(reporter, dst.height() == 0);
|
REPORTER_ASSERT(reporter, dst.height() == 0);
|
||||||
}
|
}
|
||||||
|
@ -358,7 +342,7 @@ DEF_TEST(BitmapCopy, reporter) {
|
||||||
int64_t safeSize = tstSafeSize.computeSafeSize64();
|
int64_t safeSize = tstSafeSize.computeSafeSize64();
|
||||||
if (safeSize < 0) {
|
if (safeSize < 0) {
|
||||||
ERRORF(reporter, "getSafeSize64() negative: %s",
|
ERRORF(reporter, "getSafeSize64() negative: %s",
|
||||||
getSkConfigName(tstSafeSize));
|
gColorTypeName[tstSafeSize.colorType()]);
|
||||||
}
|
}
|
||||||
bool sizeFail = false;
|
bool sizeFail = false;
|
||||||
// Compare against hand-computed values.
|
// Compare against hand-computed values.
|
||||||
|
@ -391,7 +375,7 @@ DEF_TEST(BitmapCopy, reporter) {
|
||||||
}
|
}
|
||||||
if (sizeFail) {
|
if (sizeFail) {
|
||||||
ERRORF(reporter, "computeSafeSize64() wrong size: %s",
|
ERRORF(reporter, "computeSafeSize64() wrong size: %s",
|
||||||
getSkConfigName(tstSafeSize));
|
gColorTypeName[tstSafeSize.colorType()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
int subW = 2;
|
int subW = 2;
|
||||||
|
@ -400,7 +384,7 @@ DEF_TEST(BitmapCopy, reporter) {
|
||||||
// Create bitmap to act as source for copies and subsets.
|
// Create bitmap to act as source for copies and subsets.
|
||||||
SkBitmap src, subset;
|
SkBitmap src, subset;
|
||||||
SkColorTable* ct = NULL;
|
SkColorTable* ct = NULL;
|
||||||
if (SkBitmap::kIndex8_Config == src.config()) {
|
if (kIndex_8_SkColorType == src.colorType()) {
|
||||||
ct = init_ctable(kPremul_SkAlphaType);
|
ct = init_ctable(kPremul_SkAlphaType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -419,7 +403,7 @@ DEF_TEST(BitmapCopy, reporter) {
|
||||||
// for subsequent calls to copyPixelsTo/From.
|
// for subsequent calls to copyPixelsTo/From.
|
||||||
bool srcReady = false;
|
bool srcReady = false;
|
||||||
// Test relies on older behavior that extractSubset will fail on
|
// Test relies on older behavior that extractSubset will fail on
|
||||||
// no_config
|
// kUnknown_SkColorType
|
||||||
if (kUnknown_SkColorType != src.colorType() &&
|
if (kUnknown_SkColorType != src.colorType() &&
|
||||||
isExtracted[copyCase]) {
|
isExtracted[copyCase]) {
|
||||||
// The extractedSubset() test case allows us to test copy-
|
// The extractedSubset() test case allows us to test copy-
|
||||||
|
@ -440,7 +424,7 @@ DEF_TEST(BitmapCopy, reporter) {
|
||||||
// buf to a SkBitmap, but copies are done using the
|
// buf to a SkBitmap, but copies are done using the
|
||||||
// raw buffer pointer.
|
// raw buffer pointer.
|
||||||
const size_t bufSize = subH *
|
const size_t bufSize = subH *
|
||||||
SkBitmap::ComputeRowBytes(src.config(), subW) * 2;
|
SkColorTypeMinRowBytes(src.colorType(), subW) * 2;
|
||||||
SkAutoMalloc autoBuf (bufSize);
|
SkAutoMalloc autoBuf (bufSize);
|
||||||
uint8_t* buf = static_cast<uint8_t*>(autoBuf.get());
|
uint8_t* buf = static_cast<uint8_t*>(autoBuf.get());
|
||||||
|
|
||||||
|
|
|
@ -12,19 +12,19 @@
|
||||||
|
|
||||||
DEF_TEST(GetColor, reporter) {
|
DEF_TEST(GetColor, reporter) {
|
||||||
static const struct Rec {
|
static const struct Rec {
|
||||||
SkBitmap::Config fConfig;
|
SkColorType fColorType;
|
||||||
SkColor fInColor;
|
SkColor fInColor;
|
||||||
SkColor fOutColor;
|
SkColor fOutColor;
|
||||||
} gRec[] = {
|
} gRec[] = {
|
||||||
// todo: add some tests that involve alpha, so we exercise the
|
// todo: add some tests that involve alpha, so we exercise the
|
||||||
// unpremultiply aspect of getColor()
|
// unpremultiply aspect of getColor()
|
||||||
{ SkBitmap::kA8_Config, 0xFF000000, 0xFF000000 },
|
{ kAlpha_8_SkColorType, 0xFF000000, 0xFF000000 },
|
||||||
{ SkBitmap::kA8_Config, 0, 0 },
|
{ kAlpha_8_SkColorType, 0, 0 },
|
||||||
{ SkBitmap::kRGB_565_Config, 0xFF00FF00, 0xFF00FF00 },
|
{ kRGB_565_SkColorType, 0xFF00FF00, 0xFF00FF00 },
|
||||||
{ SkBitmap::kRGB_565_Config, 0xFFFF00FF, 0xFFFF00FF },
|
{ kRGB_565_SkColorType, 0xFFFF00FF, 0xFFFF00FF },
|
||||||
{ SkBitmap::kARGB_8888_Config, 0xFFFFFFFF, 0xFFFFFFFF },
|
{ kPMColor_SkColorType, 0xFFFFFFFF, 0xFFFFFFFF },
|
||||||
{ SkBitmap::kARGB_8888_Config, 0, 0 },
|
{ kPMColor_SkColorType, 0, 0 },
|
||||||
{ SkBitmap::kARGB_8888_Config, 0xFF224466, 0xFF224466 },
|
{ kPMColor_SkColorType, 0xFF224466, 0xFF224466 },
|
||||||
};
|
};
|
||||||
|
|
||||||
// specify an area that doesn't touch (0,0) and may extend beyond the
|
// specify an area that doesn't touch (0,0) and may extend beyond the
|
||||||
|
@ -33,10 +33,11 @@ DEF_TEST(GetColor, reporter) {
|
||||||
const SkIRect area = { 1, 1, 3, 3 };
|
const SkIRect area = { 1, 1, 3, 3 };
|
||||||
|
|
||||||
for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); i++) {
|
for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); i++) {
|
||||||
|
SkImageInfo info = SkImageInfo::Make(2, 2, gRec[i].fColorType,
|
||||||
|
kPremul_SkAlphaType);
|
||||||
SkBitmap bm;
|
SkBitmap bm;
|
||||||
uint32_t storage[4];
|
uint32_t storage[4];
|
||||||
bm.setConfig(gRec[i].fConfig, 2, 2);
|
bm.installPixels(info, storage, info.minRowBytes(), NULL, NULL);
|
||||||
bm.setPixels(storage);
|
|
||||||
|
|
||||||
bm.eraseColor(initColor);
|
bm.eraseColor(initColor);
|
||||||
bm.eraseArea(area, gRec[i].fInColor);
|
bm.eraseArea(area, gRec[i].fInColor);
|
||||||
|
|
|
@ -15,12 +15,11 @@
|
||||||
typedef uint64_t checksum_result;
|
typedef uint64_t checksum_result;
|
||||||
|
|
||||||
// Fill in bitmap with test data.
|
// Fill in bitmap with test data.
|
||||||
static void CreateTestBitmap(SkBitmap &bitmap, SkBitmap::Config config, int width, int height,
|
static void CreateTestBitmap(SkBitmap* bitmap, int width, int height,
|
||||||
SkColor color, skiatest::Reporter* reporter) {
|
SkColor color, skiatest::Reporter* reporter) {
|
||||||
bitmap.setConfig(config, width, height);
|
SkImageInfo info = SkImageInfo::MakeN32(width, height, kOpaque_SkAlphaType);
|
||||||
REPORTER_ASSERT(reporter, bitmap.allocPixels());
|
REPORTER_ASSERT(reporter, bitmap->allocPixels(info));
|
||||||
bitmap.setAlphaType(kOpaque_SkAlphaType);
|
bitmap->eraseColor(color);
|
||||||
bitmap.eraseColor(color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DEF_TEST(BitmapHasher, reporter) {
|
DEF_TEST(BitmapHasher, reporter) {
|
||||||
|
@ -28,15 +27,15 @@ DEF_TEST(BitmapHasher, reporter) {
|
||||||
SkBitmap bitmap;
|
SkBitmap bitmap;
|
||||||
uint64_t digest;
|
uint64_t digest;
|
||||||
// initial test case
|
// initial test case
|
||||||
CreateTestBitmap(bitmap, SkBitmap::kARGB_8888_Config, 333, 555, SK_ColorBLUE, reporter);
|
CreateTestBitmap(&bitmap, 333, 555, SK_ColorBLUE, reporter);
|
||||||
REPORTER_ASSERT(reporter, SkBitmapHasher::ComputeDigest(bitmap, &digest));
|
REPORTER_ASSERT(reporter, SkBitmapHasher::ComputeDigest(bitmap, &digest));
|
||||||
REPORTER_ASSERT(reporter, digest == 0xfb2903562766ef87ULL);
|
REPORTER_ASSERT(reporter, digest == 0xfb2903562766ef87ULL);
|
||||||
// same pixel data but different dimensions should yield a different checksum
|
// same pixel data but different dimensions should yield a different checksum
|
||||||
CreateTestBitmap(bitmap, SkBitmap::kARGB_8888_Config, 555, 333, SK_ColorBLUE, reporter);
|
CreateTestBitmap(&bitmap, 555, 333, SK_ColorBLUE, reporter);
|
||||||
REPORTER_ASSERT(reporter, SkBitmapHasher::ComputeDigest(bitmap, &digest));
|
REPORTER_ASSERT(reporter, SkBitmapHasher::ComputeDigest(bitmap, &digest));
|
||||||
REPORTER_ASSERT(reporter, digest == 0xfe04023fb97d0f61ULL);
|
REPORTER_ASSERT(reporter, digest == 0xfe04023fb97d0f61ULL);
|
||||||
// same dimensions but different color should yield a different checksum
|
// same dimensions but different color should yield a different checksum
|
||||||
CreateTestBitmap(bitmap, SkBitmap::kARGB_8888_Config, 555, 333, SK_ColorGREEN, reporter);
|
CreateTestBitmap(&bitmap, 555, 333, SK_ColorGREEN, reporter);
|
||||||
REPORTER_ASSERT(reporter, SkBitmapHasher::ComputeDigest(bitmap, &digest));
|
REPORTER_ASSERT(reporter, SkBitmapHasher::ComputeDigest(bitmap, &digest));
|
||||||
REPORTER_ASSERT(reporter, digest == 0x2423c51cad6d1edcULL);
|
REPORTER_ASSERT(reporter, digest == 0x2423c51cad6d1edcULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
#include "Test.h"
|
#include "Test.h"
|
||||||
|
|
||||||
// these are in the same order as the SkColorType enum
|
// these are in the same order as the SkColorType enum
|
||||||
static const char* gConfigName[] = {
|
static const char* gColorTypeName[] = {
|
||||||
"Unknown", "Alpha8", "565", "4444", "RGBA", "BGRA", "Index8"
|
"None", "A8", "565", "4444", "RGBA", "BGRA", "Index8"
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Returns -1 on success, else the x coord of the first bad pixel, return its
|
/** Returns -1 on success, else the x coord of the first bad pixel, return its
|
||||||
|
@ -62,15 +62,15 @@ static int proc_bad(const void*, int, uint32_t, uint32_t* bad) {
|
||||||
|
|
||||||
static Proc find_proc(const SkBitmap& bm, SkPMColor expect32, uint16_t expect16,
|
static Proc find_proc(const SkBitmap& bm, SkPMColor expect32, uint16_t expect16,
|
||||||
uint8_t expect8, uint32_t* expect) {
|
uint8_t expect8, uint32_t* expect) {
|
||||||
switch (bm.config()) {
|
switch (bm.colorType()) {
|
||||||
case SkBitmap::kARGB_8888_Config:
|
case kPMColor_SkColorType:
|
||||||
*expect = expect32;
|
*expect = expect32;
|
||||||
return proc_32;
|
return proc_32;
|
||||||
case SkBitmap::kARGB_4444_Config:
|
case kARGB_4444_SkColorType:
|
||||||
case SkBitmap::kRGB_565_Config:
|
case kRGB_565_SkColorType:
|
||||||
*expect = expect16;
|
*expect = expect16;
|
||||||
return proc_16;
|
return proc_16;
|
||||||
case SkBitmap::kA8_Config:
|
case kAlpha_8_SkColorType:
|
||||||
*expect = expect8;
|
*expect = expect8;
|
||||||
return proc_8;
|
return proc_8;
|
||||||
default:
|
default:
|
||||||
|
@ -88,8 +88,8 @@ static bool check_color(const SkBitmap& bm, SkPMColor expect32,
|
||||||
uint32_t bad;
|
uint32_t bad;
|
||||||
int x = proc(bm.getAddr(0, y), bm.width(), expect, &bad);
|
int x = proc(bm.getAddr(0, y), bm.width(), expect, &bad);
|
||||||
if (x >= 0) {
|
if (x >= 0) {
|
||||||
ERRORF(reporter, "BlitRow config=%s [%d %d] expected %x got %x",
|
ERRORF(reporter, "BlitRow colortype=%s [%d %d] expected %x got %x",
|
||||||
gConfigName[bm.config()], x, y, expect, bad);
|
gColorTypeName[bm.colorType()], x, y, expect, bad);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -249,7 +249,7 @@ static void test_diagonal(skiatest::Reporter* reporter) {
|
||||||
if (memcmp(dstBM0.getPixels(), dstBM1.getPixels(), dstBM0.getSize())) {
|
if (memcmp(dstBM0.getPixels(), dstBM1.getPixels(), dstBM0.getSize())) {
|
||||||
ERRORF(reporter, "Diagonal colortype=%s bg=0x%x dither=%d"
|
ERRORF(reporter, "Diagonal colortype=%s bg=0x%x dither=%d"
|
||||||
" alpha=0x%x src=0x%x",
|
" alpha=0x%x src=0x%x",
|
||||||
gConfigName[gDstColorType[i]], bgColor, dither,
|
gColorTypeName[gDstColorType[i]], bgColor, dither,
|
||||||
alpha, c);
|
alpha, c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,9 +16,8 @@
|
||||||
|
|
||||||
static const SkColor bgColor = SK_ColorWHITE;
|
static const SkColor bgColor = SK_ColorWHITE;
|
||||||
|
|
||||||
static void create(SkBitmap* bm, SkIRect bound, SkBitmap::Config config) {
|
static void create(SkBitmap* bm, SkIRect bound) {
|
||||||
bm->setConfig(config, bound.width(), bound.height());
|
bm->allocN32Pixels(bound.width(), bound.height());
|
||||||
bm->allocPixels();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void drawBG(SkCanvas* canvas) {
|
static void drawBG(SkCanvas* canvas) {
|
||||||
|
@ -67,12 +66,12 @@ DEF_TEST(DrawText, reporter) {
|
||||||
|
|
||||||
SkIRect drawTextRect = SkIRect::MakeWH(64, 64);
|
SkIRect drawTextRect = SkIRect::MakeWH(64, 64);
|
||||||
SkBitmap drawTextBitmap;
|
SkBitmap drawTextBitmap;
|
||||||
create(&drawTextBitmap, drawTextRect, SkBitmap::kARGB_8888_Config);
|
create(&drawTextBitmap, drawTextRect);
|
||||||
SkCanvas drawTextCanvas(drawTextBitmap);
|
SkCanvas drawTextCanvas(drawTextBitmap);
|
||||||
|
|
||||||
SkIRect drawPosTextRect = SkIRect::MakeWH(64, 64);
|
SkIRect drawPosTextRect = SkIRect::MakeWH(64, 64);
|
||||||
SkBitmap drawPosTextBitmap;
|
SkBitmap drawPosTextBitmap;
|
||||||
create(&drawPosTextBitmap, drawPosTextRect, SkBitmap::kARGB_8888_Config);
|
create(&drawPosTextBitmap, drawPosTextRect);
|
||||||
SkCanvas drawPosTextCanvas(drawPosTextBitmap);
|
SkCanvas drawPosTextCanvas(drawPosTextBitmap);
|
||||||
|
|
||||||
for (float offsetY = 0.0f; offsetY < 1.0f; offsetY += (1.0f / 16.0f)) {
|
for (float offsetY = 0.0f; offsetY < 1.0f; offsetY += (1.0f / 16.0f)) {
|
||||||
|
|
|
@ -20,9 +20,8 @@
|
||||||
|
|
||||||
static const SkColor bgColor = SK_ColorWHITE;
|
static const SkColor bgColor = SK_ColorWHITE;
|
||||||
|
|
||||||
static void create(SkBitmap* bm, SkIRect bound, SkBitmap::Config config) {
|
static void create(SkBitmap* bm, SkIRect bound) {
|
||||||
bm->setConfig(config, bound.width(), bound.height());
|
bm->allocN32Pixels(bound.width(), bound.height());
|
||||||
bm->allocPixels();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void drawBG(SkCanvas* canvas) {
|
static void drawBG(SkCanvas* canvas) {
|
||||||
|
@ -76,12 +75,12 @@ DEF_TEST(FontHostStream, reporter) {
|
||||||
|
|
||||||
SkIRect origRect = SkIRect::MakeWH(64, 64);
|
SkIRect origRect = SkIRect::MakeWH(64, 64);
|
||||||
SkBitmap origBitmap;
|
SkBitmap origBitmap;
|
||||||
create(&origBitmap, origRect, SkBitmap::kARGB_8888_Config);
|
create(&origBitmap, origRect);
|
||||||
SkCanvas origCanvas(origBitmap);
|
SkCanvas origCanvas(origBitmap);
|
||||||
|
|
||||||
SkIRect streamRect = SkIRect::MakeWH(64, 64);
|
SkIRect streamRect = SkIRect::MakeWH(64, 64);
|
||||||
SkBitmap streamBitmap;
|
SkBitmap streamBitmap;
|
||||||
create(&streamBitmap, streamRect, SkBitmap::kARGB_8888_Config);
|
create(&streamBitmap, streamRect);
|
||||||
SkCanvas streamCanvas(streamBitmap);
|
SkCanvas streamCanvas(streamBitmap);
|
||||||
|
|
||||||
SkPoint point = SkPoint::Make(24, 32);
|
SkPoint point = SkPoint::Make(24, 32);
|
||||||
|
|
|
@ -3,40 +3,6 @@
|
||||||
#include "SkMallocPixelRef.h"
|
#include "SkMallocPixelRef.h"
|
||||||
#include "SkPixelRef.h"
|
#include "SkPixelRef.h"
|
||||||
|
|
||||||
static void test_info(skiatest::Reporter* reporter) {
|
|
||||||
static const struct {
|
|
||||||
SkBitmap::Config fConfig;
|
|
||||||
SkAlphaType fAlphaType;
|
|
||||||
SkColorType fExpectedColorType;
|
|
||||||
bool fExpectedSuccess;
|
|
||||||
} gRec[] = {
|
|
||||||
{ SkBitmap::kNo_Config, kPremul_SkAlphaType, kPMColor_SkColorType, false },
|
|
||||||
{ SkBitmap::kARGB_8888_Config, kPremul_SkAlphaType, kPMColor_SkColorType, true },
|
|
||||||
{ SkBitmap::kARGB_8888_Config, kOpaque_SkAlphaType, kPMColor_SkColorType, true },
|
|
||||||
{ SkBitmap::kRGB_565_Config, kOpaque_SkAlphaType, kRGB_565_SkColorType, true },
|
|
||||||
{ SkBitmap::kARGB_4444_Config, kPremul_SkAlphaType, kARGB_4444_SkColorType, true },
|
|
||||||
{ SkBitmap::kARGB_4444_Config, kOpaque_SkAlphaType, kARGB_4444_SkColorType, true },
|
|
||||||
{ SkBitmap::kA8_Config, kPremul_SkAlphaType, kAlpha_8_SkColorType, true },
|
|
||||||
{ SkBitmap::kA8_Config, kOpaque_SkAlphaType, kAlpha_8_SkColorType, true },
|
|
||||||
{ SkBitmap::kIndex8_Config, kPremul_SkAlphaType, kIndex_8_SkColorType, true },
|
|
||||||
{ SkBitmap::kIndex8_Config, kOpaque_SkAlphaType, kIndex_8_SkColorType, true },
|
|
||||||
};
|
|
||||||
|
|
||||||
SkBitmap bitmap;
|
|
||||||
SkImageInfo info;
|
|
||||||
|
|
||||||
for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) {
|
|
||||||
bool success = bitmap.setConfig(gRec[i].fConfig, 10, 10, 0, gRec[i].fAlphaType);
|
|
||||||
REPORTER_ASSERT(reporter, success);
|
|
||||||
success = bitmap.asImageInfo(&info);
|
|
||||||
REPORTER_ASSERT(reporter, success == gRec[i].fExpectedSuccess);
|
|
||||||
if (success && gRec[i].fExpectedSuccess) {
|
|
||||||
REPORTER_ASSERT(reporter, info.fAlphaType == gRec[i].fAlphaType);
|
|
||||||
REPORTER_ASSERT(reporter, info.fColorType == gRec[i].fExpectedColorType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class TestListener : public SkPixelRef::GenIDChangeListener {
|
class TestListener : public SkPixelRef::GenIDChangeListener {
|
||||||
public:
|
public:
|
||||||
explicit TestListener(int* ptr) : fPtr(ptr) {}
|
explicit TestListener(int* ptr) : fPtr(ptr) {}
|
||||||
|
@ -77,6 +43,4 @@ DEF_TEST(PixelRef_GenIDChange, r) {
|
||||||
REPORTER_ASSERT(r, 0 != pixelRef->getGenerationID());
|
REPORTER_ASSERT(r, 0 != pixelRef->getGenerationID());
|
||||||
pixelRef->addGenIDChangeListener(NULL);
|
pixelRef->addGenIDChangeListener(NULL);
|
||||||
pixelRef->notifyPixelsChanged();
|
pixelRef->notifyPixelsChanged();
|
||||||
|
|
||||||
test_info(r);
|
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче