OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #ifndef SkLayerRasterizer_DEFINED | 10 #ifndef SkLayerRasterizer_DEFINED |
11 #define SkLayerRasterizer_DEFINED | 11 #define SkLayerRasterizer_DEFINED |
12 | 12 |
13 #include "SkRasterizer.h" | 13 #include "SkRasterizer.h" |
14 #include "SkDeque.h" | 14 #include "SkDeque.h" |
15 #include "SkScalar.h" | 15 #include "SkScalar.h" |
16 | 16 |
17 class SkPaint; | 17 class SkPaint; |
18 | 18 |
19 class SK_API SkLayerRasterizer : public SkRasterizer { | 19 class SK_API SkLayerRasterizer : public SkRasterizer { |
20 public: | 20 public: |
21 SkLayerRasterizer(); | |
22 virtual ~SkLayerRasterizer(); | 21 virtual ~SkLayerRasterizer(); |
23 | 22 |
| 23 class SK_API Builder { |
| 24 public: |
| 25 Builder(); |
| 26 ~Builder(); |
| 27 |
| 28 void addLayer(const SkPaint& paint) { |
| 29 this->addLayer(paint, 0, 0); |
| 30 } |
| 31 |
| 32 /** |
| 33 * Add a new layer (above any previous layers) to the rasterizer. |
| 34 * The layer will extract those fields that affect the mask from |
| 35 * the specified paint, but will not retain a reference to the paint |
| 36 * object itself, so it may be reused without danger of side-effects. |
| 37 */ |
| 38 void addLayer(const SkPaint& paint, SkScalar dx, SkScalar dy); |
| 39 |
| 40 /** |
| 41 * Pass queue of layers on to newly created layer rasterizer and retur
n it. The builder |
| 42 * cannot be used any more after calling this function. |
| 43 */ |
| 44 SkLayerRasterizer* detachRasterizer(); |
| 45 |
| 46 private: |
| 47 SkDeque* fLayers; |
| 48 }; |
| 49 |
| 50 #ifdef SK_SUPPORT_LEGACY_LAYERRASTERIZER_API |
24 void addLayer(const SkPaint& paint) { | 51 void addLayer(const SkPaint& paint) { |
25 this->addLayer(paint, 0, 0); | 52 this->addLayer(paint, 0, 0); |
26 } | 53 } |
27 | 54 |
28 /** Add a new layer (above any previous layers) to the rasterizer. | 55 /** Add a new layer (above any previous layers) to the rasterizer. |
29 The layer will extract those fields that affect the mask from | 56 The layer will extract those fields that affect the mask from |
30 the specified paint, but will not retain a reference to the paint | 57 the specified paint, but will not retain a reference to the paint |
31 object itself, so it may be reused without danger of side-effects. | 58 object itself, so it may be reused without danger of side-effects. |
32 */ | 59 */ |
33 void addLayer(const SkPaint& paint, SkScalar dx, SkScalar dy); | 60 void addLayer(const SkPaint& paint, SkScalar dx, SkScalar dy); |
| 61 #endif |
34 | 62 |
35 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLayerRasterizer) | 63 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLayerRasterizer) |
36 | 64 |
37 protected: | 65 protected: |
| 66 SkLayerRasterizer(SkDeque* layers); |
38 SkLayerRasterizer(SkReadBuffer&); | 67 SkLayerRasterizer(SkReadBuffer&); |
39 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 68 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
40 | 69 |
41 // override from SkRasterizer | 70 // override from SkRasterizer |
42 virtual bool onRasterize(const SkPath& path, const SkMatrix& matrix, | 71 virtual bool onRasterize(const SkPath& path, const SkMatrix& matrix, |
43 const SkIRect* clipBounds, | 72 const SkIRect* clipBounds, |
44 SkMask* mask, SkMask::CreateMode mode) const; | 73 SkMask* mask, SkMask::CreateMode mode) const; |
45 | 74 |
| 75 #ifdef SK_SUPPORT_LEGACY_LAYERRASTERIZER_API |
| 76 public: |
| 77 #endif |
| 78 SkLayerRasterizer(); |
| 79 |
46 private: | 80 private: |
47 SkDeque fLayers; | 81 #ifdef SK_SUPPORT_LEGACY_LAYERRASTERIZER_API |
| 82 SkDeque* fLayers; |
| 83 #else |
| 84 const SkDeque* const fLayers; |
| 85 #endif |
| 86 |
| 87 static SkDeque* ReadLayers(SkReadBuffer& buffer); |
48 | 88 |
49 typedef SkRasterizer INHERITED; | 89 typedef SkRasterizer INHERITED; |
50 }; | 90 }; |
51 | 91 |
52 #endif | 92 #endif |
OLD | NEW |