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

Unified Diff: src/codec/SkScanlineDecoder.cpp

Issue 1254483004: Scanline decoding for wbmp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: More minor fixes Created 5 years, 4 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
Index: src/codec/SkScanlineDecoder.cpp
diff --git a/src/codec/SkScanlineDecoder.cpp b/src/codec/SkScanlineDecoder.cpp
index 00c020c7c276c82e72808dd7b64e18dfc91417fc..851e7e71d09e312f6564bc3a7e5deaf001d78a69 100644
--- a/src/codec/SkScanlineDecoder.cpp
+++ b/src/codec/SkScanlineDecoder.cpp
@@ -7,6 +7,7 @@
#include "SkScanlineDecoder.h"
#include "SkCodec_libpng.h"
+#include "SkCodec_wbmp.h"
#include "SkCodecPriv.h"
#ifndef SK_BUILD_FOR_ANDROID_FRAMEWORK
#include "SkJpegCodec.h"
@@ -22,6 +23,7 @@ static const DecoderProc gDecoderProcs[] = {
#ifndef SK_BUILD_FOR_ANDROID_FRAMEWORK
{ SkJpegCodec::IsJpeg, SkJpegCodec::NewSDFromStream },
#endif
+ { SkWbmpCodec::IsWbmp, SkWbmpCodec::NewSDFromStream },
};
SkScanlineDecoder* SkScanlineDecoder::NewFromStream(SkStream* stream) {
@@ -66,6 +68,19 @@ SkScanlineDecoder* SkScanlineDecoder::NewFromData(SkData* data) {
SkCodec::Result SkScanlineDecoder::start(const SkImageInfo& dstInfo,
const SkCodec::Options* options, SkPMColor ctable[], int* ctableCount) {
+ // Ensure that valid color ptrs are passed in for kIndex8 color type
+ if (kIndex_8_SkColorType == dstInfo.colorType()) {
+ if (NULL == ctable || NULL == ctableCount) {
+ return SkCodec::kInvalidParameters;
+ }
+ } else {
+ if (ctableCount) {
+ *ctableCount = 0;
+ }
+ ctableCount = NULL;
+ ctable = NULL;
+ }
+
// Set options.
SkCodec::Options optsStorage;
if (NULL == options) {
@@ -83,10 +98,6 @@ SkCodec::Result SkScanlineDecoder::start(const SkImageInfo& dstInfo,
}
SkCodec::Result SkScanlineDecoder::start(const SkImageInfo& dstInfo) {
- SkASSERT(kIndex_8_SkColorType != dstInfo.colorType());
- if (kIndex_8_SkColorType == dstInfo.colorType()) {
- return SkCodec::kInvalidConversion;
- }
return this->start(dstInfo, NULL, NULL, NULL);
}

Powered by Google App Engine
This is Rietveld 408576698