Skia
2DGraphicsLibrary
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Sk2DPathEffect.h
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 
11 #include "SkPath.h"
12 #include "SkPathEffect.h"
13 #include "SkMatrix.h"
14 
15 class SK_API Sk2DPathEffect : public SkPathEffect {
16 public:
17  bool filterPath(SkPath*, const SkPath&, SkStrokeRec*, const SkRect*) const override;
18 
19 protected:
26  virtual void begin(const SkIRect& uvBounds, SkPath* dst) const;
27  virtual void next(const SkPoint& loc, int u, int v, SkPath* dst) const;
28  virtual void end(SkPath* dst) const;
29 
34  virtual void nextSpan(int u, int v, int ucount, SkPath* dst) const;
35 
36  const SkMatrix& getMatrix() const { return fMatrix; }
37 
38  // protected so that subclasses can call this during unflattening
39  explicit Sk2DPathEffect(const SkMatrix& mat);
40  void flatten(SkWriteBuffer&) const override;
41 
42  SK_TO_STRING_OVERRIDE()
43 
44 private:
45  SkMatrix fMatrix, fInverse;
46  bool fMatrixIsInvertible;
47 
48  // illegal
50  Sk2DPathEffect& operator=(const Sk2DPathEffect&);
51 
52  friend class Sk2DPathEffectBlitter;
53  typedef SkPathEffect INHERITED;
54 };
55 
56 class SK_API SkLine2DPathEffect : public Sk2DPathEffect {
57 public:
58  static sk_sp<SkPathEffect> Make(SkScalar width, const SkMatrix& matrix) {
59  return sk_sp<SkPathEffect>(new SkLine2DPathEffect(width, matrix));
60  }
61 
62  virtual bool filterPath(SkPath* dst, const SkPath& src,
63  SkStrokeRec*, const SkRect*) const override;
64 
65  SK_TO_STRING_OVERRIDE()
66  SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLine2DPathEffect)
67 
68 protected:
69  SkLine2DPathEffect(SkScalar width, const SkMatrix& matrix)
70  : Sk2DPathEffect(matrix), fWidth(width) {}
71  void flatten(SkWriteBuffer&) const override;
72 
73  void nextSpan(int u, int v, int ucount, SkPath*) const override;
74 
75 private:
76  SkScalar fWidth;
77 
78  typedef Sk2DPathEffect INHERITED;
79 };
80 
81 class SK_API SkPath2DPathEffect : public Sk2DPathEffect {
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  SK_TO_STRING_OVERRIDE()
92  SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPath2DPathEffect)
93 
94 protected:
95  SkPath2DPathEffect(const SkMatrix&, const SkPath&);
96  void flatten(SkWriteBuffer&) const override;
97 
98  void next(const SkPoint&, int u, int v, SkPath*) const override;
99 
100 private:
101  SkPath fPath;
102 
103  typedef Sk2DPathEffect INHERITED;
104 };
105 
106 #endif
bool filterPath(SkPath *, const SkPath &, SkStrokeRec *, const SkRect *) const override
Given a src path (input) and a stroke-rec (input and output), apply this effect to the src path...
The SkPath class encapsulates compound (multiple contour) geometric paths consisting of straight line...
Definition: SkPath.h:25
SkPathEffect is the base class for objects in the SkPaint that affect the geometry of a drawing primi...
Definition: SkPathEffect.h:27
Definition: Sk2DPathEffect.h:56
Definition: SkStrokeRec.h:16
Definition: SkPoint.h:156
The SkMatrix class holds a 3x3 matrix for transforming coordinates.
Definition: SkMatrix.h:28
Definition: SkRefCnt.h:125
Definition: Sk2DPathEffect.h:15
virtual bool filterPath(SkPath *dst, const SkPath &src, SkStrokeRec *, const SkRect *cullR) const =0
Given a src path (input) and a stroke-rec (input and output), apply this effect to the src path...
void flatten(SkWriteBuffer &) const override
Override this if your subclass needs to record data that it will need to recreate itself from its Cre...
virtual void nextSpan(int u, int v, int ucount, SkPath *dst) const
Low-level virtual called per span of locations in the u-direction.
Definition: SkWriteBuffer.h:27
Definition: SkRect.h:404
Definition: Sk2DPathEffect.h:81
virtual void flatten(SkWriteBuffer &) const
Override this if your subclass needs to record data that it will need to recreate itself from its Cre...
Definition: SkFlattenable.h:117
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
SkIRect holds four 32 bit integer coordinates for a rectangle.
Definition: SkRect.h:20