Skia
2DGraphicsLibrary
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Sk1DPathEffect.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 Sk1DPathEffect_DEFINED
9 #define Sk1DPathEffect_DEFINED
10 
11 #include "SkPathEffect.h"
12 #include "SkPath.h"
13 
14 class SkPathMeasure;
15 
16 // This class is not exported to java.
17 class SK_API Sk1DPathEffect : public SkPathEffect {
18 public:
19  virtual bool filterPath(SkPath* dst, const SkPath& src,
20  SkStrokeRec*, const SkRect*) const override;
21 
22 protected:
26  virtual SkScalar begin(SkScalar contourLength) const = 0;
32  virtual SkScalar next(SkPath* dst, SkScalar dist, SkPathMeasure&) const = 0;
33 
34 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
35  bool exposedInAndroidJavaAPI() const override { return true; }
36 #endif
37 
38 private:
39  typedef SkPathEffect INHERITED;
40 };
41 
42 class SK_API SkPath1DPathEffect : public Sk1DPathEffect {
43 public:
44  enum Style {
45  kTranslate_Style, // translate the shape to each position
46  kRotate_Style, // rotate the shape about its center
47  kMorph_Style, // transform each point, and turn lines into curves
48 
49  kLastEnum_Style = kMorph_Style,
50  };
51 
59  static sk_sp<SkPathEffect> Make(const SkPath& path, SkScalar advance, SkScalar phase, Style);
60 
61  virtual bool filterPath(SkPath*, const SkPath&,
62  SkStrokeRec*, const SkRect*) const override;
63 
64  SK_TO_STRING_OVERRIDE()
65  SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPath1DPathEffect)
66 
67 protected:
68  SkPath1DPathEffect(const SkPath& path, SkScalar advance, SkScalar phase, Style);
69  void flatten(SkWriteBuffer&) const override;
70 
71  // overrides from Sk1DPathEffect
72  SkScalar begin(SkScalar contourLength) const override;
73  SkScalar next(SkPath*, SkScalar, SkPathMeasure&) const override;
74 
75 private:
76  SkPath fPath; // copied from constructor
77  SkScalar fAdvance; // copied from constructor
78  SkScalar fInitialOffset; // computed from phase
79  Style fStyle; // copied from constructor
80 
81  typedef Sk1DPathEffect INHERITED;
82 };
83 
84 #endif
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: SkStrokeRec.h:16
Definition: SkRefCnt.h:125
virtual SkScalar next(SkPath *dst, SkScalar dist, SkPathMeasure &) const =0
Called with the current distance along the path, with the current matrix for the point/tangent at the...
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...
Definition: Sk1DPathEffect.h:42
virtual bool filterPath(SkPath *dst, const SkPath &src, SkStrokeRec *, const SkRect *) const override
Given a src path (input) and a stroke-rec (input and output), apply this effect to the src path...
Definition: SkWriteBuffer.h:27
Definition: SkRect.h:404
Definition: Sk1DPathEffect.h:17
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
virtual SkScalar begin(SkScalar contourLength) const =0
Called at the start of each contour, returns the initial offset into that contour.
Definition: SkPathMeasure.h:16