Index: src/images/SkImageGenerator.cpp |
diff --git a/src/images/SkImageGenerator.cpp b/src/images/SkImageGenerator.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e80289f5caf390aa9a34f49a7ebefd651fbde626 |
--- /dev/null |
+++ b/src/images/SkImageGenerator.cpp |
@@ -0,0 +1,68 @@ |
+/* |
+ * Copyright 2014 Google Inc. |
+ * |
+ * Use of this source code is governed by a BSD-style license that can be |
+ * found in the LICENSE file. |
+ */ |
+ |
+#include "SkImageGenerator.h" |
+ |
+#ifndef SK_SUPPORT_LEGACY_IMAGEGENERATORAPI |
+bool SkImageGenerator::getInfo(SkImageInfo* info) { |
+ SkImageInfo dummy; |
+ if (NULL == info) { |
+ info = &dummy; |
+ } |
+ return this->onGetInfo(info); |
+} |
+ |
+bool SkImageGenerator::getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, |
+ SkPMColor ctable[], int* ctableCount) { |
+ if (kIndex_8_SkColorType == info.colorType()) { |
+ SkASSERT(ctable); |
+ SkASSERT(ctableCount); |
+ } else { |
+ SkASSERT(NULL == ctable); |
+ SkASSERT(NULL == ctableCount); |
+ } |
+ |
+ if (kUnknown_SkColorType == info.colorType()) { |
+ return false; |
+ } |
+ if (NULL == pixels) { |
+ return false; |
+ } |
+ if (rowBytes < info.minRowBytes()) { |
+ return false; |
+ } |
+ |
+ bool success = this->onGetPixels(info, pixels, rowBytes, ctable, ctableCount); |
+ |
+ if (success && (kIndex_8_SkColorType == info.colorType())) { |
+ SkASSERT(*ctableCount >= 0 && *ctableCount <= 256); |
+ } |
+ return success; |
+} |
+ |
+bool SkImageGenerator::getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes) { |
+ SkASSERT(kIndex_8_SkColorType != info.colorType()); |
+ if (kIndex_8_SkColorType == info.colorType()) { |
scroggo
2014/05/27 18:31:23
It seems like we typically do not recover after a
reed1
2014/05/27 18:47:34
I am of (at least) two minds here:
1. SkASSERT is
scroggo
2014/05/27 19:08:06
I think that's ok. If it ends up being a problem w
|
+ return false; |
+ } |
+ return this->getPixels(info, pixels, rowBytes, NULL, NULL); |
+} |
+#endif |
+ |
+///////////////////////////////////////////////////////////////////////////////////////////// |
+ |
+SkData* SkImageGenerator::onRefEncodedData() { |
+ return NULL; |
+} |
+ |
+bool SkImageGenerator::onGetInfo(SkImageInfo*) { |
+ return false; |
+} |
+ |
+bool SkImageGenerator::onGetPixels(const SkImageInfo&, void*, size_t, SkPMColor*, int*) { |
+ return false; |
+} |