Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Static Public Member Functions | Private Member Functions | List of all members
skottie::internal::MotionBlurEffect Class Referencefinal

#include <MotionBlurEffect.h>

Inheritance diagram for skottie::internal::MotionBlurEffect:
sksg::CustomRenderNode sksg::RenderNode sksg::Node SkRefCnt SkRefCntBase

Classes

class  AutoInvalBlocker
 

Static Public Member Functions

static sk_sp< MotionBlurEffectMake (sk_sp< Animator > animator, sk_sp< sksg::RenderNode > child, size_t samples_per_frame, float shutter_angle, float shutter_phase)
 

Private Member Functions

const RenderNodeonNodeAt (const SkPoint &) const override
 
SkRect onRevalidate (sksg::InvalidationController *ic, const SkMatrix &ctm) override
 
void onRender (SkCanvas *canvas, const RenderContext *ctx) const override
 

Additional Inherited Members

- Public Member Functions inherited from sksg::RenderNode
void render (SkCanvas *, const RenderContext *=nullptr) const
 
const RenderNodenodeAt (const SkPoint &point) const
 
bool isVisible () const
 
void setVisible (bool)
 
- Public Member Functions inherited from sksg::Node
const SkRectrevalidate (InvalidationController *, const SkMatrix &)
 
void invalidate (bool damage=true)
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 
- Protected Types inherited from sksg::Node
enum  InvalTraits { kBubbleDamage_Trait = 1 << 0 , kOverrideDamage_Trait = 1 << 1 }
 
- Protected Member Functions inherited from sksg::CustomRenderNode
 CustomRenderNode (std::vector< sk_sp< RenderNode > > &&children)
 
 ~CustomRenderNode () override
 
const std::vector< sk_sp< RenderNode > > & children () const
 
bool hasChildrenInval () const
 
- Protected Member Functions inherited from sksg::RenderNode
 RenderNode (uint32_t inval_traits=0)
 
- Protected Member Functions inherited from sksg::Node
 Node (uint32_t invalTraits)
 
 ~Node () override
 
const SkRectbounds () const
 
bool hasInval () const
 
void observeInval (const sk_sp< Node > &)
 
void unobserveInval (const sk_sp< Node > &)
 

Detailed Description

Definition at line 18 of file MotionBlurEffect.h.

Member Function Documentation

◆ Make()

sk_sp< MotionBlurEffect > skottie::internal::MotionBlurEffect::Make ( sk_sp< Animator animator,
sk_sp< sksg::RenderNode child,
size_t  samples_per_frame,
float  shutter_angle,
float  shutter_phase 
)
static

Definition at line 37 of file MotionBlurEffect.cpp.

40 {
41 if (!samples_per_frame || shutter_angle <= 0) {
42 return nullptr;
43 }
44
45 // shutter_angle is [ 0 .. 720], mapped to [ 0 .. 2] (frame space)
46 // shutter_phase is [-360 .. 360], mapped to [-1 .. 1] (frame space)
47 const auto samples_duration = shutter_angle / 360,
48 phase = shutter_phase / 360,
49 dt = samples_duration / (samples_per_frame - 1);
50
51 return sk_sp<MotionBlurEffect>(new MotionBlurEffect(std::move(animator),
52 std::move(child),
53 samples_per_frame,
54 phase, dt));
55}

◆ onNodeAt()

const sksg::RenderNode * skottie::internal::MotionBlurEffect::onNodeAt ( const SkPoint ) const
overrideprivatevirtual

Implements sksg::RenderNode.

Definition at line 66 of file MotionBlurEffect.cpp.

66 {
67 return nullptr;
68}

◆ onRender()

void skottie::internal::MotionBlurEffect::onRender ( SkCanvas canvas,
const RenderContext ctx 
) const
overrideprivatevirtual

Implements sksg::RenderNode.

Definition at line 193 of file MotionBlurEffect.cpp.

193 {
194 if (!fVisibleSampleCount) {
195 return;
196 }
197
198 SkASSERT(this->children().size() == 1ul);
199 const auto& child = this->children()[0];
200
201 // We're about to mutate/revalidate the subtree for sampling. Capture the invalidation
202 // at this scope, to prevent dirtying ancestor SG nodes (no way to revalidate the global scene).
203 AutoInvalBlocker aib(this, child);
204
205 SkPixmap pm;
206 if (canvas->peekPixels(&pm) && (canvas->imageInfo().colorType() == kRGBA_8888_SkColorType ||
208 && SkIsPow2(fVisibleSampleCount)) {
209 this->renderToRaster8888Pow2Samples(canvas, ctx);
210 return;
211 }
212
213 SkAutoCanvasRestore acr1(canvas, false);
214
215 // Accumulate in F16 for more precision.
217
218 const float frame_alpha = 1.0f / fVisibleSampleCount;
219
220 // Depending on whether we can defer frame blending,
221 // use a local (deferred) RenderContext or an explicit layer for frame/content rendering.
222 ScopedRenderContext frame_ctx(canvas, ctx);
223 SkPaint frame_paint;
224
225 const bool isolate_frames = !!frame_ctx->fBlender;
226 if (isolate_frames) {
227 frame_paint.setAlphaf(frame_alpha);
228 frame_paint.setBlendMode(SkBlendMode::kPlus);
229 } else {
230 frame_ctx = frame_ctx.modulateOpacity(frame_alpha)
231 .modulateBlender(SkBlender::Mode(SkBlendMode::kPlus));
232 }
233
234 SkDEBUGCODE(size_t frames_rendered = 0;)
235 for (size_t i = 0; i < fSampleCount; ++i) {
236 this->seekToSample(i, canvas->getTotalMatrix());
237
238 if (!child->isVisible()) {
239 continue;
240 }
241
242 SkAutoCanvasRestore acr2(canvas, false);
243 if (isolate_frames) {
244 canvas->saveLayer(nullptr, &frame_paint);
245 }
246
247 child->render(canvas, frame_ctx);
248 SkDEBUGCODE(frames_rendered++;)
249 }
250
251 SkASSERT(frames_rendered == fVisibleSampleCount);
252}
#define SkASSERT(cond)
Definition SkAssert.h:116
@ kPlus
r = min(s + d, 1)
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
Definition SkColorType.h:26
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition SkColorType.h:24
#define SkDEBUGCODE(...)
Definition SkDebug.h:23
constexpr bool SkIsPow2(T value)
Definition SkMath.h:51
static sk_sp< SkBlender > Mode(SkBlendMode mode)
int saveLayer(const SkRect *bounds, const SkPaint *paint)
Definition SkCanvas.cpp:500
bool peekPixels(SkPixmap *pixmap)
SkMatrix getTotalMatrix() const
@ kF16ColorType
Definition SkCanvas.h:674
SkImageInfo imageInfo() const
void setBlendMode(SkBlendMode mode)
Definition SkPaint.cpp:151
void setAlphaf(float a)
Definition SkPaint.cpp:130
const std::vector< sk_sp< RenderNode > > & children() const
const SkRect & bounds() const
Definition SkSGNode.h:55
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
Definition switches.h:259
SkColorType colorType() const

◆ onRevalidate()

SkRect skottie::internal::MotionBlurEffect::onRevalidate ( sksg::InvalidationController ic,
const SkMatrix ctm 
)
overrideprivatevirtual

Implements sksg::Node.

Definition at line 78 of file MotionBlurEffect.cpp.

78 {
80 fVisibleSampleCount = 0;
81
82 for (size_t i = 0; i < fSampleCount; ++i) {
83 bounds.join(this->seekToSample(i, ctm));
84 fVisibleSampleCount += SkToSizeT(this->children()[0]->isVisible());
85 }
86
87 return bounds;
88}
constexpr size_t SkToSizeT(S x)
Definition SkTo.h:31
bool isVisible() const
static constexpr SkRect MakeEmpty()
Definition SkRect.h:595
void join(const SkRect &r)
Definition SkRect.cpp:126

The documentation for this class was generated from the following files: