| 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 | 
| mike@reedtribe.org | 259210c | 2011-11-23 02:08:50 +0000 | [diff] [blame] | 22 |     virtual bool filterPath(SkPath*, const SkPath&, SkScalar* width) SK_OVERRIDE; | 
| reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 23 |  | 
 | 24 |     // overrides from SkFlattenable | 
| mike@reedtribe.org | 259210c | 2011-11-23 02:08:50 +0000 | [diff] [blame] | 25 |     virtual void flatten(SkFlattenableWriteBuffer&) SK_OVERRIDE; | 
| djsollen@google.com | ba28d03 | 2012-03-26 17:57:35 +0000 | [diff] [blame^] | 26 |     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Sk2DPathEffect) | 
| reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 27 |  | 
 | 28 | protected: | 
 | 29 |     /** New virtual, to be overridden by subclasses. | 
 | 30 |         This is called once from filterPath, and provides the | 
 | 31 |         uv parameter bounds for the path. Subsequent calls to | 
 | 32 |         next() will receive u and v values within these bounds, | 
 | 33 |         and then a call to end() will signal the end of processing. | 
 | 34 |     */ | 
 | 35 |     virtual void begin(const SkIRect& uvBounds, SkPath* dst); | 
 | 36 |     virtual void next(const SkPoint& loc, int u, int v, SkPath* dst); | 
 | 37 |     virtual void end(SkPath* dst); | 
 | 38 |  | 
 | 39 |     /** Low-level virtual called per span of locations in the u-direction. | 
 | 40 |         The default implementation calls next() repeatedly with each | 
 | 41 |         location. | 
 | 42 |     */ | 
 | 43 |     virtual void nextSpan(int u, int v, int ucount, SkPath* dst); | 
 | 44 |  | 
 | 45 |     const SkMatrix& getMatrix() const { return fMatrix; } | 
 | 46 |  | 
 | 47 |     // protected so that subclasses can call this during unflattening | 
 | 48 |     Sk2DPathEffect(SkFlattenableReadBuffer&); | 
 | 49 |  | 
 | 50 | private: | 
 | 51 |     SkMatrix    fMatrix, fInverse; | 
 | 52 |     // illegal | 
 | 53 |     Sk2DPathEffect(const Sk2DPathEffect&); | 
 | 54 |     Sk2DPathEffect& operator=(const Sk2DPathEffect&); | 
 | 55 |  | 
| reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 56 |     friend class Sk2DPathEffectBlitter; | 
 | 57 |     typedef SkPathEffect INHERITED; | 
 | 58 | }; | 
 | 59 |  | 
| reed@google.com | 18dc477 | 2011-08-09 18:47:40 +0000 | [diff] [blame] | 60 | class SkPath2DPathEffect : public Sk2DPathEffect { | 
 | 61 | public: | 
 | 62 |     /** | 
 | 63 |      *  Stamp the specified path to fill the shape, using the matrix to define | 
 | 64 |      *  the latice. | 
 | 65 |      */ | 
 | 66 |     SkPath2DPathEffect(const SkMatrix&, const SkPath&); | 
 | 67 |      | 
| djsollen@google.com | ba28d03 | 2012-03-26 17:57:35 +0000 | [diff] [blame^] | 68 |     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPath2DPathEffect) | 
| reed@google.com | 18dc477 | 2011-08-09 18:47:40 +0000 | [diff] [blame] | 69 |  | 
 | 70 | protected: | 
 | 71 |     SkPath2DPathEffect(SkFlattenableReadBuffer& buffer); | 
 | 72 |  | 
| mike@reedtribe.org | 259210c | 2011-11-23 02:08:50 +0000 | [diff] [blame] | 73 |     virtual void flatten(SkFlattenableWriteBuffer&) SK_OVERRIDE; | 
| mike@reedtribe.org | 259210c | 2011-11-23 02:08:50 +0000 | [diff] [blame] | 74 |     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] | 75 |  | 
 | 76 | private: | 
 | 77 |     SkPath  fPath; | 
 | 78 |  | 
 | 79 |     typedef Sk2DPathEffect INHERITED; | 
 | 80 | }; | 
 | 81 |  | 
 | 82 |  | 
| reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 83 | #endif |