Flutter Engine
The Flutter Engine
drrect.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2014 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"
13#include "include/core/SkRect.h"
15#include "include/core/SkSize.h"
18
19class DRRectGM : public skiagm::GM {
20public:
22
23protected:
24 SkString getName() const override { return SkString("drrect"); }
25
26 SkISize getISize() override { return SkISize::Make(640, 480); }
27
28 void onDraw(SkCanvas* canvas) override {
30 paint.setAntiAlias(true);
31
32 SkRRect outers[4];
33 // like squares/circles, to exercise fast-cases in GPU
34 SkRect r = { 0, 0, 100, 100 };
35 SkVector radii[4] = {
36 { 0, 0 }, { 30, 1 }, { 10, 40 }, { 40, 40 }
37 };
38
39 const SkScalar dx = r.width() + 16;
40 const SkScalar dy = r.height() + 16;
41
42 outers[0].setRect(r);
43 outers[1].setOval(r);
44 outers[2].setRectXY(r, 20, 20);
45 outers[3].setRectRadii(r, radii);
46
47 SkRRect inners[5];
48 r.inset(25, 25);
49
50 inners[0].setEmpty();
51 inners[1].setRect(r);
52 inners[2].setOval(r);
53 inners[3].setRectXY(r, 20, 20);
54 inners[4].setRectRadii(r, radii);
55
56 canvas->translate(16, 16);
57 for (size_t j = 0; j < std::size(inners); ++j) {
58 for (size_t i = 0; i < std::size(outers); ++i) {
59 canvas->save();
60 canvas->translate(dx * j, dy * i);
61 canvas->drawDRRect(outers[i], inners[j], paint);
62 canvas->restore();
63 }
64 }
65 }
66
67private:
68 using INHERITED = GM;
69};
70
71DEF_GM( return new DRRectGM; )
void onDraw(SkCanvas *canvas) override
Definition: drrect.cpp:28
SkISize getISize() override
Definition: drrect.cpp:26
SkString getName() const override
Definition: drrect.cpp:24
DRRectGM()
Definition: drrect.cpp:21
void restore()
Definition: SkCanvas.cpp:461
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
int save()
Definition: SkCanvas.cpp:447
void drawDRRect(const SkRRect &outer, const SkRRect &inner, const SkPaint &paint)
Definition: SkCanvas.cpp:1645
void setEmpty()
Definition: SkRRect.h:118
void setOval(const SkRect &oval)
Definition: SkRRect.cpp:30
void setRectRadii(const SkRect &rect, const SkVector radii[4])
Definition: SkRRect.cpp:189
void setRectXY(const SkRect &rect, SkScalar xRad, SkScalar yRad)
Definition: SkRRect.cpp:52
void setRect(const SkRect &rect)
Definition: SkRRect.h:126
Definition: gm.h:110
GM(SkColor backgroundColor=SK_ColorWHITE)
Definition: gm.cpp:81
const Paint & paint
Definition: color_source.cc:38
float SkScalar
Definition: extension.cpp:12
#define DEF_GM(CODE)
Definition: gm.h:40
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
Definition: SkRecords.h:208
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
Definition: SkSize.h:16
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20
void inset(float dx, float dy)
Definition: SkRect.h:1060
constexpr float height() const
Definition: SkRect.h:769
constexpr float width() const
Definition: SkRect.h:762