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: |
| 17 | Sk2DPathEffect(const SkMatrix& mat); |
| 18 | |
reed@google.com | 548a1f3 | 2012-12-18 16:12:09 +0000 | [diff] [blame] | 19 | virtual bool filterPath(SkPath*, const SkPath&, |
reed@google.com | 4bbdeac | 2013-01-24 21:03:11 +0000 | [diff] [blame^] | 20 | SkStrokeRec*, const SkRect*) const SK_OVERRIDE; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 21 | |
djsollen@google.com | ba28d03 | 2012-03-26 17:57:35 +0000 | [diff] [blame] | 22 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Sk2DPathEffect) |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 23 | |
| 24 | protected: |
| 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.com | 548a1f3 | 2012-12-18 16:12:09 +0000 | [diff] [blame] | 31 | 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.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 34 | |
| 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.com | 548a1f3 | 2012-12-18 16:12:09 +0000 | [diff] [blame] | 39 | 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] | 40 | |
| 41 | const SkMatrix& getMatrix() const { return fMatrix; } |
| 42 | |
| 43 | // protected so that subclasses can call this during unflattening |
| 44 | Sk2DPathEffect(SkFlattenableReadBuffer&); |
djsollen@google.com | 5492424 | 2012-03-29 15:18:04 +0000 | [diff] [blame] | 45 | virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 46 | |
| 47 | private: |
| 48 | SkMatrix fMatrix, fInverse; |
mike@reedtribe.org | 90bf427 | 2012-04-14 19:06:16 +0000 | [diff] [blame] | 49 | bool fMatrixIsInvertible; |
| 50 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 51 | // illegal |
| 52 | Sk2DPathEffect(const Sk2DPathEffect&); |
| 53 | Sk2DPathEffect& operator=(const Sk2DPathEffect&); |
| 54 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 55 | friend class Sk2DPathEffectBlitter; |
| 56 | typedef SkPathEffect INHERITED; |
| 57 | }; |
| 58 | |
tfarina@chromium.org | 6806fe8 | 2012-10-12 14:41:39 +0000 | [diff] [blame] | 59 | class SK_API SkLine2DPathEffect : public Sk2DPathEffect { |
scroggo@google.com | d8a6cc8 | 2012-09-12 18:53:49 +0000 | [diff] [blame] | 60 | public: |
| 61 | SkLine2DPathEffect(SkScalar width, const SkMatrix& matrix) |
| 62 | : Sk2DPathEffect(matrix), fWidth(width) {} |
| 63 | |
reed@google.com | 548a1f3 | 2012-12-18 16:12:09 +0000 | [diff] [blame] | 64 | virtual bool filterPath(SkPath* dst, const SkPath& src, |
reed@google.com | 4bbdeac | 2013-01-24 21:03:11 +0000 | [diff] [blame^] | 65 | SkStrokeRec*, const SkRect*) const SK_OVERRIDE; |
scroggo@google.com | d8a6cc8 | 2012-09-12 18:53:49 +0000 | [diff] [blame] | 66 | |
| 67 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLine2DPathEffect) |
| 68 | |
| 69 | protected: |
reed@google.com | 548a1f3 | 2012-12-18 16:12:09 +0000 | [diff] [blame] | 70 | 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] | 71 | |
| 72 | SkLine2DPathEffect(SkFlattenableReadBuffer&); |
| 73 | |
| 74 | virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; |
| 75 | |
| 76 | private: |
| 77 | SkScalar fWidth; |
| 78 | |
| 79 | typedef Sk2DPathEffect INHERITED; |
| 80 | }; |
| 81 | |
tfarina@chromium.org | 6806fe8 | 2012-10-12 14:41:39 +0000 | [diff] [blame] | 82 | class SK_API SkPath2DPathEffect : public Sk2DPathEffect { |
reed@google.com | 18dc477 | 2011-08-09 18:47:40 +0000 | [diff] [blame] | 83 | public: |
| 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.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 89 | |
djsollen@google.com | ba28d03 | 2012-03-26 17:57:35 +0000 | [diff] [blame] | 90 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPath2DPathEffect) |
reed@google.com | 18dc477 | 2011-08-09 18:47:40 +0000 | [diff] [blame] | 91 | |
| 92 | protected: |
| 93 | SkPath2DPathEffect(SkFlattenableReadBuffer& buffer); |
djsollen@google.com | 5492424 | 2012-03-29 15:18:04 +0000 | [diff] [blame] | 94 | virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; |
reed@google.com | 18dc477 | 2011-08-09 18:47:40 +0000 | [diff] [blame] | 95 | |
reed@google.com | 548a1f3 | 2012-12-18 16:12:09 +0000 | [diff] [blame] | 96 | 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] | 97 | |
| 98 | private: |
| 99 | SkPath fPath; |
| 100 | |
| 101 | typedef Sk2DPathEffect INHERITED; |
| 102 | }; |
| 103 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 104 | #endif |