blob: 3c3a3ae0178ba7ce54a32f01a88d7373087cf288 [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"
Ben Wagner7fde8e12019-05-01 17:28:53 -040010#include "include/core/SkPaint.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "include/core/SkPath.h"
Ben Wagner7fde8e12019-05-01 17:28:53 -040012#include "include/core/SkScalar.h"
13#include "include/core/SkSize.h"
14#include "include/core/SkString.h"
Kevin Lubickdc6cc022023-01-13 11:24:27 -050015#include "include/private/base/SkTArray.h"
joshualitt63648072015-02-19 10:25:21 -080016
Herb Derbyec96c212023-03-06 10:31:22 -050017using namespace skia_private;
18
joshualitt63648072015-02-19 10:25:21 -080019namespace skiagm {
20
21// this GM tests hairlines which fill nearly the entire render target
22class StLouisArchGM : public GM {
23protected:
Leandro Lovisolo24fa2112023-08-15 19:05:17 +000024 SkString getName() const override { return SkString("stlouisarch"); }
joshualitt63648072015-02-19 10:25:21 -080025
Leandro Lovisolo8f023882023-08-15 21:13:52 +000026 SkISize getISize() override { return SkISize::Make((int)kWidth, (int)kHeight); }
joshualitt63648072015-02-19 10:25:21 -080027
mtklein36352bf2015-03-25 18:17:31 -070028 void onOnceBeforeDraw() override {
joshualitt63648072015-02-19 10:25:21 -080029 {
30 SkPath* bigQuad = &fPaths.push_back();
31 bigQuad->moveTo(0, 0);
32 bigQuad->quadTo(kWidth/2, kHeight, kWidth, 0);
33 }
34
35 {
36 SkPath* degenBigQuad = &fPaths.push_back();
37 SkScalar yPos = kHeight / 2 + 10;
38 degenBigQuad->moveTo(0, yPos);
39 degenBigQuad->quadTo(0, yPos, kWidth, yPos);
40 }
41
42
43 {
44 SkPath* bigCubic = &fPaths.push_back();
45 bigCubic->moveTo(0, 0);
46 bigCubic->cubicTo(0, kHeight,
47 kWidth, kHeight,
48 kWidth, 0);
49 }
50
51 {
52 SkPath* degenBigCubic = &fPaths.push_back();
53 SkScalar yPos = kHeight / 2;
54 degenBigCubic->moveTo(0, yPos);
55 degenBigCubic->cubicTo(0, yPos,
56 0, yPos,
57 kWidth, yPos);
58 }
59
60 {
61 SkPath* bigConic = &fPaths.push_back();
62 bigConic->moveTo(0, 0);
63 bigConic->conicTo(kWidth/2, kHeight, kWidth, 0, .5);
64 }
65
66 {
67 SkPath* degenBigConic = &fPaths.push_back();
68 SkScalar yPos = kHeight / 2 - 10;
69 degenBigConic->moveTo(0, yPos);
70 degenBigConic->conicTo(0, yPos, kWidth, yPos, .5);
71 }
72 }
73
mtklein36352bf2015-03-25 18:17:31 -070074 void onDraw(SkCanvas* canvas) override {
joshualitt63648072015-02-19 10:25:21 -080075 canvas->save();
76 canvas->scale(1, -1);
77 canvas->translate(0, -kHeight);
Herb Derbyffacce52022-11-09 10:51:34 -050078 for (int p = 0; p < fPaths.size(); ++p) {
joshualitt63648072015-02-19 10:25:21 -080079 SkPaint paint;
80 paint.setARGB(0xff, 0, 0, 0);
81 paint.setAntiAlias(true);
82 paint.setStyle(SkPaint::kStroke_Style);
83 paint.setStrokeWidth(0);
84 canvas->drawPath(fPaths[p], paint);
85 }
86 canvas->restore();
87 }
88
89 const SkScalar kWidth = 256;
90 const SkScalar kHeight = 256;
91
92private:
Herb Derbyec96c212023-03-06 10:31:22 -050093 TArray<SkPath> fPaths;
John Stiles7571f9e2020-09-02 22:42:33 -040094 using INHERITED = GM;
joshualitt63648072015-02-19 10:25:21 -080095};
96
97//////////////////////////////////////////////////////////////////////////////
98
Hal Canarye964c182019-01-23 10:22:01 -050099DEF_GM( return new StLouisArchGM; )
joshualitt63648072015-02-19 10:25:21 -0800100
John Stilesa6841be2020-08-06 14:11:56 -0400101} // namespace skiagm