use SkStream factory for files, and check for null (file-not-found) speedup sampleapp's animation

BUG=

Review URL: https://codereview.chromium.org/16173003

git-svn-id: http://skia.googlecode.com/svn/trunk@9327 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
reed@google.com 2013-05-29 19:22:20 +00:00
parent ed8d6bb2be
commit 84cfce14fe
2 changed files with 10 additions and 8 deletions

View File

@ -74,7 +74,7 @@ SkTCPServer gServer;
#endif
#define ANIMATING_EVENTTYPE "nextSample"
#define ANIMATING_DELAY 750
#define ANIMATING_DELAY 250
#ifdef SK_DEBUG
#define FPS_REPEAT_MULTIPLIER 1

View File

@ -33,15 +33,17 @@
#include "SkImageRef_GlobalPool.h"
static SkBitmap load_bitmap() {
SkStream* stream = new SkFILEStream("/skimages/sesame_street_ensemble-hp.jpg");
SkBitmap bm;
SkStream* stream = SkStream::NewFromFile("/skimages/sesame_street_ensemble-hp.jpg");
if (stream) {
SkAutoUnref aur(stream);
SkBitmap bm;
if (SkImageDecoder::DecodeStream(stream, &bm, SkBitmap::kNo_Config,
SkImageDecoder::kDecodeBounds_Mode)) {
SkPixelRef* pr = new SkImageRef_GlobalPool(stream, bm.config(), 1);
bm.setPixelRef(pr)->unref();
}
}
return bm;
}