Flutter Engine
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< SkCodecImageGenerator > 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
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 size_t GetAllocationSize () const
 
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,
  kWrapperInfoIndex,
  kNumberOfNativeFields
}
 
- Static Public Member Functions inherited from flutter::Codec
static void RegisterNatives (tonic::DartLibraryNatives *natives)
 
- 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 14 of file multi_frame_codec.h.

Constructor & Destructor Documentation

◆ MultiFrameCodec()

flutter::MultiFrameCodec::MultiFrameCodec ( std::shared_ptr< SkCodecImageGenerator >  generator)

Definition at line 15 of file multi_frame_codec.cc.

References ~MultiFrameCodec().

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

◆ ~MultiFrameCodec()

flutter::MultiFrameCodec::~MultiFrameCodec ( )
overridedefault

Referenced by MultiFrameCodec().

Member Function Documentation

◆ frameCount()

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

Implements flutter::Codec.

Definition at line 194 of file multi_frame_codec.cc.

194  {
195  return state_->frameCount_;
196 }

◆ getNextFrame()

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

Implements flutter::Codec.

Definition at line 161 of file multi_frame_codec.cc.

References flutter::UIDartState::Current(), tonic::DartState::Current(), fml::MakeCopyable(), fml::TaskRunner::PostTask(), and tonic::ToDart().

161  {
162  static size_t trace_counter = 1;
163  const size_t trace_id = trace_counter++;
164 
165  if (!Dart_IsClosure(callback_handle)) {
166  return tonic::ToDart("Callback must be a function");
167  }
168 
169  auto* dart_state = UIDartState::Current();
170 
171  const auto& task_runners = dart_state->GetTaskRunners();
172 
173  task_runners.GetIOTaskRunner()->PostTask(fml::MakeCopyable(
174  [callback = std::make_unique<DartPersistentValue>(
175  tonic::DartState::Current(), callback_handle),
176  weak_state = std::weak_ptr<MultiFrameCodec::State>(state_), trace_id,
177  ui_task_runner = task_runners.GetUITaskRunner(),
178  io_manager = dart_state->GetIOManager()]() mutable {
179  auto state = weak_state.lock();
180  if (!state) {
181  ui_task_runner->PostTask(fml::MakeCopyable(
182  [callback = std::move(callback)]() { callback->Clear(); }));
183  return;
184  }
185  state->GetNextFrameAndInvokeCallback(
186  std::move(callback), std::move(ui_task_runner),
187  io_manager->GetResourceContext(), io_manager->GetSkiaUnrefQueue(),
188  trace_id);
189  }));
190 
191  return Dart_Null();
192 }
static DartState * Current()
Definition: dart_state.cc:55
internal::CopyableLambda< T > MakeCopyable(T lambda)
Definition: make_copyable.h:57
Dart_Handle ToDart(const T &object)
static UIDartState * Current()

◆ repetitionCount()

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

Implements flutter::Codec.

Definition at line 198 of file multi_frame_codec.cc.

198  {
199  return state_->repetitionCount_;
200 }

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