Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | List of all members
flutter::gpu::Context Class Reference

#include <context.h>

Inheritance diagram for flutter::gpu::Context:
flutter::RefCountedDartWrappable< Context > fml::RefCountedThreadSafe< Context > tonic::DartWrappable fml::internal::RefCountedThreadSafeBase

Public Member Functions

 Context (std::shared_ptr< impeller::Context > context)
 
 ~Context () override
 
std::shared_ptr< impeller::ContextGetContext ()
 
- Public Member Functions inherited from flutter::RefCountedDartWrappable< Context >
virtual void RetainDartWrappableReference () const override
 
virtual void ReleaseDartWrappableReference () const override
 
- Public Member Functions inherited from fml::RefCountedThreadSafe< Context >
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
 

Static Public Member Functions

static void SetOverrideContext (std::shared_ptr< impeller::Context > context)
 
static std::shared_ptr< impeller::ContextGetOverrideContext ()
 
static std::shared_ptr< impeller::ContextGetDefaultContext (std::optional< std::string > &out_error)
 

Additional Inherited Members

- Public Types inherited from tonic::DartWrappable
enum  DartNativeFields { kPeerIndex , kNumberOfNativeFields }
 
- Protected Member Functions inherited from fml::RefCountedThreadSafe< Context >
 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 context.h.

Constructor & Destructor Documentation

◆ Context()

Context::Context ( std::shared_ptr< impeller::Context context)
explicit

Definition at line 60 of file context.cc.

61 : context_(std::move(context)) {}

◆ ~Context()

Context::~Context ( )
overridedefault

Member Function Documentation

◆ GetContext()

std::shared_ptr< impeller::Context > Context::GetContext ( )

Definition at line 65 of file context.cc.

65 {
66 return context_;
67}

◆ GetDefaultContext()

std::shared_ptr< impeller::Context > Context::GetDefaultContext ( std::optional< std::string > &  out_error)
static

Definition at line 29 of file context.cc.

30 {
31 auto override_context = GetOverrideContext();
32 if (override_context) {
33 return override_context;
34 }
35
36 auto dart_state = flutter::UIDartState::Current();
37 if (!dart_state->IsImpellerEnabled()) {
38 out_error =
39 "Flutter GPU requires the Impeller rendering backend to be enabled.";
40 return nullptr;
41 }
42 // Grab the Impeller context from the IO manager.
43 std::promise<std::shared_ptr<impeller::Context>> context_promise;
44 auto impeller_context_future = context_promise.get_future();
46 dart_state->GetTaskRunners().GetIOTaskRunner(),
47 fml::MakeCopyable([promise = std::move(context_promise),
48 io_manager = dart_state->GetIOManager()]() mutable {
49 promise.set_value(io_manager ? io_manager->GetImpellerContext()
50 : nullptr);
51 }));
52 auto context = impeller_context_future.get();
53
54 if (!context) {
55 out_error = "Unable to retrieve the Impeller context.";
56 }
57 return context;
58}
static UIDartState * Current()
static std::shared_ptr< impeller::Context > GetOverrideContext()
Definition: context.cc:25
static void RunNowOrPostTask(const fml::RefPtr< fml::TaskRunner > &runner, const fml::closure &task)
Definition: task_runner.cc:55
internal::CopyableLambda< T > MakeCopyable(T lambda)
Definition: make_copyable.h:57

◆ GetOverrideContext()

std::shared_ptr< impeller::Context > Context::GetOverrideContext ( )
static

Definition at line 25 of file context.cc.

25 {
26 return default_context_;
27}

◆ SetOverrideContext()

void Context::SetOverrideContext ( std::shared_ptr< impeller::Context context)
static

Definition at line 21 of file context.cc.

21 {
22 default_context_ = std::move(context);
23}

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