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

Side by Side Diff: samplecode/SamplePictFile.cpp

Issue 17113004: Replace SkPicture(SkStream) constructors with a factory. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Respond to comments. 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
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 30 matching lines...) Expand all
41 SkBitmap bm; 41 SkBitmap bm;
42 if (SkImageDecoder::DecodeFile(path, &bm)) { 42 if (SkImageDecoder::DecodeFile(path, &bm)) {
43 bm.setImmutable(); 43 bm.setImmutable();
44 pic = SkNEW(SkPicture); 44 pic = SkNEW(SkPicture);
45 SkCanvas* can = pic->beginRecording(bm.width(), bm.height()); 45 SkCanvas* can = pic->beginRecording(bm.width(), bm.height());
46 can->drawBitmap(bm, 0, 0, NULL); 46 can->drawBitmap(bm, 0, 0, NULL);
47 pic->endRecording(); 47 pic->endRecording();
48 } else { 48 } else {
49 SkFILEStream stream(path); 49 SkFILEStream stream(path);
50 if (stream.isValid()) { 50 if (stream.isValid()) {
51 pic = SkNEW_ARGS(SkPicture, (&stream, NULL, &SkImageDecoder::Dec odeMemory)); 51 pic = SkPicture::CreateFromStream(&stream);
52 } 52 }
53 53
54 if (false) { // re-record 54 if (false) { // re-record
55 SkPicture p2; 55 SkPicture p2;
56 pic->draw(p2.beginRecording(pic->width(), pic->height())); 56 pic->draw(p2.beginRecording(pic->width(), pic->height()));
57 p2.endRecording(); 57 p2.endRecording();
58 58
59 SkString path2(path); 59 SkString path2(path);
60 path2.append(".new.skp"); 60 path2.append(".new.skp");
61 SkFILEWStream writer(path2.c_str()); 61 SkFILEWStream writer(path2.c_str());
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 SampleView* CreateSamplePictFileView(const char filename[]) { 131 SampleView* CreateSamplePictFileView(const char filename[]) {
132 return new PictFileView(filename); 132 return new PictFileView(filename);
133 } 133 }
134 134
135 ////////////////////////////////////////////////////////////////////////////// 135 //////////////////////////////////////////////////////////////////////////////
136 136
137 #if 0 137 #if 0
138 static SkView* MyFactory() { return new PictFileView; } 138 static SkView* MyFactory() { return new PictFileView; }
139 static SkViewRegister reg(MyFactory); 139 static SkViewRegister reg(MyFactory);
140 #endif 140 #endif
OLDNEW
« no previous file with comments | « samplecode/SampleApp.cpp ('k') | src/core/SkPicture.cpp » ('j') | src/core/SkPicture.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698