aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ports/SkImageGenerator_skia.cpp
diff options
context:
space:
mode:
authorGravatar scroggo <scroggo@google.com>2015-02-13 11:13:34 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-02-13 11:13:34 -0800
commit0864908ca50049d3d907fc5c3749bc8a436b4738 (patch)
treea04d0629768ac04cbb13ba235e970fe46e8460c5 /src/ports/SkImageGenerator_skia.cpp
parent9bafc30c7900375d316d47e24412ddfd8bd0b1f2 (diff)
Make SkImageGenerator::getPixels() return an enum.
The new enum describes the nature of the failure. This is in preparation for writing a replacement for SkImageDecoder, which will use this interface. Update the comments for getPixels() to specify what it means to pass an SkImageInfo with a different size. Make SkImageGenerator Noncopyable. Leave onGetYUV8Planes alone, since we have separate discussions regarding modifying that API. Make callers of SkImageDecoder consistently handle kPartialSuccess. Previously, some callers considered it a failure, and others considered it a success. BUG=skia:3257 Review URL: https://codereview.chromium.org/919693002
Diffstat (limited to 'src/ports/SkImageGenerator_skia.cpp')
-rw-r--r--src/ports/SkImageGenerator_skia.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/ports/SkImageGenerator_skia.cpp b/src/ports/SkImageGenerator_skia.cpp
index 878a44de9c..079da56155 100644
--- a/src/ports/SkImageGenerator_skia.cpp
+++ b/src/ports/SkImageGenerator_skia.cpp
@@ -52,8 +52,8 @@ protected:
return true;
}
- virtual bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
- SkPMColor ctableEntries[], int* ctableCount) SK_OVERRIDE {
+ virtual Result onGetPixelsEnum(const SkImageInfo& info, void* pixels, size_t rowBytes,
+ SkPMColor ctableEntries[], int* ctableCount) SK_OVERRIDE {
SkMemoryStream stream(fData->data(), fData->size(), false);
SkAutoTUnref<BareMemoryAllocator> allocator(SkNEW_ARGS(BareMemoryAllocator,
(info, pixels, rowBytes)));
@@ -61,13 +61,10 @@ protected:
fDecoder->setRequireUnpremultipliedColors(kUnpremul_SkAlphaType == info.alphaType());
SkBitmap bm;
- SkImageDecoder::Result result = fDecoder->decode(&stream, &bm, info.colorType(),
- SkImageDecoder::kDecodePixels_Mode);
- switch (result) {
- case SkImageDecoder::kSuccess:
- break;
- default:
- return false;
+ const SkImageDecoder::Result result = fDecoder->decode(&stream, &bm, info.colorType(),
+ SkImageDecoder::kDecodePixels_Mode);
+ if (SkImageDecoder::kFailure == result) {
+ return kInvalidInput;
}
SkASSERT(info.colorType() == bm.info().colorType());
@@ -77,13 +74,16 @@ protected:
SkColorTable* ctable = bm.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 == result) {
+ return kIncompleteInput;
+ }
+ return kSuccess;
}
bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3],