Skia
2D Graphics Library
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 
12 #include "include/core/SkScalar.h"
13 // not needed, but some of our clients need it (they don't IWYU)
14 #include "include/core/SkPath.h"
15 
16 class SkPath;
17 struct SkRect;
18 class SkStrokeRec;
19 
28 class SK_API SkPathEffect : public SkFlattenable {
29 public:
38 
46 
48  return kSkPathEffect_Type;
49  }
50 
51  // move to base?
52 
53  enum DashType {
56  };
57 
58  struct DashInfo {
59  DashInfo() : fIntervals(nullptr), fCount(0), fPhase(0) {}
60  DashInfo(SkScalar* intervals, int32_t count, SkScalar phase)
61  : fIntervals(intervals), fCount(count), fPhase(phase) {}
62 
64  // Even values represent ons, and odds offs
65  int32_t fCount;
67  // mod the sum of all intervals
68  };
69 
70  DashType asADash(DashInfo* info) const;
71 
87  bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect* cullR) const;
88 
90  bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect* cullR,
91  const SkMatrix& ctm) const;
92 
94  bool needsCTM() const;
95 
96  static sk_sp<SkPathEffect> Deserialize(const void* data, size_t size,
97  const SkDeserialProcs* procs = nullptr);
98 
99 private:
100  SkPathEffect() = default;
101  friend class SkPathEffectBase;
102 
103  using INHERITED = SkFlattenable;
104 };
105 
106 #endif
float SkScalar
Definition: SkScalar.h:14
SkFlattenable is the base class for objects that need to be flattened into a data stream for either t...
Definition: SkFlattenable.h:28
SkFlattenable()
Definition: SkFlattenable.h:43
Type
Definition: SkFlattenable.h:30
@ kSkPathEffect_Type
Definition: SkFlattenable.h:37
SkMatrix holds a 3x3 matrix for transforming coordinates.
Definition: SkMatrix.h:53
SkPathEffect is the base class for objects in the SkPaint that affect the geometry of a drawing primi...
Definition: SkPathEffect.h:28
static sk_sp< SkPathEffect > MakeSum(sk_sp< SkPathEffect > first, sk_sp< SkPathEffect > second)
Returns a patheffect that apples each effect (first and second) to the original path,...
bool filterPath(SkPath *dst, const SkPath &src, SkStrokeRec *, const SkRect *cullR, const SkMatrix &ctm) const
Version of filterPath that can be called when the CTM is known.
static sk_sp< SkPathEffect > Deserialize(const void *data, size_t size, const SkDeserialProcs *procs=nullptr)
static sk_sp< SkPathEffect > MakeCompose(sk_sp< SkPathEffect > outer, sk_sp< SkPathEffect > inner)
Returns a patheffect that applies the inner effect to the path, and then applies the outer effect to ...
DashType
Definition: SkPathEffect.h:53
@ kNone_DashType
ignores the info parameter
Definition: SkPathEffect.h:54
@ kDash_DashType
fills in all of the info parameter
Definition: SkPathEffect.h:55
DashType asADash(DashInfo *info) const
static SkFlattenable::Type GetFlattenableType()
Definition: SkPathEffect.h:47
bool needsCTM() const
True if this path effect requires a valid CTM.
bool filterPath(SkPath *dst, const SkPath &src, SkStrokeRec *, const SkRect *cullR) const
Given a src path (input) and a stroke-rec (input and output), apply this effect to the src path,...
SkPath contain geometry.
Definition: SkPath.h:58
Definition: SkRefCnt.h:119
Definition: SkStrokeRec.h:17
Definition: SkSerialProcs.h:97
Definition: SkPathEffect.h:58
SkScalar fPhase
Offset into the dashed interval pattern.
Definition: SkPathEffect.h:66
int32_t fCount
Number of intervals in the dash. Should be even number.
Definition: SkPathEffect.h:65
SkScalar * fIntervals
Length of on/off intervals for dashed lines.
Definition: SkPathEffect.h:63
DashInfo(SkScalar *intervals, int32_t count, SkScalar phase)
Definition: SkPathEffect.h:60
DashInfo()
Definition: SkPathEffect.h:59
SkRect holds four float coordinates describing the upper and lower bounds of a rectangle.
Definition: SkRect.h:582