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
|
|
|
|
|
2018-05-21 15:56:57 +00:00
|
|
|
#include "SkFlattenable.h"
|
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:
|
2015-03-26 01:17:31 +00:00
|
|
|
bool filterPath(SkPath*, const SkPath&, SkStrokeRec*, const SkRect*) const override;
|
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-05-15 15:40:41 +00:00
|
|
|
explicit Sk2DPathEffect(const SkMatrix& mat);
|
2015-03-26 01:17:31 +00:00
|
|
|
void flatten(SkWriteBuffer&) const override;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
Revert "Reland "remove toString""
This reverts commit 92e37b6d79f12ccfaaf7671413316952d182267d.
Reason for revert: toString still used by flutter
Original change's description:
> Reland "remove toString"
>
> This reverts commit 32a4910e57b1fdd3c8671de1ee85e05ca21d079f.
>
> Reason for revert: SkMatrix::toString use has been removed from flutter and has been picked up in fuchsia
>
> Original change's description:
> > Revert "remove toString"
> >
> > This reverts commit 5191880cbf3ee4d122b0d11b4945fbab0784fda7.
> >
> > Reason for revert: broke flutter
> >
> > Original change's description:
> > > remove toString
> > >
> > > toString may have been used by obsolete debugger only
> > > find out if that is so
> > >
> > > R=​brianosman@google.com,bsalomon@google.com
> > >
> > > Docs-Preview: https://skia.org/?cl=119894
> > > Bug:830651
> > > Change-Id: I737f19b7d3fbc869bea2f443fa3b5ed7c1393ffd
> > > Reviewed-on: https://skia-review.googlesource.com/119894
> > > Commit-Queue: Cary Clark <caryclark@google.com>
> > > Reviewed-by: Brian Salomon <bsalomon@google.com>
> >
> > TBR=bsalomon@google.com,brianosman@google.com,caryclark@google.com,caryclark@skia.org
> >
> > Change-Id: I9f81de6c3615ee0608bcea9081b77239b4b8816c
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Bug: 830651
> > Reviewed-on: https://skia-review.googlesource.com/129340
> > Reviewed-by: Cary Clark <caryclark@google.com>
> > Commit-Queue: Cary Clark <caryclark@google.com>
>
> TBR=bsalomon@google.com,brianosman@google.com,caryclark@google.com,caryclark@skia.org
>
> # Not skipping CQ checks because original CL landed > 1 day ago.
>
> Bug: 830651
> Change-Id: Ida8725b6051132d8c46faf99358a8fcc1bcabf34
> Reviewed-on: https://skia-review.googlesource.com/129623
> Reviewed-by: Cary Clark <caryclark@skia.org>
> Reviewed-by: Cary Clark <caryclark@google.com>
> Commit-Queue: Cary Clark <caryclark@google.com>
TBR=bsalomon@google.com,brianosman@google.com,caryclark@google.com,caryclark@skia.org
Change-Id: Iafc59ffc1b3db67c520ba31bf12d68e1b46c0ea2
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 830651
Reviewed-on: https://skia-review.googlesource.com/131082
Reviewed-by: Cary Clark <caryclark@google.com>
Commit-Queue: Cary Clark <caryclark@google.com>
2018-05-31 12:27:33 +00:00
|
|
|
void toString(SkString* str) const 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;
|
|
|
|
};
|
|
|
|
|
2012-10-12 14:41:39 +00:00
|
|
|
class SK_API SkLine2DPathEffect : public Sk2DPathEffect {
|
2012-09-12 18:53:49 +00:00
|
|
|
public:
|
2016-03-18 18:22:57 +00:00
|
|
|
static sk_sp<SkPathEffect> Make(SkScalar width, const SkMatrix& matrix) {
|
2018-05-18 20:29:11 +00:00
|
|
|
if (!(width >= 0)) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2016-03-18 18:22:57 +00:00
|
|
|
return sk_sp<SkPathEffect>(new SkLine2DPathEffect(width, matrix));
|
2014-02-20 20:40:19 +00:00
|
|
|
}
|
2012-09-12 18:53:49 +00:00
|
|
|
|
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;
|
2012-09-12 18:53:49 +00:00
|
|
|
|
Revert "Reland "remove toString""
This reverts commit 92e37b6d79f12ccfaaf7671413316952d182267d.
Reason for revert: toString still used by flutter
Original change's description:
> Reland "remove toString"
>
> This reverts commit 32a4910e57b1fdd3c8671de1ee85e05ca21d079f.
>
> Reason for revert: SkMatrix::toString use has been removed from flutter and has been picked up in fuchsia
>
> Original change's description:
> > Revert "remove toString"
> >
> > This reverts commit 5191880cbf3ee4d122b0d11b4945fbab0784fda7.
> >
> > Reason for revert: broke flutter
> >
> > Original change's description:
> > > remove toString
> > >
> > > toString may have been used by obsolete debugger only
> > > find out if that is so
> > >
> > > R=​brianosman@google.com,bsalomon@google.com
> > >
> > > Docs-Preview: https://skia.org/?cl=119894
> > > Bug:830651
> > > Change-Id: I737f19b7d3fbc869bea2f443fa3b5ed7c1393ffd
> > > Reviewed-on: https://skia-review.googlesource.com/119894
> > > Commit-Queue: Cary Clark <caryclark@google.com>
> > > Reviewed-by: Brian Salomon <bsalomon@google.com>
> >
> > TBR=bsalomon@google.com,brianosman@google.com,caryclark@google.com,caryclark@skia.org
> >
> > Change-Id: I9f81de6c3615ee0608bcea9081b77239b4b8816c
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Bug: 830651
> > Reviewed-on: https://skia-review.googlesource.com/129340
> > Reviewed-by: Cary Clark <caryclark@google.com>
> > Commit-Queue: Cary Clark <caryclark@google.com>
>
> TBR=bsalomon@google.com,brianosman@google.com,caryclark@google.com,caryclark@skia.org
>
> # Not skipping CQ checks because original CL landed > 1 day ago.
>
> Bug: 830651
> Change-Id: Ida8725b6051132d8c46faf99358a8fcc1bcabf34
> Reviewed-on: https://skia-review.googlesource.com/129623
> Reviewed-by: Cary Clark <caryclark@skia.org>
> Reviewed-by: Cary Clark <caryclark@google.com>
> Commit-Queue: Cary Clark <caryclark@google.com>
TBR=bsalomon@google.com,brianosman@google.com,caryclark@google.com,caryclark@skia.org
Change-Id: Iafc59ffc1b3db67c520ba31bf12d68e1b46c0ea2
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 830651
Reviewed-on: https://skia-review.googlesource.com/131082
Reviewed-by: Cary Clark <caryclark@google.com>
Commit-Queue: Cary Clark <caryclark@google.com>
2018-05-31 12:27:33 +00:00
|
|
|
void toString(SkString* str) const override;
|
|
|
|
|
2018-05-21 15:56:57 +00:00
|
|
|
Factory getFactory() const override { return CreateProc; }
|
2012-09-12 18:53:49 +00:00
|
|
|
|
|
|
|
protected:
|
2014-05-15 15:40:41 +00:00
|
|
|
SkLine2DPathEffect(SkScalar width, const SkMatrix& matrix)
|
2018-05-18 20:29:11 +00:00
|
|
|
: Sk2DPathEffect(matrix), fWidth(width) {
|
|
|
|
SkASSERT(width >= 0);
|
|
|
|
}
|
2015-03-26 01:17:31 +00:00
|
|
|
void flatten(SkWriteBuffer&) const override;
|
2012-09-12 18:53:49 +00:00
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
void nextSpan(int u, int v, int ucount, SkPath*) const override;
|
2014-02-20 20:40:19 +00:00
|
|
|
|
2012-09-12 18:53:49 +00:00
|
|
|
private:
|
2018-05-21 15:56:57 +00:00
|
|
|
static sk_sp<SkFlattenable> CreateProc(SkReadBuffer&);
|
|
|
|
friend class SkFlattenable::PrivateInitializer;
|
|
|
|
|
2012-09-12 18:53:49 +00:00
|
|
|
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.
|
|
|
|
*/
|
2016-03-18 18:22:57 +00:00
|
|
|
static sk_sp<SkPathEffect> Make(const SkMatrix& matrix, const SkPath& path) {
|
|
|
|
return sk_sp<SkPathEffect>(new SkPath2DPathEffect(matrix, path));
|
2014-02-20 20:40:19 +00:00
|
|
|
}
|
2012-08-23 18:09:54 +00:00
|
|
|
|
Revert "Reland "remove toString""
This reverts commit 92e37b6d79f12ccfaaf7671413316952d182267d.
Reason for revert: toString still used by flutter
Original change's description:
> Reland "remove toString"
>
> This reverts commit 32a4910e57b1fdd3c8671de1ee85e05ca21d079f.
>
> Reason for revert: SkMatrix::toString use has been removed from flutter and has been picked up in fuchsia
>
> Original change's description:
> > Revert "remove toString"
> >
> > This reverts commit 5191880cbf3ee4d122b0d11b4945fbab0784fda7.
> >
> > Reason for revert: broke flutter
> >
> > Original change's description:
> > > remove toString
> > >
> > > toString may have been used by obsolete debugger only
> > > find out if that is so
> > >
> > > R=​brianosman@google.com,bsalomon@google.com
> > >
> > > Docs-Preview: https://skia.org/?cl=119894
> > > Bug:830651
> > > Change-Id: I737f19b7d3fbc869bea2f443fa3b5ed7c1393ffd
> > > Reviewed-on: https://skia-review.googlesource.com/119894
> > > Commit-Queue: Cary Clark <caryclark@google.com>
> > > Reviewed-by: Brian Salomon <bsalomon@google.com>
> >
> > TBR=bsalomon@google.com,brianosman@google.com,caryclark@google.com,caryclark@skia.org
> >
> > Change-Id: I9f81de6c3615ee0608bcea9081b77239b4b8816c
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Bug: 830651
> > Reviewed-on: https://skia-review.googlesource.com/129340
> > Reviewed-by: Cary Clark <caryclark@google.com>
> > Commit-Queue: Cary Clark <caryclark@google.com>
>
> TBR=bsalomon@google.com,brianosman@google.com,caryclark@google.com,caryclark@skia.org
>
> # Not skipping CQ checks because original CL landed > 1 day ago.
>
> Bug: 830651
> Change-Id: Ida8725b6051132d8c46faf99358a8fcc1bcabf34
> Reviewed-on: https://skia-review.googlesource.com/129623
> Reviewed-by: Cary Clark <caryclark@skia.org>
> Reviewed-by: Cary Clark <caryclark@google.com>
> Commit-Queue: Cary Clark <caryclark@google.com>
TBR=bsalomon@google.com,brianosman@google.com,caryclark@google.com,caryclark@skia.org
Change-Id: Iafc59ffc1b3db67c520ba31bf12d68e1b46c0ea2
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 830651
Reviewed-on: https://skia-review.googlesource.com/131082
Reviewed-by: Cary Clark <caryclark@google.com>
Commit-Queue: Cary Clark <caryclark@google.com>
2018-05-31 12:27:33 +00:00
|
|
|
void toString(SkString* str) const override;
|
|
|
|
|
2018-05-21 15:56:57 +00:00
|
|
|
Factory getFactory() const override { return CreateProc; }
|
2011-08-09 18:47:40 +00:00
|
|
|
|
|
|
|
protected:
|
2014-05-15 15:40:41 +00:00
|
|
|
SkPath2DPathEffect(const SkMatrix&, const SkPath&);
|
2015-03-26 01:17:31 +00:00
|
|
|
void flatten(SkWriteBuffer&) const override;
|
2011-08-09 18:47:40 +00:00
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
void next(const SkPoint&, int u, int v, SkPath*) const override;
|
2011-08-09 18:47:40 +00:00
|
|
|
|
|
|
|
private:
|
2018-05-21 15:56:57 +00:00
|
|
|
static sk_sp<SkFlattenable> CreateProc(SkReadBuffer&);
|
|
|
|
friend class SkFlattenable::PrivateInitializer;
|
|
|
|
|
2011-08-09 18:47:40 +00:00
|
|
|
SkPath fPath;
|
|
|
|
|
|
|
|
typedef Sk2DPathEffect INHERITED;
|
|
|
|
};
|
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
#endif
|