Sk2DPathEffect.h revision 90bf427001fd4f6d9fcee88911deb015aeb4ab7c
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 Sk2DPathEffect_DEFINED
11#define Sk2DPathEffect_DEFINED
12
13#include "SkPath.h"
14#include "SkPathEffect.h"
15#include "SkMatrix.h"
16
17class Sk2DPathEffect : public SkPathEffect {
18public:
19    Sk2DPathEffect(const SkMatrix& mat);
20
21    // overrides
22    virtual bool filterPath(SkPath*, const SkPath&, SkScalar* width) SK_OVERRIDE;
23
24    SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Sk2DPathEffect)
25
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&);
47    virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
48
49private:
50    SkMatrix    fMatrix, fInverse;
51    bool        fMatrixIsInvertible;
52
53    // illegal
54    Sk2DPathEffect(const Sk2DPathEffect&);
55    Sk2DPathEffect& operator=(const Sk2DPathEffect&);
56
57    friend class Sk2DPathEffectBlitter;
58    typedef SkPathEffect INHERITED;
59};
60
61class SkPath2DPathEffect : public Sk2DPathEffect {
62public:
63    /**
64     *  Stamp the specified path to fill the shape, using the matrix to define
65     *  the latice.
66     */
67    SkPath2DPathEffect(const SkMatrix&, const SkPath&);
68
69    SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPath2DPathEffect)
70
71protected:
72    SkPath2DPathEffect(SkFlattenableReadBuffer& buffer);
73    virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
74
75    virtual void next(const SkPoint&, int u, int v, SkPath* dst) SK_OVERRIDE;
76
77private:
78    SkPath  fPath;
79
80    typedef Sk2DPathEffect INHERITED;
81};
82
83
84#endif
85