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

Unified Diff: src/images/SkImageDecoder_libpng.cpp

Issue 849103004: Make SkStream *not* ref counted. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase, just in case. Created 5 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/images/SkImageDecoder_libjpeg.cpp ('k') | src/images/SkImageDecoder_libwebp.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/images/SkImageDecoder_libpng.cpp
diff --git a/src/images/SkImageDecoder_libpng.cpp b/src/images/SkImageDecoder_libpng.cpp
index c3bba6e07af1131ca466901c7a0ac74bab8f1cef..f9ef6b7942306016c714668555d96b7c3c31fbb3 100644
--- a/src/images/SkImageDecoder_libpng.cpp
+++ b/src/images/SkImageDecoder_libpng.cpp
@@ -53,13 +53,13 @@ SK_CONF_DECLARE(bool, c_suppressPNGImageDecoderWarnings,
class SkPNGImageIndex {
public:
+ // Takes ownership of stream.
SkPNGImageIndex(SkStreamRewindable* stream, png_structp png_ptr, png_infop info_ptr)
: fStream(stream)
, fPng_ptr(png_ptr)
, fInfo_ptr(info_ptr)
, fColorType(kUnknown_SkColorType) {
SkASSERT(stream != NULL);
- stream->ref();
}
~SkPNGImageIndex() {
if (fPng_ptr) {
@@ -67,7 +67,7 @@ public:
}
}
- SkAutoTUnref<SkStreamRewindable> fStream;
+ SkAutoTDelete<SkStreamRewindable> fStream;
png_structp fPng_ptr;
png_infop fInfo_ptr;
SkColorType fColorType;
@@ -718,6 +718,7 @@ bool SkPNGImageDecoder::decodePalette(png_structp png_ptr, png_infop info_ptr,
#ifdef SK_BUILD_FOR_ANDROID
bool SkPNGImageDecoder::onBuildTileIndex(SkStreamRewindable* sk_stream, int *width, int *height) {
+ SkAutoTDelete<SkStreamRewindable> streamDeleter(sk_stream);
png_structp png_ptr;
png_infop info_ptr;
@@ -743,7 +744,7 @@ bool SkPNGImageDecoder::onBuildTileIndex(SkStreamRewindable* sk_stream, int *wid
if (fImageIndex) {
SkDELETE(fImageIndex);
}
- fImageIndex = SkNEW_ARGS(SkPNGImageIndex, (sk_stream, png_ptr, info_ptr));
+ fImageIndex = SkNEW_ARGS(SkPNGImageIndex, (streamDeleter.detach(), png_ptr, info_ptr));
return true;
}
« no previous file with comments | « src/images/SkImageDecoder_libjpeg.cpp ('k') | src/images/SkImageDecoder_libwebp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698