diff options
-rw-r--r-- | src/core/SkImageInfoPriv.h | 6 | ||||
-rw-r--r-- | tests/ImageTest.cpp | 16 |
2 files changed, 5 insertions, 17 deletions
diff --git a/src/core/SkImageInfoPriv.h b/src/core/SkImageInfoPriv.h index 2b09a4ef76..72138aebe4 100644 --- a/src/core/SkImageInfoPriv.h +++ b/src/core/SkImageInfoPriv.h @@ -51,8 +51,6 @@ static inline bool SkImageInfoIsValid(const SkImageInfo& info) { * should we use kPremul or kUnpremul color values with the opaque alphas? Or should * we just use whatever the |src| alpha is? In the future, we could choose to clearly * define this, but currently no one is asking for this feature. - * We will not convert to a particular color space if |src| is nullptr. The color space - * conversion is not well-defined. */ static inline bool SkImageInfoValidConversion(const SkImageInfo& dst, const SkImageInfo& src) { if (!SkImageInfoIsValid(dst) || !SkImageInfoIsValid(src)) { @@ -75,9 +73,5 @@ static inline bool SkImageInfoValidConversion(const SkImageInfo& dst, const SkIm return false; } - if (dst.colorSpace() && !src.colorSpace()) { - return false; - } - return true; } diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp index 904ca206e4..4f9d944d25 100644 --- a/tests/ImageTest.cpp +++ b/tests/ImageTest.cpp @@ -34,14 +34,6 @@ using namespace sk_gpu_test; -SkImageInfo read_pixels_info(SkImage* image) { - if (as_IB(image)->onImageInfo().colorSpace()) { - return SkImageInfo::MakeS32(image->width(), image->height(), image->alphaType()); - } - - return SkImageInfo::MakeN32(image->width(), image->height(), image->alphaType()); -} - static void assert_equal(skiatest::Reporter* reporter, SkImage* a, const SkIRect* subsetA, SkImage* b) { const int widthA = subsetA ? subsetA->width() : a->width(); @@ -53,9 +45,11 @@ static void assert_equal(skiatest::Reporter* reporter, SkImage* a, const SkIRect // see https://bug.skia.org/3965 //REPORTER_ASSERT(reporter, a->isOpaque() == b->isOpaque()); + // The codecs may have given us back F16, we can't read from F16 raster to N32, only S32. + SkImageInfo info = SkImageInfo::MakeS32(widthA, heightA, a->alphaType()); SkAutoPixmapStorage pmapA, pmapB; - pmapA.alloc(read_pixels_info(a)); - pmapB.alloc(read_pixels_info(b)); + pmapA.alloc(info); + pmapB.alloc(info); const int srcX = subsetA ? subsetA->x() : 0; const int srcY = subsetA ? subsetA->y() : 0; @@ -63,7 +57,7 @@ static void assert_equal(skiatest::Reporter* reporter, SkImage* a, const SkIRect REPORTER_ASSERT(reporter, a->readPixels(pmapA, srcX, srcY)); REPORTER_ASSERT(reporter, b->readPixels(pmapB, 0, 0)); - const size_t widthBytes = widthA * 4; + const size_t widthBytes = widthA * info.bytesPerPixel(); for (int y = 0; y < heightA; ++y) { REPORTER_ASSERT(reporter, !memcmp(pmapA.addr32(0, y), pmapB.addr32(0, y), widthBytes)); } |