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

Unified Diff: include/codec/SkScanlineDecoder.h

Issue 1212593003: Destroy SkScanlineDecoder in the SkCodec subclass destructors (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fixes and a test Created 5 years, 6 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: include/codec/SkScanlineDecoder.h
diff --git a/include/codec/SkScanlineDecoder.h b/include/codec/SkScanlineDecoder.h
index d7f73dda56f92ef4bccc7bc431282b43d05a05a0..009fbec3177af791dfe38e95de48a8af56591d87 100644
--- a/include/codec/SkScanlineDecoder.h
+++ b/include/codec/SkScanlineDecoder.h
@@ -17,7 +17,9 @@ class SkScanlineDecoder : public SkNoncopyable {
public:
// Note for implementations: An SkScanlineDecoder will be deleted by (and
// therefore *before*) its associated SkCodec, in case the order matters.
- virtual ~SkScanlineDecoder() {}
+ virtual ~SkScanlineDecoder() {
+ this->onFinish();
scroggo 2015/06/30 13:47:38 I almost missed this: you shouldn't call a virtual
msarett 2015/06/30 20:43:05 Acknowledged.
+ }
/**
* Write the next countLines scanlines into dst.
@@ -34,7 +36,7 @@ public:
return SkImageGenerator::kInvalidParameters;
}
const SkImageGenerator::Result result = this->onGetScanlines(dst, countLines, rowBytes);
- this->checkForFinish(countLines);
+ fCurrScanline += countLines;
return result;
}
@@ -54,7 +56,7 @@ public:
return SkImageGenerator::kInvalidParameters;
}
const SkImageGenerator::Result result = this->onSkipScanlines(countLines);
- this->checkForFinish(countLines);
+ fCurrScanline += countLines;
return result;
}
@@ -98,19 +100,11 @@ private:
size_t rowBytes) = 0;
/**
- * Called after any set of scanlines read/skipped. Updates fCurrScanline,
- * and, if we are at the end, calls onFinish().
- */
- void checkForFinish(int countLines) {
- fCurrScanline += countLines;
- if (fCurrScanline >= fDstInfo.height()) {
- this->onFinish();
- }
- }
-
- /**
- * This function will be called after reading/skipping all scanlines to do
+ * This function will be called after reading/skipping scanlines to do
* any necessary cleanups.
+ * It is possible that not all scanlines will have been read/skipped when this
+ * function is called. In fact, in the case of subset decodes, it is likely
+ * that there will be scanlines at the bottom of the image that have been ignored.
*/
virtual void onFinish() {} // Default does nothing.
};

Powered by Google App Engine
This is Rietveld 408576698