Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
flutter::gpu::Context Class Reference

#include <context.h>

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

Public Member Functions

 Context (std::shared_ptr< impeller::Context > context)
 
 ~Context () override
 
impeller::ContextGetContext ()
 
std::shared_ptr< impeller::Context > & GetContextShared ()
 
- 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< T >
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
 
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< T >
 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 18 of file context.h.

Constructor & Destructor Documentation

◆ Context()

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

Definition at line 82 of file context.cc.

83 : context_(std::move(context)) {}
std::shared_ptr< ContextGLES > context

◆ ~Context()

flutter::gpu::Context::~Context ( )
overridedefault

Member Function Documentation

◆ GetContext()

◆ GetContextShared()

std::shared_ptr< impeller::Context > & flutter::gpu::Context::GetContextShared ( )

Definition at line 91 of file context.cc.

91 {
92 return context_;
93}

Referenced by InternalFlutterGpu_CommandBuffer_Initialize(), and flutter::gpu::Texture::Overwrite().

◆ GetDefaultContext()

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

Definition at line 39 of file context.cc.

40 {
41 auto override_context = GetOverrideContext();
42 if (override_context) {
43 return override_context;
44 }
45
46 auto dart_state = flutter::UIDartState::Current();
47 if (!dart_state->IsImpellerEnabled()) {
48 out_error =
49 "Flutter GPU requires the Impeller rendering backend, but Impeller is "
50 "not enabled. For more details about where Impeller is available and "
51 "how to enable it, see: https://docs.flutter.dev/perf/impeller";
52 return nullptr;
53 }
54 if (!dart_state->IsFlutterGPUEnabled()) {
55 out_error =
56 "Flutter GPU must be enabled via the Flutter GPU manifest "
57 "setting. This can be done either via command line argument "
58 "--enable-flutter-gpu or "
59 "by adding the FLTEnableFlutterGPU key set to true in the Info.plist "
60 "on iOS/macOS, or the io.flutter.embedding.android.EnableFlutterGPU "
61 "metadata key to true in the AndroidManifest.xml on Android.";
62 return nullptr;
63 }
64 // Grab the Impeller context from the IO manager.
65 std::promise<std::shared_ptr<impeller::Context>> context_promise;
66 auto impeller_context_future = context_promise.get_future();
68 dart_state->GetTaskRunners().GetIOTaskRunner(),
69 fml::MakeCopyable([promise = std::move(context_promise),
70 io_manager = dart_state->GetIOManager()]() mutable {
71 promise.set_value(io_manager ? io_manager->GetImpellerContext()
72 : nullptr);
73 }));
74 auto context = impeller_context_future.get();
75
76 if (!context) {
77 out_error = "Unable to retrieve the Impeller context.";
78 }
79 return context;
80}
static UIDartState * Current()
static std::shared_ptr< impeller::Context > GetOverrideContext()
Definition context.cc:35
static void RunNowOrPostTask(const fml::RefPtr< fml::TaskRunner > &runner, const fml::closure &task)
internal::CopyableLambda< T > MakeCopyable(T lambda)

References context, flutter::UIDartState::Current(), GetOverrideContext(), fml::MakeCopyable(), and fml::TaskRunner::RunNowOrPostTask().

Referenced by InternalFlutterGpu_Context_InitializeDefault(), InternalFlutterGpu_ShaderLibrary_InitializeWithAsset(), and InternalFlutterGpu_ShaderLibrary_ReinitializeWithAsset().

◆ GetOverrideContext()

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

Definition at line 35 of file context.cc.

35 {
36 return default_context_;
37}

Referenced by GetDefaultContext().

◆ SetOverrideContext()

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

Definition at line 31 of file context.cc.

31 {
32 default_context_ = std::move(context);
33}

References context.

Referenced by impeller::testing::RendererDartTest::GetIsolate().


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