blob: 176fb4b6196a72bc21737a7c665d95e2986eb99b [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
8#include "gm.h"
9#include "SkCanvas.h"
10#include "SkTArray.h"
11
12namespace skiagm {
13
14// this GM tests hairlines which fill nearly the entire render target
15class StLouisArchGM : public GM {
16protected:
mtklein36352bf2015-03-25 18:17:31 -070017 SkString onShortName() override {
joshualitt63648072015-02-19 10:25:21 -080018 return SkString("stlouisarch");
19 }
20
mtklein36352bf2015-03-25 18:17:31 -070021 SkISize onISize() override { return SkISize::Make((int)kWidth, (int)kHeight); }
joshualitt63648072015-02-19 10:25:21 -080022
mtklein36352bf2015-03-25 18:17:31 -070023 void onOnceBeforeDraw() override {
joshualitt63648072015-02-19 10:25:21 -080024 {
25 SkPath* bigQuad = &fPaths.push_back();
26 bigQuad->moveTo(0, 0);
27 bigQuad->quadTo(kWidth/2, kHeight, kWidth, 0);
28 }
29
30 {
31 SkPath* degenBigQuad = &fPaths.push_back();
32 SkScalar yPos = kHeight / 2 + 10;
33 degenBigQuad->moveTo(0, yPos);
34 degenBigQuad->quadTo(0, yPos, kWidth, yPos);
35 }
36
37
38 {
39 SkPath* bigCubic = &fPaths.push_back();
40 bigCubic->moveTo(0, 0);
41 bigCubic->cubicTo(0, kHeight,
42 kWidth, kHeight,
43 kWidth, 0);
44 }
45
46 {
47 SkPath* degenBigCubic = &fPaths.push_back();
48 SkScalar yPos = kHeight / 2;
49 degenBigCubic->moveTo(0, yPos);
50 degenBigCubic->cubicTo(0, yPos,
51 0, yPos,
52 kWidth, yPos);
53 }
54
55 {
56 SkPath* bigConic = &fPaths.push_back();
57 bigConic->moveTo(0, 0);
58 bigConic->conicTo(kWidth/2, kHeight, kWidth, 0, .5);
59 }
60
61 {
62 SkPath* degenBigConic = &fPaths.push_back();
63 SkScalar yPos = kHeight / 2 - 10;
64 degenBigConic->moveTo(0, yPos);
65 degenBigConic->conicTo(0, yPos, kWidth, yPos, .5);
66 }
67 }
68
mtklein36352bf2015-03-25 18:17:31 -070069 void onDraw(SkCanvas* canvas) override {
joshualitt63648072015-02-19 10:25:21 -080070 canvas->save();
71 canvas->scale(1, -1);
72 canvas->translate(0, -kHeight);
73 for (int p = 0; p < fPaths.count(); ++p) {
74 SkPaint paint;
75 paint.setARGB(0xff, 0, 0, 0);
76 paint.setAntiAlias(true);
77 paint.setStyle(SkPaint::kStroke_Style);
78 paint.setStrokeWidth(0);
79 canvas->drawPath(fPaths[p], paint);
80 }
81 canvas->restore();
82 }
83
84 const SkScalar kWidth = 256;
85 const SkScalar kHeight = 256;
86
87private:
88 SkTArray<SkPath> fPaths;
89 typedef GM INHERITED;
90};
91
92//////////////////////////////////////////////////////////////////////////////
93
94static GM* MyFactory(void*) { return new StLouisArchGM; }
95static GMRegistry reg(MyFactory);
96
97}