Sk2DPathEffect.h revision a2ca41e3afdd8fad5e0e924dec029f33918e0a67
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    // overrides from SkFlattenable
25    virtual void flatten(SkFlattenableWriteBuffer&) SK_OVERRIDE;
26    virtual Factory getFactory() SK_OVERRIDE;
27
28protected:
29    /** New virtual, to be overridden by subclasses.
30        This is called once from filterPath, and provides the
31        uv parameter bounds for the path. Subsequent calls to
32        next() will receive u and v values within these bounds,
33        and then a call to end() will signal the end of processing.
34    */
35    virtual void begin(const SkIRect& uvBounds, SkPath* dst);
36    virtual void next(const SkPoint& loc, int u, int v, SkPath* dst);
37    virtual void end(SkPath* dst);
38
39    /** Low-level virtual called per span of locations in the u-direction.
40        The default implementation calls next() repeatedly with each
41        location.
42    */
43    virtual void nextSpan(int u, int v, int ucount, SkPath* dst);
44
45    const SkMatrix& getMatrix() const { return fMatrix; }
46
47    // protected so that subclasses can call this during unflattening
48    Sk2DPathEffect(SkFlattenableReadBuffer&);
49
50private:
51    SkMatrix    fMatrix, fInverse;
52    // illegal
53    Sk2DPathEffect(const Sk2DPathEffect&);
54    Sk2DPathEffect& operator=(const Sk2DPathEffect&);
55
56    static SkFlattenable* CreateProc(SkFlattenableReadBuffer&);
57
58    friend class Sk2DPathEffectBlitter;
59    typedef SkPathEffect INHERITED;
60};
61
62class SkPath2DPathEffect : public Sk2DPathEffect {
63public:
64    /**
65     *  Stamp the specified path to fill the shape, using the matrix to define
66     *  the latice.
67     */
68    SkPath2DPathEffect(const SkMatrix&, const SkPath&);
69
70    static SkFlattenable* CreateProc(SkFlattenableReadBuffer&);
71
72protected:
73    SkPath2DPathEffect(SkFlattenableReadBuffer& buffer);
74
75    virtual void flatten(SkFlattenableWriteBuffer&) SK_OVERRIDE;
76    virtual Factory getFactory() SK_OVERRIDE;
77    virtual void next(const SkPoint&, int u, int v, SkPath* dst) SK_OVERRIDE;
78
79private:
80    SkPath  fPath;
81
82    typedef Sk2DPathEffect INHERITED;
83};
84
85
86#endif
87