diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/BitmapCopyTest.cpp | 4 | ||||
-rw-r--r-- | tests/BitmapTest.cpp | 6 | ||||
-rw-r--r-- | tests/BlitRowTest.cpp | 2 | ||||
-rw-r--r-- | tests/CachedDecodingPixelRefTest.cpp | 16 | ||||
-rw-r--r-- | tests/CanvasTest.cpp | 8 | ||||
-rw-r--r-- | tests/DrawBitmapRectTest.cpp | 5 | ||||
-rw-r--r-- | tests/PremulAlphaRoundTripTest.cpp | 5 | ||||
-rw-r--r-- | tests/RecordReplaceDrawTest.cpp | 2 | ||||
-rw-r--r-- | tests/SerializationTest.cpp | 3 | ||||
-rw-r--r-- | tests/SurfaceTest.cpp | 12 |
10 files changed, 26 insertions, 37 deletions
diff --git a/tests/BitmapCopyTest.cpp b/tests/BitmapCopyTest.cpp index 6a20668cf6..3923846226 100644 --- a/tests/BitmapCopyTest.cpp +++ b/tests/BitmapCopyTest.cpp @@ -609,8 +609,8 @@ DEF_TEST(BitmapReadPixels, reporter) { for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { clear_4x4_pixels(dstPixels); - dstInfo.fWidth = gRec[i].fRequestedDstSize.width(); - dstInfo.fHeight = gRec[i].fRequestedDstSize.height(); + dstInfo = dstInfo.makeWH(gRec[i].fRequestedDstSize.width(), + gRec[i].fRequestedDstSize.height()); bool success = srcBM.readPixels(dstInfo, dstPixels, rowBytes, gRec[i].fRequestedSrcLoc.x(), gRec[i].fRequestedSrcLoc.y()); diff --git a/tests/BitmapTest.cpp b/tests/BitmapTest.cpp index 4826b831fe..ef69531912 100644 --- a/tests/BitmapTest.cpp +++ b/tests/BitmapTest.cpp @@ -51,8 +51,7 @@ static void test_bigwidth(skiatest::Reporter* reporter) { SkImageInfo info = SkImageInfo::MakeA8(width, 1); REPORTER_ASSERT(reporter, bm.setInfo(info)); - info.fColorType = kRGB_565_SkColorType; - REPORTER_ASSERT(reporter, bm.setInfo(info)); + REPORTER_ASSERT(reporter, bm.setInfo(info.makeColorType(kRGB_565_SkColorType))); // for a 4-byte config, this width will compute a rowbytes of 0x80000000, // which does not fit in a int32_t. setConfig should detect this, and fail. @@ -60,8 +59,7 @@ static void test_bigwidth(skiatest::Reporter* reporter) { // TODO: perhaps skia can relax this, and only require that rowBytes fit // in a uint32_t (or larger), but for now this is the constraint. - info.fColorType = kN32_SkColorType; - REPORTER_ASSERT(reporter, !bm.setInfo(info)); + REPORTER_ASSERT(reporter, !bm.setInfo(info.makeColorType(kN32_SkColorType))); } /** diff --git a/tests/BlitRowTest.cpp b/tests/BlitRowTest.cpp index 911f2a0f40..4689a305ac 100644 --- a/tests/BlitRowTest.cpp +++ b/tests/BlitRowTest.cpp @@ -212,7 +212,7 @@ static void test_diagonal(skiatest::Reporter* reporter) { kPremul_SkAlphaType); for (size_t i = 0; i < SK_ARRAY_COUNT(gDstColorType); i++) { - info.fColorType = gDstColorType[i]; + info = info.makeColorType(gDstColorType[i]); SkBitmap dstBM0, dstBM1; dstBM0.allocPixels(info); diff --git a/tests/CachedDecodingPixelRefTest.cpp b/tests/CachedDecodingPixelRefTest.cpp index 7c63a0e925..82789a1bfb 100644 --- a/tests/CachedDecodingPixelRefTest.cpp +++ b/tests/CachedDecodingPixelRefTest.cpp @@ -188,28 +188,26 @@ protected: if ((NULL == info) || (kFailGetInfo_TestType == fType)) { return false; } - info->fWidth = TestImageGenerator::Width(); - info->fHeight = TestImageGenerator::Height(); - info->fColorType = kN32_SkColorType; - info->fAlphaType = kOpaque_SkAlphaType; + *info = SkImageInfo::MakeN32(TestImageGenerator::Width(), + TestImageGenerator::Height(), + kOpaque_SkAlphaType); return true; } virtual bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, SkPMColor ctable[], int* ctableCount) SK_OVERRIDE { REPORTER_ASSERT(fReporter, pixels != NULL); - size_t minRowBytes - = static_cast<size_t>(info.fWidth * info.bytesPerPixel()); + size_t minRowBytes = static_cast<size_t>(info.width() * info.bytesPerPixel()); REPORTER_ASSERT(fReporter, rowBytes >= minRowBytes); if ((NULL == pixels) || (fType != kSucceedGetPixels_TestType) - || (info.fColorType != kN32_SkColorType)) { + || (info.colorType() != kN32_SkColorType)) { return false; } char* bytePtr = static_cast<char*>(pixels); - for (int y = 0; y < info.fHeight; ++y) { + for (int y = 0; y < info.height(); ++y) { sk_memset32(reinterpret_cast<SkColor*>(bytePtr), - TestImageGenerator::Color(), info.fWidth); + TestImageGenerator::Color(), info.width()); bytePtr += rowBytes; } return true; diff --git a/tests/CanvasTest.cpp b/tests/CanvasTest.cpp index d4600514b7..216a408155 100644 --- a/tests/CanvasTest.cpp +++ b/tests/CanvasTest.cpp @@ -883,17 +883,15 @@ static void test_newraster(skiatest::Reporter* reporter) { SkDELETE(canvas); // now try a deliberately bad info - info.fWidth = -1; + info = info.makeWH(-1, info.height()); REPORTER_ASSERT(reporter, NULL == SkCanvas::NewRaster(info)); // too big - info.fWidth = 1 << 30; - info.fHeight = 1 << 30; + info = info.makeWH(1 << 30, 1 << 30); REPORTER_ASSERT(reporter, NULL == SkCanvas::NewRaster(info)); // not a valid pixel type - info.fWidth = info.fHeight = 10; - info.fColorType = kUnknown_SkColorType; + info = SkImageInfo::Make(10, 10, kUnknown_SkColorType, info.alphaType()); REPORTER_ASSERT(reporter, NULL == SkCanvas::NewRaster(info)); // We should succeed with a zero-sized valid info diff --git a/tests/DrawBitmapRectTest.cpp b/tests/DrawBitmapRectTest.cpp index 720155ca0c..71ad2cf733 100644 --- a/tests/DrawBitmapRectTest.cpp +++ b/tests/DrawBitmapRectTest.cpp @@ -25,10 +25,7 @@ public: protected: virtual bool onGetInfo(SkImageInfo* info) SK_OVERRIDE { - info->fWidth = 100; - info->fHeight = 100; - info->fColorType = kN32_SkColorType; - info->fAlphaType = kPremul_SkAlphaType; + *info = SkImageInfo::MakeN32Premul(100, 100); return true; } // default onGetPixels() returns false, which is what we want. diff --git a/tests/PremulAlphaRoundTripTest.cpp b/tests/PremulAlphaRoundTripTest.cpp index 1e655fb738..8bdb77012a 100644 --- a/tests/PremulAlphaRoundTripTest.cpp +++ b/tests/PremulAlphaRoundTripTest.cpp @@ -58,9 +58,8 @@ static void fillCanvas(SkCanvas* canvas, SkColorType colorType, PackUnpremulProc } } - SkImageInfo info = bmp.info(); - info.fColorType = colorType; - info.fAlphaType = kUnpremul_SkAlphaType; + const SkImageInfo info = SkImageInfo::Make(bmp.width(), bmp.height(), + colorType, kUnpremul_SkAlphaType); canvas->writePixels(info, bmp.getPixels(), bmp.rowBytes(), 0, 0); } diff --git a/tests/RecordReplaceDrawTest.cpp b/tests/RecordReplaceDrawTest.cpp index 6893876402..23bf9adb5a 100644 --- a/tests/RecordReplaceDrawTest.cpp +++ b/tests/RecordReplaceDrawTest.cpp @@ -72,7 +72,7 @@ static SkImage* make_image(SkColor color) { const SkPMColor pmcolor = SkPreMultiplyColor(color); const SkImageInfo info = SkImageInfo::MakeN32Premul(kWidth, kHeight); const size_t rowBytes = info.minRowBytes(); - const size_t size = rowBytes * info.fHeight; + const size_t size = rowBytes * info.height(); SkAutoMalloc addr(size); sk_memset32((SkPMColor*)addr.get(), pmcolor, SkToInt(size >> 2)); diff --git a/tests/SerializationTest.cpp b/tests/SerializationTest.cpp index 450f94f47e..ea03e875a2 100644 --- a/tests/SerializationTest.cpp +++ b/tests/SerializationTest.cpp @@ -463,9 +463,8 @@ DEF_TEST(Serialization, reporter) { validBitmap.setInfo(info); // Create a bitmap with a really large height - info.fHeight = 1000000000; SkBitmap invalidBitmap; - invalidBitmap.setInfo(info); + invalidBitmap.setInfo(info.makeWH(info.width(), 1000000000)); // The deserialization should succeed, and the rendering shouldn't crash, // even when the device fails to initialize, due to its size diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp index d317186947..eca929e0cc 100644 --- a/tests/SurfaceTest.cpp +++ b/tests/SurfaceTest.cpp @@ -90,7 +90,7 @@ static SkImage* createImage(ImageType imageType, GrContext* context, const SkPMColor pmcolor = SkPreMultiplyColor(color); const SkImageInfo info = SkImageInfo::MakeN32Premul(10, 10); const size_t rowBytes = info.minRowBytes(); - const size_t size = rowBytes * info.fHeight; + const size_t size = rowBytes * info.height(); void* addr = sk_malloc_throw(size); sk_memset32((SkPMColor*)addr, pmcolor, SkToInt(size >> 2)); @@ -142,11 +142,11 @@ static void test_imagepeek(skiatest::Reporter* reporter) { bool success = (NULL != addr); REPORTER_ASSERT(reporter, gRec[i].fPeekShouldSucceed == success); if (success) { - REPORTER_ASSERT(reporter, 10 == info.fWidth); - REPORTER_ASSERT(reporter, 10 == info.fHeight); - REPORTER_ASSERT(reporter, kN32_SkColorType == info.fColorType); - REPORTER_ASSERT(reporter, kPremul_SkAlphaType == info.fAlphaType || - kOpaque_SkAlphaType == info.fAlphaType); + REPORTER_ASSERT(reporter, 10 == info.width()); + REPORTER_ASSERT(reporter, 10 == info.height()); + REPORTER_ASSERT(reporter, kN32_SkColorType == info.colorType()); + REPORTER_ASSERT(reporter, kPremul_SkAlphaType == info.alphaType() || + kOpaque_SkAlphaType == info.alphaType()); REPORTER_ASSERT(reporter, info.minRowBytes() <= rowBytes); REPORTER_ASSERT(reporter, pmcolor == *(const SkPMColor*)addr); } |