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

Unified Diff: src/codec/SkCodecImageGenerator.cpp

Issue 1487683004: Create an SkCodecImageGenerator (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Move to src/codec and codec.gyp Created 4 years, 11 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/codec/SkCodecImageGenerator.h ('k') | tests/CodexTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
+}
« no previous file with comments | « src/codec/SkCodecImageGenerator.h ('k') | tests/CodexTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698