Flutter Engine
 
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 13 of file android_surface_gl_impeller.cc.

15 : android_context_(android_context) {
16 offscreen_surface_ = android_context_->CreateOffscreenSurface();
17
18 if (!offscreen_surface_) {
19 FML_DLOG(ERROR) << "Could not create offscreen surface.";
20 return;
21 }
22
23 // The onscreen surface will be acquired once the native window is set.
24
25 is_valid_ = true;
26}
#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 36 of file android_surface_gl_impeller.cc.

37 {
38 auto surface = std::make_unique<GPUSurfaceGLImpeller>(
39 this, // delegate
40 android_context_->GetImpellerContext(), // context
41 true // render to surface
42 );
43 if (!surface->IsValid()) {
44 return nullptr;
45 }
46 return surface;
47}
VkSurfaceKHR surface
Definition main.cc:65

References surface.

◆ CreateSnapshotSurface()

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

Reimplemented from flutter::AndroidSurface.

Definition at line 84 of file android_surface_gl_impeller.cc.

84 {
85 if (!onscreen_surface_ || !onscreen_surface_->IsValid()) {
86 onscreen_surface_ = android_context_->CreateOffscreenSurface();
87 if (!onscreen_surface_) {
88 FML_DLOG(ERROR) << "Could not create offscreen surface for snapshot.";
89 return nullptr;
90 }
91 }
92 // Make the snapshot surface current because constucting a
93 // GPUSurfaceGLImpeller and its AiksContext may invoke graphics APIs.
94 if (!android_context_->OnscreenContextMakeCurrent(onscreen_surface_.get())) {
95 FML_DLOG(ERROR) << "Could not make snapshot surface current.";
96 return nullptr;
97 }
98 return std::make_unique<GPUSurfaceGLImpeller>(
99 this, // delegate
100 android_context_->GetImpellerContext(), // context
101 true // render to surface
102 );
103}

References FML_DLOG.

◆ GetGLInterface()

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

Reimplemented from flutter::GPUSurfaceGLDelegate.

Definition at line 169 of file android_surface_gl_impeller.cc.

169 {
170 return nullptr;
171}

◆ GetImpellerContext()

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

Reimplemented from flutter::AndroidSurface.

Definition at line 107 of file android_surface_gl_impeller.cc.

107 {
108 return android_context_->GetImpellerContext();
109}

◆ GLContextClearCurrent()

bool flutter::AndroidSurfaceGLImpeller::GLContextClearCurrent ( )
overridevirtual

Implements flutter::GPUSurfaceGLDelegate.

Definition at line 126 of file android_surface_gl_impeller.cc.

126 {
127 if (!onscreen_surface_) {
128 return false;
129 }
130
131 return android_context_->OnscreenContextClearCurrent();
132}

Referenced by TeardownOnScreenContext().

◆ GLContextFBO()

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

Implements flutter::GPUSurfaceGLDelegate.

Definition at line 161 of file android_surface_gl_impeller.cc.

161 {
162 // FBO0 is the default window bound framebuffer in EGL environments.
163 return GLFBOInfo{
164 .fbo_id = 0,
165 };
166}

References flutter::GLFBOInfo::fbo_id.

◆ GLContextFramebufferInfo()

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

Reimplemented from flutter::GPUSurfaceGLDelegate.

Definition at line 136 of file android_surface_gl_impeller.cc.

136 {
137 auto info = SurfaceFrame::FramebufferInfo{};
138 info.supports_readback = true;
139 info.supports_partial_repaint = false;
140 return info;
141}

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

◆ GLContextMakeCurrent()

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

Implements flutter::GPUSurfaceGLDelegate.

Definition at line 113 of file android_surface_gl_impeller.cc.

113 {
114 return std::make_unique<GLContextDefaultResult>(OnGLContextMakeCurrent());
115}

◆ GLContextPresent()

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

Implements flutter::GPUSurfaceGLDelegate.

Definition at line 150 of file android_surface_gl_impeller.cc.

151 {
152 // The FBO ID is superfluous and was introduced for iOS where the default
153 // framebuffer was not FBO0.
154 if (!onscreen_surface_) {
155 return false;
156 }
157 return onscreen_surface_->Present();
158}

◆ GLContextSetDamageRegion()

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

Reimplemented from flutter::GPUSurfaceGLDelegate.

Definition at line 144 of file android_surface_gl_impeller.cc.

145 {
146 // Not supported.
147}

◆ IsValid()

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

Implements flutter::AndroidSurface.

Definition at line 31 of file android_surface_gl_impeller.cc.

31 {
32 return is_valid_;
33}

◆ OnScreenSurfaceResize()

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

Implements flutter::AndroidSurface.

Definition at line 56 of file android_surface_gl_impeller.cc.

56 {
57 // The size is unused. It was added only for iOS where the sizes were
58 // necessary to re-create auxiliary buffers (stencil, depth, etc.).
59 return RecreateOnscreenSurfaceAndMakeOnscreenContextCurrent();
60}

◆ ResourceContextClearCurrent()

bool flutter::AndroidSurfaceGLImpeller::ResourceContextClearCurrent ( )
overridevirtual

Implements flutter::AndroidSurface.

Definition at line 71 of file android_surface_gl_impeller.cc.

71 {
72 return android_context_->ResourceContextClearCurrent();
73}

◆ ResourceContextMakeCurrent()

bool flutter::AndroidSurfaceGLImpeller::ResourceContextMakeCurrent ( )
overridevirtual

Implements flutter::AndroidSurface.

Definition at line 63 of file android_surface_gl_impeller.cc.

63 {
64 if (!offscreen_surface_) {
65 return false;
66 }
67 return android_context_->ResourceContextMakeCurrent(offscreen_surface_.get());
68}

◆ SetNativeWindow()

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

Implements flutter::AndroidSurface.

Definition at line 76 of file android_surface_gl_impeller.cc.

78 {
79 native_window_ = std::move(window);
80 return RecreateOnscreenSurfaceAndMakeOnscreenContextCurrent();
81}
GLFWwindow * window
Definition main.cc:60

References window.

◆ TeardownOnScreenContext()

void flutter::AndroidSurfaceGLImpeller::TeardownOnScreenContext ( )
overridevirtual

Implements flutter::AndroidSurface.

Definition at line 50 of file android_surface_gl_impeller.cc.

50 {
52 onscreen_surface_.reset();
53}

References GLContextClearCurrent().


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