blob: 820f6fca66e7106b37617b9c1331c4171938db03 [file] [log] [blame]
reed@android.com8a1c16f2008-12-17 15:59:43 +00001/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef SkLayerRasterizer_DEFINED
18#define SkLayerRasterizer_DEFINED
19
20#include "SkRasterizer.h"
21#include "SkDeque.h"
22#include "SkScalar.h"
23
24class SkPaint;
25
26class SkLayerRasterizer : public SkRasterizer {
27public:
28 SkLayerRasterizer();
29 virtual ~SkLayerRasterizer();
30
31 void addLayer(const SkPaint& paint)
32 {
33 this->addLayer(paint, 0, 0);
34 }
35
36 /** Add a new layer (above any previous layers) to the rasterizer.
37 The layer will extract those fields that affect the mask from
38 the specified paint, but will not retain a reference to the paint
39 object itself, so it may be reused without danger of side-effects.
40 */
41 void addLayer(const SkPaint& paint, SkScalar dx, SkScalar dy);
42
43 // overrides from SkFlattenable
44 virtual Factory getFactory();
45 virtual void flatten(SkFlattenableWriteBuffer&);
46
47protected:
48 SkLayerRasterizer(SkFlattenableReadBuffer&);
49
50 // override from SkRasterizer
51 virtual bool onRasterize(const SkPath& path, const SkMatrix& matrix,
52 const SkIRect* clipBounds,
53 SkMask* mask, SkMask::CreateMode mode);
54
55private:
56 SkDeque fLayers;
57
58 static SkFlattenable* CreateProc(SkFlattenableReadBuffer&);
59
60 typedef SkRasterizer INHERITED;
61};
62
63#endif