Flutter Engine
The Flutter Engine
Classes | Public Member Functions | List of all members
flutter::MultiFrameCodec Class Reference

#include <multi_frame_codec.h>

Inheritance diagram for flutter::MultiFrameCodec:
flutter::Codec flutter::RefCountedDartWrappable< Codec > fml::RefCountedThreadSafe< Codec > tonic::DartWrappable fml::internal::RefCountedThreadSafeBase

Public Member Functions

 MultiFrameCodec (std::shared_ptr< ImageGenerator > generator)
 
 ~MultiFrameCodec () override
 
int frameCount () const override
 
int repetitionCount () const override
 
Dart_Handle getNextFrame (Dart_Handle args) override
 
- Public Member Functions inherited from flutter::Codec
virtual int frameCount () const =0
 
virtual int repetitionCount () const =0
 
virtual Dart_Handle getNextFrame (Dart_Handle callback_handle)=0
 
void dispose ()
 
- Public Member Functions inherited from flutter::RefCountedDartWrappable< Codec >
virtual void RetainDartWrappableReference () const override
 
virtual void ReleaseDartWrappableReference () const override
 
- Public Member Functions inherited from fml::RefCountedThreadSafe< Codec >
void Release () const
 
- Public Member Functions inherited from fml::internal::RefCountedThreadSafeBase
void AddRef () const
 
bool HasOneRef () const
 
void AssertHasOneRef () const
 
- Public Member Functions inherited from tonic::DartWrappable
 DartWrappable ()
 
virtual const DartWrapperInfoGetDartWrapperInfo () const =0
 
virtual void RetainDartWrappableReference () const =0
 
virtual void ReleaseDartWrappableReference () const =0
 
Dart_Handle CreateDartWrapper (DartState *dart_state)
 
void AssociateWithDartWrapper (Dart_Handle wrappable)
 
void ClearDartWrapper ()
 
Dart_WeakPersistentHandle dart_wrapper () const
 

Additional Inherited Members

- Public Types inherited from tonic::DartWrappable
enum  DartNativeFields { kPeerIndex , kNumberOfNativeFields }
 
- Protected Member Functions inherited from fml::RefCountedThreadSafe< Codec >
 RefCountedThreadSafe ()
 
 ~RefCountedThreadSafe ()
 
- Protected Member Functions inherited from fml::internal::RefCountedThreadSafeBase
 RefCountedThreadSafeBase ()
 
 ~RefCountedThreadSafeBase ()
 
bool Release () const
 
void Adopt ()
 
- Protected Member Functions inherited from tonic::DartWrappable
virtual ~DartWrappable ()
 
- Static Protected Member Functions inherited from tonic::DartWrappable
static Dart_PersistentHandle GetTypeForWrapper (tonic::DartState *dart_state, const tonic::DartWrapperInfo &wrapper_info)
 

Detailed Description

Definition at line 16 of file multi_frame_codec.h.

Constructor & Destructor Documentation

◆ MultiFrameCodec()

flutter::MultiFrameCodec::MultiFrameCodec ( std::shared_ptr< ImageGenerator generator)
explicit

Definition at line 24 of file multi_frame_codec.cc.

25 : state_(new State(std::move(generator))) {}

◆ ~MultiFrameCodec()

flutter::MultiFrameCodec::~MultiFrameCodec ( )
overridedefault

Member Function Documentation

◆ frameCount()

int flutter::MultiFrameCodec::frameCount ( ) const
overridevirtual

Implements flutter::Codec.

Definition at line 272 of file multi_frame_codec.cc.

272 {
273 return state_->frameCount_;
274}

◆ getNextFrame()

Dart_Handle flutter::MultiFrameCodec::getNextFrame ( Dart_Handle  args)
overridevirtual

Implements flutter::Codec.

Definition at line 222 of file multi_frame_codec.cc.

222 {
223 static size_t trace_counter = 1;
224 const size_t trace_id = trace_counter++;
225
226 if (!Dart_IsClosure(callback_handle)) {
227 return tonic::ToDart("Callback must be a function");
228 }
229
230 auto* dart_state = UIDartState::Current();
231
232 const auto& task_runners = dart_state->GetTaskRunners();
233
234 if (state_->frameCount_ == 0) {
235 std::string decode_error("Could not provide any frame.");
236 FML_LOG(ERROR) << decode_error;
237 task_runners.GetUITaskRunner()->PostTask(fml::MakeCopyable(
238 [trace_id, decode_error = std::move(decode_error),
239 callback = std::make_unique<tonic::DartPersistentValue>(
240 tonic::DartState::Current(), callback_handle)]() mutable {
241 InvokeNextFrameCallback(nullptr, 0, decode_error, std::move(callback),
242 trace_id);
243 }));
244 return Dart_Null();
245 }
246
247 task_runners.GetIOTaskRunner()->PostTask(fml::MakeCopyable(
248 [callback = std::make_unique<tonic::DartPersistentValue>(
249 tonic::DartState::Current(), callback_handle),
250 weak_state = std::weak_ptr<MultiFrameCodec::State>(state_), trace_id,
251 ui_task_runner = task_runners.GetUITaskRunner(),
252 io_manager = dart_state->GetIOManager()]() mutable {
253 auto state = weak_state.lock();
254 if (!state) {
255 ui_task_runner->PostTask(fml::MakeCopyable(
256 [callback = std::move(callback)]() { callback->Clear(); }));
257 return;
258 }
259 state->GetNextFrameAndInvokeCallback(
260 std::move(callback), ui_task_runner,
261 io_manager->GetResourceContext(), io_manager->GetSkiaUnrefQueue(),
262 io_manager->GetIsGpuDisabledSyncSwitch(), trace_id,
263 io_manager->GetImpellerContext());
264 }));
265
266 return Dart_Null();
267 // The static leak checker gets confused by the control flow, unique
268 // pointers and closures in this function.
269 // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
270}
static UIDartState * Current()
static DartState * Current()
Definition: dart_state.cc:56
DART_EXPORT Dart_Handle Dart_Null(void)
DART_EXPORT bool Dart_IsClosure(Dart_Handle object)
AtkStateType state
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
#define FML_LOG(severity)
Definition: logging.h:82
static void InvokeNextFrameCallback(const fml::RefPtr< CanvasImage > &image, int duration, const std::string &decode_error, std::unique_ptr< tonic::DartPersistentValue > callback, size_t trace_id)
internal::CopyableLambda< T > MakeCopyable(T lambda)
Definition: make_copyable.h:57
Dart_Handle ToDart(const T &object)
#define ERROR(message)
Definition: elf_loader.cc:260

◆ repetitionCount()

int flutter::MultiFrameCodec::repetitionCount ( ) const
overridevirtual

Implements flutter::Codec.

Definition at line 276 of file multi_frame_codec.cc.

276 {
277 return state_->repetitionCount_;
278}

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