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

Side by Side 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, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « samplecode/SampleApp.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "SampleCode.h" 8 #include "SampleCode.h"
9 #include "SkDumpCanvas.h" 9 #include "SkDumpCanvas.h"
10 #include "SkView.h" 10 #include "SkView.h"
(...skipping 15 matching lines...) Expand all
26 #include "SkXfermode.h" 26 #include "SkXfermode.h"
27 27
28 #include "SkStream.h" 28 #include "SkStream.h"
29 #include "SkXMLParser.h" 29 #include "SkXMLParser.h"
30 30
31 /////////////////////////////////////////////////////////////////////////////// 31 ///////////////////////////////////////////////////////////////////////////////
32 32
33 #include "SkImageRef_GlobalPool.h" 33 #include "SkImageRef_GlobalPool.h"
34 34
35 static SkBitmap load_bitmap() { 35 static SkBitmap load_bitmap() {
36 SkStream* stream = new SkFILEStream("/skimages/sesame_street_ensemble-hp.jpg "); 36 SkBitmap bm;
37 SkAutoUnref aur(stream); 37 SkStream* stream = SkStream::NewFromFile("/skimages/sesame_street_ensemble-h p.jpg");
38 if (stream) {
39 SkAutoUnref aur(stream);
38 40
39 SkBitmap bm; 41 if (SkImageDecoder::DecodeStream(stream, &bm, SkBitmap::kNo_Config,
40 if (SkImageDecoder::DecodeStream(stream, &bm, SkBitmap::kNo_Config, 42 SkImageDecoder::kDecodeBounds_Mode)) {
41 SkImageDecoder::kDecodeBounds_Mode)) { 43 SkPixelRef* pr = new SkImageRef_GlobalPool(stream, bm.config(), 1);
42 SkPixelRef* pr = new SkImageRef_GlobalPool(stream, bm.config(), 1); 44 bm.setPixelRef(pr)->unref();
43 bm.setPixelRef(pr)->unref(); 45 }
44 } 46 }
45 return bm; 47 return bm;
46 } 48 }
47 49
48 static void drawCircle(SkCanvas* canvas, int r, SkColor color) { 50 static void drawCircle(SkCanvas* canvas, int r, SkColor color) {
49 SkPaint paint; 51 SkPaint paint;
50 paint.setAntiAlias(true); 52 paint.setAntiAlias(true);
51 paint.setColor(color); 53 paint.setColor(color);
52 54
53 canvas->drawCircle(SkIntToScalar(r), SkIntToScalar(r), SkIntToScalar(r), 55 canvas->drawCircle(SkIntToScalar(r), SkIntToScalar(r), SkIntToScalar(r),
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 SkPicture* fPicture; 191 SkPicture* fPicture;
190 SkPicture* fSubPicture; 192 SkPicture* fSubPicture;
191 193
192 typedef SampleView INHERITED; 194 typedef SampleView INHERITED;
193 }; 195 };
194 196
195 ////////////////////////////////////////////////////////////////////////////// 197 //////////////////////////////////////////////////////////////////////////////
196 198
197 static SkView* MyFactory() { return new PictureView; } 199 static SkView* MyFactory() { return new PictureView; }
198 static SkViewRegister reg(MyFactory); 200 static SkViewRegister reg(MyFactory);
OLDNEW
« 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