Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkPathEffect.h
Go to the documentation of this file.
1/*
2 * Copyright 2006 The Android Open Source Project
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 SkPathEffect_DEFINED
9#define SkPathEffect_DEFINED
10
15
16// TODO(kjlubick) update clients and remove this unnecessary #include
17#include "include/core/SkPath.h" // IWYU pragma: keep
18
19#include <cstddef>
20#include <cstdint>
21
22class SkMatrix;
23class SkStrokeRec;
24struct SkDeserialProcs;
25struct SkRect;
26
27/** \class SkPathEffect
28
29 SkPathEffect is the base class for objects in the SkPaint that affect
30 the geometry of a drawing primitive before it is transformed by the
31 canvas' matrix and drawn.
32
33 Dashing is implemented as a subclass of SkPathEffect.
34*/
36public:
37 /**
38 * Returns a patheffect that apples each effect (first and second) to the original path,
39 * and returns a path with the sum of these.
40 *
41 * result = first(path) + second(path)
42 *
43 */
45
46 /**
47 * Returns a patheffect that applies the inner effect to the path, and then applies the
48 * outer effect to the result of the inner's.
49 *
50 * result = outer(inner(path))
51 */
52 static sk_sp<SkPathEffect> MakeCompose(sk_sp<SkPathEffect> outer, sk_sp<SkPathEffect> inner);
53
57
58 // move to base?
59
60 enum DashType {
61 kNone_DashType, //!< ignores the info parameter
62 kDash_DashType, //!< fills in all of the info parameter
63 };
64
65 struct DashInfo {
66 DashInfo() : fIntervals(nullptr), fCount(0), fPhase(0) {}
67 DashInfo(SkScalar* intervals, int32_t count, SkScalar phase)
68 : fIntervals(intervals), fCount(count), fPhase(phase) {}
69
70 SkScalar* fIntervals; //!< Length of on/off intervals for dashed lines
71 // Even values represent ons, and odds offs
72 int32_t fCount; //!< Number of intervals in the dash. Should be even number
73 SkScalar fPhase; //!< Offset into the dashed interval pattern
74 // mod the sum of all intervals
75 };
76
77 DashType asADash(DashInfo* info) const;
78
79 /**
80 * Given a src path (input) and a stroke-rec (input and output), apply
81 * this effect to the src path, returning the new path in dst, and return
82 * true. If this effect cannot be applied, return false and ignore dst
83 * and stroke-rec.
84 *
85 * The stroke-rec specifies the initial request for stroking (if any).
86 * The effect can treat this as input only, or it can choose to change
87 * the rec as well. For example, the effect can decide to change the
88 * stroke's width or join, or the effect can change the rec from stroke
89 * to fill (or fill to stroke) in addition to returning a new (dst) path.
90 *
91 * If this method returns true, the caller will apply (as needed) the
92 * resulting stroke-rec to dst and then draw.
93 */
94 bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect* cullR) const;
95
96 /** Version of filterPath that can be called when the CTM is known. */
97 bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect* cullR,
98 const SkMatrix& ctm) const;
99
100 /** True if this path effect requires a valid CTM */
101 bool needsCTM() const;
102
103 static sk_sp<SkPathEffect> Deserialize(const void* data, size_t size,
104 const SkDeserialProcs* procs = nullptr);
105
106private:
107 SkPathEffect() = default;
108 friend class SkPathEffectBase;
109
110 using INHERITED = SkFlattenable;
111};
112
113#endif
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
int count
#define SK_API
Definition SkAPI.h:35
static sk_sp< SkFlattenable > Deserialize(Type, const void *data, size_t length, const SkDeserialProcs *procs=nullptr)
@ kNone_DashType
ignores the info parameter
@ kDash_DashType
fills in all of the info parameter
static SkFlattenable::Type GetFlattenableType()
float SkScalar
Definition extension.cpp:12
SkScalar fPhase
Offset into the dashed interval pattern.
int32_t fCount
Number of intervals in the dash. Should be even number.
SkScalar * fIntervals
Length of on/off intervals for dashed lines.
DashInfo(SkScalar *intervals, int32_t count, SkScalar phase)