Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | List of all members
skottie_utils::ExternalAnimationPrecompInterceptor Class Referencefinal

#include <SkottieUtils.h>

Inheritance diagram for skottie_utils::ExternalAnimationPrecompInterceptor:
skottie::PrecompInterceptor SkRefCnt SkRefCntBase

Public Member Functions

 ExternalAnimationPrecompInterceptor (sk_sp< skresources::ResourceProvider >, const char prefix[])
 
 ~ExternalAnimationPrecompInterceptor () override
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Private Member Functions

sk_sp< skottie::ExternalLayeronLoadPrecomp (const char[], const char[], const SkSize &) override
 

Detailed Description

A sample PrecompInterceptor implementation.

Attempts to substitute all precomp layers matching the given pattern (name prefix) with external Lottie animations.

Definition at line 137 of file SkottieUtils.h.

Constructor & Destructor Documentation

◆ ExternalAnimationPrecompInterceptor()

skottie_utils::ExternalAnimationPrecompInterceptor::ExternalAnimationPrecompInterceptor ( sk_sp< skresources::ResourceProvider rprovider,
const char  prefix[] 
)

Definition at line 271 of file SkottieUtils.cpp.

274 : fResourceProvider(std::move(rprovider))
275 , fPrefix(prefixp) {}

◆ ~ExternalAnimationPrecompInterceptor()

skottie_utils::ExternalAnimationPrecompInterceptor::~ExternalAnimationPrecompInterceptor ( )
overridedefault

Member Function Documentation

◆ onLoadPrecomp()

sk_sp< skottie::ExternalLayer > skottie_utils::ExternalAnimationPrecompInterceptor::onLoadPrecomp ( const char  id[],
const char  name[],
const SkSize size 
)
overrideprivatevirtual

Invoked at animation build time, for each precomp layer.

Parameters
idThe target composition ID (usually assigned automatically by BM: comp_0, ...)
nameThe name of the precomp layer (by default it matches the target comp name, but can be changed in AE)
sizeLottie-specified precomp layer size
Returns
An ExternalLayer implementation (to be used instead of the actual Lottie file content), or nullptr (to use the Lottie file content).

Implements skottie::PrecompInterceptor.

Definition at line 279 of file SkottieUtils.cpp.

280 {
281 if (0 != strncmp(name, fPrefix.c_str(), fPrefix.size())) {
282 return nullptr;
283 }
284
285 auto data = fResourceProvider->load("", name + fPrefix.size());
286 if (!data) {
287 return nullptr;
288 }
289
290 auto anim = skottie::Animation::Builder()
292 .setResourceProvider(fResourceProvider)
293 .make(static_cast<const char*>(data->data()), data->size());
294
295 return anim ? sk_make_sp<ExternalAnimationLayer>(std::move(anim), size)
296 : nullptr;
297}
sk_sp< T > sk_ref_sp(T *obj)
Definition SkRefCnt.h:381
size_t size() const
Definition SkString.h:131
const char * c_str() const
Definition SkString.h:133
Builder & setResourceProvider(sk_sp< ResourceProvider >)
Definition Skottie.cpp:309
Builder & setPrecompInterceptor(sk_sp< PrecompInterceptor >)
Definition Skottie.cpp:334
sk_sp< Animation > make(SkStream *)
Definition Skottie.cpp:349
virtual sk_sp< SkData > load(const char[], const char[]) const
const char * name
Definition fuchsia.cc:50
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switches.h:41

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