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< 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
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,
  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< ImageGenerator generator)

Definition at line 15 of file multi_frame_codec.cc.

16  : 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 224 of file multi_frame_codec.cc.

224  {
225  return state_->frameCount_;
226 }

◆ getNextFrame()

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

Implements flutter::Codec.

Definition at line 180 of file multi_frame_codec.cc.

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

180  {
181  static size_t trace_counter = 1;
182  const size_t trace_id = trace_counter++;
183 
184  if (!Dart_IsClosure(callback_handle)) {
185  return tonic::ToDart("Callback must be a function");
186  }
187 
188  auto* dart_state = UIDartState::Current();
189 
190  const auto& task_runners = dart_state->GetTaskRunners();
191 
192  if (state_->frameCount_ == 0) {
193  FML_LOG(ERROR) << "Could not provide any frame.";
194  task_runners.GetUITaskRunner()->PostTask(fml::MakeCopyable(
195  [trace_id,
196  callback = std::make_unique<DartPersistentValue>(
197  tonic::DartState::Current(), callback_handle)]() mutable {
198  InvokeNextFrameCallback(nullptr, 0, std::move(callback), trace_id);
199  }));
200  return Dart_Null();
201  }
202 
203  task_runners.GetIOTaskRunner()->PostTask(fml::MakeCopyable(
204  [callback = std::make_unique<DartPersistentValue>(
205  tonic::DartState::Current(), callback_handle),
206  weak_state = std::weak_ptr<MultiFrameCodec::State>(state_), trace_id,
207  ui_task_runner = task_runners.GetUITaskRunner(),
208  io_manager = dart_state->GetIOManager()]() mutable {
209  auto state = weak_state.lock();
210  if (!state) {
211  ui_task_runner->PostTask(fml::MakeCopyable(
212  [callback = std::move(callback)]() { callback->Clear(); }));
213  return;
214  }
215  state->GetNextFrameAndInvokeCallback(
216  std::move(callback), std::move(ui_task_runner),
217  io_manager->GetResourceContext(), io_manager->GetSkiaUnrefQueue(),
218  io_manager->GetIsGpuDisabledSyncSwitch(), trace_id);
219  }));
220 
221  return Dart_Null();
222 }
static DartState * Current()
Definition: dart_state.cc:56
#define FML_LOG(severity)
Definition: logging.h:65
FlKeyEvent FlKeyResponderAsyncCallback callback
internal::CopyableLambda< T > MakeCopyable(T lambda)
Definition: make_copyable.h:57
Dart_Handle ToDart(const T &object)
static void InvokeNextFrameCallback(fml::RefPtr< CanvasImage > image, int duration, std::unique_ptr< DartPersistentValue > callback, size_t trace_id)
AtkStateType state
static UIDartState * Current()

◆ repetitionCount()

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

Implements flutter::Codec.

Definition at line 228 of file multi_frame_codec.cc.

228  {
229  return state_->repetitionCount_;
230 }

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