| Flutter iOS Embedder |

Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
flutter::IOSContext Class Referenceabstract

Manages the lifetime of the on-screen and off-screen rendering contexts on iOS. On-screen contexts are used by Flutter for rendering into the surface. The lifecycle of this context may be tied to the lifecycle of the surface. On the other hand, the lifecycle of the off-screen context it tied to that of the platform view. This one object used to manage both context because GPU handles may need to be shared between the two context. To achieve this, context may need references to one another at creation time. This one object manages the creation, use and collection of both contexts in a client rendering API agnostic manner. More...

`#include <ios_context.h>`

Inheritance diagram for flutter::IOSContext:

## Public Member Functions
virtual | ~IOSContext ()
| Collects the context object. This must happen on the thread on which this object was created. More...
virtual IOSRenderingBackend | GetBackend () const
| Get the rendering backend used by this context. More...
virtual std::unique_ptr< Texture > | CreateExternalTexture (int64_t texture_id, NSObject< FlutterTexture > *texture)=0
| Creates an external texture proxy of the appropriate client rendering API. More...
virtual std::shared_ptr< impeller::Context > | GetImpellerContext () const
virtual std::shared_ptr< impeller::AiksContext > | GetAiksContext () const

## Static Public Member Functions
static std::unique_ptr< IOSContext > | Create (IOSRenderingAPI api, IOSRenderingBackend backend, const std::shared_ptr< const fml::SyncSwitch > &is_gpu_disabled_sync_switch, const Settings &settings)
| Create an iOS context object capable of creating the on-screen and off-screen GPU context for use by Impeller. More...

## Protected Member Functions
| IOSContext ()

## Detailed Description

Manages the lifetime of the on-screen and off-screen rendering contexts on iOS. On-screen contexts are used by Flutter for rendering into the surface. The lifecycle of this context may be tied to the lifecycle of the surface. On the other hand, the lifecycle of the off-screen context it tied to that of the platform view. This one object used to manage both context because GPU handles may need to be shared between the two context. To achieve this, context may need references to one another at creation time. This one object manages the creation, use and collection of both contexts in a client rendering API agnostic manner.

Definition at line 39 of file ios_context.h.

## Constructor & Destructor Documentation

## ◆ ~IOSContext()

flutter::IOSContext::~IOSContext | ( |  | ) |
| virtual default

Collects the context object. This must happen on the thread on which this object was created.

## ◆ IOSContext()

flutter::IOSContext::IOSContext | ( |  | ) |
| explicit protected default

## Member Function Documentation

## ◆ Create()

std::unique_ptr< IOSContext > flutter::IOSContext::Create | ( | IOSRenderingAPI | api,
|  | IOSRenderingBackend | backend,
|  | const std::shared_ptr< const fml::SyncSwitch > & | is_gpu_disabled_sync_switch,
|  | const Settings & | settings
| ) |  |
| static

Create an iOS context object capable of creating the on-screen and off-screen GPU context for use by Impeller.

In case the engine does not support the specified client rendering API, this a `nullptr` may be returned.

Parameters

  [in] | api | A client rendering API supported by the engine/platform.
  [in] | backend | A client rendering backend supported by the engine/platform.

Returns
  A valid context on success. `nullptr` on failure.

Definition at line 23 of file ios_context.mm.

27 {
28 switch (api) {
29 case IOSRenderingAPI::kSoftware:
30 [FlutterLogger logImportant:@"Software rendering is incompatible with Impeller.\n"
31 "Software rendering may have been automatically selected when "
32 "running on a simulator in an environment that does not support "
33 "Metal. Enabling GPU passthrough in your environment may fix "
34 "this."];
35 return std::make_unique<IOSContextNoop>();
36 case IOSRenderingAPI::kMetal:
37 switch (backend) {
38 case IOSRenderingBackend::kSkia:
39 [FlutterLogger logFatal:@"Impeller opt-out unavailable."];
40 return nullptr;
41 case IOSRenderingBackend::kImpeller:
42 return std::make_unique<IOSContextMetalImpeller>(settings, is_gpu_disabled_sync_switch);
43 }
44 default:
45 break;
46 }
47 FML_CHECK(false);
48 return nullptr;
49 }
flutter::IOSRenderingBackend::kImpeller
@ kImpeller
flutter::IOSRenderingBackend::kSkia
@ kSkia
flutter::IOSRenderingAPI::kMetal
@ kMetal
flutter::IOSRenderingAPI::kSoftware
@ kSoftware

References flutter::kImpeller, flutter::kMetal, flutter::kSkia, and flutter::kSoftware.

## ◆ CreateExternalTexture()

virtual std::unique_ptr<Texture> flutter::IOSContext::CreateExternalTexture | ( | int64_t | texture_id,
|  | NSObject< FlutterTexture > * | texture
| ) |  |
| pure virtual

Creates an external texture proxy of the appropriate client rendering API.

Parameters

  [in] | texture_id | The texture identifier
  [in] | texture | The texture

Returns
  The texture proxy if the rendering backend supports embedder provided external textures.

Implemented in flutter::IOSContextNoop.

## ◆ GetAiksContext()

std::shared_ptr< impeller::AiksContext > flutter::IOSContext::GetAiksContext | ( |  | ) | const
| virtual

Definition at line 60 of file ios_context.mm.

60 {
61 return nullptr;
62 }

## ◆ GetBackend()

IOSRenderingBackend flutter::IOSContext::GetBackend | ( |  | ) | const
| virtual

Get the rendering backend used by this context.

Returns
  The rendering backend.

Reimplemented in flutter::IOSContextNoop, and flutter::IOSContextMetalImpeller.

Definition at line 51 of file ios_context.mm.

51 {
52 // Overridden by Impeller subclasses.
53 return IOSRenderingBackend::kSkia;
54 }

References flutter::kSkia.

## ◆ GetImpellerContext()

std::shared_ptr< impeller::Context > flutter::IOSContext::GetImpellerContext | ( |  | ) | const
| virtual

Definition at line 56 of file ios_context.mm.

56 {
57 return nullptr;
58 }

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

- shell/platform/darwin/ios/ios_context.h
- shell/platform/darwin/ios/ios_context.mm