use SkStream::NewFromFile()
authormike@reedtribe.org <mike@reedtribe.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 19 Mar 2013 02:18:33 +0000 (02:18 +0000)
committermike@reedtribe.org <mike@reedtribe.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 19 Mar 2013 02:18:33 +0000 (02:18 +0000)
git-svn-id: http://skia.googlecode.com/svn/trunk@8210 2bbb7eff-a529-9590-31e7-b0007b416f81

src/animator/SkAnimateMaker.cpp
src/animator/SkAnimator.cpp
src/animator/SkDrawBitmap.cpp
src/images/SkImageDecoder.cpp
src/images/SkMovie.cpp
src/ports/SkFontHost_fontconfig.cpp
src/ports/SkFontHost_linux.cpp
src/ports/SkFontHost_win.cpp
src/views/animated/SkWidgetViews.cpp

index ddde2eb8911a920538776176ce7ce034417ce5d0..a3ebb642fe7cfd2f4cb04beec69da2380c952bf5 100644 (file)
@@ -99,13 +99,15 @@ bool SkAnimateMaker::decodeURI(const char uri[]) {
 //  SkDebugf("animator decode %s\n", uri);
 
 //    SkStream* stream = SkStream::GetURIStream(fPrefix.c_str(), uri);
-    SkStream* stream = new SkFILEStream(uri);
-
-    SkAutoTDelete<SkStream> autoDel(stream);
-    bool success = decodeStream(stream);
-    if (hasError() && fError.hasNoun() == false)
-        fError.setNoun(uri);
-    return success;
+    SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(uri));
+    if (stream.get()) {
+        bool success = decodeStream(stream);
+        if (hasError() && fError.hasNoun() == false)
+            fError.setNoun(uri);
+        return success;
+    } else {
+        return false;
+    }
 }
 
 #if defined SK_DEBUG && 0
index 6d8fb62db5b2dfd234be19b23519287086208d69..1c53e30a95bffa7a308b45598ce79b41962f8a6d 100644 (file)
@@ -84,11 +84,13 @@ bool SkAnimator::decodeURI(const char uri[]) {
 //  SkDebugf("animator decode %s\n", uri);
 
 //    SkStream* stream = SkStream::GetURIStream(fMaker->fPrefix.c_str(), uri);
-    SkStream* stream = new SkFILEStream(uri);
-
-    SkAutoTDelete<SkStream> autoDel(stream);
-    setURIBase(uri);
-    return decodeStream(stream);
+    SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(uri));
+    if (stream.get()) {
+        this->setURIBase(uri);
+        return decodeStream(stream);
+    } else {
+        return false;
+    }
 }
 
 bool SkAnimator::doCharEvent(SkUnichar code) {
index 2a482d7584ed543373097871f0e0f758b7b10b1d..30af9dbd0e06d772e01cbf96a68a9538bf33abde 100644 (file)
@@ -190,9 +190,9 @@ void SkImageBaseBitmap::resolve() {
         fBitmap.reset();
 
         //SkStream* stream = SkStream::GetURIStream(fUriBase, src.c_str());
-        SkStream* stream = new SkFILEStream(src.c_str());
-
-        SkAutoTDelete<SkStream> autoDel(stream);
-        SkImageDecoder::DecodeStream(stream, &fBitmap);
+        SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(src.c_str()));
+        if (stream.get()) {
+            SkImageDecoder::DecodeStream(stream, &fBitmap);
+        }
     }
 }
index 3999dcc2d6f253ddf1c838f571d1d56839ab88d2..c16efcf1f32797330cf39d29d10ed2da2f5ee951 100644 (file)
@@ -225,9 +225,9 @@ bool SkImageDecoder::DecodeFile(const char file[], SkBitmap* bm,
     SkASSERT(file);
     SkASSERT(bm);
 
-    SkFILEStream    stream(file);
-    if (stream.isValid()) {
-        if (SkImageDecoder::DecodeStream(&stream, bm, pref, mode, format)) {
+    SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(file));
+    if (stream.get()) {
+        if (SkImageDecoder::DecodeStream(stream, bm, pref, mode, format)) {
             bm->pixelRef()->setURI(file);
             return true;
         }
index ea4a76c6a19b47756b481cf178a9daa11624bfc3..2560014965cee524885ebe68d0e8bb5fe382d000 100644 (file)
@@ -91,19 +91,7 @@ SkMovie* SkMovie::DecodeMemory(const void* data, size_t length) {
     return SkMovie::DecodeStream(&stream);
 }
 
-SkMovie* SkMovie::DecodeFile(const char path[])
-{
-    SkMovie* movie = NULL;
-
-    SkFILEStream stream(path);
-    if (stream.isValid()) {
-        movie = SkMovie::DecodeStream(&stream);
-    }
-#ifdef SK_DEBUG
-    else {
-        SkDebugf("Movie file not found <%s>\n", path);
-    }
-#endif
-
-    return movie;
+SkMovie* SkMovie::DecodeFile(const char path[]) {
+    SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path));
+    return stream.get() ? SkMovie::DecodeStream(stream) : NULL;
 }
index 52f53551dc97a7a31e9c92c9ecbdf5c67f38f293..4dd18880d2cfb4be83c4d92804877b7f5fc321a9 100644 (file)
@@ -167,14 +167,8 @@ SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) {
 }
 
 SkTypeface* SkFontHost::CreateTypefaceFromFile(const char path[]) {
-    SkTypeface* face = NULL;
-    SkFILEStream* stream = SkNEW_ARGS(SkFILEStream, (path));
-
-    if (stream->isValid()) {
-        face = CreateTypefaceFromStream(stream);
-    }
-    stream->unref();
-    return face;
+    SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path));
+    return stream.get() ? CreateTypefaceFromStream(stream) : NULL;
 }
 
 ///////////////////////////////////////////////////////////////////////////////
index 25ae7effe242586a75a15d99401403a735b53ed9..f409cd404154137c1ac331f6f6a2743a92337886 100644 (file)
@@ -567,12 +567,6 @@ SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) {
 }
 
 SkTypeface* SkFontHost::CreateTypefaceFromFile(const char path[]) {
-    SkTypeface* face = NULL;
-    SkFILEStream* stream = SkNEW_ARGS(SkFILEStream, (path));
-
-    if (stream->isValid()) {
-        face = CreateTypefaceFromStream(stream);
-    }
-    stream->unref();
-    return face;
+    SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path));
+    return stream.get() ? CreateTypefaceFromStream(stream) : NULL;
 }
index ab2dd8f1296f3c34e69e0455156f7028d6be92b5..383aecd78b6f5df15d48f2eaf5917e9e799c2de7 100755 (executable)
@@ -1638,13 +1638,8 @@ SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace,
 }
 
 SkTypeface* SkFontHost::CreateTypefaceFromFile(const char path[]) {
-    SkTypeface* face = NULL;
-    SkAutoTUnref<SkFILEStream> stream(SkNEW_ARGS(SkFILEStream, (path)));
-
-    if (stream->isValid()) {
-        face = CreateTypefaceFromStream(stream);
-    }
-    return face;
+    SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path));
+    return stream.get() ? CreateTypefaceFromStream(stream) : NULL;
 }
 
 void SkFontHost::FilterRec(SkScalerContext::Rec* rec, SkTypeface* typeface) {
index 9c1cae7fb21b36c94455d915de66be6310332e70..45e9868856f4b2cf348bdeeb46522a290ec6a409 100644 (file)
@@ -41,20 +41,16 @@ const char* get_skin_enum_path(SkinEnum se)
     return gSkinPaths[se];
 }
 
-void init_skin_anim(const char path[], SkAnimator* anim)
-{
+void init_skin_anim(const char path[], SkAnimator* anim) {
     SkASSERT(path && anim);
 
-    SkFILEStream    stream(path);
-
-    if (!stream.isValid())
-    {
+    SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path));
+    if (!stream.get()) {
         SkDEBUGF(("init_skin_anim: loading skin failed <%s>\n", path));
         sk_throw();
     }
 
-    if (!anim->decodeStream(&stream))
-    {
+    if (!anim->decodeStream(stream)) {
         SkDEBUGF(("init_skin_anim: decoding skin failed <%s>\n", path));
         sk_throw();
     }