Home | History | Annotate | Download | only in effects
      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 */
     19 class SK_API SkDashPathEffect : public SkPathEffect {
     20 public:
     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     //  This method is not exported to java.
     38     virtual void flatten(SkFlattenableWriteBuffer&);
     39 
     40     static SkFlattenable* CreateProc(SkFlattenableReadBuffer&);
     41 
     42     SK_DECLARE_FLATTENABLE_REGISTRAR()
     43 
     44 protected:
     45     SkDashPathEffect(SkFlattenableReadBuffer&);
     46 
     47 private:
     48     SkScalar*   fIntervals;
     49     int32_t     fCount;
     50     // computed from phase
     51     SkScalar    fInitialDashLength;
     52     int32_t     fInitialDashIndex;
     53     SkScalar    fIntervalLength;
     54     bool        fScaleToFit;
     55 
     56     typedef SkPathEffect INHERITED;
     57 };
     58 
     59 #endif
     60 
     61