// 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
// 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) {
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);
+ }
}
}
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;
}
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;
}
}
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;
}
///////////////////////////////////////////////////////////////////////////////
}
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;
}
}
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) {
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();
}