blob: f037e335085674ae3108d8626e563b1e30056ccb [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:
commit-bot@chromium.org0a2bf902014-02-20 20:40:19 +000017 static Sk2DPathEffect* Create(const SkMatrix& mat) {
18 return SkNEW_ARGS(Sk2DPathEffect, (mat));
19 }
reed@android.com8a1c16f2008-12-17 15:59:43 +000020
reed@google.com548a1f32012-12-18 16:12:09 +000021 virtual bool filterPath(SkPath*, const SkPath&,
reed@google.com4bbdeac2013-01-24 21:03:11 +000022 SkStrokeRec*, const SkRect*) const SK_OVERRIDE;
reed@android.com8a1c16f2008-12-17 15:59:43 +000023
djsollen@google.comba28d032012-03-26 17:57:35 +000024 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Sk2DPathEffect)
reed@android.com8a1c16f2008-12-17 15:59:43 +000025
26protected:
27 /** New virtual, to be overridden by subclasses.
28 This is called once from filterPath, and provides the
29 uv parameter bounds for the path. Subsequent calls to
30 next() will receive u and v values within these bounds,
31 and then a call to end() will signal the end of processing.
32 */
reed@google.com548a1f32012-12-18 16:12:09 +000033 virtual void begin(const SkIRect& uvBounds, SkPath* dst) const;
34 virtual void next(const SkPoint& loc, int u, int v, SkPath* dst) const;
35 virtual void end(SkPath* dst) const;
reed@android.com8a1c16f2008-12-17 15:59:43 +000036
37 /** Low-level virtual called per span of locations in the u-direction.
38 The default implementation calls next() repeatedly with each
39 location.
40 */
reed@google.com548a1f32012-12-18 16:12:09 +000041 virtual void nextSpan(int u, int v, int ucount, SkPath* dst) const;
reed@android.com8a1c16f2008-12-17 15:59:43 +000042
43 const SkMatrix& getMatrix() const { return fMatrix; }
44
45 // protected so that subclasses can call this during unflattening
commit-bot@chromium.org8b0e8ac2014-01-30 18:58:24 +000046 Sk2DPathEffect(SkReadBuffer&);
47 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
reed@android.com8a1c16f2008-12-17 15:59:43 +000048
commit-bot@chromium.org0a2bf902014-02-20 20:40:19 +000049#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
50public:
51#endif
52 Sk2DPathEffect(const SkMatrix& mat);
53
reed@android.com8a1c16f2008-12-17 15:59:43 +000054private:
55 SkMatrix fMatrix, fInverse;
mike@reedtribe.org90bf4272012-04-14 19:06:16 +000056 bool fMatrixIsInvertible;
57
reed@android.com8a1c16f2008-12-17 15:59:43 +000058 // illegal
59 Sk2DPathEffect(const Sk2DPathEffect&);
60 Sk2DPathEffect& operator=(const Sk2DPathEffect&);
61
reed@android.com8a1c16f2008-12-17 15:59:43 +000062 friend class Sk2DPathEffectBlitter;
63 typedef SkPathEffect INHERITED;
64};
65
tfarina@chromium.org6806fe82012-10-12 14:41:39 +000066class SK_API SkLine2DPathEffect : public Sk2DPathEffect {
scroggo@google.comd8a6cc82012-09-12 18:53:49 +000067public:
commit-bot@chromium.org0a2bf902014-02-20 20:40:19 +000068 static SkLine2DPathEffect* Create(SkScalar width, const SkMatrix& matrix) {
69 return SkNEW_ARGS(SkLine2DPathEffect, (width, matrix));
70 }
scroggo@google.comd8a6cc82012-09-12 18:53:49 +000071
reed@google.com548a1f32012-12-18 16:12:09 +000072 virtual bool filterPath(SkPath* dst, const SkPath& src,
reed@google.com4bbdeac2013-01-24 21:03:11 +000073 SkStrokeRec*, const SkRect*) const SK_OVERRIDE;
scroggo@google.comd8a6cc82012-09-12 18:53:49 +000074
75 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLine2DPathEffect)
76
77protected:
reed@google.com548a1f32012-12-18 16:12:09 +000078 virtual void nextSpan(int u, int v, int ucount, SkPath*) const SK_OVERRIDE;
scroggo@google.comd8a6cc82012-09-12 18:53:49 +000079
commit-bot@chromium.org8b0e8ac2014-01-30 18:58:24 +000080 SkLine2DPathEffect(SkReadBuffer&);
scroggo@google.comd8a6cc82012-09-12 18:53:49 +000081
commit-bot@chromium.org8b0e8ac2014-01-30 18:58:24 +000082 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
scroggo@google.comd8a6cc82012-09-12 18:53:49 +000083
commit-bot@chromium.org0a2bf902014-02-20 20:40:19 +000084#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
85public:
86#endif
87 SkLine2DPathEffect(SkScalar width, const SkMatrix& matrix)
88 : Sk2DPathEffect(matrix), fWidth(width) {}
89
scroggo@google.comd8a6cc82012-09-12 18:53:49 +000090private:
91 SkScalar fWidth;
92
93 typedef Sk2DPathEffect INHERITED;
94};
95
tfarina@chromium.org6806fe82012-10-12 14:41:39 +000096class SK_API SkPath2DPathEffect : public Sk2DPathEffect {
reed@google.com18dc4772011-08-09 18:47:40 +000097public:
98 /**
99 * Stamp the specified path to fill the shape, using the matrix to define
100 * the latice.
101 */
commit-bot@chromium.org0a2bf902014-02-20 20:40:19 +0000102 static SkPath2DPathEffect* Create(const SkMatrix& matrix, const SkPath& path) {
103 return SkNEW_ARGS(SkPath2DPathEffect, (matrix, path));
104 }
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000105
djsollen@google.comba28d032012-03-26 17:57:35 +0000106 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPath2DPathEffect)
reed@google.com18dc4772011-08-09 18:47:40 +0000107
108protected:
commit-bot@chromium.org8b0e8ac2014-01-30 18:58:24 +0000109 SkPath2DPathEffect(SkReadBuffer& buffer);
110 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
reed@google.com18dc4772011-08-09 18:47:40 +0000111
reed@google.com548a1f32012-12-18 16:12:09 +0000112 virtual void next(const SkPoint&, int u, int v, SkPath*) const SK_OVERRIDE;
reed@google.com18dc4772011-08-09 18:47:40 +0000113
commit-bot@chromium.org0a2bf902014-02-20 20:40:19 +0000114#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
115public:
116#endif
117 SkPath2DPathEffect(const SkMatrix&, const SkPath&);
118
reed@google.com18dc4772011-08-09 18:47:40 +0000119private:
120 SkPath fPath;
121
122 typedef Sk2DPathEffect INHERITED;
123};
124
reed@android.com8a1c16f2008-12-17 15:59:43 +0000125#endif