Flutter Engine
flutter::IOSSurfaceGL Class Referencefinal

#include <ios_surface_gl.h>

Inheritance diagram for flutter::IOSSurfaceGL:
flutter::IOSSurface flutter::GPUSurfaceGLDelegate flutter::GPUSurfaceDelegate

Public Member Functions

 IOSSurfaceGL (fml::scoped_nsobject< CAEAGLLayer > layer, std::shared_ptr< IOSContext > context, FlutterPlatformViewsController *platform_views_controller=nullptr)
 
 ~IOSSurfaceGL () override
 
bool IsValid () const override
 
void UpdateStorageSizeIfNecessary () override
 
std::unique_ptr< SurfaceCreateGPUSurface (GrDirectContext *gr_context) override
 
std::unique_ptr< GLContextResultGLContextMakeCurrent () override
 
bool GLContextClearCurrent () override
 
bool GLContextPresent (uint32_t fbo_id) override
 
intptr_t GLContextFBO (GLFrameInfo frame_info) const override
 
bool SurfaceSupportsReadback () const override
 
ExternalViewEmbedderGetExternalViewEmbedder () override
 Gets the view embedder that controls how the Flutter layer hierarchy split into multiple chunks should be composited back on-screen. This field is optional and the Flutter rasterizer will render into a single on-screen surface if this call returns a null external view embedder. This happens on the GPU thread. More...
 
- Public Member Functions inherited from flutter::IOSSurface
std::shared_ptr< IOSContextGetContext () const
 
std::shared_ptr< IOSExternalViewEmbedderGetSurfaceExternalViewEmbedder () const
 
virtual ~IOSSurface ()
 
- Public Member Functions inherited from flutter::GPUSurfaceGLDelegate
 ~GPUSurfaceGLDelegate () override
 
virtual bool GLContextFBOResetAfterPresent () const
 
virtual SkMatrix GLContextSurfaceTransformation () const
 
virtual sk_sp< const GrGLInterface > GetGLInterface () const
 
virtual GLProcResolver GetGLProcResolver () const
 
- Public Member Functions inherited from flutter::GPUSurfaceDelegate
virtual ~GPUSurfaceDelegate ()
 

Additional Inherited Members

- Public Types inherited from flutter::GPUSurfaceGLDelegate
using GLProcResolver = std::function< void *(const char *)>
 
- Static Public Member Functions inherited from flutter::IOSSurface
static std::unique_ptr< IOSSurfaceCreate (std::shared_ptr< IOSContext > context, fml::scoped_nsobject< CALayer > layer, FlutterPlatformViewsController *platform_views_controller)
 
- Static Public Member Functions inherited from flutter::GPUSurfaceGLDelegate
static sk_sp< const GrGLInterface > GetDefaultPlatformGLInterface ()
 
- Protected Member Functions inherited from flutter::IOSSurface
 IOSSurface (std::shared_ptr< IOSContext > ios_context, FlutterPlatformViewsController *platform_views_controller)
 

Detailed Description

Definition at line 19 of file ios_surface_gl.h.

Constructor & Destructor Documentation

◆ IOSSurfaceGL()

flutter::IOSSurfaceGL::IOSSurfaceGL ( fml::scoped_nsobject< CAEAGLLayer >  layer,
std::shared_ptr< IOSContext context,
FlutterPlatformViewsController platform_views_controller = nullptr 
)

Definition at line 17 of file ios_surface_gl.mm.

References flutter::CastToGLContext(), flutter::IOSContextGL::CreateRenderTarget(), and ~IOSSurfaceGL().

20  : IOSSurface(context, platform_views_controller) {
21  render_target_ = CastToGLContext(context)->CreateRenderTarget(std::move(layer));
22 }
std::unique_ptr< IOSRenderTargetGL > CreateRenderTarget(fml::scoped_nsobject< CAEAGLLayer > layer)
IOSSurface(std::shared_ptr< IOSContext > ios_context, FlutterPlatformViewsController *platform_views_controller)
Definition: ios_surface.mm:54
static IOSContextGL * CastToGLContext(const std::shared_ptr< IOSContext > &context)

◆ ~IOSSurfaceGL()

flutter::IOSSurfaceGL::~IOSSurfaceGL ( )
overridedefault

Referenced by IOSSurfaceGL().

Member Function Documentation

◆ CreateGPUSurface()

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

Implements flutter::IOSSurface.

Definition at line 39 of file ios_surface_gl.mm.

39  {
40  if (gr_context) {
41  return std::make_unique<GPUSurfaceGL>(sk_ref_sp(gr_context), this, true);
42  }
43  return std::make_unique<GPUSurfaceGL>(this, true);
44 }

◆ GetExternalViewEmbedder()

ExternalViewEmbedder * flutter::IOSSurfaceGL::GetExternalViewEmbedder ( )
overridevirtual

Gets the view embedder that controls how the Flutter layer hierarchy split into multiple chunks should be composited back on-screen. This field is optional and the Flutter rasterizer will render into a single on-screen surface if this call returns a null external view embedder. This happens on the GPU thread.

Returns
The external view embedder, or, null if Flutter is rendering into a single on-screen surface.

Reimplemented from flutter::GPUSurfaceGLDelegate.

Definition at line 86 of file ios_surface_gl.mm.

References flutter::IOSSurface::GetSurfaceExternalViewEmbedder().

86  {
87  return GetSurfaceExternalViewEmbedder().get();
88 }
std::shared_ptr< IOSExternalViewEmbedder > GetSurfaceExternalViewEmbedder() const
Definition: ios_surface.mm:68

◆ GLContextClearCurrent()

bool flutter::IOSSurfaceGL::GLContextClearCurrent ( )
overridevirtual

Implements flutter::GPUSurfaceGLDelegate.

Definition at line 74 of file ios_surface_gl.mm.

74  {
75  // |GLContextMakeCurrent| should handle the scope of the gl context.
76  return true;
77 }

◆ GLContextFBO()

intptr_t flutter::IOSSurfaceGL::GLContextFBO ( GLFrameInfo  frame_info) const
overridevirtual

Implements flutter::GPUSurfaceGLDelegate.

Definition at line 47 of file ios_surface_gl.mm.

References IsValid().

47  {
48  return IsValid() ? render_target_->GetFramebuffer() : GL_NONE;
49 }
bool IsValid() const override

◆ GLContextMakeCurrent()

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

Implements flutter::GPUSurfaceGLDelegate.

Definition at line 62 of file ios_surface_gl.mm.

References flutter::IOSSurface::GetContext(), and IsValid().

62  {
63  if (!IsValid()) {
64  return std::make_unique<GLContextDefaultResult>(false);
65  }
66  bool update_if_necessary = render_target_->UpdateStorageSizeIfNecessary();
67  if (!update_if_necessary) {
68  return std::make_unique<GLContextDefaultResult>(false);
69  }
70  return GetContext()->MakeCurrent();
71 }
std::shared_ptr< IOSContext > GetContext() const
Definition: ios_surface.mm:64
bool IsValid() const override

◆ GLContextPresent()

bool flutter::IOSSurfaceGL::GLContextPresent ( uint32_t  fbo_id)
overridevirtual

Implements flutter::GPUSurfaceGLDelegate.

Definition at line 80 of file ios_surface_gl.mm.

References IsValid(), and TRACE_EVENT0.

80  {
81  TRACE_EVENT0("flutter", "IOSSurfaceGL::GLContextPresent");
82  return IsValid() && render_target_->PresentRenderBuffer();
83 }
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:75
bool IsValid() const override

◆ IsValid()

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

Implements flutter::IOSSurface.

Definition at line 27 of file ios_surface_gl.mm.

Referenced by GLContextFBO(), GLContextMakeCurrent(), GLContextPresent(), and UpdateStorageSizeIfNecessary().

27  {
28  return render_target_->IsValid();
29 }

◆ SurfaceSupportsReadback()

bool flutter::IOSSurfaceGL::SurfaceSupportsReadback ( ) const
overridevirtual

Reimplemented from flutter::GPUSurfaceGLDelegate.

Definition at line 52 of file ios_surface_gl.mm.

52  {
53  // The onscreen surface wraps a GL renderbuffer, which is extremely slow to read on iOS.
54  // Certain filter effects, in particular BackdropFilter, require making a copy of
55  // the current destination. For performance, the iOS surface will specify that it
56  // does not support readback so that the engine compositor can implement a workaround
57  // such as rendering the scene to an offscreen surface or Skia saveLayer.
58  return false;
59 }

◆ UpdateStorageSizeIfNecessary()

void flutter::IOSSurfaceGL::UpdateStorageSizeIfNecessary ( )
overridevirtual

Implements flutter::IOSSurface.

Definition at line 32 of file ios_surface_gl.mm.

References IsValid().

32  {
33  if (IsValid()) {
34  render_target_->UpdateStorageSizeIfNecessary();
35  }
36 }
bool IsValid() const override

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