33class InvalidationController;
43 enum class CompositeMode { kBelow, kAbove };
59 const RenderNode* onNodeAt(
const SkPoint&)
const override {
return nullptr; }
61 SkMatrix instanceTransform(
size_t i)
const {
62 const auto t = fOffset +
i;
66 t * fPosition.y + fAnchorPoint.
y)
69 std::pow(fScale.
y, t))
76 for (
const auto& child : this->children()) {
77 fChildrenBounds.
join(child->revalidate(ic, ctm));
82 bounds.join(this->instanceTransform(
i).mapRect(fChildrenBounds));
88 void onRender(
SkCanvas* canvas,
const RenderContext* ctx)
const override {
91 const auto dOpacity =
fCount > 1 ? (fEndOpacity - fStartOpacity) / fCount : 0.0f;
94 const auto render_index =
fMode == CompositeMode::kAbove ?
i :
fCount -
i - 1;
95 const auto opacity = fStartOpacity + dOpacity * render_index;
102 canvas->
concat(this->instanceTransform(render_index));
104 const auto& children = this->children();
105 const auto local_ctx = ScopedRenderContext(canvas, ctx)
106 .modulateOpacity(opacity)
107 .setIsolation(fChildrenBounds,
109 children.size() > 1);
110 for (
const auto& child : children) {
111 child->render(canvas, local_ctx);
116 const CompositeMode
fMode;
125 SkV2 fAnchorPoint = {0,0},
132class RepeaterAdapter final :
public DiscardableAdapterBase<RepeaterAdapter, RepeaterRenderNode> {
136 const AnimationBuilder& abuilder,
140 ? RepeaterRenderNode::CompositeMode::kBelow
141 : RepeaterRenderNode::CompositeMode::kAbove))
143 this->bind(abuilder, jrepeater[
"c"], fCount);
144 this->bind(abuilder, jrepeater[
"o"], fOffset);
146 this->bind(abuilder, jtransform[
"a" ], fAnchorPoint);
147 this->bind(abuilder, jtransform[
"p" ], fPosition);
148 this->bind(abuilder, jtransform[
"s" ], fScale);
149 this->bind(abuilder, jtransform[
"r" ], fRotation);
150 this->bind(abuilder, jtransform[
"so"], fStartOpacity);
151 this->bind(abuilder, jtransform[
"eo"], fEndOpacity);
155 void onSync()
override {
157 this->node()->setCount(
static_cast<size_t>(
SkTPin(fCount, 0.0f,
kMaxCount) + 0.5f));
158 this->node()->setOffset(fOffset);
159 this->node()->setAnchorPoint(fAnchorPoint);
160 this->node()->setPosition(fPosition);
161 this->node()->setScale(fScale * 0.01f);
162 this->node()->setRotation(fRotation);
163 this->node()->setStartOpacity(
SkTPin(fStartOpacity * 0.01f, 0.0f, 1.0f));
164 this->node()->setEndOpacity (
SkTPin(fEndOpacity * 0.01f, 0.0f, 1.0f));
173 fPosition = { 0, 0 },
174 fScale = { 100, 100 };
179 using INHERITED = DiscardableAdapterBase<RepeaterAdapter, RepeaterRenderNode>;
188 std::vector<sk_sp<sksg::RenderNode>> repeater_draws;
194 repeater_draws.reserve(1);
195 repeater_draws.push_back(
201 repeater_draws = std::move(draws);
204 return repeater_draws;
#define INHERITED(method,...)
sk_sp< T > sk_make_sp(Args &&... args)
#define SG_ATTRIBUTE(attr_name, attr_type, attr_container)
static constexpr const T & SkTPin(const T &x, const T &lo, const T &hi)
SkMatrix getTotalMatrix() const
void concat(const SkMatrix &matrix)
static SkMatrix Scale(SkScalar sx, SkScalar sy)
static SkMatrix RotateDeg(SkScalar deg)
static SkMatrix Translate(SkScalar dx, SkScalar dy)
void attachDiscardableAdapter(sk_sp< T > adapter) const
static std::vector< sk_sp< sksg::RenderNode > > AttachRepeaterDrawEffect(const skjson::ObjectValue &, const AnimationBuilder *, std::vector< sk_sp< sksg::RenderNode > > &&)
Optional< SkRect > bounds
static constexpr size_t kMaxCount
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive mode
T ParseDefault(const skjson::Value &v, const T &defaultValue)
static constexpr SkRect MakeEmpty()
void join(const SkRect &r)