2 * Copyright 2006 The Android Open Source Project
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #ifndef Sk2DPathEffect_DEFINED
9 #define Sk2DPathEffect_DEFINED
12 #include "SkPathEffect.h"
15 class SK_API Sk2DPathEffect : public SkPathEffect {
17 virtual bool filterPath(SkPath*, const SkPath&, SkStrokeRec*, const SkRect*) const SK_OVERRIDE;
19 SK_DECLARE_UNFLATTENABLE_OBJECT()
22 /** New virtual, to be overridden by subclasses.
23 This is called once from filterPath, and provides the
24 uv parameter bounds for the path. Subsequent calls to
25 next() will receive u and v values within these bounds,
26 and then a call to end() will signal the end of processing.
28 virtual void begin(const SkIRect& uvBounds, SkPath* dst) const;
29 virtual void next(const SkPoint& loc, int u, int v, SkPath* dst) const;
30 virtual void end(SkPath* dst) const;
32 /** Low-level virtual called per span of locations in the u-direction.
33 The default implementation calls next() repeatedly with each
36 virtual void nextSpan(int u, int v, int ucount, SkPath* dst) const;
38 const SkMatrix& getMatrix() const { return fMatrix; }
40 // protected so that subclasses can call this during unflattening
41 explicit Sk2DPathEffect(const SkMatrix& mat);
42 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
43 explicit Sk2DPathEffect(SkReadBuffer&);
45 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
48 SkMatrix fMatrix, fInverse;
49 bool fMatrixIsInvertible;
52 Sk2DPathEffect(const Sk2DPathEffect&);
53 Sk2DPathEffect& operator=(const Sk2DPathEffect&);
55 friend class Sk2DPathEffectBlitter;
56 typedef SkPathEffect INHERITED;
59 class SK_API SkLine2DPathEffect : public Sk2DPathEffect {
61 static SkLine2DPathEffect* Create(SkScalar width, const SkMatrix& matrix) {
62 return SkNEW_ARGS(SkLine2DPathEffect, (width, matrix));
65 virtual bool filterPath(SkPath* dst, const SkPath& src,
66 SkStrokeRec*, const SkRect*) const SK_OVERRIDE;
68 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLine2DPathEffect)
71 SkLine2DPathEffect(SkScalar width, const SkMatrix& matrix)
72 : Sk2DPathEffect(matrix), fWidth(width) {}
73 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
74 explicit SkLine2DPathEffect(SkReadBuffer&);
77 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
79 virtual void nextSpan(int u, int v, int ucount, SkPath*) const SK_OVERRIDE;
84 typedef Sk2DPathEffect INHERITED;
87 class SK_API SkPath2DPathEffect : public Sk2DPathEffect {
90 * Stamp the specified path to fill the shape, using the matrix to define
93 static SkPath2DPathEffect* Create(const SkMatrix& matrix, const SkPath& path) {
94 return SkNEW_ARGS(SkPath2DPathEffect, (matrix, path));
97 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPath2DPathEffect)
100 SkPath2DPathEffect(const SkMatrix&, const SkPath&);
101 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
102 explicit SkPath2DPathEffect(SkReadBuffer& buffer);
104 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
106 virtual void next(const SkPoint&, int u, int v, SkPath*) const SK_OVERRIDE;
111 typedef Sk2DPathEffect INHERITED;