• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 SkLayerRasterizer : public SkRasterizer {
20 public:
21             SkLayerRasterizer();
22     virtual ~SkLayerRasterizer();
23 
addLayer(const SkPaint & paint)24     void addLayer(const SkPaint& paint) {
25         this->addLayer(paint, 0, 0);
26     }
27 
28 	/**	Add a new layer (above any previous layers) to the rasterizer.
29 		The layer will extract those fields that affect the mask from
30 		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.
32 	*/
33     void addLayer(const SkPaint& paint, SkScalar dx, SkScalar dy);
34 
35     // overrides from SkFlattenable
36     virtual Factory getFactory();
37     virtual void    flatten(SkFlattenableWriteBuffer&);
38 
39     static SkFlattenable* CreateProc(SkFlattenableReadBuffer&);
40 
41     SK_DECLARE_FLATTENABLE_REGISTRAR()
42 
43 protected:
44     SkLayerRasterizer(SkFlattenableReadBuffer&);
45 
46     // override from SkRasterizer
47     virtual bool onRasterize(const SkPath& path, const SkMatrix& matrix,
48                              const SkIRect* clipBounds,
49                              SkMask* mask, SkMask::CreateMode mode);
50 
51 private:
52     SkDeque fLayers;
53 
54     typedef SkRasterizer INHERITED;
55 };
56 
57 #endif
58