blob: be81a2ba3defd30f273788967bfb95481ec50d51 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
reed@android.com8a1c16f2008-12-17 15:59:43 +00002/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00003 * Copyright 2006 The Android Open Source Project
reed@android.com8a1c16f2008-12-17 15:59:43 +00004 *
epoger@google.comec3ed6a2011-07-28 14:26:00 +00005 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
reed@android.com8a1c16f2008-12-17 15:59:43 +00007 */
8
epoger@google.comec3ed6a2011-07-28 14:26:00 +00009
reed@android.com8a1c16f2008-12-17 15:59:43 +000010#ifndef SkLayerRasterizer_DEFINED
11#define SkLayerRasterizer_DEFINED
12
13#include "SkRasterizer.h"
14#include "SkDeque.h"
15#include "SkScalar.h"
16
17class SkPaint;
18
tfarina@chromium.org6806fe82012-10-12 14:41:39 +000019class SK_API SkLayerRasterizer : public SkRasterizer {
reed@android.com8a1c16f2008-12-17 15:59:43 +000020public:
21 SkLayerRasterizer();
22 virtual ~SkLayerRasterizer();
rmistry@google.comfbfcd562012-08-23 18:09:54 +000023
mike@reedtribe.org6b919c32011-04-20 11:17:30 +000024 void addLayer(const SkPaint& paint) {
reed@android.com8a1c16f2008-12-17 15:59:43 +000025 this->addLayer(paint, 0, 0);
26 }
27
rmistry@google.comfbfcd562012-08-23 18:09:54 +000028 /** 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 */
reed@android.com8a1c16f2008-12-17 15:59:43 +000033 void addLayer(const SkPaint& paint, SkScalar dx, SkScalar dy);
34
djsollen@google.comba28d032012-03-26 17:57:35 +000035 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLayerRasterizer)
reed@google.com43e9f202011-08-09 19:01:50 +000036
reed@android.com8a1c16f2008-12-17 15:59:43 +000037protected:
commit-bot@chromium.org8b0e8ac2014-01-30 18:58:24 +000038 SkLayerRasterizer(SkReadBuffer&);
39 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
reed@android.com8a1c16f2008-12-17 15:59:43 +000040
41 // override from SkRasterizer
42 virtual bool onRasterize(const SkPath& path, const SkMatrix& matrix,
43 const SkIRect* clipBounds,
reed@google.comfdba4042012-12-18 16:57:03 +000044 SkMask* mask, SkMask::CreateMode mode) const;
reed@android.com8a1c16f2008-12-17 15:59:43 +000045
46private:
47 SkDeque fLayers;
reed@android.com8a1c16f2008-12-17 15:59:43 +000048
49 typedef SkRasterizer INHERITED;
50};
51
52#endif