Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(414)

Unified Diff: samplecode/SamplePicture.cpp

Issue 16173003: use SkStream factory for files, and check for null (file-not-found) speedup sampleapp's animation (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « samplecode/SampleApp.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samplecode/SamplePicture.cpp
diff --git a/samplecode/SamplePicture.cpp b/samplecode/SamplePicture.cpp
index eaec82984335e2f3ca6b6eeaa421f299687ff2b1..825e561654284a0575a097ad444669cc01ca0769 100644
--- a/samplecode/SamplePicture.cpp
+++ b/samplecode/SamplePicture.cpp
@@ -33,14 +33,16 @@
#include "SkImageRef_GlobalPool.h"
static SkBitmap load_bitmap() {
- SkStream* stream = new SkFILEStream("/skimages/sesame_street_ensemble-hp.jpg");
- 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();
+ SkStream* stream = SkStream::NewFromFile("/skimages/sesame_street_ensemble-hp.jpg");
+ if (stream) {
+ SkAutoUnref aur(stream);
+
+ 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;
}
« no previous file with comments | « samplecode/SampleApp.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698