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

Unified Diff: src/images/SkDecodingImageGenerator.cpp

Issue 919693002: Make SkImageGenerator::getPixels() return an enum. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Stage the change for chromium Created 5 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/core/SkImageGenerator.cpp ('k') | src/lazy/SkCachingPixelRef.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/images/SkDecodingImageGenerator.cpp
diff --git a/src/images/SkDecodingImageGenerator.cpp b/src/images/SkDecodingImageGenerator.cpp
index e7a775e264b8e9181f5ddaad6e4f57299f10afbe..cce01d2832c611d5160b65061c9ab08b25f8cea3 100644
--- a/src/images/SkDecodingImageGenerator.cpp
+++ b/src/images/SkDecodingImageGenerator.cpp
@@ -42,9 +42,9 @@ protected:
*info = fInfo;
return true;
}
- virtual bool onGetPixels(const SkImageInfo& info,
- void* pixels, size_t rowBytes,
- SkPMColor ctable[], int* ctableCount) SK_OVERRIDE;
+ virtual Result onGetPixelsEnum(const SkImageInfo& info,
+ void* pixels, size_t rowBytes,
+ SkPMColor ctable[], int* ctableCount) SK_OVERRIDE;
virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3],
SkYUVColorSpace* colorSpace) SK_OVERRIDE;
@@ -147,20 +147,22 @@ SkData* DecodingImageGenerator::onRefEncodedData() {
return SkSafeRef(fData);
}
-bool DecodingImageGenerator::onGetPixels(const SkImageInfo& info,
- void* pixels, size_t rowBytes,
- SkPMColor ctableEntries[], int* ctableCount) {
+SkImageGenerator::Result DecodingImageGenerator::onGetPixelsEnum(const SkImageInfo& info,
+ void* pixels, size_t rowBytes, SkPMColor ctableEntries[], int* ctableCount) {
if (fInfo != info) {
// The caller has specified a different info. This is an
// error for this kind of SkImageGenerator. Use the Options
// to change the settings.
- return false;
+ if (info.dimensions() != fInfo.dimensions()) {
+ return kInvalidScale;
+ }
+ return kInvalidConversion;
}
SkAssertResult(fStream->rewind());
SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(fStream));
if (NULL == decoder.get()) {
- return false;
+ return kInvalidInput;
}
decoder->setDitherImage(fDitherImage);
decoder->setSampleSize(fSampleSize);
@@ -169,11 +171,11 @@ bool DecodingImageGenerator::onGetPixels(const SkImageInfo& info,
SkBitmap bitmap;
TargetAllocator allocator(fInfo, pixels, rowBytes);
decoder->setAllocator(&allocator);
- bool success = decoder->decode(fStream, &bitmap, info.colorType(),
- SkImageDecoder::kDecodePixels_Mode) != SkImageDecoder::kFailure;
+ const SkImageDecoder::Result decodeResult = decoder->decode(fStream, &bitmap, info.colorType(),
+ SkImageDecoder::kDecodePixels_Mode);
decoder->setAllocator(NULL);
- if (!success) {
- return false;
+ if (SkImageDecoder::kFailure == decodeResult) {
+ return kInvalidInput;
}
if (allocator.isReady()) { // Did not use pixels!
SkBitmap bm;
@@ -182,7 +184,7 @@ bool DecodingImageGenerator::onGetPixels(const SkImageInfo& info,
if (!copySuccess || allocator.isReady()) {
SkDEBUGFAIL("bitmap.copyTo(requestedConfig) failed.");
// Earlier we checked canCopyto(); we expect consistency.
- return false;
+ return kInvalidConversion;
}
SkASSERT(check_alpha(info.alphaType(), bm.alphaType()));
} else {
@@ -191,17 +193,21 @@ bool DecodingImageGenerator::onGetPixels(const SkImageInfo& info,
if (kIndex_8_SkColorType == info.colorType()) {
if (kIndex_8_SkColorType != bitmap.colorType()) {
- return false; // they asked for Index8, but we didn't receive that from decoder
+ // they asked for Index8, but we didn't receive that from decoder
+ return kInvalidConversion;
}
SkColorTable* ctable = bitmap.getColorTable();
if (NULL == ctable) {
- return false;
+ return kInvalidConversion;
}
const int count = ctable->count();
memcpy(ctableEntries, ctable->readColors(), count * sizeof(SkPMColor));
*ctableCount = count;
}
- return true;
+ if (SkImageDecoder::kPartialSuccess == decodeResult) {
+ return kIncompleteInput;
+ }
+ return kSuccess;
}
bool DecodingImageGenerator::onGetYUV8Planes(SkISize sizes[3], void* planes[3],
« no previous file with comments | « src/core/SkImageGenerator.cpp ('k') | src/lazy/SkCachingPixelRef.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698