blob: 7389642da3c474e8357d845824665b55f75a90ca [file] [log] [blame]
Stephen Whitee7a364d2017-01-11 16:19:26 -05001/*
2 * Copyright 2017 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#include "gm.h"
9#include "SkCanvas.h"
10#include "SkPath.h"
11
Stephen Whitee7a364d2017-01-11 16:19:26 -050012namespace {
13// Test thin stroked rect (stroked "by hand", not by stroking).
14void draw_thin_stroked_rect(SkCanvas* canvas, const SkPaint& paint, SkScalar width) {
15 SkPath path;
16 path.moveTo(10 + width, 10 + width);
17 path.lineTo(40, 10 + width);
18 path.lineTo(40, 20);
19 path.lineTo(10 + width, 20);
20 path.moveTo(10, 10);
21 path.lineTo(10, 20 + width);
22 path.lineTo(40 + width, 20 + width);
23 path.lineTo(40 + width, 10);
24 canvas->drawPath(path, paint);
25}
26
Stephen Whiteeaf00792017-01-16 11:47:21 -050027void draw_thin_right_angle(SkCanvas* canvas, const SkPaint& paint, SkScalar width) {
28 SkPath path;
29 path.moveTo(10 + width, 10 + width);
30 path.lineTo(40, 10 + width);
31 path.lineTo(40, 20);
32 path.lineTo(40 + width, 20 + width);
33 path.lineTo(40 + width, 10);
34 path.lineTo(10, 10);
35 canvas->drawPath(path, paint);
36}
37
Stephen Whitee7a364d2017-01-11 16:19:26 -050038};
39
Stephen White930f69e2017-01-12 17:15:50 -050040DEF_SIMPLE_GM(thinconcavepaths, canvas, 400, 400) {
41 SkPaint paint;
Stephen Whitee7a364d2017-01-11 16:19:26 -050042
Stephen White930f69e2017-01-12 17:15:50 -050043 paint.setAntiAlias(true);
44 paint.setStyle(SkPaint::kFill_Style);
45
46 canvas->save();
47 for (SkScalar width = 1.0; width < 2.05; width += 0.25) {
48 draw_thin_stroked_rect(canvas, paint, width);
49 canvas->translate(0, 25);
Stephen Whitee7a364d2017-01-11 16:19:26 -050050 }
Stephen White930f69e2017-01-12 17:15:50 -050051 canvas->restore();
Stephen Whiteeaf00792017-01-16 11:47:21 -050052 canvas->translate(50, 0);
53 canvas->save();
54 for (SkScalar width = 0.5; width < 2.05; width += 0.25) {
55 draw_thin_right_angle(canvas, paint, width);
56 canvas->translate(0, 25);
57 }
58 canvas->restore();
59 canvas->translate(100, 0);
Stephen White930f69e2017-01-12 17:15:50 -050060}