2011-07-28 14:26:00 +00:00
|
|
|
|
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
|
|
|
*/
|
|
|
|
|
2011-07-28 14:26:00 +00:00
|
|
|
|
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"
|
|
|
|
|
|
|
|
class Sk2DPathEffect : public SkPathEffect {
|
|
|
|
public:
|
|
|
|
Sk2DPathEffect(const SkMatrix& mat);
|
|
|
|
|
|
|
|
// overrides
|
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(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.
|
|
|
|
*/
|
|
|
|
virtual void begin(const SkIRect& uvBounds, SkPath* dst);
|
|
|
|
virtual void next(const SkPoint& loc, int u, int v, SkPath* dst);
|
|
|
|
virtual void end(SkPath* dst);
|
|
|
|
|
|
|
|
/** Low-level virtual called per span of locations in the u-direction.
|
|
|
|
The default implementation calls next() repeatedly with each
|
|
|
|
location.
|
|
|
|
*/
|
|
|
|
virtual void nextSpan(int u, int v, int ucount, SkPath* dst);
|
|
|
|
|
|
|
|
const SkMatrix& getMatrix() const { return fMatrix; }
|
|
|
|
|
|
|
|
// protected so that subclasses can call this during unflattening
|
|
|
|
Sk2DPathEffect(SkFlattenableReadBuffer&);
|
2012-03-29 15:18:04 +00:00
|
|
|
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
|
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;
|
|
|
|
};
|
|
|
|
|
2011-08-09 18:47:40 +00:00
|
|
|
class SkPath2DPathEffect : public Sk2DPathEffect {
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Stamp the specified path to fill the shape, using the matrix to define
|
|
|
|
* the latice.
|
|
|
|
*/
|
|
|
|
SkPath2DPathEffect(const SkMatrix&, const SkPath&);
|
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:
|
|
|
|
SkPath2DPathEffect(SkFlattenableReadBuffer& buffer);
|
2012-03-29 15:18:04 +00:00
|
|
|
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
|
2011-08-09 18:47:40 +00:00
|
|
|
|
2011-11-23 02:08:50 +00:00
|
|
|
virtual void next(const SkPoint&, int u, int v, SkPath* dst) SK_OVERRIDE;
|
2011-08-09 18:47:40 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
SkPath fPath;
|
|
|
|
|
|
|
|
typedef Sk2DPathEffect INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
#endif
|