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

Side by Side Diff: tools/skpmaker.cpp

Issue 1811703002: return pictures as sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rely on RVO in picturerecorder Created 4 years, 9 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
« no previous file with comments | « tools/skiaserve/Request.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 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 * 6 *
7 * Simple tool to generate SKP files for testing. 7 * Simple tool to generate SKP files for testing.
8 */ 8 */
9 9
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 23 matching lines...) Expand all
34 SkPictureRecorder recorder; 34 SkPictureRecorder recorder;
35 SkCanvas* canvas = recorder.beginRecording(width, height, nullptr, 0); 35 SkCanvas* canvas = recorder.beginRecording(width, height, nullptr, 0);
36 SkPaint paint; 36 SkPaint paint;
37 paint.setStyle(SkPaint::kFill_Style); 37 paint.setStyle(SkPaint::kFill_Style);
38 paint.setColor(SK_ColorBLACK); 38 paint.setColor(SK_ColorBLACK);
39 SkRect r = SkRect::MakeWH(width, height); 39 SkRect r = SkRect::MakeWH(width, height);
40 canvas->drawRect(r, paint); 40 canvas->drawRect(r, paint);
41 paint.setColor(color); 41 paint.setColor(color);
42 r.inset(border, border); 42 r.inset(border, border);
43 canvas->drawRect(r, paint); 43 canvas->drawRect(r, paint);
44 SkAutoTUnref<SkPicture> pict(recorder.endRecording());
45 SkFILEWStream stream(writePath); 44 SkFILEWStream stream(writePath);
46 pict->serialize(&stream); 45 recorder.finishRecordingAsPicture()->serialize(&stream);
47 } 46 }
48 47
49 int tool_main(int argc, char** argv); 48 int tool_main(int argc, char** argv);
50 int tool_main(int argc, char** argv) { 49 int tool_main(int argc, char** argv) {
51 SkCommandLineFlags::SetUsage("Creates a simple .skp file for testing."); 50 SkCommandLineFlags::SetUsage("Creates a simple .skp file for testing.");
52 SkCommandLineFlags::Parse(argc, argv); 51 SkCommandLineFlags::Parse(argc, argv);
53 52
54 // Validate flags. 53 // Validate flags.
55 if ((FLAGS_blue < 0) || (FLAGS_blue > 255)) { 54 if ((FLAGS_blue < 0) || (FLAGS_blue > 255)) {
56 SkDebugf("--blue must be within range [0,255]\n"); 55 SkDebugf("--blue must be within range [0,255]\n");
(...skipping 26 matching lines...) Expand all
83 SkIntToScalar(FLAGS_border), 82 SkIntToScalar(FLAGS_border),
84 color, FLAGS_writePath[0]); 83 color, FLAGS_writePath[0]);
85 return 0; 84 return 0;
86 } 85 }
87 86
88 #if !defined SK_BUILD_FOR_IOS 87 #if !defined SK_BUILD_FOR_IOS
89 int main(int argc, char * const argv[]) { 88 int main(int argc, char * const argv[]) {
90 return tool_main(argc, (char**) argv); 89 return tool_main(argc, (char**) argv);
91 } 90 }
92 #endif 91 #endif
OLDNEW
« no previous file with comments | « tools/skiaserve/Request.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698