Skia
2DGraphicsLibrary
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SkPathEffect.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 SkPathEffect_DEFINED
9 #define SkPathEffect_DEFINED
10 
11 #include "SkFlattenable.h"
12 #include "SkPath.h"
13 #include "SkPoint.h"
14 #include "SkRect.h"
15 
16 class SkPath;
17 class SkStrokeRec;
18 
27 class SK_API SkPathEffect : public SkFlattenable {
28 public:
36  static sk_sp<SkPathEffect> MakeSum(sk_sp<SkPathEffect> first, sk_sp<SkPathEffect> second);
37 
44  static sk_sp<SkPathEffect> MakeCompose(sk_sp<SkPathEffect> outer, sk_sp<SkPathEffect> inner);
45 
61  virtual bool filterPath(SkPath* dst, const SkPath& src,
62  SkStrokeRec*, const SkRect* cullR) const = 0;
63 
68  virtual void computeFastBounds(SkRect* dst, const SkRect& src) const;
69 
75  class PointData {
76  public:
77  PointData()
78  : fFlags(0)
79  , fPoints(NULL)
80  , fNumPoints(0) {
81  fSize.set(SK_Scalar1, SK_Scalar1);
82  // 'asPoints' needs to initialize/fill-in 'fClipRect' if it sets
83  // the kUseClip flag
84  }
85  ~PointData() {
86  delete [] fPoints;
87  }
88 
89  // TODO: consider using passed-in flags to limit the work asPoints does.
90  // For example, a kNoPath flag could indicate don't bother generating
91  // stamped solutions.
92 
93  // Currently none of these flags are supported.
94  enum PointFlags {
95  kCircles_PointFlag = 0x01, // draw points as circles (instead of rects)
96  kUsePath_PointFlag = 0x02, // draw points as stamps of the returned path
97  kUseClip_PointFlag = 0x04, // apply 'fClipRect' before drawing the points
98  };
99 
100  uint32_t fFlags; // flags that impact the drawing of the points
101  SkPoint* fPoints; // the center point of each generated point
102  int fNumPoints; // number of points in fPoints
103  SkVector fSize; // the size to draw the points
104  SkRect fClipRect; // clip required to draw the points (if kUseClip is set)
105  SkPath fPath; // 'stamp' to be used at each point (if kUsePath is set)
106 
107  SkPath fFirst; // If not empty, contains geometry for first point
108  SkPath fLast; // If not empty, contains geometry for last point
109  };
110 
115  virtual bool asPoints(PointData* results, const SkPath& src,
116  const SkStrokeRec&, const SkMatrix&,
117  const SkRect* cullR) const;
118 
129  enum DashType {
132  };
133 
134  struct DashInfo {
135  DashInfo() : fIntervals(NULL), fCount(0), fPhase(0) {}
136  DashInfo(SkScalar* intervals, int32_t count, SkScalar phase)
137  : fIntervals(intervals), fCount(count), fPhase(phase) {}
138 
139  SkScalar* fIntervals;
140  // Even values represent ons, and odds offs
141  int32_t fCount;
142  SkScalar fPhase;
143  // mod the sum of all intervals
144  };
145 
146  virtual DashType asADash(DashInfo* info) const;
147 
148  SK_TO_STRING_PUREVIRT()
149  SK_DEFINE_FLATTENABLE_TYPE(SkPathEffect)
150 
151 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
152  virtual bool exposedInAndroidJavaAPI() const { return false; }
154 #endif
155 
156  SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
157 
158 protected:
159  SkPathEffect() {}
160 
161 private:
162  // illegal
163  SkPathEffect(const SkPathEffect&);
164  SkPathEffect& operator=(const SkPathEffect&);
165 
166  typedef SkFlattenable INHERITED;
167 };
168 
169 #endif
Definition: SkPathEffect.h:134
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
DashType
If the PathEffect can be represented as a dash pattern, asADash will return kDash_DashType and None o...
Definition: SkPathEffect.h:129
Definition: SkStrokeRec.h:16
Definition: SkPoint.h:156
The SkMatrix class holds a 3x3 matrix for transforming coordinates.
Definition: SkMatrix.h:28
SkScalar fPhase
Offset into the dashed interval pattern.
Definition: SkPathEffect.h:142
SkFlattenable is the base class for objects that need to be flattened into a data stream for either t...
Definition: SkFlattenable.h:70
ignores the info parameter
Definition: SkPathEffect.h:130
int32_t fCount
Number of intervals in the dash. Should be even number.
Definition: SkPathEffect.h:141
Definition: SkRect.h:404
SkScalar * fIntervals
Length of on/off intervals for dashed lines.
Definition: SkPathEffect.h:139
fills in all of the info parameter
Definition: SkPathEffect.h:131
PointData aggregates all the information needed to draw the point primitives returned by an 'asPoints...
Definition: SkPathEffect.h:75