44class InvalidationController;
82 const RenderNode* onNodeAt(
const SkPoint&)
const override {
return nullptr; }
86 if (!fLayerPicture || this->hasChildrenInval()) {
88 const auto& layer = this->children()[0];
90 layer->revalidate(ic, ctm);
98 const auto tileW =
SkTPin(fTileW, 0.0f, 100.0f) * 0.01f * fLayerSize.
width(),
99 tileH =
SkTPin(fTileH, 0.0f, 100.0f) * 0.01f * fLayerSize.
height();
103 fTileCenter.
fY - 0.5f * tile_size.height(),
112 &layerShaderMatrix,
nullptr);
114 if (
fPhase && layer_shader && tile.isFinite()) {
118 const auto phase_vec = fHorizontalPhase
121 const auto phase_shift =
SkVector::Make(phase_vec.fX, phase_vec.fY)
122 * std::fmod(
fPhase * (1/360.0f), 1);
127 static constexpr SkColor colors[] = { 0xffffffff, 0x00000000 };
130 const SkPoint pts[] = {{ tile.
x(), tile.y() },
131 { tile.x() + 2 * (tile.width() - phase_vec.fX),
132 tile.y() + 2 * (tile.height() - phase_vec.fY) }};
144 fMainPassShader = std::move(layer_shader);
145 fPhasePassShader =
nullptr;
149 const auto outputW = fOutputW * 0.01f * fLayerSize.
width(),
150 outputH = fOutputH * 0.01f * fLayerSize.
height();
153 (fLayerSize.
height() - outputH) * 0.5f,
157 void onRender(
SkCanvas* canvas,
const RenderContext* ctx)
const override {
159 if (this->
bounds().isEmpty() || (fTileW <= 0 && fTileH <= 0)) {
164 paint.setAntiAlias(
true);
171 paint.setShader(fMainPassShader);
174 if (fPhasePassShader) {
175 paint.setShader(fPhasePassShader);
183 SkPoint fTileCenter = { 0, 0 };
189 bool fMirrorEdges =
false;
190 bool fHorizontalPhase =
false;
200class MotionTileAdapter final :
public DiscardableAdapterBase<MotionTileAdapter, TileRenderNode> {
204 const AnimationBuilder& abuilder,
209 kTileCenter_Index = 0,
210 kTileWidth_Index = 1,
211 kTileHeight_Index = 2,
212 kOutputWidth_Index = 3,
213 kOutputHeight_Index = 4,
214 kMirrorEdges_Index = 5,
216 kHorizontalPhaseShift_Index = 7,
219 EffectBinder(jprops, abuilder,
this)
220 .bind( kTileCenter_Index, fTileCenter )
221 .bind( kTileWidth_Index, fTileW )
222 .bind( kTileHeight_Index, fTileH )
223 .bind( kOutputWidth_Index, fOutputW )
224 .bind( kOutputHeight_Index, fOutputH )
225 .bind( kMirrorEdges_Index, fMirrorEdges )
226 .bind( kPhase_Index,
fPhase )
227 .bind(kHorizontalPhaseShift_Index, fHorizontalPhase);
231 void onSync()
override {
232 const auto& tiler = this->node();
234 tiler->setTileCenter({fTileCenter.
x, fTileCenter.
y});
235 tiler->setTileWidth (fTileW);
236 tiler->setTileHeight(fTileH);
237 tiler->setOutputWidth (fOutputW);
238 tiler->setOutputHeight(fOutputH);
240 tiler->setMirrorEdges(
SkToBool(fMirrorEdges));
241 tiler->setHorizontalPhase(
SkToBool(fHorizontalPhase));
251 fHorizontalPhase = 0;
253 using INHERITED = DiscardableAdapterBase<MotionTileAdapter, TileRenderNode>;
#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)
static constexpr bool SkToBool(const T &x)
void drawRect(const SkRect &rect, const SkPaint &paint)
SkMatrix getLocalToDeviceAs3x3() const
static sk_sp< SkShader > MakeLinear(const SkPoint pts[2], const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)
static SkMatrix RectToRect(const SkRect &src, const SkRect &dst, ScaleToFit mode=kFill_ScaleToFit)
static SkMatrix Translate(SkScalar dx, SkScalar dy)
SkCanvas * beginRecording(const SkRect &bounds, sk_sp< SkBBoxHierarchy > bbh)
sk_sp< SkPicture > finishRecordingAsPicture()
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, SkFilterMode mode, const SkMatrix *localMatrix, const SkRect *tileRect) const
sk_sp< SkShader > makeWithLocalMatrix(const SkMatrix &) const
void attachDiscardableAdapter(sk_sp< T > adapter) const
static float max(float r, float g, float b)
SK_API sk_sp< SkDocument > Make(SkWStream *dst, const SkSerialProcs *=nullptr, std::function< void(const SkPicture *)> onEndPage=nullptr)
Optional< SkRect > bounds
PODArray< SkColor > colors
SK_API sk_sp< SkShader > Blend(SkBlendMode mode, sk_sp< SkShader > dst, sk_sp< SkShader > src)
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 keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
static constexpr SkPoint Make(float x, float y)
constexpr float y() const
constexpr float x() const
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
static constexpr SkRect MakeWH(float w, float h)
static constexpr SkSize Make(SkScalar w, SkScalar h)