gfx/skia/trunk/include/effects/SkLayerRasterizer.h

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:b05725eba7fc
1
2 /*
3 * Copyright 2006 The Android Open Source Project
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9
10 #ifndef SkLayerRasterizer_DEFINED
11 #define SkLayerRasterizer_DEFINED
12
13 #include "SkRasterizer.h"
14 #include "SkDeque.h"
15 #include "SkScalar.h"
16
17 class SkPaint;
18
19 class SK_API SkLayerRasterizer : public SkRasterizer {
20 public:
21 virtual ~SkLayerRasterizer();
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 return 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
51 void addLayer(const SkPaint& paint) {
52 this->addLayer(paint, 0, 0);
53 }
54
55 /** Add a new layer (above any previous layers) to the rasterizer.
56 The layer will extract those fields that affect the mask from
57 the specified paint, but will not retain a reference to the paint
58 object itself, so it may be reused without danger of side-effects.
59 */
60 void addLayer(const SkPaint& paint, SkScalar dx, SkScalar dy);
61 #endif
62
63 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLayerRasterizer)
64
65 protected:
66 SkLayerRasterizer(SkDeque* layers);
67 SkLayerRasterizer(SkReadBuffer&);
68 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
69
70 // override from SkRasterizer
71 virtual bool onRasterize(const SkPath& path, const SkMatrix& matrix,
72 const SkIRect* clipBounds,
73 SkMask* mask, SkMask::CreateMode mode) const;
74
75 #ifdef SK_SUPPORT_LEGACY_LAYERRASTERIZER_API
76 public:
77 #endif
78 SkLayerRasterizer();
79
80 private:
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);
88
89 typedef SkRasterizer INHERITED;
90 };
91
92 #endif

mercurial