blob: ed7f674f89caba74c3106a76580314597fa655e2 [file] [log] [blame]
reed@android.com8a1c16f2008-12-17 15:59:43 +00001/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00002 * Copyright 2006 The Android Open Source Project
reed@android.com8a1c16f2008-12-17 15:59:43 +00003 *
epoger@google.comec3ed6a2011-07-28 14:26:00 +00004 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
reed@android.com8a1c16f2008-12-17 15:59:43 +00006 */
7
8#ifndef Sk2DPathEffect_DEFINED
9#define Sk2DPathEffect_DEFINED
10
reed@google.com18dc4772011-08-09 18:47:40 +000011#include "SkPath.h"
reed@android.com8a1c16f2008-12-17 15:59:43 +000012#include "SkPathEffect.h"
13#include "SkMatrix.h"
14
tfarina@chromium.org6806fe82012-10-12 14:41:39 +000015class SK_API Sk2DPathEffect : public SkPathEffect {
reed@android.com8a1c16f2008-12-17 15:59:43 +000016public:
17 Sk2DPathEffect(const SkMatrix& mat);
18
reed@google.com548a1f32012-12-18 16:12:09 +000019 virtual bool filterPath(SkPath*, const SkPath&,
reed@google.com4bbdeac2013-01-24 21:03:11 +000020 SkStrokeRec*, const SkRect*) const SK_OVERRIDE;
reed@android.com8a1c16f2008-12-17 15:59:43 +000021
djsollen@google.comba28d032012-03-26 17:57:35 +000022 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Sk2DPathEffect)
reed@android.com8a1c16f2008-12-17 15:59:43 +000023
24protected:
25 /** New virtual, to be overridden by subclasses.
26 This is called once from filterPath, and provides the
27 uv parameter bounds for the path. Subsequent calls to
28 next() will receive u and v values within these bounds,
29 and then a call to end() will signal the end of processing.
30 */
reed@google.com548a1f32012-12-18 16:12:09 +000031 virtual void begin(const SkIRect& uvBounds, SkPath* dst) const;
32 virtual void next(const SkPoint& loc, int u, int v, SkPath* dst) const;
33 virtual void end(SkPath* dst) const;
reed@android.com8a1c16f2008-12-17 15:59:43 +000034
35 /** Low-level virtual called per span of locations in the u-direction.
36 The default implementation calls next() repeatedly with each
37 location.
38 */
reed@google.com548a1f32012-12-18 16:12:09 +000039 virtual void nextSpan(int u, int v, int ucount, SkPath* dst) const;
reed@android.com8a1c16f2008-12-17 15:59:43 +000040
41 const SkMatrix& getMatrix() const { return fMatrix; }
42
43 // protected so that subclasses can call this during unflattening
44 Sk2DPathEffect(SkFlattenableReadBuffer&);
djsollen@google.com54924242012-03-29 15:18:04 +000045 virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
reed@android.com8a1c16f2008-12-17 15:59:43 +000046
47private:
48 SkMatrix fMatrix, fInverse;
mike@reedtribe.org90bf4272012-04-14 19:06:16 +000049 bool fMatrixIsInvertible;
50
reed@android.com8a1c16f2008-12-17 15:59:43 +000051 // illegal
52 Sk2DPathEffect(const Sk2DPathEffect&);
53 Sk2DPathEffect& operator=(const Sk2DPathEffect&);
54
reed@android.com8a1c16f2008-12-17 15:59:43 +000055 friend class Sk2DPathEffectBlitter;
56 typedef SkPathEffect INHERITED;
57};
58
tfarina@chromium.org6806fe82012-10-12 14:41:39 +000059class SK_API SkLine2DPathEffect : public Sk2DPathEffect {
scroggo@google.comd8a6cc82012-09-12 18:53:49 +000060public:
61 SkLine2DPathEffect(SkScalar width, const SkMatrix& matrix)
62 : Sk2DPathEffect(matrix), fWidth(width) {}
63
reed@google.com548a1f32012-12-18 16:12:09 +000064 virtual bool filterPath(SkPath* dst, const SkPath& src,
reed@google.com4bbdeac2013-01-24 21:03:11 +000065 SkStrokeRec*, const SkRect*) const SK_OVERRIDE;
scroggo@google.comd8a6cc82012-09-12 18:53:49 +000066
67 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLine2DPathEffect)
68
69protected:
reed@google.com548a1f32012-12-18 16:12:09 +000070 virtual void nextSpan(int u, int v, int ucount, SkPath*) const SK_OVERRIDE;
scroggo@google.comd8a6cc82012-09-12 18:53:49 +000071
72 SkLine2DPathEffect(SkFlattenableReadBuffer&);
73
74 virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
75
76private:
77 SkScalar fWidth;
78
79 typedef Sk2DPathEffect INHERITED;
80};
81
tfarina@chromium.org6806fe82012-10-12 14:41:39 +000082class SK_API SkPath2DPathEffect : public Sk2DPathEffect {
reed@google.com18dc4772011-08-09 18:47:40 +000083public:
84 /**
85 * Stamp the specified path to fill the shape, using the matrix to define
86 * the latice.
87 */
88 SkPath2DPathEffect(const SkMatrix&, const SkPath&);
rmistry@google.comfbfcd562012-08-23 18:09:54 +000089
djsollen@google.comba28d032012-03-26 17:57:35 +000090 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPath2DPathEffect)
reed@google.com18dc4772011-08-09 18:47:40 +000091
92protected:
93 SkPath2DPathEffect(SkFlattenableReadBuffer& buffer);
djsollen@google.com54924242012-03-29 15:18:04 +000094 virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
reed@google.com18dc4772011-08-09 18:47:40 +000095
reed@google.com548a1f32012-12-18 16:12:09 +000096 virtual void next(const SkPoint&, int u, int v, SkPath*) const SK_OVERRIDE;
reed@google.com18dc4772011-08-09 18:47:40 +000097
98private:
99 SkPath fPath;
100
101 typedef Sk2DPathEffect INHERITED;
102};
103
reed@android.com8a1c16f2008-12-17 15:59:43 +0000104#endif