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

Side by Side Diff: tools/skpmaker.cpp

Issue 139553002: Revert of skpmaker: make the SKP slightly more interesting (add a border) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 11 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 | « no previous file | tools/tests/render_pictures_test.py » ('j') | 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 "SkScalar.h" 15 #include "SkScalar.h"
16 #include "SkStream.h" 16 #include "SkStream.h"
17 17
18 // Flags used by this file, alphabetically: 18 // Flags used by this file, alphabetically:
19 DEFINE_int32(blue, 128, "Value of blue color channel in image, 0-255."); 19 DEFINE_int32(blue, 128, "Value of blue color channel in image, 0-255.");
20 DEFINE_int32(border, 4, "Width of the black border around the image.");
21 DEFINE_int32(green, 128, "Value of green color channel in image, 0-255."); 20 DEFINE_int32(green, 128, "Value of green color channel in image, 0-255.");
22 DEFINE_int32(height, 200, "Height of canvas to create."); 21 DEFINE_int32(height, 200, "Height of canvas to create.");
23 DEFINE_int32(red, 128, "Value of red color channel in image, 0-255."); 22 DEFINE_int32(red, 128, "Value of red color channel in image, 0-255.");
24 DEFINE_int32(width, 300, "Width of canvas to create."); 23 DEFINE_int32(width, 300, "Width of canvas to create.");
25 DEFINE_string(writePath, "", "Filepath to write the SKP into."); 24 DEFINE_string(writePath, "", "Filepath to write the SKP into.");
26 25
27 static void skpmaker(int width, int height, int border, SkColor color, 26 static void skpmaker(int width, int height, SkColor color,
28 const char *writePath) { 27 const char *writePath) {
29 SkPicture pict; 28 SkPicture pict;
30 SkCanvas* canvas = pict.beginRecording(width, height); 29 SkCanvas* canvas = pict.beginRecording(width, height);
31 SkPaint paint; 30 SkPaint paint;
32 paint.setStyle(SkPaint::kFill_Style); 31 paint.setStyle(SkPaint::kFill_Style);
33 paint.setColor(SK_ColorBLACK); 32 paint.setColor(color);
34 canvas->drawRectCoords(0, 0, SkIntToScalar(width), SkIntToScalar(height), pa int); 33 canvas->drawRectCoords(0, 0, SkIntToScalar(width), SkIntToScalar(height), pa int);
35 paint.setColor(color);
36 canvas->drawRectCoords(SkIntToScalar(border), SkIntToScalar(border),
37 SkIntToScalar(width - border*2), SkIntToScalar(height - border*2),
38 paint);
39 pict.endRecording(); 34 pict.endRecording();
40 SkFILEWStream stream(writePath); 35 SkFILEWStream stream(writePath);
41 pict.serialize(&stream); 36 pict.serialize(&stream);
42 } 37 }
43 38
44 int tool_main(int argc, char** argv); 39 int tool_main(int argc, char** argv);
45 int tool_main(int argc, char** argv) { 40 int tool_main(int argc, char** argv) {
46 SkCommandLineFlags::SetUsage("Creates a simple .skp file for testing."); 41 SkCommandLineFlags::SetUsage("Creates a simple .skp file for testing.");
47 SkCommandLineFlags::Parse(argc, argv); 42 SkCommandLineFlags::Parse(argc, argv);
48 43
(...skipping 17 matching lines...) Expand all
66 if (FLAGS_width <= 0) { 61 if (FLAGS_width <= 0) {
67 SkDebugf("--width must be >0\n"); 62 SkDebugf("--width must be >0\n");
68 exit(-1); 63 exit(-1);
69 } 64 }
70 if (FLAGS_writePath.isEmpty()) { 65 if (FLAGS_writePath.isEmpty()) {
71 SkDebugf("--writePath must be nonempty\n"); 66 SkDebugf("--writePath must be nonempty\n");
72 exit(-1); 67 exit(-1);
73 } 68 }
74 69
75 SkColor color = SkColorSetRGB(FLAGS_red, FLAGS_green, FLAGS_blue); 70 SkColor color = SkColorSetRGB(FLAGS_red, FLAGS_green, FLAGS_blue);
76 skpmaker(FLAGS_width, FLAGS_height, FLAGS_border, color, FLAGS_writePath[0]) ; 71 skpmaker(FLAGS_width, FLAGS_height, color, FLAGS_writePath[0]);
77 return 0; 72 return 0;
78 } 73 }
79 74
80 #if !defined SK_BUILD_FOR_IOS 75 #if !defined SK_BUILD_FOR_IOS
81 int main(int argc, char * const argv[]) { 76 int main(int argc, char * const argv[]) {
82 return tool_main(argc, (char**) argv); 77 return tool_main(argc, (char**) argv);
83 } 78 }
84 #endif 79 #endif
OLDNEW
« no previous file with comments | « no previous file | tools/tests/render_pictures_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698