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

Unified Diff: src/core/SkImageGenerator.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 | « include/core/SkImageGenerator.h ('k') | src/images/SkDecodingImageGenerator.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkImageGenerator.cpp
diff --git a/src/core/SkImageGenerator.cpp b/src/core/SkImageGenerator.cpp
index 0f63db50f637e82633caf9bd6f611979c941ffcb..c6167ff278ec318767c4551939da279e3700d6f5 100644
--- a/src/core/SkImageGenerator.cpp
+++ b/src/core/SkImageGenerator.cpp
@@ -15,21 +15,22 @@ bool SkImageGenerator::getInfo(SkImageInfo* info) {
return this->onGetInfo(info);
}
-bool SkImageGenerator::getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
- SkPMColor ctable[], int* ctableCount) {
+SkImageGenerator::Result SkImageGenerator::getPixels(const SkImageInfo& info, void* pixels,
+ size_t rowBytes, SkPMColor ctable[],
+ int* ctableCount) {
if (kUnknown_SkColorType == info.colorType()) {
- return false;
+ return kInvalidConversion;
}
if (NULL == pixels) {
- return false;
+ return kInvalidParameters;
}
if (rowBytes < info.minRowBytes()) {
- return false;
+ return kInvalidParameters;
}
if (kIndex_8_SkColorType == info.colorType()) {
if (NULL == ctable || NULL == ctableCount) {
- return false;
+ return kInvalidParameters;
}
} else {
if (ctableCount) {
@@ -39,18 +40,19 @@ bool SkImageGenerator::getPixels(const SkImageInfo& info, void* pixels, size_t r
ctable = NULL;
}
- bool success = this->onGetPixels(info, pixels, rowBytes, ctable, ctableCount);
+ const Result result = this->onGetPixelsEnum(info, pixels, rowBytes, ctable, ctableCount);
- if (success && ctableCount) {
+ if ((kIncompleteInput == result || kSuccess == result) && ctableCount) {
SkASSERT(*ctableCount >= 0 && *ctableCount <= 256);
}
- return success;
+ return result;
}
-bool SkImageGenerator::getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes) {
+SkImageGenerator::Result SkImageGenerator::getPixels(const SkImageInfo& info, void* pixels,
+ size_t rowBytes) {
SkASSERT(kIndex_8_SkColorType != info.colorType());
if (kIndex_8_SkColorType == info.colorType()) {
- return false;
+ return kInvalidConversion;
}
return this->getPixels(info, pixels, rowBytes, NULL, NULL);
}
@@ -117,6 +119,19 @@ bool SkImageGenerator::onGetInfo(SkImageInfo*) {
return false;
}
-bool SkImageGenerator::onGetPixels(const SkImageInfo&, void*, size_t, SkPMColor*, int*) {
- return false;
+#ifdef SK_SUPPORT_LEGACY_IMAGE_GENERATOR_RETURN
+bool SkImageGenerator::onGetPixels(const SkImageInfo&, void*, size_t,
+ SkPMColor*, int*) {
+ return kUnimplemented;
+}
+#endif
+SkImageGenerator::Result SkImageGenerator::onGetPixelsEnum(const SkImageInfo& info, void* pixels,
+ size_t rowBytes, SkPMColor* colors,
+ int* colorCount) {
+#ifdef SK_SUPPORT_LEGACY_IMAGE_GENERATOR_RETURN
+ if (this->onGetPixels(info, pixels, rowBytes, colors, colorCount)) {
+ return kSuccess;
+ }
+#endif
+ return kUnimplemented;
}
« no previous file with comments | « include/core/SkImageGenerator.h ('k') | src/images/SkDecodingImageGenerator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698