Sk2DPathEffect.h revision 8a1c16ff38322f0210116fa7293eb8817c7e477e
1b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam/*
2b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam * Copyright (C) 2006 The Android Open Source Project
3b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam *
4b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam * Licensed under the Apache License, Version 2.0 (the "License");
5b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam * you may not use this file except in compliance with the License.
6b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam * You may obtain a copy of the License at
7b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam *
8b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam *      http://www.apache.org/licenses/LICENSE-2.0
9b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam *
10b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam * Unless required by applicable law or agreed to in writing, software
11b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam * distributed under the License is distributed on an "AS IS" BASIS,
12b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam * See the License for the specific language governing permissions and
14b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam * limitations under the License.
15b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam */
16b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
17b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam#ifndef Sk2DPathEffect_DEFINED
18b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam#define Sk2DPathEffect_DEFINED
19b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
20b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam#include "SkPathEffect.h"
21b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam#include "SkMatrix.h"
22b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
23b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam//  This class is not exported to java.
24b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallamclass Sk2DPathEffect : public SkPathEffect {
25b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallampublic:
26b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    Sk2DPathEffect(const SkMatrix& mat);
27b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
28b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    // overrides
29b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    //  This method is not exported to java.
30b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    virtual bool    filterPath(SkPath* dst, const SkPath& src, SkScalar* width);
31b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
32b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    // overrides from SkFlattenable
33b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    //  This method is not exported to java.
34b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    virtual void    flatten(SkFlattenableWriteBuffer&);
35b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
36b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    //  This method is not exported to java.
37b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam       virtual Factory getFactory();
38b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
39b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallamprotected:
40b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    /** New virtual, to be overridden by subclasses.
41b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        This is called once from filterPath, and provides the
42b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        uv parameter bounds for the path. Subsequent calls to
43b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        next() will receive u and v values within these bounds,
44b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        and then a call to end() will signal the end of processing.
45b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    */
46b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    virtual void begin(const SkIRect& uvBounds, SkPath* dst);
47b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    virtual void next(const SkPoint& loc, int u, int v, SkPath* dst);
48b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    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