[try 2] skpmaker: make the SKP more graphically interesting (add a border)
relanding https://codereview.chromium.org/137993008/ BUG=skia:1942 NOTRY=True R=rmistry@google.com TBR=rmistry Author: epoger@google.com Review URL: https://codereview.chromium.org/139583002 git-svn-id: http://skia.googlecode.com/svn/trunk@13088 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
7e1a31db6a
commit
238771c930
@ -17,20 +17,25 @@
|
|||||||
|
|
||||||
// Flags used by this file, alphabetically:
|
// Flags used by this file, alphabetically:
|
||||||
DEFINE_int32(blue, 128, "Value of blue color channel in image, 0-255.");
|
DEFINE_int32(blue, 128, "Value of blue color channel in image, 0-255.");
|
||||||
|
DEFINE_int32(border, 4, "Width of the black border around the image.");
|
||||||
DEFINE_int32(green, 128, "Value of green color channel in image, 0-255.");
|
DEFINE_int32(green, 128, "Value of green color channel in image, 0-255.");
|
||||||
DEFINE_int32(height, 200, "Height of canvas to create.");
|
DEFINE_int32(height, 200, "Height of canvas to create.");
|
||||||
DEFINE_int32(red, 128, "Value of red color channel in image, 0-255.");
|
DEFINE_int32(red, 128, "Value of red color channel in image, 0-255.");
|
||||||
DEFINE_int32(width, 300, "Width of canvas to create.");
|
DEFINE_int32(width, 300, "Width of canvas to create.");
|
||||||
DEFINE_string(writePath, "", "Filepath to write the SKP into.");
|
DEFINE_string(writePath, "", "Filepath to write the SKP into.");
|
||||||
|
|
||||||
static void skpmaker(int width, int height, SkColor color,
|
static void skpmaker(int width, int height, int border, SkColor color,
|
||||||
const char *writePath) {
|
const char *writePath) {
|
||||||
SkPicture pict;
|
SkPicture pict;
|
||||||
SkCanvas* canvas = pict.beginRecording(width, height);
|
SkCanvas* canvas = pict.beginRecording(width, height);
|
||||||
SkPaint paint;
|
SkPaint paint;
|
||||||
paint.setStyle(SkPaint::kFill_Style);
|
paint.setStyle(SkPaint::kFill_Style);
|
||||||
paint.setColor(color);
|
paint.setColor(SK_ColorBLACK);
|
||||||
canvas->drawRectCoords(0, 0, SkIntToScalar(width), SkIntToScalar(height), paint);
|
canvas->drawRectCoords(0, 0, SkIntToScalar(width), SkIntToScalar(height), paint);
|
||||||
|
paint.setColor(color);
|
||||||
|
canvas->drawRectCoords(SkIntToScalar(border), SkIntToScalar(border),
|
||||||
|
SkIntToScalar(width - border*2), SkIntToScalar(height - border*2),
|
||||||
|
paint);
|
||||||
pict.endRecording();
|
pict.endRecording();
|
||||||
SkFILEWStream stream(writePath);
|
SkFILEWStream stream(writePath);
|
||||||
pict.serialize(&stream);
|
pict.serialize(&stream);
|
||||||
@ -68,7 +73,7 @@ int tool_main(int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SkColor color = SkColorSetRGB(FLAGS_red, FLAGS_green, FLAGS_blue);
|
SkColor color = SkColorSetRGB(FLAGS_red, FLAGS_green, FLAGS_blue);
|
||||||
skpmaker(FLAGS_width, FLAGS_height, color, FLAGS_writePath[0]);
|
skpmaker(FLAGS_width, FLAGS_height, FLAGS_border, color, FLAGS_writePath[0]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,10 +40,11 @@ class RenderPicturesTest(base_unittest.TestCase):
|
|||||||
expected_summary_dict = {
|
expected_summary_dict = {
|
||||||
"actual-results" : {
|
"actual-results" : {
|
||||||
"no-comparison" : {
|
"no-comparison" : {
|
||||||
"input.png" : [ "bitmap-64bitMD5", 12793741875005523433 ]
|
# Manually verified: 640x400 red image with black border
|
||||||
}
|
"input.png" : [ "bitmap-64bitMD5", 11092453015575919668 ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
self._assert_json_contents(output_json_path, expected_summary_dict)
|
self._assert_json_contents(output_json_path, expected_summary_dict)
|
||||||
|
|
||||||
def test_tiled_no_comparison(self):
|
def test_tiled_no_comparison(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user