Change (correct) SkImageRef's ownership rule for streams to the skia standard
pattern: the receiver will call ref() if it chooses when passed to a constructor
or setter, so the caller must balance its ownership itself. This matches how all
other refcnt objects are handled.
git-svn-id: http://skia.googlecode.com/svn/trunk@120 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/samplecode/SampleImageDir.cpp b/samplecode/SampleImageDir.cpp
index 32a719b..922910c 100644
--- a/samplecode/SampleImageDir.cpp
+++ b/samplecode/SampleImageDir.cpp
@@ -91,7 +91,6 @@
canvas.drawRoundRect(r, SkFloatToFixed(91.756363), SkFloatToFixed(91.756363), paint);
}
-// ownership of the stream is transferred
static bool SetImageRef(SkBitmap* bitmap, SkStream* stream,
SkBitmap::Config pref, const char name[] = NULL) {
#if 0
@@ -142,6 +141,7 @@
#if 1
SkStream* stream = new SkFILEStream(SPECIFIC_IMAGE);
SetImageRef(&fBitmaps[i], stream, configs[i], SPECIFIC_IMAGE);
+ stream->unref();
#else
SkImageDecoder::DecodeFile(SPECIFIC_IMAGE, &fBitmaps[i]);
#endif
@@ -164,6 +164,7 @@
SetImageRef(&fBitmaps[i], stream, SkBitmap::kNo_Config,
name.c_str());
+ stream->unref();
fStrings[i] = name;
}
fBitmapCount = N;