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

Unified Diff: src/codec/SkCodec.cpp

Issue 1220733013: SkCodec no longer inherits from SkImageGenerator. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Manually handle the lifetime of fScanlineDecoder. Created 5 years, 5 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/codec/SkScanlineDecoder.h ('k') | src/codec/SkCodec_libbmp.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/codec/SkCodec.cpp
diff --git a/src/codec/SkCodec.cpp b/src/codec/SkCodec.cpp
index c24bb548baaaa712b5c5286a34d188175414ff1d..760975ece0cfe40af0af8e83a9c202de672b4614 100644
--- a/src/codec/SkCodec.cpp
+++ b/src/codec/SkCodec.cpp
@@ -16,6 +16,7 @@
#ifndef SK_BUILD_FOR_ANDROID_FRAMEWORK
#include "SkJpegCodec.h"
#endif
+#include "SkScanlineDecoder.h"
#include "SkStream.h"
#include "SkWebpCodec.h"
@@ -76,11 +77,16 @@ SkCodec* SkCodec::NewFromData(SkData* data) {
}
SkCodec::SkCodec(const SkImageInfo& info, SkStream* stream)
- : INHERITED(info)
+ : fInfo(info)
, fStream(stream)
, fNeedsRewind(false)
+ , fScanlineDecoder(NULL)
{}
+SkCodec::~SkCodec() {
+ SkDELETE(fScanlineDecoder);
+}
+
SkCodec::RewindState SkCodec::rewindIfNeeded() {
// Store the value of fNeedsRewind so we can update it. Next read will
// require a rewind.
@@ -93,6 +99,51 @@ SkCodec::RewindState SkCodec::rewindIfNeeded() {
: kCouldNotRewind_RewindState;
}
+SkCodec::Result SkCodec::getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
+ const Options* options, SkPMColor ctable[], int* ctableCount) {
+ if (kUnknown_SkColorType == info.colorType()) {
+ return kInvalidConversion;
+ }
+ if (NULL == pixels) {
+ return kInvalidParameters;
+ }
+ if (rowBytes < info.minRowBytes()) {
+ return kInvalidParameters;
+ }
+
+ if (kIndex_8_SkColorType == info.colorType()) {
+ if (NULL == ctable || NULL == ctableCount) {
+ return kInvalidParameters;
+ }
+ } else {
+ if (ctableCount) {
+ *ctableCount = 0;
+ }
+ ctableCount = NULL;
+ ctable = NULL;
+ }
+
+ // Default options.
+ Options optsStorage;
+ if (NULL == options) {
+ options = &optsStorage;
+ }
+ const Result result = this->onGetPixels(info, pixels, rowBytes, *options, ctable, ctableCount);
+
+ if ((kIncompleteInput == result || kSuccess == result) && ctableCount) {
+ SkASSERT(*ctableCount >= 0 && *ctableCount <= 256);
+ }
+ return result;
+}
+
+SkCodec::Result SkCodec::getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes) {
+ SkASSERT(kIndex_8_SkColorType != info.colorType());
+ if (kIndex_8_SkColorType == info.colorType()) {
+ return kInvalidConversion;
+ }
+ return this->getPixels(info, pixels, rowBytes, NULL, NULL, NULL);
+}
+
SkScanlineDecoder* SkCodec::getScanlineDecoder(const SkImageInfo& dstInfo, const Options* options,
SkPMColor ctable[], int* ctableCount) {
@@ -102,8 +153,9 @@ SkScanlineDecoder* SkCodec::getScanlineDecoder(const SkImageInfo& dstInfo, const
options = &optsStorage;
}
- fScanlineDecoder.reset(this->onGetScanlineDecoder(dstInfo, *options, ctable, ctableCount));
- return fScanlineDecoder.get();
+ SkDELETE(fScanlineDecoder);
+ fScanlineDecoder = this->onGetScanlineDecoder(dstInfo, *options, ctable, ctableCount);
+ return fScanlineDecoder;
}
SkScanlineDecoder* SkCodec::getScanlineDecoder(const SkImageInfo& dstInfo) {
« no previous file with comments | « include/codec/SkScanlineDecoder.h ('k') | src/codec/SkCodec_libbmp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698