blob: 0373b05fb1788604a85157cb0d3a182c9231068a [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
mike@reedtribe.org6b919c32011-04-20 11:17:30 +000031 void addLayer(const SkPaint& paint) {
reed@android.com8a1c16f2008-12-17 15:59:43 +000032 this->addLayer(paint, 0, 0);
33 }
34
35 /** Add a new layer (above any previous layers) to the rasterizer.
36 The layer will extract those fields that affect the mask from
37 the specified paint, but will not retain a reference to the paint
38 object itself, so it may be reused without danger of side-effects.
39 */
40 void addLayer(const SkPaint& paint, SkScalar dx, SkScalar dy);
41
42 // overrides from SkFlattenable
43 virtual Factory getFactory();
44 virtual void flatten(SkFlattenableWriteBuffer&);
45
46protected:
47 SkLayerRasterizer(SkFlattenableReadBuffer&);
48
49 // override from SkRasterizer
50 virtual bool onRasterize(const SkPath& path, const SkMatrix& matrix,
51 const SkIRect* clipBounds,
52 SkMask* mask, SkMask::CreateMode mode);
53
54private:
55 SkDeque fLayers;
56
57 static SkFlattenable* CreateProc(SkFlattenableReadBuffer&);
58
59 typedef SkRasterizer INHERITED;
60};
61
62#endif