Flutter Engine
 
Loading...
Searching...
No Matches
embedder_render_target.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_EMBEDDER_EMBEDDER_RENDER_TARGET_H_
6#define FLUTTER_SHELL_PLATFORM_EMBEDDER_EMBEDDER_RENDER_TARGET_H_
7
8#include <memory>
10#include "flutter/fml/closure.h"
11#include "flutter/fml/macros.h"
13#include "third_party/skia/include/core/SkSurface.h"
14
15namespace impeller {
16class RenderTarget;
17class AiksContext;
18} // namespace impeller
19
20namespace flutter {
21
22//------------------------------------------------------------------------------
23/// @brief Describes a surface whose backing store is managed by the
24/// embedder. The type of surface depends on the client rendering
25/// API used. The embedder is notified of the collection of this
26/// render target via a callback.
27///
29 public:
31 /// This is true if the operation succeeded (even if it was a no-op),
32 /// false if the surface could not be made current / the current surface
33 /// could not be cleared.
34 bool success;
35
36 /// This is true if any native graphics API (e.g. GL, but not EGL) state has
37 /// changed and Skia/Impeller should not assume any GL state values are the
38 /// same as before the context change operation was attempted.
40 };
41
43
44 //----------------------------------------------------------------------------
45 /// @brief Destroys this instance of the render target and invokes the
46 /// callback for the embedder to release its resource associated
47 /// with the particular backing store.
48 ///
49 virtual ~EmbedderRenderTarget();
50
51 //----------------------------------------------------------------------------
52 /// @brief A render surface the rasterizer can use to draw into the
53 /// backing store of this render target.
54 ///
55 /// @return The render surface.
56 ///
57 virtual sk_sp<SkSurface> GetSkiaSurface() const = 0;
58
59 //----------------------------------------------------------------------------
60 /// @brief An impeller render target the rasterizer can use to draw into
61 /// the backing store.
62 ///
63 /// @return The Impeller render target.
64 ///
66
67 //----------------------------------------------------------------------------
68 /// @brief Returns the AiksContext that should be used for rendering, if
69 /// this render target is backed by Impeller.
70 ///
71 /// @return The Impeller Aiks context.
72 ///
73 virtual std::shared_ptr<impeller::AiksContext> GetAiksContext() const = 0;
74
75 //----------------------------------------------------------------------------
76 /// @brief Returns the size of the render target.
77 ///
78 /// @return The size of the render target.
79 ///
80 virtual DlISize GetRenderTargetSize() const = 0;
81
82 //----------------------------------------------------------------------------
83 /// @brief The embedder backing store descriptor. This is the descriptor
84 /// that was given to the engine by the embedder. This descriptor
85 /// may contain context the embedder can use to associate it
86 /// resources with the compositor layers when they are given back
87 /// to it in present callback. The engine does not use this in any
88 /// way.
89 ///
90 /// @return The backing store.
91 ///
93
94 //----------------------------------------------------------------------------
95 /// @brief Make the render target current.
96 ///
97 /// Sometimes render targets are actually (for example)
98 /// EGL surfaces instead of framebuffers or textures.
99 /// In that case, we can't fully wrap them as SkSurfaces, instead,
100 /// the embedder will provide a callback that should be called
101 /// when the target surface should be made current.
102 ///
103 /// @return The result of the operation.
104 virtual SetCurrentResult MaybeMakeCurrent() const { return {true, false}; }
105
106 //----------------------------------------------------------------------------
107 /// @brief Clear the current render target. @see MaybeMakeCurrent
108 ///
109 /// @return The result of the operation.
110 virtual SetCurrentResult MaybeClearCurrent() const { return {true, false}; }
111
112 protected:
113 //----------------------------------------------------------------------------
114 /// @brief Creates a render target whose backing store is managed by the
115 /// embedder. The way this render target is exposed to the engine
116 /// is via an SkSurface and a callback that is invoked by this
117 /// object in its destructor.
118 ///
119 /// @param[in] backing_store The backing store describing this render
120 /// target.
121 /// @param[in] on_release The callback to invoke (eventually forwarded
122 /// to the embedder) when the backing store is no
123 /// longer required by the engine.
124 ///
126 fml::closure on_release);
127
128 private:
129 FlutterBackingStore backing_store_;
130
131 fml::closure on_release_;
132
134};
135
136} // namespace flutter
137
138#endif // FLUTTER_SHELL_PLATFORM_EMBEDDER_EMBEDDER_RENDER_TARGET_H_
Describes a surface whose backing store is managed by the embedder. The type of surface depends on th...
virtual impeller::RenderTarget * GetImpellerRenderTarget() const =0
An impeller render target the rasterizer can use to draw into the backing store.
std::function< SetCurrentResult()> MakeOrClearCurrentCallback
virtual sk_sp< SkSurface > GetSkiaSurface() const =0
A render surface the rasterizer can use to draw into the backing store of this render target.
virtual SetCurrentResult MaybeClearCurrent() const
Clear the current render target.
virtual std::shared_ptr< impeller::AiksContext > GetAiksContext() const =0
Returns the AiksContext that should be used for rendering, if this render target is backed by Impelle...
virtual SetCurrentResult MaybeMakeCurrent() const
Make the render target current.
virtual ~EmbedderRenderTarget()
Destroys this instance of the render target and invokes the callback for the embedder to release its ...
virtual DlISize GetRenderTargetSize() const =0
Returns the size of the render target.
const FlutterBackingStore * GetBackingStore() const
The embedder backing store descriptor. This is the descriptor that was given to the engine by the emb...
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27
std::function< void()> closure
Definition closure.h:14