SkDashPathEffect.h revision 7ffb1b21abcc7bbed5a0fc711f6dd7b9dbb4f577
1a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)/*
2a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) * Copyright (C) 2006 The Android Open Source Project
3a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) *
4a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) * Licensed under the Apache License, Version 2.0 (the "License");
5a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) * you may not use this file except in compliance with the License.
6a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) * You may obtain a copy of the License at
7a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) *
8a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) *      http://www.apache.org/licenses/LICENSE-2.0
9a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) *
10a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) * Unless required by applicable law or agreed to in writing, software
11a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) * distributed under the License is distributed on an "AS IS" BASIS,
12a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) * See the License for the specific language governing permissions and
14a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) * limitations under the License.
15a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) */
16a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
17a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#ifndef SkDashPathEffect_DEFINED
18a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#define SkDashPathEffect_DEFINED
19a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
20a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "SkPathEffect.h"
21a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
22a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)/** \class SkDashPathEffect
23a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
24a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    SkDashPathEffect is a subclass of SkPathEffect that implements dashing
25a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)*/
26a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)class SK_API SkDashPathEffect : public SkPathEffect {
27a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)public:
28a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    /** The intervals array must contain an even number of entries (>=2), with the even
29a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)        indices specifying the "on" intervals, and the odd indices specifying the "off"
30a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)        intervals. phase is an offset into the intervals array (mod the sum of all of the
31a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)        intervals).
32a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)        Note: only affects framed paths
33a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    */
34a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    SkDashPathEffect(const SkScalar intervals[], int count, SkScalar phase, bool scaleToFit = false);
35a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    virtual ~SkDashPathEffect();
36a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
37a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    // overrides for SkPathEffect
38a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    //  This method is not exported to java.
39a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    virtual bool filterPath(SkPath* dst, const SkPath& src, SkScalar* width);
40a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
41a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    // overrides for SkFlattenable
42a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    //  This method is not exported to java.
43a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    virtual Factory getFactory();
44a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    //  This method is not exported to java.
45a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    virtual void flatten(SkFlattenableWriteBuffer&);
46a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
47a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)protected:
48a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    SkDashPathEffect(SkFlattenableReadBuffer&);
49a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
50a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)private:
51a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    SkScalar*   fIntervals;
52a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    int32_t     fCount;
53a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    // computed from phase
54a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    SkScalar    fInitialDashLength;
55a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    int32_t     fInitialDashIndex;
56a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    SkScalar    fIntervalLength;
57a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    bool        fScaleToFit;
58a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
59a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    static SkFlattenable* CreateProc(SkFlattenableReadBuffer&);
60a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
61a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    typedef SkPathEffect INHERITED;
62a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)};
63a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
64a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#endif
65a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
66a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)