Skia
2D Graphics Library
Sk2DPathEffect.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 Sk2DPathEffect_DEFINED
9 #define Sk2DPathEffect_DEFINED
10 
12 #include "include/core/SkMatrix.h"
13 #include "include/core/SkPath.h"
15 
17 protected:
24  virtual void begin(const SkIRect& uvBounds, SkPath* dst) const;
25  virtual void next(const SkPoint& loc, int u, int v, SkPath* dst) const;
26  virtual void end(SkPath* dst) const;
27 
32  virtual void nextSpan(int u, int v, int ucount, SkPath* dst) const;
33 
34  const SkMatrix& getMatrix() const { return fMatrix; }
35 
36  // protected so that subclasses can call this during unflattening
37  explicit Sk2DPathEffect(const SkMatrix& mat);
38  void flatten(SkWriteBuffer&) const override;
39  bool onFilterPath(SkPath*, const SkPath&, SkStrokeRec*, const SkRect*) const override;
40 
41 private:
42  SkMatrix fMatrix, fInverse;
43  bool fMatrixIsInvertible;
44 
45  // illegal
47  Sk2DPathEffect& operator=(const Sk2DPathEffect&);
48 
49  friend class Sk2DPathEffectBlitter;
50  using INHERITED = SkPathEffect;
51 };
52 
54 public:
55  static sk_sp<SkPathEffect> Make(SkScalar width, const SkMatrix& matrix) {
56  if (!(width >= 0)) {
57  return nullptr;
58  }
59  return sk_sp<SkPathEffect>(new SkLine2DPathEffect(width, matrix));
60  }
61 
62 
63 protected:
64  SkLine2DPathEffect(SkScalar width, const SkMatrix& matrix)
65  : Sk2DPathEffect(matrix), fWidth(width) {
66  SkASSERT(width >= 0);
67  }
68  void flatten(SkWriteBuffer&) const override;
69  bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override;
70 
71  void nextSpan(int u, int v, int ucount, SkPath*) const override;
72 
73 private:
75 
76  SkScalar fWidth;
77 
78  using INHERITED = Sk2DPathEffect;
79 };
80 
82 public:
87  static sk_sp<SkPathEffect> Make(const SkMatrix& matrix, const SkPath& path) {
88  return sk_sp<SkPathEffect>(new SkPath2DPathEffect(matrix, path));
89  }
90 
91 protected:
93  void flatten(SkWriteBuffer&) const override;
94 
95  void next(const SkPoint&, int u, int v, SkPath*) const override;
96 
97 private:
99 
100  SkPath fPath;
101 
102  using INHERITED = Sk2DPathEffect;
103 };
104 
105 #endif
SkLine2DPathEffect::SkLine2DPathEffect
SkLine2DPathEffect(SkScalar width, const SkMatrix &matrix)
Definition: Sk2DPathEffect.h:64
Sk2DPathEffect::getMatrix
const SkMatrix & getMatrix() const
Definition: Sk2DPathEffect.h:34
SkFlattenable.h
SkLine2DPathEffect
Definition: Sk2DPathEffect.h:53
SkPath
Definition: SkPath.h:44
SkRefCnt
Definition: SkRefCnt.h:118
SkPath2DPathEffect::Make
static sk_sp< SkPathEffect > Make(const SkMatrix &matrix, const SkPath &path)
Stamp the specified path to fill the shape, using the matrix to define the latice.
Definition: Sk2DPathEffect.h:87
SkLine2DPathEffect::nextSpan
void nextSpan(int u, int v, int ucount, SkPath *) const override
Low-level virtual called per span of locations in the u-direction.
Sk2DPathEffect::begin
virtual void begin(const SkIRect &uvBounds, SkPath *dst) const
New virtual, to be overridden by subclasses.
SkPathEffect
Definition: SkPathEffect.h:27
SkPath2DPathEffect::SkPath2DPathEffect
SkPath2DPathEffect(const SkMatrix &, const SkPath &)
sk_sp< SkPathEffect >
SkPoint
Definition: SkPoint.h:160
SK_API
#define SK_API
Definition: SkTypes.h:181
SkASSERT
#define SkASSERT(cond)
Definition: SkTypes.h:460
SkStrokeRec
Definition: SkStrokeRec.h:17
SkScalar
float SkScalar
Definition: SkScalar.h:16
SkPath.h
Sk2DPathEffect::flatten
void flatten(SkWriteBuffer &) const override
Override this if your subclass needs to record data that it will need to recreate itself from its Cre...
Sk2DPathEffect::end
virtual void end(SkPath *dst) const
SkPathEffect.h
SkMatrix
Definition: SkMatrix.h:48
SkMatrix.h
SkIRect
Definition: SkRect.h:28
SK_FLATTENABLE_HOOKS
#define SK_FLATTENABLE_HOOKS(type)
Definition: SkFlattenable.h:110
SkLine2DPathEffect::flatten
void flatten(SkWriteBuffer &) const override
Override this if your subclass needs to record data that it will need to recreate itself from its Cre...
SkLine2DPathEffect::Make
static sk_sp< SkPathEffect > Make(SkScalar width, const SkMatrix &matrix)
Definition: Sk2DPathEffect.h:55
SkPath2DPathEffect
Definition: Sk2DPathEffect.h:81
SkPathEffect::SkPathEffect
SkPathEffect()
Definition: SkPathEffect.h:165
Sk2DPathEffect::Sk2DPathEffect
Sk2DPathEffect(const SkMatrix &mat)
Sk2DPathEffect::nextSpan
virtual void nextSpan(int u, int v, int ucount, SkPath *dst) const
Low-level virtual called per span of locations in the u-direction.
SkPath2DPathEffect::next
void next(const SkPoint &, int u, int v, SkPath *) const override
SkRect
Definition: SkRect.h:579
Sk2DPathEffect
Definition: Sk2DPathEffect.h:16
Sk2DPathEffect::next
virtual void next(const SkPoint &loc, int u, int v, SkPath *dst) const
Sk2DPathEffect::onFilterPath
bool onFilterPath(SkPath *, const SkPath &, SkStrokeRec *, const SkRect *) const override
SkPath2DPathEffect::flatten
void flatten(SkWriteBuffer &) const override
Override this if your subclass needs to record data that it will need to recreate itself from its Cre...
SkLine2DPathEffect::onFilterPath
bool onFilterPath(SkPath *dst, const SkPath &src, SkStrokeRec *, const SkRect *) const override