Index: src/codec/SkCodecImageGenerator.cpp |
diff --git a/src/codec/SkCodecImageGenerator.cpp b/src/codec/SkCodecImageGenerator.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..2fef381ec1ffa332f5d62c8eb30d6b7eebcbe909 |
--- /dev/null |
+++ b/src/codec/SkCodecImageGenerator.cpp |
@@ -0,0 +1,46 @@ |
+/* |
+ * Copyright 2015 Google Inc. |
+ * |
+ * Use of this source code is governed by a BSD-style license that can be |
+ * found in the LICENSE file. |
+ */ |
+ |
+#include "SkCodecImageGenerator.h" |
+ |
+SkImageGenerator* SkCodecImageGenerator::NewFromEncodedCodec(SkData* data) { |
+ SkCodec* codec = SkCodec::NewFromData(data); |
+ if (nullptr == codec) { |
+ return nullptr; |
+ } |
+ |
+ return new SkCodecImageGenerator(codec, data); |
+} |
+ |
+SkCodecImageGenerator::SkCodecImageGenerator(SkCodec* codec, SkData* data) |
+ : INHERITED(codec->getInfo()) |
+ , fCodec(codec) |
+ , fData(SkRef(data)) |
+{} |
+ |
+SkData* SkCodecImageGenerator::onRefEncodedData(SK_REFENCODEDDATA_CTXPARAM) { |
+ return SkRef(fData.get()); |
+} |
+ |
+bool SkCodecImageGenerator::onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, |
+ SkPMColor ctable[], int* ctableCount) { |
+ |
+ SkCodec::Result result = fCodec->getPixels(info, pixels, rowBytes, nullptr, ctable, |
+ ctableCount); |
+ switch (result) { |
+ case SkCodec::kSuccess: |
+ case SkCodec::kIncompleteInput: |
+ return true; |
+ default: |
+ return false; |
+ } |
+} |
+ |
+bool SkCodecImageGenerator::onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3], |
+ SkYUVColorSpace* colorSpace) { |
+ return false; |
+} |