5#include "flutter/lib/gpu/context.h"
9#include "flutter/lib/gpu/formats.h"
10#include "flutter/lib/ui/ui_dart_state.h"
19std::shared_ptr<impeller::Context> Context::default_context_;
22 default_context_ = std::move(context);
26 return default_context_;
30 std::optional<std::string>& out_error) {
32 if (override_context) {
33 return override_context;
37 if (!dart_state->IsImpellerEnabled()) {
39 "Flutter GPU requires the Impeller rendering backend to be enabled.";
43 std::promise<std::shared_ptr<impeller::Context>> context_promise;
44 auto impeller_context_future = context_promise.get_future();
46 dart_state->GetTaskRunners().GetIOTaskRunner(),
48 io_manager = dart_state->GetIOManager()]()
mutable {
49 promise.set_value(io_manager ? io_manager->GetImpellerContext()
52 auto context = impeller_context_future.get();
55 out_error =
"Unable to retrieve the Impeller context.";
61 : context_(
std::move(context)) {}
77 std::optional<std::string> out_error;
79 if (out_error.has_value()) {
83 auto res = fml::MakeRefCounted<flutter::gpu::Context>(impeller_context);
84 res->AssociateWithDartWrapper(wrapper);
92 wrapper->
GetContext()->GetCapabilities()->GetDefaultColorFormat()));
98 wrapper->
GetContext()->GetCapabilities()->GetDefaultStencilFormat()));
106 ->GetDefaultDepthStencilFormat()));
static UIDartState * Current()
static std::shared_ptr< impeller::Context > GetOverrideContext()
Context(std::shared_ptr< impeller::Context > context)
std::shared_ptr< impeller::Context > GetContext()
static std::shared_ptr< impeller::Context > GetDefaultContext(std::optional< std::string > &out_error)
static void SetOverrideContext(std::shared_ptr< impeller::Context > context)
static void RunNowOrPostTask(const fml::RefPtr< fml::TaskRunner > &runner, const fml::closure &task)
struct _Dart_Handle * Dart_Handle
DART_EXPORT Dart_Handle Dart_Null(void)
int InternalFlutterGpu_Context_GetDefaultDepthStencilFormat(flutter::gpu::Context *wrapper)
Dart_Handle InternalFlutterGpu_Context_InitializeDefault(Dart_Handle wrapper)
int InternalFlutterGpu_Context_GetDefaultColorFormat(flutter::gpu::Context *wrapper)
int InternalFlutterGpu_Context_GetDefaultStencilFormat(flutter::gpu::Context *wrapper)
constexpr FlutterGPUPixelFormat FromImpellerPixelFormat(impeller::PixelFormat value)
IMPLEMENT_WRAPPERTYPEINFO(flutter_gpu, CommandBuffer)
internal::CopyableLambda< T > MakeCopyable(T lambda)
Dart_Handle ToDart(const T &object)