Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
stlouisarch.cpp
Go to the documentation of this file.
1/*
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/gm.h"
11#include "include/core/SkPath.h"
13#include "include/core/SkSize.h"
16
17using namespace skia_private;
18
19namespace skiagm {
20
21// this GM tests hairlines which fill nearly the entire render target
22class StLouisArchGM : public GM {
23protected:
24 SkString getName() const override { return SkString("stlouisarch"); }
25
26 SkISize getISize() override { return SkISize::Make((int)kWidth, (int)kHeight); }
27
28 void onOnceBeforeDraw() override {
29 {
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,
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
74 void onDraw(SkCanvas* canvas) override {
75 canvas->save();
76 canvas->scale(1, -1);
77 canvas->translate(0, -kHeight);
78 for (int p = 0; p < fPaths.size(); ++p) {
80 paint.setARGB(0xff, 0, 0, 0);
81 paint.setAntiAlias(true);
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 TArray<SkPath> fPaths;
94 using INHERITED = GM;
95};
96
97//////////////////////////////////////////////////////////////////////////////
98
99DEF_GM( return new StLouisArchGM; )
100
101} // namespace skiagm
void restore()
Definition SkCanvas.cpp:465
void translate(SkScalar dx, SkScalar dy)
int save()
Definition SkCanvas.cpp:451
void drawPath(const SkPath &path, const SkPaint &paint)
void scale(SkScalar sx, SkScalar sy)
@ kStroke_Style
set to stroke geometry
Definition SkPaint.h:194
SkPath & moveTo(SkScalar x, SkScalar y)
Definition SkPath.cpp:678
SkPath & quadTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2)
Definition SkPath.cpp:736
SkPath & cubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar x3, SkScalar y3)
Definition SkPath.cpp:789
SkPath & conicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar w)
Definition SkPath.cpp:756
int size() const
Definition SkTArray.h:416
SkString getName() const override
SkISize getISize() override
const SkScalar kWidth
void onOnceBeforeDraw() override
const SkScalar kHeight
void onDraw(SkCanvas *canvas) override
const Paint & paint
float SkScalar
Definition extension.cpp:12
#define DEF_GM(CODE)
Definition gm.h:40
static constexpr SkISize Make(int32_t w, int32_t h)
Definition SkSize.h:20