Flutter Engine
 
Loading...
Searching...
No Matches
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
14#include "flutter/fml/macros.h"
19
20namespace impeller {
21class Context;
22} // namespace impeller
23
24namespace 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///
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(
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:
96};
97
98} // namespace flutter
99
100#endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_CONTEXT_H_
Manages the lifetime of the on-screen and off-screen rendering contexts on iOS. On-screen contexts ar...
Definition ios_context.h:39
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.
virtual std::shared_ptr< impeller::Context > GetImpellerContext() const
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 ...
virtual ~IOSContext()
Collects the context object. This must happen on the thread on which this object was created.
virtual IOSRenderingBackend GetBackend() const
Get the rendering backend used by this context.
virtual std::shared_ptr< impeller::AiksContext > GetAiksContext() const
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27
FlTexture * texture
int64_t texture_id