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

Side by Side Diff: tools/skpmaker.cpp

Issue 513983002: Try out scalar picture sizes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update to ToT again Created 6 years, 3 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/skpinfo.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"
11 #include "SkColor.h" 11 #include "SkColor.h"
12 #include "SkCommandLineFlags.h" 12 #include "SkCommandLineFlags.h"
13 #include "SkPaint.h" 13 #include "SkPaint.h"
14 #include "SkPicture.h" 14 #include "SkPicture.h"
15 #include "SkPictureRecorder.h" 15 #include "SkPictureRecorder.h"
16 #include "SkScalar.h" 16 #include "SkScalar.h"
17 #include "SkStream.h" 17 #include "SkStream.h"
18 18
19 // Flags used by this file, alphabetically: 19 // Flags used by this file, alphabetically:
20 DEFINE_int32(blue, 128, "Value of blue color channel in image, 0-255."); 20 DEFINE_int32(blue, 128, "Value of blue color channel in image, 0-255.");
21 DEFINE_int32(border, 4, "Width of the black border around the image."); 21 DEFINE_int32(border, 4, "Width of the black border around the image.");
22 DEFINE_int32(green, 128, "Value of green color channel in image, 0-255."); 22 DEFINE_int32(green, 128, "Value of green color channel in image, 0-255.");
23 DEFINE_int32(height, 200, "Height of canvas to create."); 23 DEFINE_int32(height, 200, "Height of canvas to create.");
24 DEFINE_int32(red, 128, "Value of red color channel in image, 0-255."); 24 DEFINE_int32(red, 128, "Value of red color channel in image, 0-255.");
25 DEFINE_int32(width, 300, "Width of canvas to create."); 25 DEFINE_int32(width, 300, "Width of canvas to create.");
26 DEFINE_string(writePath, "", "Filepath to write the SKP into."); 26 DEFINE_string(writePath, "", "Filepath to write the SKP into.");
27 27
28 static void skpmaker(int width, int height, int border, SkColor color, 28 // Create a 'width' by 'height' skp with a 'border'-wide black border around
29 // a 'color' rectangle.
30 static void make_skp(SkScalar width, SkScalar height, SkScalar border, SkColor c olor,
29 const char *writePath) { 31 const char *writePath) {
30 SkPictureRecorder recorder; 32 SkPictureRecorder recorder;
31 SkCanvas* canvas = recorder.beginRecording(width, height, NULL, 0); 33 SkCanvas* canvas = recorder.beginRecording(width, height, NULL, 0);
32 SkPaint paint; 34 SkPaint paint;
33 paint.setStyle(SkPaint::kFill_Style); 35 paint.setStyle(SkPaint::kFill_Style);
34 paint.setColor(SK_ColorBLACK); 36 paint.setColor(SK_ColorBLACK);
35 canvas->drawRectCoords(0, 0, SkIntToScalar(width), SkIntToScalar(height), pa int); 37 SkRect r = SkRect::MakeWH(width, height);
38 canvas->drawRect(r, paint);
36 paint.setColor(color); 39 paint.setColor(color);
37 canvas->drawRectCoords(SkIntToScalar(border), SkIntToScalar(border), 40 r.inset(border, border);
38 SkIntToScalar(width - border*2), SkIntToScalar(height - border*2), 41 canvas->drawRect(r, paint);
39 paint);
40 SkAutoTUnref<SkPicture> pict(recorder.endRecording()); 42 SkAutoTUnref<SkPicture> pict(recorder.endRecording());
41 SkFILEWStream stream(writePath); 43 SkFILEWStream stream(writePath);
42 pict->serialize(&stream); 44 pict->serialize(&stream);
43 } 45 }
44 46
45 int tool_main(int argc, char** argv); 47 int tool_main(int argc, char** argv);
46 int tool_main(int argc, char** argv) { 48 int tool_main(int argc, char** argv) {
47 SkCommandLineFlags::SetUsage("Creates a simple .skp file for testing."); 49 SkCommandLineFlags::SetUsage("Creates a simple .skp file for testing.");
48 SkCommandLineFlags::Parse(argc, argv); 50 SkCommandLineFlags::Parse(argc, argv);
49 51
(...skipping 17 matching lines...) Expand all
67 if (FLAGS_width <= 0) { 69 if (FLAGS_width <= 0) {
68 SkDebugf("--width must be >0\n"); 70 SkDebugf("--width must be >0\n");
69 exit(-1); 71 exit(-1);
70 } 72 }
71 if (FLAGS_writePath.isEmpty()) { 73 if (FLAGS_writePath.isEmpty()) {
72 SkDebugf("--writePath must be nonempty\n"); 74 SkDebugf("--writePath must be nonempty\n");
73 exit(-1); 75 exit(-1);
74 } 76 }
75 77
76 SkColor color = SkColorSetRGB(FLAGS_red, FLAGS_green, FLAGS_blue); 78 SkColor color = SkColorSetRGB(FLAGS_red, FLAGS_green, FLAGS_blue);
77 skpmaker(FLAGS_width, FLAGS_height, FLAGS_border, color, FLAGS_writePath[0]) ; 79 make_skp(SkIntToScalar(FLAGS_width),
80 SkIntToScalar(FLAGS_height),
81 SkIntToScalar(FLAGS_border),
82 color, FLAGS_writePath[0]);
78 return 0; 83 return 0;
79 } 84 }
80 85
81 #if !defined SK_BUILD_FOR_IOS 86 #if !defined SK_BUILD_FOR_IOS
82 int main(int argc, char * const argv[]) { 87 int main(int argc, char * const argv[]) {
83 return tool_main(argc, (char**) argv); 88 return tool_main(argc, (char**) argv);
84 } 89 }
85 #endif 90 #endif
OLDNEW
« no previous file with comments | « tools/skpinfo.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698