| Index: src/codec/SkPngCodec.cpp
|
| diff --git a/src/codec/SkPngCodec.cpp b/src/codec/SkPngCodec.cpp
|
| index 34e6f91131c3c696ed95d72ce292016e46c6e0ee..36ec21f0b8b2093f233134c5ad5f84bde3c221e1 100644
|
| --- a/src/codec/SkPngCodec.cpp
|
| +++ b/src/codec/SkPngCodec.cpp
|
| @@ -357,25 +357,6 @@ static int bytes_per_pixel(int bitsPerPixel) {
|
| return bitsPerPixel / 8;
|
| }
|
|
|
| -static bool png_conversion_possible(const SkImageInfo& dst, const SkImageInfo& src) {
|
| - // Ensure the alpha type is valid
|
| - if (!valid_alpha(dst.alphaType(), src.alphaType())) {
|
| - return false;
|
| - }
|
| -
|
| - // Check for supported color types
|
| - switch (dst.colorType()) {
|
| - case kRGBA_8888_SkColorType:
|
| - case kBGRA_8888_SkColorType:
|
| - case kRGBA_F16_SkColorType:
|
| - return true;
|
| - case kRGB_565_SkColorType:
|
| - return kOpaque_SkAlphaType == src.alphaType();
|
| - default:
|
| - return dst.colorType() == src.colorType();
|
| - }
|
| -}
|
| -
|
| void SkPngCodec::allocateStorage(const SkImageInfo& dstInfo) {
|
| switch (fXformMode) {
|
| case kSwizzleOnly_XformMode:
|
| @@ -422,7 +403,7 @@ public:
|
|
|
| Result onStartScanlineDecode(const SkImageInfo& dstInfo, const Options& options,
|
| SkPMColor ctable[], int* ctableCount) override {
|
| - if (!png_conversion_possible(dstInfo, this->getInfo()) ||
|
| + if (!conversion_possible(dstInfo, this->getInfo()) ||
|
| !this->initializeXforms(dstInfo, options, ctable, ctableCount))
|
| {
|
| return kInvalidConversion;
|
| @@ -489,7 +470,7 @@ public:
|
|
|
| Result onStartScanlineDecode(const SkImageInfo& dstInfo, const Options& options,
|
| SkPMColor ctable[], int* ctableCount) override {
|
| - if (!png_conversion_possible(dstInfo, this->getInfo()) ||
|
| + if (!conversion_possible(dstInfo, this->getInfo()) ||
|
| !this->initializeXforms(dstInfo, options, ctable, ctableCount))
|
| {
|
| return kInvalidConversion;
|
| @@ -807,20 +788,10 @@ bool SkPngCodec::initializeXforms(const SkImageInfo& dstInfo, const Options& opt
|
| fSwizzler.reset(nullptr);
|
| fColorXform = nullptr;
|
|
|
| - bool needsColorXform = needs_color_xform(dstInfo, this->getInfo());
|
| - if (needsColorXform) {
|
| - if (kGray_8_SkColorType == dstInfo.colorType() ||
|
| - kRGB_565_SkColorType == dstInfo.colorType())
|
| - {
|
| - return false;
|
| - }
|
| -
|
| + if (needs_color_xform(dstInfo, this->getInfo())) {
|
| fColorXform = SkColorSpaceXform::New(sk_ref_sp(this->getInfo().colorSpace()),
|
| sk_ref_sp(dstInfo.colorSpace()));
|
| -
|
| - if (!fColorXform && kRGBA_F16_SkColorType == dstInfo.colorType()) {
|
| - return false;
|
| - }
|
| + SkASSERT(fColorXform);
|
| }
|
|
|
| // If the image is RGBA and we have a color xform, we can skip the swizzler.
|
| @@ -907,7 +878,7 @@ SkCodec::Result SkPngCodec::onGetPixels(const SkImageInfo& dstInfo, void* dst,
|
| size_t rowBytes, const Options& options,
|
| SkPMColor ctable[], int* ctableCount,
|
| int* rowsDecoded) {
|
| - if (!png_conversion_possible(dstInfo, this->getInfo()) ||
|
| + if (!conversion_possible(dstInfo, this->getInfo()) ||
|
| !this->initializeXforms(dstInfo, options, ctable, ctableCount))
|
| {
|
| return kInvalidConversion;
|
|
|