blob: 67e78579e3b3bd0a29b9a1e8bf97282242621610 [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 Sk2DPathEffect_DEFINED
11#define Sk2DPathEffect_DEFINED
12
reed@google.com18dc4772011-08-09 18:47:40 +000013#include "SkPath.h"
reed@android.com8a1c16f2008-12-17 15:59:43 +000014#include "SkPathEffect.h"
15#include "SkMatrix.h"
16
reed@android.com8a1c16f2008-12-17 15:59:43 +000017class Sk2DPathEffect : public SkPathEffect {
18public:
19 Sk2DPathEffect(const SkMatrix& mat);
20
21 // overrides
mike@reedtribe.org259210c2011-11-23 02:08:50 +000022 virtual bool filterPath(SkPath*, const SkPath&, SkScalar* width) SK_OVERRIDE;
reed@android.com8a1c16f2008-12-17 15:59:43 +000023
djsollen@google.comba28d032012-03-26 17:57:35 +000024 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Sk2DPathEffect)
reed@android.com8a1c16f2008-12-17 15:59:43 +000025
26protected:
27 /** New virtual, to be overridden by subclasses.
28 This is called once from filterPath, and provides the
29 uv parameter bounds for the path. Subsequent calls to
30 next() will receive u and v values within these bounds,
31 and then a call to end() will signal the end of processing.
32 */
33 virtual void begin(const SkIRect& uvBounds, SkPath* dst);
34 virtual void next(const SkPoint& loc, int u, int v, SkPath* dst);
35 virtual void end(SkPath* dst);
36
37 /** Low-level virtual called per span of locations in the u-direction.
38 The default implementation calls next() repeatedly with each
39 location.
40 */
41 virtual void nextSpan(int u, int v, int ucount, SkPath* dst);
42
43 const SkMatrix& getMatrix() const { return fMatrix; }
44
45 // protected so that subclasses can call this during unflattening
46 Sk2DPathEffect(SkFlattenableReadBuffer&);
djsollen@google.com54924242012-03-29 15:18:04 +000047 virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
reed@android.com8a1c16f2008-12-17 15:59:43 +000048
49private:
50 SkMatrix fMatrix, fInverse;
51 // illegal
52 Sk2DPathEffect(const Sk2DPathEffect&);
53 Sk2DPathEffect& operator=(const Sk2DPathEffect&);
54
reed@android.com8a1c16f2008-12-17 15:59:43 +000055 friend class Sk2DPathEffectBlitter;
56 typedef SkPathEffect INHERITED;
57};
58
reed@google.com18dc4772011-08-09 18:47:40 +000059class SkPath2DPathEffect : public Sk2DPathEffect {
60public:
61 /**
62 * Stamp the specified path to fill the shape, using the matrix to define
63 * the latice.
64 */
65 SkPath2DPathEffect(const SkMatrix&, const SkPath&);
66
djsollen@google.comba28d032012-03-26 17:57:35 +000067 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPath2DPathEffect)
reed@google.com18dc4772011-08-09 18:47:40 +000068
69protected:
70 SkPath2DPathEffect(SkFlattenableReadBuffer& buffer);
djsollen@google.com54924242012-03-29 15:18:04 +000071 virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
reed@google.com18dc4772011-08-09 18:47:40 +000072
mike@reedtribe.org259210c2011-11-23 02:08:50 +000073 virtual void next(const SkPoint&, int u, int v, SkPath* dst) SK_OVERRIDE;
reed@google.com18dc4772011-08-09 18:47:40 +000074
75private:
76 SkPath fPath;
77
78 typedef Sk2DPathEffect INHERITED;
79};
80
81
reed@android.com8a1c16f2008-12-17 15:59:43 +000082#endif