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 Sk1DPathEffect_DEFINED
|
|
|
|
#define Sk1DPathEffect_DEFINED
|
|
|
|
|
|
|
|
#include "SkPathEffect.h"
|
|
|
|
#include "SkPath.h"
|
|
|
|
|
|
|
|
class SkPathMeasure;
|
|
|
|
|
2012-10-12 14:41:39 +00:00
|
|
|
// This class is not exported to java.
|
|
|
|
class SK_API Sk1DPathEffect : public SkPathEffect {
|
2008-12-17 15:59:43 +00:00
|
|
|
public:
|
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
|
|
|
|
|
|
|
protected:
|
|
|
|
/** Called at the start of each contour, returns the initial offset
|
|
|
|
into that contour.
|
|
|
|
*/
|
|
|
|
virtual SkScalar begin(SkScalar contourLength) = 0;
|
|
|
|
/** Called with the current distance along the path, with the current matrix
|
|
|
|
for the point/tangent at the specified distance.
|
|
|
|
Return the distance to travel for the next call. If return <= 0, then that
|
|
|
|
contour is done.
|
|
|
|
*/
|
|
|
|
virtual SkScalar next(SkPath* dst, SkScalar distance, SkPathMeasure&) = 0;
|
|
|
|
|
|
|
|
private:
|
|
|
|
typedef SkPathEffect INHERITED;
|
|
|
|
};
|
|
|
|
|
2012-10-12 14:41:39 +00:00
|
|
|
class SK_API SkPath1DPathEffect : public Sk1DPathEffect {
|
2008-12-17 15:59:43 +00:00
|
|
|
public:
|
|
|
|
enum Style {
|
|
|
|
kTranslate_Style, // translate the shape to each position
|
|
|
|
kRotate_Style, // rotate the shape about its center
|
|
|
|
kMorph_Style, // transform each point, and turn lines into curves
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
kStyleCount
|
|
|
|
};
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
/** Dash by replicating the specified path.
|
|
|
|
@param path The path to replicate (dash)
|
|
|
|
@param advance The space between instances of path
|
|
|
|
@param phase distance (mod advance) along path for its initial position
|
|
|
|
@param style how to transform path at each point (based on the current
|
|
|
|
position and tangent)
|
|
|
|
*/
|
|
|
|
SkPath1DPathEffect(const SkPath& path, SkScalar advance, SkScalar phase, Style);
|
|
|
|
|
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*, const SkPath&, SkStrokeRec*) SK_OVERRIDE;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2012-03-26 17:57:35 +00:00
|
|
|
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPath1DPathEffect)
|
2011-08-09 18:14:31 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
protected:
|
|
|
|
SkPath1DPathEffect(SkFlattenableReadBuffer& buffer);
|
2012-03-29 15:18:04 +00:00
|
|
|
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
// overrides from Sk1DPathEffect
|
2011-11-23 02:08:50 +00:00
|
|
|
virtual SkScalar begin(SkScalar contourLength) SK_OVERRIDE;
|
|
|
|
virtual SkScalar next(SkPath*, SkScalar distance, SkPathMeasure&) SK_OVERRIDE;
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
private:
|
|
|
|
SkPath fPath; // copied from constructor
|
|
|
|
SkScalar fAdvance; // copied from constructor
|
|
|
|
SkScalar fInitialOffset; // computed from phase
|
|
|
|
Style fStyle; // copied from constructor
|
|
|
|
|
|
|
|
typedef Sk1DPathEffect INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|