From f381162e5616daacdbcc06d693aca5111aeeebe8 Mon Sep 17 00:00:00 2001 From: "mike@reedtribe.org" Date: Tue, 19 Mar 2013 02:18:33 +0000 Subject: use SkStream::NewFromFile() git-svn-id: http://skia.googlecode.com/svn/trunk@8210 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/animator/SkAnimateMaker.cpp | 16 +++++++++------- src/animator/SkAnimator.cpp | 12 +++++++----- src/animator/SkDrawBitmap.cpp | 8 ++++---- 3 files changed, 20 insertions(+), 16 deletions(-) (limited to 'src/animator') diff --git a/src/animator/SkAnimateMaker.cpp b/src/animator/SkAnimateMaker.cpp index ddde2eb891..a3ebb642fe 100644 --- a/src/animator/SkAnimateMaker.cpp +++ b/src/animator/SkAnimateMaker.cpp @@ -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 autoDel(stream); - bool success = decodeStream(stream); - if (hasError() && fError.hasNoun() == false) - fError.setNoun(uri); - return success; + SkAutoTUnref 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 diff --git a/src/animator/SkAnimator.cpp b/src/animator/SkAnimator.cpp index 6d8fb62db5..1c53e30a95 100644 --- a/src/animator/SkAnimator.cpp +++ b/src/animator/SkAnimator.cpp @@ -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 autoDel(stream); - setURIBase(uri); - return decodeStream(stream); + SkAutoTUnref stream(SkStream::NewFromFile(uri)); + if (stream.get()) { + this->setURIBase(uri); + return decodeStream(stream); + } else { + return false; + } } bool SkAnimator::doCharEvent(SkUnichar code) { diff --git a/src/animator/SkDrawBitmap.cpp b/src/animator/SkDrawBitmap.cpp index 2a482d7584..30af9dbd0e 100644 --- a/src/animator/SkDrawBitmap.cpp +++ b/src/animator/SkDrawBitmap.cpp @@ -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 autoDel(stream); - SkImageDecoder::DecodeStream(stream, &fBitmap); + SkAutoTUnref stream(SkStream::NewFromFile(src.c_str())); + if (stream.get()) { + SkImageDecoder::DecodeStream(stream, &fBitmap); + } } } -- cgit v1.2.3