2018-01-07 13:54:24 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2017 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkSGTrimEffect_DEFINED
|
|
|
|
#define SkSGTrimEffect_DEFINED
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "modules/sksg/include/SkSGGeometryNode.h"
|
2018-01-07 13:54:24 +00:00
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkPath.h"
|
|
|
|
#include "include/effects/SkTrimPathEffect.h"
|
2018-01-07 13:54:24 +00:00
|
|
|
|
|
|
|
class SkCanvas;
|
|
|
|
class SkPaint;
|
|
|
|
|
|
|
|
namespace sksg {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Concrete Geometry node, applying a trim effect to its child.
|
|
|
|
*/
|
|
|
|
class TrimEffect final : public GeometryNode {
|
|
|
|
public:
|
|
|
|
static sk_sp<TrimEffect> Make(sk_sp<GeometryNode> child) {
|
|
|
|
return child ? sk_sp<TrimEffect>(new TrimEffect(std::move(child))) : nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
~TrimEffect() override;
|
|
|
|
|
2018-03-22 16:20:02 +00:00
|
|
|
SG_ATTRIBUTE(Start , SkScalar , fStart )
|
|
|
|
SG_ATTRIBUTE(Stop , SkScalar , fStop )
|
|
|
|
SG_ATTRIBUTE(Mode , SkTrimPathEffect::Mode, fMode )
|
2018-01-07 13:54:24 +00:00
|
|
|
|
|
|
|
protected:
|
2018-01-29 21:31:14 +00:00
|
|
|
void onClip(SkCanvas*, bool antiAlias) const override;
|
2018-01-07 13:54:24 +00:00
|
|
|
void onDraw(SkCanvas*, const SkPaint&) const override;
|
2019-02-12 14:33:21 +00:00
|
|
|
bool onContains(const SkPoint&) const override;
|
2018-01-07 13:54:24 +00:00
|
|
|
|
|
|
|
SkRect onRevalidate(InvalidationController*, const SkMatrix&) override;
|
|
|
|
SkPath onAsPath() const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
explicit TrimEffect(sk_sp<GeometryNode>);
|
|
|
|
|
|
|
|
const sk_sp<GeometryNode> fChild;
|
|
|
|
|
2018-03-07 21:37:38 +00:00
|
|
|
SkPath fTrimmedPath;
|
2018-03-22 16:20:02 +00:00
|
|
|
SkScalar fStart = 0,
|
|
|
|
fStop = 1;
|
|
|
|
SkTrimPathEffect::Mode fMode = SkTrimPathEffect::Mode::kNormal;
|
2018-01-31 22:06:59 +00:00
|
|
|
|
|
|
|
using INHERITED = GeometryNode;
|
2018-01-07 13:54:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace sksg
|
|
|
|
|
|
|
|
#endif // SkSGTrimEffect_DEFINED
|