Chromium Code Reviews| 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(); | 21 SkLayerRasterizer(); |
| 22 virtual ~SkLayerRasterizer(); | 22 virtual ~SkLayerRasterizer(); |
| 23 | 23 |
| 24 class SK_API Builder { | |
| 25 public: | |
| 26 Builder(); | |
| 27 ~Builder(); | |
| 28 | |
| 29 void addLayer(const SkPaint& paint) { | |
| 30 this->addLayer(paint, 0, 0); | |
| 31 } | |
| 32 | |
| 33 /** | |
| 34 * Add a new layer (above any previous layers) to the rasterizer. | |
| 35 * The layer will extract those fields that affect the mask from | |
| 36 * the specified paint, but will not retain a reference to the paint | |
| 37 * object itself, so it may be reused without danger of side-effects. | |
| 38 */ | |
| 39 void addLayer(const SkPaint& paint, SkScalar dx, SkScalar dy); | |
| 40 | |
| 41 /** | |
| 42 * Pass queue of layers on to newly created layer rasterizer and retur n it. The builder | |
| 43 * cannot be used any more after calling this function. | |
| 44 */ | |
| 45 SkLayerRasterizer* detachRasterizer(); | |
| 46 | |
| 47 private: | |
| 48 SkDeque* fLayers; | |
| 49 }; | |
| 50 | |
| 24 void addLayer(const SkPaint& paint) { | 51 void addLayer(const SkPaint& paint) { |
|
reed1
2014/02/24 13:35:40
Consider adding a build-guard here, to remind us t
Dominik Grewe
2014/02/24 13:54:34
Done.
| |
| 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); |
| 34 | 61 |
| 35 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLayerRasterizer) | 62 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLayerRasterizer) |
| 36 | 63 |
| 37 protected: | 64 protected: |
| 65 SkLayerRasterizer(SkDeque* layers); | |
| 38 SkLayerRasterizer(SkReadBuffer&); | 66 SkLayerRasterizer(SkReadBuffer&); |
| 39 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 67 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
| 40 | 68 |
| 41 // override from SkRasterizer | 69 // override from SkRasterizer |
| 42 virtual bool onRasterize(const SkPath& path, const SkMatrix& matrix, | 70 virtual bool onRasterize(const SkPath& path, const SkMatrix& matrix, |
| 43 const SkIRect* clipBounds, | 71 const SkIRect* clipBounds, |
| 44 SkMask* mask, SkMask::CreateMode mode) const; | 72 SkMask* mask, SkMask::CreateMode mode) const; |
| 45 | 73 |
| 46 private: | 74 private: |
| 47 SkDeque fLayers; | 75 SkDeque* fLayers; |
| 48 | 76 |
| 49 typedef SkRasterizer INHERITED; | 77 typedef SkRasterizer INHERITED; |
| 50 }; | 78 }; |
| 51 | 79 |
| 52 #endif | 80 #endif |
| OLD | NEW |