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/SampleImage.cpp b/samplecode/SampleImage.cpp
index 4cefd27..7683e63 100644
--- a/samplecode/SampleImage.cpp
+++ b/samplecode/SampleImage.cpp
@@ -23,7 +23,6 @@
"2.bmp", "2.gif", "2.jpg", "2.png"
};
-// ownership of the stream is transferred
static bool SetImageRef(SkBitmap* bitmap, SkStream* stream,
SkBitmap::Config pref, const char name[] = NULL)
{
@@ -36,7 +35,6 @@
bitmap->setPixelRef(ref)->unref();
return true;
} else {
- delete stream;
return false;
}
}
@@ -60,6 +58,7 @@
SetImageRef(&fBitmaps[i], stream, SkBitmap::kNo_Config, gNames[i]);
if (i & 1)
fBitmaps[i].buildMipMap();
+ stream->unref();
}
fShader = SkShader::CreateBitmapShader(fBitmaps[5],