Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(780)

Unified Diff: src/codec/SkBmpStandardCodec.cpp

Issue 1694023002: Revert of Fix colorType/alphaType checks in SkCodec (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/codec/SkBmpStandardCodec.h ('k') | src/codec/SkCodec.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/codec/SkBmpStandardCodec.cpp
diff --git a/src/codec/SkBmpStandardCodec.cpp b/src/codec/SkBmpStandardCodec.cpp
index 07596e167720112e08ad78001cb95cd58554f2be..203e7da654568c0de1e8e33e427e96a41fd64ca4 100644
--- a/src/codec/SkBmpStandardCodec.cpp
+++ b/src/codec/SkBmpStandardCodec.cpp
@@ -152,9 +152,9 @@
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 @@
break;
default:
SkASSERT(false);
+ return false;
}
// Get a pointer to the color table if it exists
@@ -187,7 +188,11 @@
// 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 @@
// 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;
}
« no previous file with comments | « src/codec/SkBmpStandardCodec.h ('k') | src/codec/SkCodec.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698