Flutter Engine
The Flutter Engine
SkSGRect.h
Go to the documentation of this file.
1/*
2 * Copyright 2017 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#ifndef SkSGRect_DEFINED
9#define SkSGRect_DEFINED
10
11#include "include/core/SkPath.h"
14#include "include/core/SkRect.h"
20
21#include <cstdint>
22
23class SkCanvas;
24class SkMatrix;
25class SkPaint;
26struct SkPoint;
27
28namespace sksg {
29class InvalidationController;
30
31/**
32 * Concrete Geometry node, wrapping an SkRect.
33 */
34class Rect final : public GeometryNode {
35public:
36 static sk_sp<Rect> Make() { return sk_sp<Rect>(new Rect(SkRect::MakeEmpty())); }
37 static sk_sp<Rect> Make(const SkRect& r) { return sk_sp<Rect>(new Rect(r)); }
38
39 SG_ATTRIBUTE(L, SkScalar, fRect.fLeft )
40 SG_ATTRIBUTE(T, SkScalar, fRect.fTop )
41 SG_ATTRIBUTE(R, SkScalar, fRect.fRight )
42 SG_ATTRIBUTE(B, SkScalar, fRect.fBottom)
43
44 SG_MAPPED_ATTRIBUTE(Direction , SkPathDirection, fAttrContaier)
45 SG_MAPPED_ATTRIBUTE(InitialPointIndex, uint8_t , fAttrContaier)
46
47protected:
48 void onClip(SkCanvas*, bool antiAlias) const override;
49 void onDraw(SkCanvas*, const SkPaint&) const override;
50 bool onContains(const SkPoint&) const override;
51
53 SkPath onAsPath() const override;
54
55private:
56 explicit Rect(const SkRect&);
57
58 SkRect fRect;
59
60 struct AttrContainer {
61 uint8_t fDirection : 1;
62 uint8_t fInitialPointIndex : 2;
63
64 SkPathDirection getDirection() const {
65 return static_cast<SkPathDirection>(fDirection);
66 }
67 void setDirection(SkPathDirection dir) { fDirection = SkTo<uint8_t>(dir); }
68
69 uint8_t getInitialPointIndex() const { return fInitialPointIndex; }
70 void setInitialPointIndex(uint8_t idx) { fInitialPointIndex = idx; }
71 };
72 AttrContainer fAttrContaier = { (int)SkPathDirection::kCW, 0 };
73
74 using INHERITED = GeometryNode;
75};
76
77/**
78 * Concrete Geometry node, wrapping an SkRRect.
79 */
80class RRect final : public GeometryNode {
81public:
82 static sk_sp<RRect> Make() { return sk_sp<RRect>(new RRect(SkRRect())); }
83 static sk_sp<RRect> Make(const SkRRect& rr) { return sk_sp<RRect>(new RRect(rr)); }
84
85 SG_ATTRIBUTE(RRect, SkRRect, fRRect)
86
87 SG_MAPPED_ATTRIBUTE(Direction , SkPathDirection, fAttrContaier)
88 SG_MAPPED_ATTRIBUTE(InitialPointIndex, uint8_t , fAttrContaier)
89
90protected:
91 void onClip(SkCanvas*, bool antiAlias) const override;
92 void onDraw(SkCanvas*, const SkPaint&) const override;
93 bool onContains(const SkPoint&) const override;
94
96 SkPath onAsPath() const override;
97
98private:
99 explicit RRect(const SkRRect&);
100
101 SkRRect fRRect;
102
103 struct AttrContainer {
104 uint8_t fDirection : 1;
105 uint8_t fInitialPointIndex : 2;
106
107 SkPathDirection getDirection() const {
108 return static_cast<SkPathDirection>(fDirection);
109 }
110 void setDirection(SkPathDirection dir) { fDirection = SkTo<uint8_t>(dir); }
111
112 uint8_t getInitialPointIndex() const { return fInitialPointIndex; }
113 void setInitialPointIndex(uint8_t idx) { fInitialPointIndex = idx; }
114 };
115 AttrContainer fAttrContaier = { (int)SkPathDirection::kCW, 0 };
116
117 using INHERITED = GeometryNode;
118};
119
120} // namespace sksg
121
122#endif // SkSGRect_DEFINED
SkPathDirection
Definition: SkPathTypes.h:34
#define SG_ATTRIBUTE(attr_name, attr_type, attr_container)
Definition: SkSGNode.h:100
#define SG_MAPPED_ATTRIBUTE(attr_name, attr_type, attr_container)
Definition: SkSGNode.h:113
Definition: SkPath.h:59
bool onContains(const SkPoint &) const override
Definition: SkSGRect.cpp:54
void onDraw(SkCanvas *, const SkPaint &) const override
Definition: SkSGRect.cpp:50
static sk_sp< RRect > Make(const SkRRect &rr)
Definition: SkSGRect.h:83
void onClip(SkCanvas *, bool antiAlias) const override
Definition: SkSGRect.cpp:46
static sk_sp< RRect > Make()
Definition: SkSGRect.h:82
SkRect onRevalidate(InvalidationController *, const SkMatrix &) override
Definition: SkSGRect.cpp:70
SkPath onAsPath() const override
Definition: SkSGRect.cpp:76
SkRect onRevalidate(InvalidationController *, const SkMatrix &) override
Definition: SkSGRect.cpp:34
SkPath onAsPath() const override
Definition: SkSGRect.cpp:40
static sk_sp< Rect > Make(const SkRect &r)
Definition: SkSGRect.h:37
void onClip(SkCanvas *, bool antiAlias) const override
Definition: SkSGRect.cpp:22
static sk_sp< Rect > Make()
Definition: SkSGRect.h:36
bool onContains(const SkPoint &) const override
Definition: SkSGRect.cpp:30
void onDraw(SkCanvas *, const SkPaint &) const override
Definition: SkSGRect.cpp:26
float SkScalar
Definition: extension.cpp:12
#define R(r)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets dir
Definition: switches.h:145
Definition: Skottie.h:32
#define T
Definition: precompiler.cc:65
static constexpr SkRect MakeEmpty()
Definition: SkRect.h:595