aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/codec/SkBmpStandardCodec.cpp
diff options
context:
space:
mode:
authorGravatar msarett <msarett@google.com>2016-02-12 13:07:15 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-02-12 13:07:15 -0800
commitc7578b6cdd03b61f076ffc7956efd952d6c301c0 (patch)
tree8a3618f653636727d677e2057d1c7d93567a27b7 /src/codec/SkBmpStandardCodec.cpp
parentdae774eff41b36ae6511450d458060dd3d031689 (diff)
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 Review URL: https://codereview.chromium.org/1695473002
Diffstat (limited to 'src/codec/SkBmpStandardCodec.cpp')
-rw-r--r--src/codec/SkBmpStandardCodec.cpp18
1 files changed, 5 insertions, 13 deletions
diff --git a/src/codec/SkBmpStandardCodec.cpp b/src/codec/SkBmpStandardCodec.cpp
index 47b10701d3..39d357be8b 100644
--- a/src/codec/SkBmpStandardCodec.cpp
+++ b/src/codec/SkBmpStandardCodec.cpp
@@ -152,9 +152,9 @@ SkCodec::Result SkBmpStandardCodec::onGetPixels(const SkImageInfo& dstInfo,
return true;
}
-bool SkBmpStandardCodec::initializeSwizzler(const SkImageInfo& dstInfo, const Options& opts) {
+void SkBmpStandardCodec::initializeSwizzler(const SkImageInfo& dstInfo, const Options& opts) {
// Get swizzler configuration
- SkSwizzler::SrcConfig config;
+ SkSwizzler::SrcConfig config = SkSwizzler::kUnknown;
switch (this->bitsPerPixel()) {
case 1:
config = SkSwizzler::kIndex1;
@@ -180,7 +180,6 @@ bool SkBmpStandardCodec::initializeSwizzler(const SkImageInfo& dstInfo, const Op
break;
default:
SkASSERT(false);
- return false;
}
// Get a pointer to the color table if it exists
@@ -188,11 +187,7 @@ bool SkBmpStandardCodec::initializeSwizzler(const SkImageInfo& dstInfo, const Op
// Create swizzler
fSwizzler.reset(SkSwizzler::CreateSwizzler(config, colorPtr, dstInfo, opts));
-
- if (nullptr == fSwizzler.get()) {
- return false;
- }
- return true;
+ SkASSERT(fSwizzler);
}
SkCodec::Result SkBmpStandardCodec::prepareToDecode(const SkImageInfo& dstInfo,
@@ -207,11 +202,8 @@ 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 if necessary
- if (!this->initializeSwizzler(dstInfo, options)) {
- SkCodecPrintf("Error: cannot initialize swizzler.\n");
- return SkCodec::kInvalidConversion;
- }
+ // Initialize a swizzler
+ this->initializeSwizzler(dstInfo, options);
return SkCodec::kSuccess;
}