| epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 |  | 
| reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 2 | /* | 
| epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 3 |  * Copyright 2006 The Android Open Source Project | 
| reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 4 |  * | 
| epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 5 |  * Use of this source code is governed by a BSD-style license that can be | 
 | 6 |  * found in the LICENSE file. | 
| reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 7 |  */ | 
 | 8 |  | 
| epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 9 |  | 
| reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 10 | #ifndef Sk2DPathEffect_DEFINED | 
 | 11 | #define Sk2DPathEffect_DEFINED | 
 | 12 |  | 
| reed@google.com | 18dc477 | 2011-08-09 18:47:40 +0000 | [diff] [blame] | 13 | #include "SkPath.h" | 
| reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 14 | #include "SkPathEffect.h" | 
 | 15 | #include "SkMatrix.h" | 
 | 16 |  | 
| reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 17 | class Sk2DPathEffect : public SkPathEffect { | 
 | 18 | public: | 
 | 19 |     Sk2DPathEffect(const SkMatrix& mat); | 
 | 20 |  | 
 | 21 |     // overrides | 
| reed@google.com | fd4be26 | 2012-05-25 01:04:12 +0000 | [diff] [blame] | 22 |     virtual bool filterPath(SkPath*, const SkPath&, SkStrokeRec*) 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 |     */ | 
 | 33 |     virtual void begin(const SkIRect& uvBounds, SkPath* dst); | 
 | 34 |     virtual void next(const SkPoint& loc, int u, int v, SkPath* dst); | 
 | 35 |     virtual void end(SkPath* dst); | 
 | 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 |     */ | 
 | 41 |     virtual void nextSpan(int u, int v, int ucount, SkPath* dst); | 
 | 42 |  | 
 | 43 |     const SkMatrix& getMatrix() const { return fMatrix; } | 
 | 44 |  | 
 | 45 |     // protected so that subclasses can call this during unflattening | 
 | 46 |     Sk2DPathEffect(SkFlattenableReadBuffer&); | 
| djsollen@google.com | 5492424 | 2012-03-29 15:18:04 +0000 | [diff] [blame] | 47 |     virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; | 
| reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 48 |  | 
 | 49 | private: | 
 | 50 |     SkMatrix    fMatrix, fInverse; | 
| mike@reedtribe.org | 90bf427 | 2012-04-14 19:06:16 +0000 | [diff] [blame] | 51 |     bool        fMatrixIsInvertible; | 
 | 52 |  | 
| reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 53 |     // illegal | 
 | 54 |     Sk2DPathEffect(const Sk2DPathEffect&); | 
 | 55 |     Sk2DPathEffect& operator=(const Sk2DPathEffect&); | 
 | 56 |  | 
| reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 57 |     friend class Sk2DPathEffectBlitter; | 
 | 58 |     typedef SkPathEffect INHERITED; | 
 | 59 | }; | 
 | 60 |  | 
| scroggo@google.com | d8a6cc8 | 2012-09-12 18:53:49 +0000 | [diff] [blame^] | 61 | class SkLine2DPathEffect : public Sk2DPathEffect { | 
 | 62 | public: | 
 | 63 |     SkLine2DPathEffect(SkScalar width, const SkMatrix& matrix) | 
 | 64 |     : Sk2DPathEffect(matrix), fWidth(width) {} | 
 | 65 |  | 
 | 66 |     virtual bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec* rec) SK_OVERRIDE; | 
 | 67 |  | 
 | 68 |     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLine2DPathEffect) | 
 | 69 |  | 
 | 70 | protected: | 
 | 71 |     virtual void nextSpan(int u, int v, int ucount, SkPath* dst) SK_OVERRIDE; | 
 | 72 |  | 
 | 73 |     SkLine2DPathEffect(SkFlattenableReadBuffer&); | 
 | 74 |  | 
 | 75 |     virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; | 
 | 76 |  | 
 | 77 | private: | 
 | 78 |     SkScalar fWidth; | 
 | 79 |  | 
 | 80 |     typedef Sk2DPathEffect INHERITED; | 
 | 81 | }; | 
 | 82 |  | 
| reed@google.com | 18dc477 | 2011-08-09 18:47:40 +0000 | [diff] [blame] | 83 | class SkPath2DPathEffect : public Sk2DPathEffect { | 
 | 84 | public: | 
 | 85 |     /** | 
 | 86 |      *  Stamp the specified path to fill the shape, using the matrix to define | 
 | 87 |      *  the latice. | 
 | 88 |      */ | 
 | 89 |     SkPath2DPathEffect(const SkMatrix&, const SkPath&); | 
| rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 90 |  | 
| djsollen@google.com | ba28d03 | 2012-03-26 17:57:35 +0000 | [diff] [blame] | 91 |     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPath2DPathEffect) | 
| reed@google.com | 18dc477 | 2011-08-09 18:47:40 +0000 | [diff] [blame] | 92 |  | 
 | 93 | protected: | 
 | 94 |     SkPath2DPathEffect(SkFlattenableReadBuffer& buffer); | 
| djsollen@google.com | 5492424 | 2012-03-29 15:18:04 +0000 | [diff] [blame] | 95 |     virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; | 
| reed@google.com | 18dc477 | 2011-08-09 18:47:40 +0000 | [diff] [blame] | 96 |  | 
| mike@reedtribe.org | 259210c | 2011-11-23 02:08:50 +0000 | [diff] [blame] | 97 |     virtual void next(const SkPoint&, int u, int v, SkPath* dst) SK_OVERRIDE; | 
| reed@google.com | 18dc477 | 2011-08-09 18:47:40 +0000 | [diff] [blame] | 98 |  | 
 | 99 | private: | 
 | 100 |     SkPath  fPath; | 
 | 101 |  | 
 | 102 |     typedef Sk2DPathEffect INHERITED; | 
 | 103 | }; | 
 | 104 |  | 
 | 105 |  | 
| reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 106 | #endif |