Flutter Engine
The Flutter Engine
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:461
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
int save()
Definition: SkCanvas.cpp:447
void drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747
void scale(SkScalar sx, SkScalar sy)
Definition: SkCanvas.cpp:1289
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
Definition: SkPath.h:59
SkPath & moveTo(SkScalar x, SkScalar y)
Definition: SkPath.cpp:688
SkPath & quadTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2)
Definition: SkPath.cpp:746
SkPath & cubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar x3, SkScalar y3)
Definition: SkPath.cpp:799
SkPath & conicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar w)
Definition: SkPath.cpp:766
int size() const
Definition: SkTArray.h:421
Definition: gm.h:110
GM(SkColor backgroundColor=SK_ColorWHITE)
Definition: gm.cpp:81
SkString getName() const override
Definition: stlouisarch.cpp:24
SkISize getISize() override
Definition: stlouisarch.cpp:26
const SkScalar kWidth
Definition: stlouisarch.cpp:89
void onOnceBeforeDraw() override
Definition: stlouisarch.cpp:28
const SkScalar kHeight
Definition: stlouisarch.cpp:90
void onDraw(SkCanvas *canvas) override
Definition: stlouisarch.cpp:74
const Paint & paint
Definition: color_source.cc:38
float SkScalar
Definition: extension.cpp:12
DEF_GM(return F(C(clipbox), 0.0f, 0.0f, {})) DEF_GM(return F(C(clipbox)
Definition: SkSize.h:16
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20