blob: 931af556e64fbf26ad27e5981a219131fc2aa80f [file] [log] [blame]
joshualitt63648072015-02-19 10:25:21 -08001/*
2 * Copyright 2015 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
Mike Kleinc0bd9f92019-04-23 12:05:21 -05008#include "gm/gm.h"
9#include "include/core/SkCanvas.h"
10#include "include/core/SkPath.h"
11#include "include/private/SkTArray.h"
joshualitt63648072015-02-19 10:25:21 -080012
13namespace skiagm {
14
15// this GM tests hairlines which fill nearly the entire render target
16class StLouisArchGM : public GM {
17protected:
mtklein36352bf2015-03-25 18:17:31 -070018 SkString onShortName() override {
joshualitt63648072015-02-19 10:25:21 -080019 return SkString("stlouisarch");
20 }
21
mtklein36352bf2015-03-25 18:17:31 -070022 SkISize onISize() override { return SkISize::Make((int)kWidth, (int)kHeight); }
joshualitt63648072015-02-19 10:25:21 -080023
mtklein36352bf2015-03-25 18:17:31 -070024 void onOnceBeforeDraw() override {
joshualitt63648072015-02-19 10:25:21 -080025 {
26 SkPath* bigQuad = &fPaths.push_back();
27 bigQuad->moveTo(0, 0);
28 bigQuad->quadTo(kWidth/2, kHeight, kWidth, 0);
29 }
30
31 {
32 SkPath* degenBigQuad = &fPaths.push_back();
33 SkScalar yPos = kHeight / 2 + 10;
34 degenBigQuad->moveTo(0, yPos);
35 degenBigQuad->quadTo(0, yPos, kWidth, yPos);
36 }
37
38
39 {
40 SkPath* bigCubic = &fPaths.push_back();
41 bigCubic->moveTo(0, 0);
42 bigCubic->cubicTo(0, kHeight,
43 kWidth, kHeight,
44 kWidth, 0);
45 }
46
47 {
48 SkPath* degenBigCubic = &fPaths.push_back();
49 SkScalar yPos = kHeight / 2;
50 degenBigCubic->moveTo(0, yPos);
51 degenBigCubic->cubicTo(0, yPos,
52 0, yPos,
53 kWidth, yPos);
54 }
55
56 {
57 SkPath* bigConic = &fPaths.push_back();
58 bigConic->moveTo(0, 0);
59 bigConic->conicTo(kWidth/2, kHeight, kWidth, 0, .5);
60 }
61
62 {
63 SkPath* degenBigConic = &fPaths.push_back();
64 SkScalar yPos = kHeight / 2 - 10;
65 degenBigConic->moveTo(0, yPos);
66 degenBigConic->conicTo(0, yPos, kWidth, yPos, .5);
67 }
68 }
69
mtklein36352bf2015-03-25 18:17:31 -070070 void onDraw(SkCanvas* canvas) override {
joshualitt63648072015-02-19 10:25:21 -080071 canvas->save();
72 canvas->scale(1, -1);
73 canvas->translate(0, -kHeight);
74 for (int p = 0; p < fPaths.count(); ++p) {
75 SkPaint paint;
76 paint.setARGB(0xff, 0, 0, 0);
77 paint.setAntiAlias(true);
78 paint.setStyle(SkPaint::kStroke_Style);
79 paint.setStrokeWidth(0);
80 canvas->drawPath(fPaths[p], paint);
81 }
82 canvas->restore();
83 }
84
85 const SkScalar kWidth = 256;
86 const SkScalar kHeight = 256;
87
88private:
89 SkTArray<SkPath> fPaths;
90 typedef GM INHERITED;
91};
92
93//////////////////////////////////////////////////////////////////////////////
94
Hal Canarye964c182019-01-23 10:22:01 -050095DEF_GM( return new StLouisArchGM; )
joshualitt63648072015-02-19 10:25:21 -080096
97}