aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/animator/SkAnimateMaker.cpp16
-rw-r--r--src/animator/SkAnimator.cpp12
-rw-r--r--src/animator/SkDrawBitmap.cpp8
-rw-r--r--src/images/SkImageDecoder.cpp6
-rw-r--r--src/images/SkMovie.cpp18
-rw-r--r--src/ports/SkFontHost_fontconfig.cpp10
-rw-r--r--src/ports/SkFontHost_linux.cpp10
-rwxr-xr-xsrc/ports/SkFontHost_win.cpp9
-rw-r--r--src/views/animated/SkWidgetViews.cpp12
9 files changed, 36 insertions, 65 deletions
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<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
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<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) {
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<SkStream> autoDel(stream);
- SkImageDecoder::DecodeStream(stream, &fBitmap);
+ SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(src.c_str()));
+ if (stream.get()) {
+ SkImageDecoder::DecodeStream(stream, &fBitmap);
+ }
}
}
diff --git a/src/images/SkImageDecoder.cpp b/src/images/SkImageDecoder.cpp
index 3999dcc2d6..c16efcf1f3 100644
--- a/src/images/SkImageDecoder.cpp
+++ b/src/images/SkImageDecoder.cpp
@@ -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;
}
diff --git a/src/images/SkMovie.cpp b/src/images/SkMovie.cpp
index ea4a76c6a1..2560014965 100644
--- a/src/images/SkMovie.cpp
+++ b/src/images/SkMovie.cpp
@@ -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;
}
diff --git a/src/ports/SkFontHost_fontconfig.cpp b/src/ports/SkFontHost_fontconfig.cpp
index 52f53551dc..4dd18880d2 100644
--- a/src/ports/SkFontHost_fontconfig.cpp
+++ b/src/ports/SkFontHost_fontconfig.cpp
@@ -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;
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/ports/SkFontHost_linux.cpp b/src/ports/SkFontHost_linux.cpp
index 25ae7effe2..f409cd4041 100644
--- a/src/ports/SkFontHost_linux.cpp
+++ b/src/ports/SkFontHost_linux.cpp
@@ -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;
}
diff --git a/src/ports/SkFontHost_win.cpp b/src/ports/SkFontHost_win.cpp
index ab2dd8f129..383aecd78b 100755
--- a/src/ports/SkFontHost_win.cpp
+++ b/src/ports/SkFontHost_win.cpp
@@ -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) {
diff --git a/src/views/animated/SkWidgetViews.cpp b/src/views/animated/SkWidgetViews.cpp
index 9c1cae7fb2..45e9868856 100644
--- a/src/views/animated/SkWidgetViews.cpp
+++ b/src/views/animated/SkWidgetViews.cpp
@@ -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();
}