skia2/include/effects/SkDashPathEffect.h
egdaniel 90b8cafb6a Revert of Move Dashing filterPath to a dashing utils file (https://codereview.chromium.org/314623004/)
Reason for revert:
Need to create utils.gypi file and update chrome

Original issue's description:
> Move Dashing filterPath to a dashing utils file
>
> From inside GrContext, we have a need to create an SkPath an original path and
> some dashing info. We do not have access to the original path effect so we need
> a way to make the FilterPath function accessible outside of the effect. So I moved
> the core filterPath code (and all need helper functions) out of SkDashPathEffect
> and created a SkDashPath in utils to store these helper functions.
>
> BUG=skia:
>
> Committed: https://skia.googlesource.com/skia/+/576dcdc793a762ec63fbecdbfd5768066b548fe5

R=bsalomon@google.com, reed@google.com, rmistry@google.com
TBR=bsalomon@google.com, reed@google.com, rmistry@google.com
NOTREECHECKS=true
NOTRY=true
BUG=skia:

Author: egdaniel@google.com

Review URL: https://codereview.chromium.org/317663003
2014-06-04 09:59:08 -07:00

78 lines
2.4 KiB
C++

/*
* Copyright 2006 The Android Open Source Project
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkDashPathEffect_DEFINED
#define SkDashPathEffect_DEFINED
#include "SkPathEffect.h"
/** \class SkDashPathEffect
SkDashPathEffect is a subclass of SkPathEffect that implements dashing
*/
class SK_API SkDashPathEffect : public SkPathEffect {
public:
/** 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.
count: number of elements in the intervals array
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.
*/
static SkDashPathEffect* Create(const SkScalar intervals[], int count,
SkScalar phase) {
return SkNEW_ARGS(SkDashPathEffect, (intervals, count, phase));
}
virtual ~SkDashPathEffect();
virtual bool filterPath(SkPath* dst, const SkPath& src,
SkStrokeRec*, const SkRect*) const SK_OVERRIDE;
virtual bool asPoints(PointData* results, const SkPath& src,
const SkStrokeRec&, const SkMatrix&,
const SkRect*) const SK_OVERRIDE;
virtual DashType asADash(DashInfo* info) const SK_OVERRIDE;
virtual Factory getFactory() const SK_OVERRIDE;
static SkFlattenable* CreateProc(SkReadBuffer&);
protected:
SkDashPathEffect(const SkScalar intervals[], int count, SkScalar phase);
explicit SkDashPathEffect(SkReadBuffer&);
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
private:
void setInternalMembers(SkScalar phase);
SkScalar* fIntervals;
int32_t fCount;
SkScalar fPhase;
// computed from phase
SkScalar fInitialDashLength;
int32_t fInitialDashIndex;
SkScalar fIntervalLength;
typedef SkPathEffect INHERITED;
};
#endif