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

Unified Diff: src/codec/SkCodec.cpp

Issue 1365313002: Merge SkCodec with SkScanlineDecoder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 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
Index: src/codec/SkCodec.cpp
diff --git a/src/codec/SkCodec.cpp b/src/codec/SkCodec.cpp
index d12de21f515e45c861f6793cdd0b73b4bcc8055f..aa0af4827e682e10849b1ae63bdf5067b8aa1ed1 100644
--- a/src/codec/SkCodec.cpp
+++ b/src/codec/SkCodec.cpp
@@ -76,9 +76,12 @@ SkCodec* SkCodec::NewFromData(SkData* data) {
}
SkCodec::SkCodec(const SkImageInfo& info, SkStream* stream)
- : fInfo(info)
+ : fSrcInfo(info)
, fStream(stream)
, fNeedsRewind(false)
+ , fDstInfo()
+ , fOptions()
+ , fCurrScanline(-1)
{}
SkCodec::~SkCodec() {}
@@ -92,6 +95,9 @@ bool SkCodec::rewindIfNeeded() {
return true;
}
+ // start will need to be called before decoding scanlines.
+ fCurrScanline = -1;
+
if (!fStream->rewind()) {
return false;
}
@@ -148,3 +154,42 @@ SkCodec::Result SkCodec::getPixels(const SkImageInfo& info, void* pixels, size_t
SkCodec::Result SkCodec::getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes) {
return this->getPixels(info, pixels, rowBytes, nullptr, nullptr, nullptr);
}
+
+SkCodec::Result SkCodec::start(const SkImageInfo& dstInfo,
+ const SkCodec::Options* options, SkPMColor ctable[], int* ctableCount) {
+ // Reset fCurrScanline in case of failure.
+ fCurrScanline = -1;
+ // Ensure that valid color ptrs are passed in for kIndex8 color type
+ if (kIndex_8_SkColorType == dstInfo.colorType()) {
+ if (nullptr == ctable || nullptr == ctableCount) {
+ return SkCodec::kInvalidParameters;
+ }
+ } else {
+ if (ctableCount) {
+ *ctableCount = 0;
+ }
+ ctableCount = nullptr;
+ ctable = nullptr;
+ }
+
+ // Set options.
+ Options optsStorage;
+ if (nullptr == options) {
+ options = &optsStorage;
+ }
+
+ const Result result = this->onStart(dstInfo, *options, ctable, ctableCount);
+ if (result != SkCodec::kSuccess) {
+ return result;
+ }
+
+ fCurrScanline = 0;
+ fDstInfo = dstInfo;
+ fOptions = *options;
+ return kSuccess;
+}
+
+SkCodec::Result SkCodec::start(const SkImageInfo& dstInfo) {
+ return this->start(dstInfo, nullptr, nullptr, nullptr);
+}
+

Powered by Google App Engine
This is Rietveld 408576698