diff options
author | msarett <msarett@google.com> | 2016-02-12 15:00:10 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-12 15:00:10 -0800 |
commit | deabdb5b9712de9e3c6bbb9aa68ec2f20df80a8e (patch) | |
tree | df8951bf09f0dc3b1926d082340f65c3e756100a /src/codec/SkBmpStandardCodec.cpp | |
parent | 3478f753ffc28a6f0f0877cc06be7373f960c527 (diff) |
Revert of Fix colorType/alphaType checks in SkCodec (patchset #5 id:80001 of https://codereview.chromium.org/1695473002/ )
Reason for revert:
Really bad images in Gold.
Original issue's description:
> Fix colorType/alphaType checks in SkCodec
>
> Make getPixels() and startScanlineDecode() behave
> consistently.
>
> Require that kGray8 decodes are opaque.
>
> Assert that creating the swizzler succeeds.
>
> BUG=skia:4203
> GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1695473002
>
> Committed: https://skia.googlesource.com/skia/+/c7578b6cdd03b61f076ffc7956efd952d6c301c0
TBR=scroggo@google.com
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:4203
Review URL: https://codereview.chromium.org/1694023002
Diffstat (limited to 'src/codec/SkBmpStandardCodec.cpp')
-rw-r--r-- | src/codec/SkBmpStandardCodec.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/codec/SkBmpStandardCodec.cpp b/src/codec/SkBmpStandardCodec.cpp index 39d357be8b..47b10701d3 100644 --- a/src/codec/SkBmpStandardCodec.cpp +++ b/src/codec/SkBmpStandardCodec.cpp @@ -152,9 +152,9 @@ SkCodec::Result SkBmpStandardCodec::onGetPixels(const SkImageInfo& dstInfo, return true; } -void SkBmpStandardCodec::initializeSwizzler(const SkImageInfo& dstInfo, const Options& opts) { +bool SkBmpStandardCodec::initializeSwizzler(const SkImageInfo& dstInfo, const Options& opts) { // Get swizzler configuration - SkSwizzler::SrcConfig config = SkSwizzler::kUnknown; + SkSwizzler::SrcConfig config; switch (this->bitsPerPixel()) { case 1: config = SkSwizzler::kIndex1; @@ -180,6 +180,7 @@ void SkBmpStandardCodec::initializeSwizzler(const SkImageInfo& dstInfo, const Op break; default: SkASSERT(false); + return false; } // Get a pointer to the color table if it exists @@ -187,7 +188,11 @@ void SkBmpStandardCodec::initializeSwizzler(const SkImageInfo& dstInfo, const Op // Create swizzler fSwizzler.reset(SkSwizzler::CreateSwizzler(config, colorPtr, dstInfo, opts)); - SkASSERT(fSwizzler); + + if (nullptr == fSwizzler.get()) { + return false; + } + return true; } SkCodec::Result SkBmpStandardCodec::prepareToDecode(const SkImageInfo& dstInfo, @@ -202,8 +207,11 @@ SkCodec::Result SkBmpStandardCodec::prepareToDecode(const SkImageInfo& dstInfo, // Copy the color table to the client if necessary copy_color_table(dstInfo, this->fColorTable, inputColorPtr, inputColorCount); - // Initialize a swizzler - this->initializeSwizzler(dstInfo, options); + // Initialize a swizzler if necessary + if (!this->initializeSwizzler(dstInfo, options)) { + SkCodecPrintf("Error: cannot initialize swizzler.\n"); + return SkCodec::kInvalidConversion; + } return SkCodec::kSuccess; } |