2018-05-01 03:08:15 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2018 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkSGRoundEffect_DEFINED
|
|
|
|
#define SkSGRoundEffect_DEFINED
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "modules/sksg/include/SkSGGeometryNode.h"
|
2018-05-01 03:08:15 +00:00
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkPath.h"
|
2018-05-01 03:08:15 +00:00
|
|
|
|
|
|
|
namespace sksg {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Concrete Geometry node, applying a rounded-corner effect to its child.
|
|
|
|
*/
|
|
|
|
class RoundEffect final : public GeometryNode {
|
|
|
|
public:
|
|
|
|
static sk_sp<RoundEffect> Make(sk_sp<GeometryNode> child) {
|
|
|
|
return child ? sk_sp<RoundEffect>(new RoundEffect(std::move(child))) : nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
~RoundEffect() override;
|
|
|
|
|
|
|
|
SG_ATTRIBUTE(Radius, SkScalar, fRadius)
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void onClip(SkCanvas*, bool antiAlias) const override;
|
|
|
|
void onDraw(SkCanvas*, const SkPaint&) const override;
|
2019-02-12 14:33:21 +00:00
|
|
|
bool onContains(const SkPoint&) const override;
|
2018-05-01 03:08:15 +00:00
|
|
|
|
|
|
|
SkRect onRevalidate(InvalidationController*, const SkMatrix&) override;
|
|
|
|
SkPath onAsPath() const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
explicit RoundEffect(sk_sp<GeometryNode>);
|
|
|
|
|
|
|
|
const sk_sp<GeometryNode> fChild;
|
|
|
|
|
|
|
|
SkPath fRoundedPath;
|
|
|
|
SkScalar fRadius = 0;
|
|
|
|
|
|
|
|
using INHERITED = GeometryNode;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace sksg
|
|
|
|
|
|
|
|
#endif // SkSGRoundEffect_DEFINED
|