SkDashPathEffect.h revision 54924243c1b65b3ee6d8fa064b50a9b1bb2a19a5
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 SkDashPathEffect_DEFINED
11#define SkDashPathEffect_DEFINED
12
13#include "SkPathEffect.h"
14
15/** \class SkDashPathEffect
16
17    SkDashPathEffect is a subclass of SkPathEffect that implements dashing
18*/
19class SK_API SkDashPathEffect : public SkPathEffect {
20public:
21    /** The intervals array must contain an even number of entries (>=2), with the even
22        indices specifying the "on" intervals, and the odd indices specifying the "off"
23        intervals. phase is an offset into the intervals array (mod the sum of all of the
24        intervals).
25        Note: only affects framed paths
26    */
27    SkDashPathEffect(const SkScalar intervals[], int count, SkScalar phase, bool scaleToFit = false);
28    virtual ~SkDashPathEffect();
29
30    // overrides for SkPathEffect
31    //  This method is not exported to java.
32    virtual bool filterPath(SkPath* dst, const SkPath& src, SkScalar* width);
33
34    // overrides for SkFlattenable
35    //  This method is not exported to java.
36    virtual Factory getFactory();
37    static SkFlattenable* CreateProc(SkFlattenableReadBuffer&);
38
39protected:
40    SkDashPathEffect(SkFlattenableReadBuffer&);
41    virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
42
43private:
44    SkScalar*   fIntervals;
45    int32_t     fCount;
46    // computed from phase
47    SkScalar    fInitialDashLength;
48    int32_t     fInitialDashIndex;
49    SkScalar    fIntervalLength;
50    bool        fScaleToFit;
51
52    typedef SkPathEffect INHERITED;
53};
54
55#endif
56
57