OLD | NEW |
1 | |
2 /* | 1 /* |
3 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
4 * | 3 * |
5 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
7 */ | 6 */ |
8 | 7 |
9 | |
10 #ifndef SkLayerRasterizer_DEFINED | 8 #ifndef SkLayerRasterizer_DEFINED |
11 #define SkLayerRasterizer_DEFINED | 9 #define SkLayerRasterizer_DEFINED |
12 | 10 |
13 #include "SkRasterizer.h" | 11 #include "SkRasterizer.h" |
14 #include "SkDeque.h" | 12 #include "SkDeque.h" |
15 #include "SkScalar.h" | 13 #include "SkScalar.h" |
16 | 14 |
17 class SkPaint; | 15 class SkPaint; |
18 | 16 |
19 class SK_API SkLayerRasterizer : public SkRasterizer { | 17 class SK_API SkLayerRasterizer : public SkRasterizer { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 * Future calls to addLayer will not affect rasterizers previously ret
urned by this call. | 55 * Future calls to addLayer will not affect rasterizers previously ret
urned by this call. |
58 * | 56 * |
59 * The caller is responsible for calling unref() on the returned objec
t, if non NULL. | 57 * The caller is responsible for calling unref() on the returned objec
t, if non NULL. |
60 */ | 58 */ |
61 SkLayerRasterizer* snapshotRasterizer() const; | 59 SkLayerRasterizer* snapshotRasterizer() const; |
62 | 60 |
63 private: | 61 private: |
64 SkDeque* fLayers; | 62 SkDeque* fLayers; |
65 }; | 63 }; |
66 | 64 |
67 #ifdef SK_SUPPORT_LEGACY_LAYERRASTERIZER_API | |
68 void addLayer(const SkPaint& paint) { | |
69 this->addLayer(paint, 0, 0); | |
70 } | |
71 | |
72 /** Add a new layer (above any previous layers) to the rasterizer. | |
73 The layer will extract those fields that affect the mask from | |
74 the specified paint, but will not retain a reference to the paint | |
75 object itself, so it may be reused without danger of side-effects. | |
76 */ | |
77 void addLayer(const SkPaint& paint, SkScalar dx, SkScalar dy); | |
78 #endif | |
79 | |
80 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLayerRasterizer) | 65 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLayerRasterizer) |
81 | 66 |
82 protected: | 67 protected: |
83 SkLayerRasterizer(SkDeque* layers); | |
84 SkLayerRasterizer(SkReadBuffer&); | |
85 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 68 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
86 | 69 |
87 // override from SkRasterizer | 70 // override from SkRasterizer |
88 virtual bool onRasterize(const SkPath& path, const SkMatrix& matrix, | 71 virtual bool onRasterize(const SkPath& path, const SkMatrix& matrix, |
89 const SkIRect* clipBounds, | 72 const SkIRect* clipBounds, |
90 SkMask* mask, SkMask::CreateMode mode) const; | 73 SkMask* mask, SkMask::CreateMode mode) const; |
91 | 74 |
92 #ifdef SK_SUPPORT_LEGACY_LAYERRASTERIZER_API | 75 private: |
93 public: | 76 const SkDeque* const fLayers; |
94 #endif | 77 |
95 SkLayerRasterizer(); | 78 SkLayerRasterizer(); |
96 | 79 SkLayerRasterizer(SkDeque* layers); |
97 private: | 80 SkLayerRasterizer(SkReadBuffer&); |
98 #ifdef SK_SUPPORT_LEGACY_LAYERRASTERIZER_API | |
99 SkDeque* fLayers; | |
100 #else | |
101 const SkDeque* const fLayers; | |
102 #endif | |
103 | 81 |
104 static SkDeque* ReadLayers(SkReadBuffer& buffer); | 82 static SkDeque* ReadLayers(SkReadBuffer& buffer); |
105 | 83 |
106 friend class LayerRasterizerTester; | 84 friend class LayerRasterizerTester; |
107 | 85 |
108 typedef SkRasterizer INHERITED; | 86 typedef SkRasterizer INHERITED; |
109 }; | 87 }; |
110 | 88 |
111 #endif | 89 #endif |
OLD | NEW |