2008-12-17 15:59:43 +00:00
|
|
|
/*
|
2011-07-28 14:26:00 +00:00
|
|
|
* Copyright 2006 The Android Open Source Project
|
2008-12-17 15:59:43 +00:00
|
|
|
*
|
2011-07-28 14:26:00 +00:00
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkDashPathEffect_DEFINED
|
|
|
|
#define SkDashPathEffect_DEFINED
|
|
|
|
|
|
|
|
#include "SkPathEffect.h"
|
|
|
|
|
|
|
|
/** \class SkDashPathEffect
|
|
|
|
|
|
|
|
SkDashPathEffect is a subclass of SkPathEffect that implements dashing
|
|
|
|
*/
|
2011-03-15 21:27:08 +00:00
|
|
|
class SK_API SkDashPathEffect : public SkPathEffect {
|
2008-12-17 15:59:43 +00:00
|
|
|
public:
|
2012-04-27 13:34:52 +00:00
|
|
|
/** intervals: array containing an even number of entries (>=2), with
|
|
|
|
the even indices specifying the length of "on" intervals, and the odd
|
|
|
|
indices specifying the length of "off" intervals.
|
2012-08-23 18:09:54 +00:00
|
|
|
count: number of elements in the intervals array
|
2012-04-27 13:34:52 +00:00
|
|
|
phase: offset into the intervals array (mod the sum of all of the
|
|
|
|
intervals).
|
|
|
|
|
|
|
|
For example: if intervals[] = {10, 20}, count = 2, and phase = 25,
|
|
|
|
this will set up a dashed path like so:
|
|
|
|
5 pixels off
|
|
|
|
10 pixels on
|
|
|
|
20 pixels off
|
|
|
|
10 pixels on
|
|
|
|
20 pixels off
|
|
|
|
...
|
|
|
|
A phase of -5, 25, 55, 85, etc. would all result in the same path,
|
|
|
|
because the sum of all the intervals is 30.
|
|
|
|
|
|
|
|
Note: only affects stroked paths.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
SkDashPathEffect(const SkScalar intervals[], int count, SkScalar phase, bool scaleToFit = false);
|
|
|
|
virtual ~SkDashPathEffect();
|
|
|
|
|
Change patheffect to take a (new) StrokeRec object, which encapsulates the fill
or stroke parameters for a path.
Today, the patheffect only sees if the caller was going to stroke or fill, and
if stroke, it just sees the width. With this change, the effect can see all of the
related parameters (e.g. cap/join/miter). No other change is intended at this
time.
After this change, I hope to use this additional data to allow SkDashPathEffect
to, at times, apply the stroke as part of its effect, which may be much more
efficient than first dashing, and then reading that and stroking it.
Most of these files changed just because of the new parameter to filterPath. The
key changes are in SkPathEffect.[h,cpp], SkPaint.cpp and SkScalerContext.cpp
Review URL: https://codereview.appspot.com/6250051
git-svn-id: http://skia.googlecode.com/svn/trunk@4048 2bbb7eff-a529-9590-31e7-b0007b416f81
2012-05-25 01:04:12 +00:00
|
|
|
virtual bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*) SK_OVERRIDE;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
// overrides for SkFlattenable
|
|
|
|
// This method is not exported to java.
|
|
|
|
virtual Factory getFactory();
|
2011-06-21 19:24:00 +00:00
|
|
|
static SkFlattenable* CreateProc(SkFlattenableReadBuffer&);
|
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
protected:
|
|
|
|
SkDashPathEffect(SkFlattenableReadBuffer&);
|
2012-03-29 15:18:04 +00:00
|
|
|
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
private:
|
|
|
|
SkScalar* fIntervals;
|
|
|
|
int32_t fCount;
|
|
|
|
// computed from phase
|
|
|
|
SkScalar fInitialDashLength;
|
|
|
|
int32_t fInitialDashIndex;
|
|
|
|
SkScalar fIntervalLength;
|
|
|
|
bool fScaleToFit;
|
|
|
|
|
|
|
|
typedef SkPathEffect INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|