reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 1 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 2 | * Copyright 2006 The Android Open Source Project |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 3 | * |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #ifndef Sk2DPathEffect_DEFINED |
| 9 | #define Sk2DPathEffect_DEFINED |
| 10 | |
reed@google.com | 18dc477 | 2011-08-09 18:47:40 +0000 | [diff] [blame] | 11 | #include "SkPath.h" |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 12 | #include "SkPathEffect.h" |
| 13 | #include "SkMatrix.h" |
| 14 | |
tfarina@chromium.org | 6806fe8 | 2012-10-12 14:41:39 +0000 | [diff] [blame] | 15 | class SK_API Sk2DPathEffect : public SkPathEffect { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 16 | public: |
commit-bot@chromium.org | 0a2bf90 | 2014-02-20 20:40:19 +0000 | [diff] [blame^] | 17 | static Sk2DPathEffect* Create(const SkMatrix& mat) { |
| 18 | return SkNEW_ARGS(Sk2DPathEffect, (mat)); |
| 19 | } |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 20 | |
reed@google.com | 548a1f3 | 2012-12-18 16:12:09 +0000 | [diff] [blame] | 21 | virtual bool filterPath(SkPath*, const SkPath&, |
reed@google.com | 4bbdeac | 2013-01-24 21:03:11 +0000 | [diff] [blame] | 22 | SkStrokeRec*, const SkRect*) const SK_OVERRIDE; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 23 | |
djsollen@google.com | ba28d03 | 2012-03-26 17:57:35 +0000 | [diff] [blame] | 24 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Sk2DPathEffect) |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 25 | |
| 26 | protected: |
| 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.com | 548a1f3 | 2012-12-18 16:12:09 +0000 | [diff] [blame] | 33 | 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.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 36 | |
| 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.com | 548a1f3 | 2012-12-18 16:12:09 +0000 | [diff] [blame] | 41 | virtual void nextSpan(int u, int v, int ucount, SkPath* dst) const; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 42 | |
| 43 | const SkMatrix& getMatrix() const { return fMatrix; } |
| 44 | |
| 45 | // protected so that subclasses can call this during unflattening |
commit-bot@chromium.org | 8b0e8ac | 2014-01-30 18:58:24 +0000 | [diff] [blame] | 46 | Sk2DPathEffect(SkReadBuffer&); |
| 47 | virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 48 | |
commit-bot@chromium.org | 0a2bf90 | 2014-02-20 20:40:19 +0000 | [diff] [blame^] | 49 | #ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS |
| 50 | public: |
| 51 | #endif |
| 52 | Sk2DPathEffect(const SkMatrix& mat); |
| 53 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 54 | private: |
| 55 | SkMatrix fMatrix, fInverse; |
mike@reedtribe.org | 90bf427 | 2012-04-14 19:06:16 +0000 | [diff] [blame] | 56 | bool fMatrixIsInvertible; |
| 57 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 58 | // illegal |
| 59 | Sk2DPathEffect(const Sk2DPathEffect&); |
| 60 | Sk2DPathEffect& operator=(const Sk2DPathEffect&); |
| 61 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 62 | friend class Sk2DPathEffectBlitter; |
| 63 | typedef SkPathEffect INHERITED; |
| 64 | }; |
| 65 | |
tfarina@chromium.org | 6806fe8 | 2012-10-12 14:41:39 +0000 | [diff] [blame] | 66 | class SK_API SkLine2DPathEffect : public Sk2DPathEffect { |
scroggo@google.com | d8a6cc8 | 2012-09-12 18:53:49 +0000 | [diff] [blame] | 67 | public: |
commit-bot@chromium.org | 0a2bf90 | 2014-02-20 20:40:19 +0000 | [diff] [blame^] | 68 | static SkLine2DPathEffect* Create(SkScalar width, const SkMatrix& matrix) { |
| 69 | return SkNEW_ARGS(SkLine2DPathEffect, (width, matrix)); |
| 70 | } |
scroggo@google.com | d8a6cc8 | 2012-09-12 18:53:49 +0000 | [diff] [blame] | 71 | |
reed@google.com | 548a1f3 | 2012-12-18 16:12:09 +0000 | [diff] [blame] | 72 | virtual bool filterPath(SkPath* dst, const SkPath& src, |
reed@google.com | 4bbdeac | 2013-01-24 21:03:11 +0000 | [diff] [blame] | 73 | SkStrokeRec*, const SkRect*) const SK_OVERRIDE; |
scroggo@google.com | d8a6cc8 | 2012-09-12 18:53:49 +0000 | [diff] [blame] | 74 | |
| 75 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLine2DPathEffect) |
| 76 | |
| 77 | protected: |
reed@google.com | 548a1f3 | 2012-12-18 16:12:09 +0000 | [diff] [blame] | 78 | virtual void nextSpan(int u, int v, int ucount, SkPath*) const SK_OVERRIDE; |
scroggo@google.com | d8a6cc8 | 2012-09-12 18:53:49 +0000 | [diff] [blame] | 79 | |
commit-bot@chromium.org | 8b0e8ac | 2014-01-30 18:58:24 +0000 | [diff] [blame] | 80 | SkLine2DPathEffect(SkReadBuffer&); |
scroggo@google.com | d8a6cc8 | 2012-09-12 18:53:49 +0000 | [diff] [blame] | 81 | |
commit-bot@chromium.org | 8b0e8ac | 2014-01-30 18:58:24 +0000 | [diff] [blame] | 82 | virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
scroggo@google.com | d8a6cc8 | 2012-09-12 18:53:49 +0000 | [diff] [blame] | 83 | |
commit-bot@chromium.org | 0a2bf90 | 2014-02-20 20:40:19 +0000 | [diff] [blame^] | 84 | #ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS |
| 85 | public: |
| 86 | #endif |
| 87 | SkLine2DPathEffect(SkScalar width, const SkMatrix& matrix) |
| 88 | : Sk2DPathEffect(matrix), fWidth(width) {} |
| 89 | |
scroggo@google.com | d8a6cc8 | 2012-09-12 18:53:49 +0000 | [diff] [blame] | 90 | private: |
| 91 | SkScalar fWidth; |
| 92 | |
| 93 | typedef Sk2DPathEffect INHERITED; |
| 94 | }; |
| 95 | |
tfarina@chromium.org | 6806fe8 | 2012-10-12 14:41:39 +0000 | [diff] [blame] | 96 | class SK_API SkPath2DPathEffect : public Sk2DPathEffect { |
reed@google.com | 18dc477 | 2011-08-09 18:47:40 +0000 | [diff] [blame] | 97 | public: |
| 98 | /** |
| 99 | * Stamp the specified path to fill the shape, using the matrix to define |
| 100 | * the latice. |
| 101 | */ |
commit-bot@chromium.org | 0a2bf90 | 2014-02-20 20:40:19 +0000 | [diff] [blame^] | 102 | static SkPath2DPathEffect* Create(const SkMatrix& matrix, const SkPath& path) { |
| 103 | return SkNEW_ARGS(SkPath2DPathEffect, (matrix, path)); |
| 104 | } |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 105 | |
djsollen@google.com | ba28d03 | 2012-03-26 17:57:35 +0000 | [diff] [blame] | 106 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPath2DPathEffect) |
reed@google.com | 18dc477 | 2011-08-09 18:47:40 +0000 | [diff] [blame] | 107 | |
| 108 | protected: |
commit-bot@chromium.org | 8b0e8ac | 2014-01-30 18:58:24 +0000 | [diff] [blame] | 109 | SkPath2DPathEffect(SkReadBuffer& buffer); |
| 110 | virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
reed@google.com | 18dc477 | 2011-08-09 18:47:40 +0000 | [diff] [blame] | 111 | |
reed@google.com | 548a1f3 | 2012-12-18 16:12:09 +0000 | [diff] [blame] | 112 | virtual void next(const SkPoint&, int u, int v, SkPath*) const SK_OVERRIDE; |
reed@google.com | 18dc477 | 2011-08-09 18:47:40 +0000 | [diff] [blame] | 113 | |
commit-bot@chromium.org | 0a2bf90 | 2014-02-20 20:40:19 +0000 | [diff] [blame^] | 114 | #ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS |
| 115 | public: |
| 116 | #endif |
| 117 | SkPath2DPathEffect(const SkMatrix&, const SkPath&); |
| 118 | |
reed@google.com | 18dc477 | 2011-08-09 18:47:40 +0000 | [diff] [blame] | 119 | private: |
| 120 | SkPath fPath; |
| 121 | |
| 122 | typedef Sk2DPathEffect INHERITED; |
| 123 | }; |
| 124 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 125 | #endif |