| 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 | ( |  | ) |
| virtualdefault

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

## ◆ IOSContext()

flutter::IOSContext::IOSContext | ( |  | ) |
| explicitprotecteddefault

## 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 21 of file ios_context.mm.

25 {
26 switch (api) {
27 case IOSRenderingAPI::kSoftware:
28 FML_LOG(IMPORTANT)
29 << "Software rendering is incompatible with Impeller.\n"
30 "Software rendering may have been automatically selected when running on a "
31 "simulator "
32 "in an environment that does not support Metal. Enabling GPU passthrough in your "
33 "environment may fix this.";
34 return std::make_unique<IOSContextNoop>();
35 case IOSRenderingAPI::kMetal:
36 switch (backend) {
37 case IOSRenderingBackend::kSkia:
38 FML_LOG(FATAL) << "Impeller opt-out unavailable.";
39 return nullptr;
40 case IOSRenderingBackend::kImpeller:
41 return std::make_unique<IOSContextMetalImpeller>(settings, is_gpu_disabled_sync_switch);
42 }
43 default:
44 break;
45 }
46 FML_CHECK(false);
47 return nullptr;
48 }
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 59 of file ios_context.mm.

59 {
60 return nullptr;
61 }

## ◆ 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 50 of file ios_context.mm.

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

References flutter::kSkia.

## ◆ GetImpellerContext()

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

Definition at line 55 of file ios_context.mm.

55 {
56 return nullptr;
57 }

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