Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
flutter::AndroidSurfaceGLImpeller Class Referencefinal

#include <android_surface_gl_impeller.h>

Inheritance diagram for flutter::AndroidSurfaceGLImpeller:
flutter::GPUSurfaceGLDelegate flutter::AndroidSurface

Public Member Functions

 AndroidSurfaceGLImpeller (const std::shared_ptr< AndroidContextGLImpeller > &android_context)
 
 ~AndroidSurfaceGLImpeller () override
 
bool IsValid () const override
 
std::unique_ptr< SurfaceCreateGPUSurface (GrDirectContext *gr_context) override
 
void TeardownOnScreenContext () override
 
bool OnScreenSurfaceResize (const DlISize &size) override
 
bool ResourceContextMakeCurrent () override
 
bool ResourceContextClearCurrent () override
 
bool SetNativeWindow (fml::RefPtr< AndroidNativeWindow > window, const std::shared_ptr< PlatformViewAndroidJNI > &jni_facade) override
 
std::unique_ptr< SurfaceCreateSnapshotSurface () override
 
std::shared_ptr< impeller::ContextGetImpellerContext () override
 
std::unique_ptr< GLContextResultGLContextMakeCurrent () override
 
bool GLContextClearCurrent () override
 
SurfaceFrame::FramebufferInfo GLContextFramebufferInfo () const override
 
void GLContextSetDamageRegion (const std::optional< DlIRect > &region) override
 
bool GLContextPresent (const GLPresentInfo &present_info) override
 
GLFBOInfo GLContextFBO (GLFrameInfo frame_info) const override
 
sk_sp< const GrGLInterface > GetGLInterface () const override
 
- Public Member Functions inherited from flutter::GPUSurfaceGLDelegate
 ~GPUSurfaceGLDelegate ()
 
virtual bool GLContextFBOResetAfterPresent () const
 
virtual DlMatrix GLContextSurfaceTransformation () const
 
virtual GLProcResolver GetGLProcResolver () const
 
virtual bool AllowsDrawingWhenGpuDisabled () const
 
- Public Member Functions inherited from flutter::AndroidSurface
virtual ~AndroidSurface ()
 
virtual void SetupImpellerSurface ()
 

Additional Inherited Members

- Public Types inherited from flutter::GPUSurfaceGLDelegate
using GLProcResolver = std::function< void *(const char *)>
 
- Static Public Member Functions inherited from flutter::GPUSurfaceGLDelegate
static sk_sp< const GrGLInterface > GetDefaultPlatformGLInterface ()
 
- Protected Member Functions inherited from flutter::AndroidSurface
 AndroidSurface ()
 

Detailed Description

Definition at line 17 of file android_surface_gl_impeller.h.

Constructor & Destructor Documentation

◆ AndroidSurfaceGLImpeller()

flutter::AndroidSurfaceGLImpeller::AndroidSurfaceGLImpeller ( const std::shared_ptr< AndroidContextGLImpeller > &  android_context)
explicit

Definition at line 78 of file android_surface_gl_impeller.cc.

80 : android_context_(android_context) {
81 offscreen_surface_ = android_context_->CreateOffscreenSurface();
82
83 if (!offscreen_surface_) {
84 FML_DLOG(ERROR) << "Could not create offscreen surface.";
85 return;
86 }
87
88 // The onscreen surface will be acquired once the native window is set.
89
90 is_valid_ = true;
91}
#define FML_DLOG(severity)
Definition logging.h:121

References FML_DLOG.

◆ ~AndroidSurfaceGLImpeller()

flutter::AndroidSurfaceGLImpeller::~AndroidSurfaceGLImpeller ( )
overridedefault

Member Function Documentation

◆ CreateGPUSurface()

std::unique_ptr< Surface > flutter::AndroidSurfaceGLImpeller::CreateGPUSurface ( GrDirectContext *  gr_context)
overridevirtual

Implements flutter::AndroidSurface.

Definition at line 101 of file android_surface_gl_impeller.cc.

102 {
103 auto surface = std::make_unique<GPUSurfaceGLImpeller>(
104 this, // delegate
105 android_context_->GetImpellerContext(), // context
106 true // render to surface
107 );
108 if (!surface->IsValid()) {
109 return nullptr;
110 }
111 return surface;
112}
VkSurfaceKHR surface
Definition main.cc:65

References surface.

◆ CreateSnapshotSurface()

std::unique_ptr< Surface > flutter::AndroidSurfaceGLImpeller::CreateSnapshotSurface ( )
overridevirtual

Reimplemented from flutter::AndroidSurface.

Definition at line 149 of file android_surface_gl_impeller.cc.

149 {
150 if (!onscreen_surface_ || !onscreen_surface_->IsValid()) {
151 onscreen_surface_ = android_context_->CreateOffscreenSurface();
152 if (!onscreen_surface_) {
153 FML_DLOG(ERROR) << "Could not create offscreen surface for snapshot.";
154 return nullptr;
155 }
156 }
157 // Make the snapshot surface current because constucting a
158 // GPUSurfaceGLImpeller and its AiksContext may invoke graphics APIs.
159 if (!android_context_->OnscreenContextMakeCurrent(onscreen_surface_.get())) {
160 FML_DLOG(ERROR) << "Could not make snapshot surface current.";
161 return nullptr;
162 }
163 return std::make_unique<GPUSurfaceGLImpeller>(
164 this, // delegate
165 android_context_->GetImpellerContext(), // context
166 true // render to surface
167 );
168}

References FML_DLOG.

◆ GetGLInterface()

sk_sp< const GrGLInterface > flutter::AndroidSurfaceGLImpeller::GetGLInterface ( ) const
overridevirtual

Reimplemented from flutter::GPUSurfaceGLDelegate.

Definition at line 245 of file android_surface_gl_impeller.cc.

245 {
246 return nullptr;
247}

◆ GetImpellerContext()

std::shared_ptr< impeller::Context > flutter::AndroidSurfaceGLImpeller::GetImpellerContext ( )
overridevirtual

Reimplemented from flutter::AndroidSurface.

Definition at line 172 of file android_surface_gl_impeller.cc.

172 {
173 return android_context_->GetImpellerContext();
174}

◆ GLContextClearCurrent()

bool flutter::AndroidSurfaceGLImpeller::GLContextClearCurrent ( )
overridevirtual

Implements flutter::GPUSurfaceGLDelegate.

Definition at line 202 of file android_surface_gl_impeller.cc.

202 {
203 if (!onscreen_surface_) {
204 return false;
205 }
206
207 return android_context_->OnscreenContextClearCurrent();
208}

Referenced by TeardownOnScreenContext().

◆ GLContextFBO()

GLFBOInfo flutter::AndroidSurfaceGLImpeller::GLContextFBO ( GLFrameInfo  frame_info) const
overridevirtual

Implements flutter::GPUSurfaceGLDelegate.

Definition at line 237 of file android_surface_gl_impeller.cc.

237 {
238 // FBO0 is the default window bound framebuffer in EGL environments.
239 return GLFBOInfo{
240 .fbo_id = 0,
241 };
242}

References flutter::GLFBOInfo::fbo_id.

◆ GLContextFramebufferInfo()

SurfaceFrame::FramebufferInfo flutter::AndroidSurfaceGLImpeller::GLContextFramebufferInfo ( ) const
overridevirtual

Reimplemented from flutter::GPUSurfaceGLDelegate.

Definition at line 212 of file android_surface_gl_impeller.cc.

212 {
213 auto info = SurfaceFrame::FramebufferInfo{};
214 info.supports_readback = true;
215 info.supports_partial_repaint = false;
216 return info;
217}

References flutter::SurfaceFrame::FramebufferInfo::supports_readback.

◆ GLContextMakeCurrent()

std::unique_ptr< GLContextResult > flutter::AndroidSurfaceGLImpeller::GLContextMakeCurrent ( )
overridevirtual

Implements flutter::GPUSurfaceGLDelegate.

Definition at line 178 of file android_surface_gl_impeller.cc.

178 {
179 bool success = OnGLContextMakeCurrent();
180 if (!success) {
181 return std::make_unique<GLContextDefaultResult>(false);
182 }
183 if (!should_clear_context_between_frames_.has_value()) {
184 should_clear_context_between_frames_ = ShouldClearContextBetweenFrames();
185 }
186 if (should_clear_context_between_frames_.value()) {
187 return std::make_unique<GLContextSwitch>(
188 std::make_unique<AndroidSwitchableGLContextImpeller>(android_context_));
189 }
190 return std::make_unique<GLContextDefaultResult>(true);
191}

◆ GLContextPresent()

bool flutter::AndroidSurfaceGLImpeller::GLContextPresent ( const GLPresentInfo present_info)
overridevirtual

Implements flutter::GPUSurfaceGLDelegate.

Definition at line 226 of file android_surface_gl_impeller.cc.

227 {
228 // The FBO ID is superfluous and was introduced for iOS where the default
229 // framebuffer was not FBO0.
230 if (!onscreen_surface_) {
231 return false;
232 }
233 return onscreen_surface_->Present();
234}

◆ GLContextSetDamageRegion()

void flutter::AndroidSurfaceGLImpeller::GLContextSetDamageRegion ( const std::optional< DlIRect > &  region)
overridevirtual

Reimplemented from flutter::GPUSurfaceGLDelegate.

Definition at line 220 of file android_surface_gl_impeller.cc.

221 {
222 // Not supported.
223}

◆ IsValid()

bool flutter::AndroidSurfaceGLImpeller::IsValid ( ) const
overridevirtual

Implements flutter::AndroidSurface.

Definition at line 96 of file android_surface_gl_impeller.cc.

96 {
97 return is_valid_;
98}

◆ OnScreenSurfaceResize()

bool flutter::AndroidSurfaceGLImpeller::OnScreenSurfaceResize ( const DlISize size)
overridevirtual

Implements flutter::AndroidSurface.

Definition at line 121 of file android_surface_gl_impeller.cc.

121 {
122 // The size is unused. It was added only for iOS where the sizes were
123 // necessary to re-create auxiliary buffers (stencil, depth, etc.).
124 return RecreateOnscreenSurfaceAndMakeOnscreenContextCurrent();
125}

◆ ResourceContextClearCurrent()

bool flutter::AndroidSurfaceGLImpeller::ResourceContextClearCurrent ( )
overridevirtual

Implements flutter::AndroidSurface.

Definition at line 136 of file android_surface_gl_impeller.cc.

136 {
137 return android_context_->ResourceContextClearCurrent();
138}

◆ ResourceContextMakeCurrent()

bool flutter::AndroidSurfaceGLImpeller::ResourceContextMakeCurrent ( )
overridevirtual

Implements flutter::AndroidSurface.

Definition at line 128 of file android_surface_gl_impeller.cc.

128 {
129 if (!offscreen_surface_) {
130 return false;
131 }
132 return android_context_->ResourceContextMakeCurrent(offscreen_surface_.get());
133}

◆ SetNativeWindow()

bool flutter::AndroidSurfaceGLImpeller::SetNativeWindow ( fml::RefPtr< AndroidNativeWindow window,
const std::shared_ptr< PlatformViewAndroidJNI > &  jni_facade 
)
overridevirtual

Implements flutter::AndroidSurface.

Definition at line 141 of file android_surface_gl_impeller.cc.

143 {
144 native_window_ = std::move(window);
145 return RecreateOnscreenSurfaceAndMakeOnscreenContextCurrent();
146}
GLFWwindow * window
Definition main.cc:60

References window.

◆ TeardownOnScreenContext()

void flutter::AndroidSurfaceGLImpeller::TeardownOnScreenContext ( )
overridevirtual

Implements flutter::AndroidSurface.

Definition at line 115 of file android_surface_gl_impeller.cc.

115 {
117 onscreen_surface_.reset();
118}

References GLContextClearCurrent().


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