blob: 106c47b20e6b6fcd512068bc998bd2970b327959 [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"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050015#include "include/private/SkTArray.h"
joshualitt63648072015-02-19 10:25:21 -080016
17namespace skiagm {
18
19// this GM tests hairlines which fill nearly the entire render target
20class StLouisArchGM : public GM {
21protected:
mtklein36352bf2015-03-25 18:17:31 -070022 SkString onShortName() override {
joshualitt63648072015-02-19 10:25:21 -080023 return SkString("stlouisarch");
24 }
25
mtklein36352bf2015-03-25 18:17:31 -070026 SkISize onISize() 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);
78 for (int p = 0; p < fPaths.count(); ++p) {
79 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:
93 SkTArray<SkPath> fPaths;
94 typedef GM INHERITED;
95};
96
97//////////////////////////////////////////////////////////////////////////////
98
Hal Canarye964c182019-01-23 10:22:01 -050099DEF_GM( return new StLouisArchGM; )
joshualitt63648072015-02-19 10:25:21 -0800100
101}