blob: 341e71e5fb5ac6f4b6a5c06ac414ae474db5b08b [file] [log] [blame]
* Copyright 2020 Google Inc.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
#ifndef SkSGDashEffect_DEFINED
#define SkSGDashEffect_DEFINED
#include "include/core/SkPath.h"
#include "modules/sksg/include/SkSGGeometryNode.h"
#include <vector>
namespace sksg {
* Apply a dash effect to the child geometry.
* Follows the same semantics as SkDashPathEffect, with one minor tweak: when the number of
* intervals is odd, they are repeated once more to attain an even sequence (same as SVG
* stroke-dasharray:
class DashEffect final : public GeometryNode {
static sk_sp<DashEffect> Make(sk_sp<GeometryNode> child) {
return child ? sk_sp<DashEffect>(new DashEffect(std::move(child))) : nullptr;
~DashEffect() override;
SG_ATTRIBUTE(Intervals, std::vector<float>, fIntervals)
SG_ATTRIBUTE(Phase, float , fPhase )
void onClip(SkCanvas*, bool antiAlias) const override;
void onDraw(SkCanvas*, const SkPaint&) const override;
bool onContains(const SkPoint&) const override;
SkRect onRevalidate(InvalidationController*, const SkMatrix&) override;
SkPath onAsPath() const override;
explicit DashEffect(sk_sp<GeometryNode>);
const sk_sp<GeometryNode> fChild;
SkPath fDashedPath; // cache
std::vector<float> fIntervals;
float fPhase;
} // namespace sksg
#endif // SkSGDashEffect_DEFINED