22 auto& capabilities =
context.GetCapabilities();
23 return capabilities->SupportsOffscreenMSAA() &&
24 !capabilities->SupportsImplicitResolvingMSAA();
29std::shared_ptr<impeller::Context> Context::default_context_;
32 default_context_ = std::move(
context);
36 return default_context_;
40 std::optional<std::string>& out_error) {
42 if (override_context) {
43 return override_context;
47 if (!dart_state->IsImpellerEnabled()) {
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";
54 if (!dart_state->IsFlutterGPUEnabled()) {
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.";
65 std::promise<std::shared_ptr<impeller::Context>> context_promise;
66 auto impeller_context_future = context_promise.get_future();
68 dart_state->GetTaskRunners().GetIOTaskRunner(),
70 io_manager = dart_state->GetIOManager()]()
mutable {
71 promise.set_value(io_manager ? io_manager->GetImpellerContext()
74 auto context = impeller_context_future.get();
77 out_error =
"Unable to retrieve the Impeller context.";
103 std::optional<std::string> out_error;
105 if (out_error.has_value()) {
109 auto res = fml::MakeRefCounted<flutter::gpu::Context>(impeller_context);
110 res->AssociateWithDartWrapper(wrapper);
147 ->SupportsFramebufferRenderMipmap();
154 ->SupportsManuallyMippedTextures();
178 if (render_target || shader_write || !shader_read) {
static UIDartState * Current()
static std::shared_ptr< impeller::Context > GetOverrideContext()
static void SetOverrideContext(std::shared_ptr< impeller::Context > context)
std::shared_ptr< impeller::Context > & GetContextShared()
impeller::Context & GetContext()
Context(std::shared_ptr< impeller::Context > context)
static std::shared_ptr< impeller::Context > GetDefaultContext(std::optional< std::string > &out_error)
static void RunNowOrPostTask(const fml::RefPtr< fml::TaskRunner > &runner, const fml::closure &task)
To do anything rendering related with Impeller, you need a context.
virtual const std::shared_ptr< const Capabilities > & GetCapabilities() const =0
Get the capabilities of Impeller context. All optionally supported feature of the platform,...
#define IMPLEMENT_WRAPPERTYPEINFO(LibraryName, ClassName)
uint32_t uint32_t * format
bool InternalFlutterGpu_Context_SupportsTextureCompression(flutter::gpu::Context *wrapper, int family)
bool InternalFlutterGpu_Context_GetSupportsFramebufferRenderMipmap(flutter::gpu::Context *wrapper)
int InternalFlutterGpu_Context_GetMinimumUniformByteAlignment(flutter::gpu::Context *wrapper)
int InternalFlutterGpu_Context_GetDefaultDepthStencilFormat(flutter::gpu::Context *wrapper)
Dart_Handle InternalFlutterGpu_Context_InitializeDefault(Dart_Handle wrapper)
int InternalFlutterGpu_Context_GetDefaultColorFormat(flutter::gpu::Context *wrapper)
bool InternalFlutterGpu_Context_GetSupportsManuallyMippedTextures(flutter::gpu::Context *wrapper)
bool InternalFlutterGpu_Context_GetSupportsOffscreenMSAA(flutter::gpu::Context *wrapper)
bool InternalFlutterGpu_Context_SupportsTextureFormat(flutter::gpu::Context *wrapper, int format, bool render_target, bool shader_read, bool shader_write)
int InternalFlutterGpu_Context_GetDefaultStencilFormat(flutter::gpu::Context *wrapper)
constexpr impeller::PixelFormat ToImpellerPixelFormat(FlutterGPUPixelFormat value)
bool SupportsNormalOffscreenMSAA(const impeller::Context &context)
constexpr FlutterGPUPixelFormat FromImpellerPixelFormat(impeller::PixelFormat value)
constexpr impeller::CompressedTextureFamily ToImpellerCompressedTextureFamily(FlutterGPUTextureCompressionFamily value)
internal::CopyableLambda< T > MakeCopyable(T lambda)
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
constexpr CompressedTextureFamily CompressedTextureFamilyForFormat(PixelFormat format)
The compression family that format belongs to. Only valid for formats where IsCompressed is true.
constexpr bool IsCompressed(PixelFormat format)
Whether format is a block-compressed format.
Dart_Handle ToDart(const T &object)
std::shared_ptr< ContextGLES > context