gfx/skia/trunk/include/effects/SkDashPathEffect.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/include/effects/SkDashPathEffect.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,78 @@
     1.4 +/*
     1.5 + * Copyright 2006 The Android Open Source Project
     1.6 + *
     1.7 + * Use of this source code is governed by a BSD-style license that can be
     1.8 + * found in the LICENSE file.
     1.9 + */
    1.10 +
    1.11 +#ifndef SkDashPathEffect_DEFINED
    1.12 +#define SkDashPathEffect_DEFINED
    1.13 +
    1.14 +#include "SkPathEffect.h"
    1.15 +
    1.16 +/** \class SkDashPathEffect
    1.17 +
    1.18 +    SkDashPathEffect is a subclass of SkPathEffect that implements dashing
    1.19 +*/
    1.20 +class SK_API SkDashPathEffect : public SkPathEffect {
    1.21 +public:
    1.22 +    /** intervals: array containing an even number of entries (>=2), with
    1.23 +         the even indices specifying the length of "on" intervals, and the odd
    1.24 +         indices specifying the length of "off" intervals.
    1.25 +        count: number of elements in the intervals array
    1.26 +        phase: offset into the intervals array (mod the sum of all of the
    1.27 +         intervals).
    1.28 +
    1.29 +        For example: if intervals[] = {10, 20}, count = 2, and phase = 25,
    1.30 +         this will set up a dashed path like so:
    1.31 +         5 pixels off
    1.32 +         10 pixels on
    1.33 +         20 pixels off
    1.34 +         10 pixels on
    1.35 +         20 pixels off
    1.36 +         ...
    1.37 +        A phase of -5, 25, 55, 85, etc. would all result in the same path,
    1.38 +         because the sum of all the intervals is 30.
    1.39 +
    1.40 +        Note: only affects stroked paths.
    1.41 +    */
    1.42 +    static SkDashPathEffect* Create(const SkScalar intervals[], int count,
    1.43 +                                    SkScalar phase, bool scaleToFit = false) {
    1.44 +        return SkNEW_ARGS(SkDashPathEffect, (intervals, count, phase, scaleToFit));
    1.45 +    }
    1.46 +    virtual ~SkDashPathEffect();
    1.47 +
    1.48 +    virtual bool filterPath(SkPath* dst, const SkPath& src,
    1.49 +                            SkStrokeRec*, const SkRect*) const SK_OVERRIDE;
    1.50 +
    1.51 +    virtual bool asPoints(PointData* results, const SkPath& src,
    1.52 +                          const SkStrokeRec&, const SkMatrix&,
    1.53 +                          const SkRect*) const SK_OVERRIDE;
    1.54 +
    1.55 +    virtual Factory getFactory() const SK_OVERRIDE;
    1.56 +
    1.57 +    static SkFlattenable* CreateProc(SkReadBuffer&);
    1.58 +
    1.59 +protected:
    1.60 +    SkDashPathEffect(SkReadBuffer&);
    1.61 +    virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
    1.62 +
    1.63 +#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
    1.64 +public:
    1.65 +#endif
    1.66 +    SkDashPathEffect(const SkScalar intervals[], int count, SkScalar phase,
    1.67 +                     bool scaleToFit = false);
    1.68 +
    1.69 +private:
    1.70 +    SkScalar*   fIntervals;
    1.71 +    int32_t     fCount;
    1.72 +    // computed from phase
    1.73 +    SkScalar    fInitialDashLength;
    1.74 +    int32_t     fInitialDashIndex;
    1.75 +    SkScalar    fIntervalLength;
    1.76 +    bool        fScaleToFit;
    1.77 +
    1.78 +    typedef SkPathEffect INHERITED;
    1.79 +};
    1.80 +
    1.81 +#endif

mercurial