see prev. checkin (missed these files). Change ownership rule for streams to the
authorreed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 16 Mar 2009 13:56:10 +0000 (13:56 +0000)
committerreed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 16 Mar 2009 13:56:10 +0000 (13:56 +0000)
skia std. of receiver calls ref() if it needs to, but regardless, the caller
always manages/balances its own ownership.

git-svn-id: http://skia.googlecode.com/svn/trunk@121 2bbb7eff-a529-9590-31e7-b0007b416f81

include/images/SkImageRef.h
src/images/SkImageRef.cpp

index e94b7d4..26ade5e 100644 (file)
@@ -35,9 +35,9 @@ public:
         that this imageref is the only owner of the stream. i.e. - sole
         ownership of the stream object is transferred to this imageref object.
     
-        @param stream The stream containing the encoded image data. Ownership
-                      of this stream is transferred to the imageref, and
-                      therefore the stream's ownercount must be 1.
+        @param stream The stream containing the encoded image data. This may be
+                      retained (by calling ref()), so the caller should not
+                      explicitly delete it.
         @param config The preferred config of the decoded bitmap.
         @param sampleSize Requested sampleSize for decoding. Defaults to 1.
     */
index 90c37b6..8b14375 100644 (file)
@@ -15,8 +15,7 @@ SkImageRef::SkImageRef(SkStream* stream, SkBitmap::Config config,
                        int sampleSize)
         : SkPixelRef(&gImageRefMutex), fErrorInDecoding(false) {
     SkASSERT(stream);
-    SkASSERT(1 == stream->getRefCnt());
-
+    stream->ref();
     fStream = stream;
     fConfig = config;
     fSampleSize = sampleSize;
@@ -36,7 +35,7 @@ SkImageRef::~SkImageRef() {
               this, fConfig, (int)fStream->getLength());
 #endif
 
-    delete fStream;
+    fStream->unref();
 }
 
 bool SkImageRef::getInfo(SkBitmap* bitmap) {