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:
|
2012-12-18 16:12:09 +00:00
|
|
|
virtual bool filterPath(SkPath* dst, const SkPath& src,
|
2015-03-26 01:17:31 +00:00
|
|
|
SkStrokeRec*, const SkRect*) const override;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
/** Called at the start of each contour, returns the initial offset
|
|
|
|
into that contour.
|
|
|
|
*/
|
2012-12-18 16:12:09 +00:00
|
|
|
virtual SkScalar begin(SkScalar contourLength) const = 0;
|
2008-12-17 15:59:43 +00:00
|
|
|
/** 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.
|
|
|
|
*/
|
2012-12-18 16:12:09 +00:00
|
|
|
virtual SkScalar next(SkPath* dst, SkScalar dist, SkPathMeasure&) const = 0;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2015-03-05 16:01:07 +00:00
|
|
|
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
|
2015-03-26 01:17:31 +00:00
|
|
|
bool exposedInAndroidJavaAPI() const override { return true; }
|
2015-03-05 16:01:07 +00:00
|
|
|
#endif
|
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
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
|
2016-02-22 15:42:18 +00:00
|
|
|
|
2016-02-22 20:50:25 +00:00
|
|
|
kLastEnum_Style = kMorph_Style,
|
2008-12-17 15:59:43 +00:00
|
|
|
};
|
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)
|
|
|
|
*/
|
2016-03-18 18:22:57 +00:00
|
|
|
static sk_sp<SkPathEffect> Make(const SkPath& path, SkScalar advance, SkScalar phase, Style);
|
|
|
|
|
2012-12-18 16:12:09 +00:00
|
|
|
virtual bool filterPath(SkPath*, const SkPath&,
|
2015-03-26 01:17:31 +00:00
|
|
|
SkStrokeRec*, const SkRect*) const override;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2018-05-20 23:15:43 +00:00
|
|
|
void toString(SkString* str) const override;
|
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:
|
2014-05-15 15:40:41 +00:00
|
|
|
SkPath1DPathEffect(const SkPath& path, SkScalar advance, SkScalar phase, Style);
|
2015-03-26 01:17:31 +00:00
|
|
|
void flatten(SkWriteBuffer&) const override;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
// overrides from Sk1DPathEffect
|
2015-03-26 01:17:31 +00:00
|
|
|
SkScalar begin(SkScalar contourLength) const override;
|
|
|
|
SkScalar next(SkPath*, SkScalar, SkPathMeasure&) const 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
|