| Flutter iOS Embedder |

ios_context.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_CONTEXT_H_
6 #define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_CONTEXT_H_
7
8 #include <memory>
9
10 #include "flutter/common/graphics/gl_context_switch.h"
11 #include "flutter/common/graphics/texture.h"
12 #include "flutter/common/settings.h"
13 #include "flutter/fml/concurrent_message_loop.h"
14 #include "flutter/fml/macros.h"
15 #include "flutter/fml/synchronization/sync_switch.h"
16 #import "flutter/shell/platform/darwin/common/framework/Headers/FlutterTexture.h"
17 #import "flutter/shell/platform/darwin/ios/rendering_api_selection.h"
18 #include "impeller/display_list/aiks_context.h"
19
20 namespace impeller {
21 class Context;
22 } // namespace impeller
23
24 namespace flutter {
25
26 //------------------------------------------------------------------------------
27 /// @brief Manages the lifetime of the on-screen and off-screen rendering
28 /// contexts on iOS. On-screen contexts are used by Flutter for
29 /// rendering into the surface. The lifecycle of this context may be
30 /// tied to the lifecycle of the surface. On the other hand, the
31 /// lifecycle of the off-screen context it tied to that of the
32 /// platform view. This one object used to manage both context
33 /// because GPU handles may need to be shared between the two
34 /// context. To achieve this, context may need references to one
35 /// another at creation time. This one object manages the creation,
36 /// use and collection of both contexts in a client rendering API
37 /// agnostic manner.
38 ///
39 class IOSContext {
40 public:
41 //----------------------------------------------------------------------------
42 /// @brief Create an iOS context object capable of creating the on-screen
43 /// and off-screen GPU context for use by Impeller.
44 ///
45 /// In case the engine does not support the specified client
46 /// rendering API, this a `nullptr` may be returned.
47 ///
48 /// @param[in] api A client rendering API supported by the
49 /// engine/platform.
50 /// @param[in] backend A client rendering backend supported by the
51 /// engine/platform.
52 ///
53 /// @return A valid context on success. `nullptr` on failure.
54 ///
55 static std::unique_ptr<IOSContext> Create(
56 IOSRenderingAPI api,
57 IOSRenderingBackend backend,
58 const std::shared_ptr<const fml::SyncSwitch>& is_gpu_disabled_sync_switch,
59 const Settings& settings);
60
61 //----------------------------------------------------------------------------
62 /// @brief Collects the context object. This must happen on the thread on
63 /// which this object was created.
64 ///
65 virtual ~IOSContext();
66
67 //----------------------------------------------------------------------------
68 /// @brief Get the rendering backend used by this context.
69 ///
70 /// @return The rendering backend.
71 ///
72 virtual IOSRenderingBackend GetBackend() const;
73
74 //----------------------------------------------------------------------------
75 /// @brief Creates an external texture proxy of the appropriate client
76 /// rendering API.
77 ///
78 /// @param[in] texture_id The texture identifier
79 /// @param[in] texture The texture
80 ///
81 /// @return The texture proxy if the rendering backend supports embedder
82 /// provided external textures.
83 ///
84 virtual std::unique_ptr<Texture> CreateExternalTexture(int64_t texture_id,
85 NSObject<FlutterTexture>* texture) = 0;
86
87 virtual std::shared_ptr<impeller::Context> GetImpellerContext() const;
88
89 virtual std::shared_ptr<impeller::AiksContext> GetAiksContext() const;
90
91 protected:
92 explicit IOSContext();
93
94 private:
95 FML_DISALLOW_COPY_AND_ASSIGN(IOSContext);
96 };
97
98 } // namespace flutter
99
100 #endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_CONTEXT_H_
FlutterTexture.h
flutter::IOSContext
Manages the lifetime of the on-screen and off-screen rendering contexts on iOS. On-screen contexts ar...
Definition: ios_context.h:39
flutter::IOSContext::IOSContext
IOSContext()
flutter::IOSContext::CreateExternalTexture
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.
flutter::IOSContext::GetImpellerContext
virtual std::shared_ptr< impeller::Context > GetImpellerContext() const
Definition: ios_context.mm:56
flutter::IOSContext::Create
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 ...
Definition: ios_context.mm:23
flutter::IOSContext::~IOSContext
virtual ~IOSContext()
Collects the context object. This must happen on the thread on which this object was created.
flutter::IOSContext::GetBackend
virtual IOSRenderingBackend GetBackend() const
Get the rendering backend used by this context.
Definition: ios_context.mm:51
flutter::IOSContext::GetAiksContext
virtual std::shared_ptr< impeller::AiksContext > GetAiksContext() const
Definition: ios_context.mm:60
flutter
Definition: accessibility_bridge.h:26
flutter::IOSRenderingBackend
IOSRenderingBackend
Definition: rendering_api_selection.h:19
flutter::IOSRenderingAPI
IOSRenderingAPI
Definition: rendering_api_selection.h:14
impeller
Definition: ios_context.h:20
rendering_api_selection.h
texture_id
int64_t texture_id
Definition: texture_registrar_unittests.cc:24