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 Sk2DPathEffect_DEFINED
|
|
|
|
#define Sk2DPathEffect_DEFINED
|
|
|
|
|
2011-08-09 18:47:40 +00:00
|
|
|
#include "SkPath.h"
|
2008-12-17 15:59:43 +00:00
|
|
|
#include "SkPathEffect.h"
|
|
|
|
#include "SkMatrix.h"
|
|
|
|
|
2012-10-12 14:41:39 +00:00
|
|
|
class SK_API Sk2DPathEffect : public SkPathEffect {
|
2008-12-17 15:59:43 +00:00
|
|
|
public:
|
2014-02-20 20:40:19 +00:00
|
|
|
static Sk2DPathEffect* Create(const SkMatrix& mat) {
|
|
|
|
return SkNEW_ARGS(Sk2DPathEffect, (mat));
|
|
|
|
}
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2012-12-18 16:12:09 +00:00
|
|
|
virtual bool filterPath(SkPath*, const SkPath&,
|
2013-01-24 21:03:11 +00:00
|
|
|
SkStrokeRec*, const SkRect*) const SK_OVERRIDE;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2012-03-26 17:57:35 +00:00
|
|
|
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Sk2DPathEffect)
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
/** New virtual, to be overridden by subclasses.
|
|
|
|
This is called once from filterPath, and provides the
|
|
|
|
uv parameter bounds for the path. Subsequent calls to
|
|
|
|
next() will receive u and v values within these bounds,
|
|
|
|
and then a call to end() will signal the end of processing.
|
|
|
|
*/
|
2012-12-18 16:12:09 +00:00
|
|
|
virtual void begin(const SkIRect& uvBounds, SkPath* dst) const;
|
|
|
|
virtual void next(const SkPoint& loc, int u, int v, SkPath* dst) const;
|
|
|
|
virtual void end(SkPath* dst) const;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
/** Low-level virtual called per span of locations in the u-direction.
|
|
|
|
The default implementation calls next() repeatedly with each
|
|
|
|
location.
|
|
|
|
*/
|
2012-12-18 16:12:09 +00:00
|
|
|
virtual void nextSpan(int u, int v, int ucount, SkPath* dst) const;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
const SkMatrix& getMatrix() const { return fMatrix; }
|
|
|
|
|
|
|
|
// protected so that subclasses can call this during unflattening
|
2014-01-30 18:58:24 +00:00
|
|
|
Sk2DPathEffect(SkReadBuffer&);
|
|
|
|
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2014-02-20 20:40:19 +00:00
|
|
|
#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
|
|
|
|
public:
|
|
|
|
#endif
|
|
|
|
Sk2DPathEffect(const SkMatrix& mat);
|
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
private:
|
|
|
|
SkMatrix fMatrix, fInverse;
|
2012-04-14 19:06:16 +00:00
|
|
|
bool fMatrixIsInvertible;
|
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
// illegal
|
|
|
|
Sk2DPathEffect(const Sk2DPathEffect&);
|
|
|
|
Sk2DPathEffect& operator=(const Sk2DPathEffect&);
|
|
|
|
|
|
|
|
friend class Sk2DPathEffectBlitter;
|
|
|
|
typedef SkPathEffect INHERITED;
|
|
|
|
};
|
|
|
|
|
2012-10-12 14:41:39 +00:00
|
|
|
class SK_API SkLine2DPathEffect : public Sk2DPathEffect {
|
2012-09-12 18:53:49 +00:00
|
|
|
public:
|
2014-02-20 20:40:19 +00:00
|
|
|
static SkLine2DPathEffect* Create(SkScalar width, const SkMatrix& matrix) {
|
|
|
|
return SkNEW_ARGS(SkLine2DPathEffect, (width, matrix));
|
|
|
|
}
|
2012-09-12 18:53:49 +00:00
|
|
|
|
2012-12-18 16:12:09 +00:00
|
|
|
virtual bool filterPath(SkPath* dst, const SkPath& src,
|
2013-01-24 21:03:11 +00:00
|
|
|
SkStrokeRec*, const SkRect*) const SK_OVERRIDE;
|
2012-09-12 18:53:49 +00:00
|
|
|
|
|
|
|
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLine2DPathEffect)
|
|
|
|
|
|
|
|
protected:
|
2012-12-18 16:12:09 +00:00
|
|
|
virtual void nextSpan(int u, int v, int ucount, SkPath*) const SK_OVERRIDE;
|
2012-09-12 18:53:49 +00:00
|
|
|
|
2014-01-30 18:58:24 +00:00
|
|
|
SkLine2DPathEffect(SkReadBuffer&);
|
2012-09-12 18:53:49 +00:00
|
|
|
|
2014-01-30 18:58:24 +00:00
|
|
|
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
2012-09-12 18:53:49 +00:00
|
|
|
|
2014-02-20 20:40:19 +00:00
|
|
|
#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
|
|
|
|
public:
|
|
|
|
#endif
|
|
|
|
SkLine2DPathEffect(SkScalar width, const SkMatrix& matrix)
|
|
|
|
: Sk2DPathEffect(matrix), fWidth(width) {}
|
|
|
|
|
2012-09-12 18:53:49 +00:00
|
|
|
private:
|
|
|
|
SkScalar fWidth;
|
|
|
|
|
|
|
|
typedef Sk2DPathEffect INHERITED;
|
|
|
|
};
|
|
|
|
|
2012-10-12 14:41:39 +00:00
|
|
|
class SK_API SkPath2DPathEffect : public Sk2DPathEffect {
|
2011-08-09 18:47:40 +00:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Stamp the specified path to fill the shape, using the matrix to define
|
|
|
|
* the latice.
|
|
|
|
*/
|
2014-02-20 20:40:19 +00:00
|
|
|
static SkPath2DPathEffect* Create(const SkMatrix& matrix, const SkPath& path) {
|
|
|
|
return SkNEW_ARGS(SkPath2DPathEffect, (matrix, path));
|
|
|
|
}
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2012-03-26 17:57:35 +00:00
|
|
|
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPath2DPathEffect)
|
2011-08-09 18:47:40 +00:00
|
|
|
|
|
|
|
protected:
|
2014-01-30 18:58:24 +00:00
|
|
|
SkPath2DPathEffect(SkReadBuffer& buffer);
|
|
|
|
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
2011-08-09 18:47:40 +00:00
|
|
|
|
2012-12-18 16:12:09 +00:00
|
|
|
virtual void next(const SkPoint&, int u, int v, SkPath*) const SK_OVERRIDE;
|
2011-08-09 18:47:40 +00:00
|
|
|
|
2014-02-20 20:40:19 +00:00
|
|
|
#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
|
|
|
|
public:
|
|
|
|
#endif
|
|
|
|
SkPath2DPathEffect(const SkMatrix&, const SkPath&);
|
|
|
|
|
2011-08-09 18:47:40 +00:00
|
|
|
private:
|
|
|
|
SkPath fPath;
|
|
|
|
|
|
|
|
typedef Sk2DPathEffect INHERITED;
|
|
|
|
};
|
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
#endif
|