Debian Codegraph @

gm/strokefill.cpp

raw
1 /*
2 * Copyright 2011 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/gm.h"
9 #include "include/core/SkCanvas.h"
10 #include "include/core/SkColor.h"
11 #include "include/core/SkFont.h"
12 #include "include/core/SkFontStyle.h"
13 #include "include/core/SkPaint.h"
14 #include "include/core/SkPath.h"
15 #include "include/core/SkRect.h"
16 #include "include/core/SkScalar.h"
17 #include "include/core/SkString.h"
18 #include "include/core/SkTypeface.h"
19 #include "include/core/SkTypes.h"
20 #include "src/core/SkPathPriv.h"
21 #include "src/core/SkTextFormatParams.h"
22 #include "tools/ToolUtils.h"
23
24 DEF_SIMPLE_GM(bug339297, canvas, 640, 480) {
25 SkPath path = SkPathBuilder()
26 .moveTo(-469515, -10354890)
27 .cubicTo(771919.62f, -10411179, 2013360.1f, -10243774, 3195542.8f, -9860664)
28 .lineTo(3195550, -9860655)
29 .lineTo(3195539, -9860652)
30 .lineTo(3195539, -9860652)
31 .lineTo(3195539, -9860652)
32 .cubicTo(2013358.1f, -10243761, 771919.25f, -10411166, -469513.84f, -10354877)
33 .lineTo(-469515, -10354890)
34 .close()
35 .detach();
36
37 canvas->translate(258, 10365663);
38
39 SkPaint paint;
40 paint.setAntiAlias(true);
41 paint.setColor(SK_ColorBLACK);
42 paint.setStyle(SkPaint::kFill_Style);
43 canvas->drawPath(path, paint);
44
45 paint.setColor(SK_ColorRED);
46 paint.setStyle(SkPaint::kStroke_Style);
47 paint.setStrokeWidth(1);
48 canvas->drawPath(path, paint);
49 }
50
51 DEF_SIMPLE_GM(bug339297_as_clip, canvas, 640, 480) {
52 SkPath path = SkPathBuilder()
53 .moveTo(-469515, -10354890)
54 .cubicTo(771919.62f, -10411179, 2013360.1f, -10243774, 3195542.8f, -9860664)
55 .lineTo(3195550, -9860655)
56 .lineTo(3195539, -9860652)
57 .lineTo(3195539, -9860652)
58 .lineTo(3195539, -9860652)
59 .cubicTo(2013358.1f, -10243761, 771919.25f, -10411166, -469513.84f, -10354877)
60 .lineTo(-469515, -10354890)
61 .close()
62 .detach();
63
64 canvas->translate(258, 10365663);
65
66 canvas->save();
67 canvas->clipPath(path, true);
68 canvas->clear(SK_ColorBLACK);
69 canvas->restore();
70
71 SkPaint paint;
72 paint.setAntiAlias(true);
73 paint.setStyle(SkPaint::kFill_Style);
74 paint.setColor(SK_ColorRED);
75 paint.setStyle(SkPaint::kStroke_Style);
76 paint.setStrokeWidth(1);
77 canvas->drawPath(path, paint);
78 }
79
80 DEF_SIMPLE_GM(bug6987, canvas, 200, 200) {
81 SkPaint paint;
82 paint.setStyle(SkPaint::kStroke_Style);
83 paint.setStrokeWidth(0.0001f);
84 paint.setAntiAlias(true);
85
86 SkPath path = SkPathBuilder()
87 .moveTo(0.0005f, 0.0004f)
88 .lineTo(0.0008f, 0.0010f)
89 .lineTo(0.0002f, 0.0010f)
90 .close()
91 .detach();
92
93 canvas->save();
94 canvas->scale(50000.0f, 50000.0f);
95 canvas->drawPath(path, paint);
96 canvas->restore();
97 }