Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
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 SkISize &size) override
 
bool ResourceContextMakeCurrent () override
 
bool ResourceContextClearCurrent () override
 
bool SetNativeWindow (fml::RefPtr< AndroidNativeWindow > window) 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< SkIRect > &region) override
 
bool GLContextPresent (const GLPresentInfo &present_info) override
 
GLFBOInfo GLContextFBO (GLFrameInfo frame_info) const override
 
sk_sp< const GrGLInterfaceGetGLInterface () const override
 
- Public Member Functions inherited from flutter::GPUSurfaceGLDelegate
 ~GPUSurfaceGLDelegate ()
 
virtual std::unique_ptr< GLContextResultGLContextMakeCurrent ()=0
 
virtual bool GLContextClearCurrent ()=0
 
virtual void GLContextSetDamageRegion (const std::optional< SkIRect > &region)
 
virtual bool GLContextPresent (const GLPresentInfo &present_info)=0
 
virtual GLFBOInfo GLContextFBO (GLFrameInfo frame_info) const =0
 
virtual bool GLContextFBOResetAfterPresent () const
 
virtual SurfaceFrame::FramebufferInfo GLContextFramebufferInfo () const
 
virtual SkMatrix GLContextSurfaceTransformation () const
 
virtual sk_sp< const GrGLInterfaceGetGLInterface () const
 
virtual GLProcResolver GetGLProcResolver () const
 
virtual bool AllowsDrawingWhenGpuDisabled () const
 
- Public Member Functions inherited from flutter::AndroidSurface
virtual ~AndroidSurface ()
 
virtual bool IsValid () const =0
 
virtual void TeardownOnScreenContext ()=0
 
virtual std::unique_ptr< SurfaceCreateGPUSurface (GrDirectContext *gr_context=nullptr)=0
 
virtual bool OnScreenSurfaceResize (const SkISize &size)=0
 
virtual bool ResourceContextMakeCurrent ()=0
 
virtual bool ResourceContextClearCurrent ()=0
 
virtual bool SetNativeWindow (fml::RefPtr< AndroidNativeWindow > window)=0
 
virtual std::unique_ptr< SurfaceCreateSnapshotSurface ()
 
virtual std::shared_ptr< impeller::ContextGetImpellerContext ()
 

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 GrGLInterfaceGetDefaultPlatformGLInterface ()
 
- 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:102
#define ERROR(message)
Definition: elf_loader.cc:260

◆ ~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:49

◆ CreateSnapshotSurface()

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

Reimplemented from flutter::AndroidSurface.

Definition at line 83 of file android_surface_gl_impeller.cc.

83 {
85}
#define FML_UNREACHABLE()
Definition: logging.h:109

◆ GetGLInterface()

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

Reimplemented from flutter::GPUSurfaceGLDelegate.

Definition at line 151 of file android_surface_gl_impeller.cc.

151 {
152 return nullptr;
153}

◆ GetImpellerContext()

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

Reimplemented from flutter::AndroidSurface.

Definition at line 89 of file android_surface_gl_impeller.cc.

89 {
90 return android_context_->GetImpellerContext();
91}

◆ GLContextClearCurrent()

bool flutter::AndroidSurfaceGLImpeller::GLContextClearCurrent ( )
overridevirtual

Implements flutter::GPUSurfaceGLDelegate.

Definition at line 108 of file android_surface_gl_impeller.cc.

108 {
109 if (!onscreen_surface_) {
110 return false;
111 }
112
113 return android_context_->OnscreenContextClearCurrent();
114}

◆ GLContextFBO()

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

Implements flutter::GPUSurfaceGLDelegate.

Definition at line 143 of file android_surface_gl_impeller.cc.

143 {
144 // FBO0 is the default window bound framebuffer in EGL environments.
145 return GLFBOInfo{
146 .fbo_id = 0,
147 };
148}

◆ GLContextFramebufferInfo()

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

Reimplemented from flutter::GPUSurfaceGLDelegate.

Definition at line 118 of file android_surface_gl_impeller.cc.

118 {
119 auto info = SurfaceFrame::FramebufferInfo{};
120 info.supports_readback = true;
121 info.supports_partial_repaint = false;
122 return info;
123}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213

◆ GLContextMakeCurrent()

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

Implements flutter::GPUSurfaceGLDelegate.

Definition at line 95 of file android_surface_gl_impeller.cc.

95 {
96 return std::make_unique<GLContextDefaultResult>(OnGLContextMakeCurrent());
97}

◆ GLContextPresent()

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

Implements flutter::GPUSurfaceGLDelegate.

Definition at line 132 of file android_surface_gl_impeller.cc.

133 {
134 // The FBO ID is superfluous and was introduced for iOS where the default
135 // framebuffer was not FBO0.
136 if (!onscreen_surface_) {
137 return false;
138 }
139 return onscreen_surface_->Present();
140}

◆ GLContextSetDamageRegion()

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

Reimplemented from flutter::GPUSurfaceGLDelegate.

Definition at line 126 of file android_surface_gl_impeller.cc.

127 {
128 // Not supported.
129}

◆ 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 SkISize 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)
overridevirtual

Implements flutter::AndroidSurface.

Definition at line 76 of file android_surface_gl_impeller.cc.

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

◆ 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}

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