Sk2DPathEffect.h revision 6b919c353727f72342a20a7aa4ded9c022f5d816
1/*
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 Sk2DPathEffect_DEFINED
18#define Sk2DPathEffect_DEFINED
19
20#include "SkPathEffect.h"
21#include "SkMatrix.h"
22
23//  This class is not exported to java.
24class Sk2DPathEffect : public SkPathEffect {
25public:
26    Sk2DPathEffect(const SkMatrix& mat);
27
28    // overrides
29    //  This method is not exported to java.
30    virtual bool filterPath(SkPath* dst, const SkPath& src, SkScalar* width);
31
32    // overrides from SkFlattenable
33    //  This method is not exported to java.
34    virtual void flatten(SkFlattenableWriteBuffer&);
35
36    //  This method is not exported to java.
37    virtual Factory getFactory();
38
39protected:
40    /** New virtual, to be overridden by subclasses.
41        This is called once from filterPath, and provides the
42        uv parameter bounds for the path. Subsequent calls to
43        next() will receive u and v values within these bounds,
44        and then a call to end() will signal the end of processing.
45    */
46    virtual void begin(const SkIRect& uvBounds, SkPath* dst);
47    virtual void next(const SkPoint& loc, int u, int v, SkPath* dst);
48    virtual void end(SkPath* dst);
49
50    /** Low-level virtual called per span of locations in the u-direction.
51        The default implementation calls next() repeatedly with each
52        location.
53    */
54    virtual void nextSpan(int u, int v, int ucount, SkPath* dst);
55
56    const SkMatrix& getMatrix() const { return fMatrix; }
57
58    // protected so that subclasses can call this during unflattening
59    Sk2DPathEffect(SkFlattenableReadBuffer&);
60
61private:
62    SkMatrix    fMatrix, fInverse;
63    // illegal
64    Sk2DPathEffect(const Sk2DPathEffect&);
65    Sk2DPathEffect& operator=(const Sk2DPathEffect&);
66
67    static SkFlattenable* CreateProc(SkFlattenableReadBuffer&);
68
69    friend class Sk2DPathEffectBlitter;
70    typedef SkPathEffect INHERITED;
71};
72
73#endif
74