Flutter Engine
flutter::IOSSurfaceGL Class Referencefinal

#include <ios_surface_gl.h>

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

Public Member Functions

 IOSSurfaceGL (fml::scoped_nsobject< CAEAGLLayer > layer, std::shared_ptr< IOSContext > context)
 
 ~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
 
bool AllowsDrawingWhenGpuDisabled () const override
 
- Public Member Functions inherited from flutter::IOSSurface
std::shared_ptr< IOSContextGetContext () const
 
virtual ~IOSSurface ()
 
- Public Member Functions inherited from flutter::GPUSurfaceGLDelegate
 ~GPUSurfaceGLDelegate ()
 
virtual bool GLContextFBOResetAfterPresent () const
 
virtual SkMatrix GLContextSurfaceTransformation () const
 
virtual sk_sp< const GrGLInterface > GetGLInterface () const
 
virtual GLProcResolver GetGLProcResolver () const
 

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)
 
- 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)
 

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 
)

Definition at line 17 of file ios_surface_gl.mm.

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

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

◆ ~IOSSurfaceGL()

flutter::IOSSurfaceGL::~IOSSurfaceGL ( )
overridedefault

Referenced by IOSSurfaceGL().

Member Function Documentation

◆ AllowsDrawingWhenGpuDisabled()

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

Reimplemented from flutter::GPUSurfaceGLDelegate.

Definition at line 93 of file ios_surface_gl.mm.

93  {
94  return false;
95 }

◆ CreateGPUSurface()

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

Implements flutter::IOSSurface.

Definition at line 38 of file ios_surface_gl.mm.

References flutter::CastToGLContext(), flutter::IOSSurface::GetContext(), flutter::IOSContextGL::GetMainContext(), flutter::GPUSurfaceGL::MakeGLContext(), and flutter::IOSContextGL::SetMainContext().

38  {
39  if (gr_context) {
40  return std::make_unique<GPUSurfaceGL>(sk_ref_sp(gr_context), this, true);
41  } else {
42  IOSContextGL* gl_context = CastToGLContext(GetContext());
43  sk_sp<GrDirectContext> context = gl_context->GetMainContext();
44  if (!context) {
45  context = GPUSurfaceGL::MakeGLContext(this);
46  gl_context->SetMainContext(context);
47  }
48 
49  return std::make_unique<GPUSurfaceGL>(context, this, true);
50  }
51 }
std::shared_ptr< IOSContext > GetContext() const
Definition: ios_surface.mm:55
static IOSContextGL * CastToGLContext(const std::shared_ptr< IOSContext > &context)
static sk_sp< GrDirectContext > MakeGLContext(GPUSurfaceGLDelegate *delegate)

◆ GLContextClearCurrent()

bool flutter::IOSSurfaceGL::GLContextClearCurrent ( )
overridevirtual

Implements flutter::GPUSurfaceGLDelegate.

Definition at line 81 of file ios_surface_gl.mm.

81  {
82  // |GLContextMakeCurrent| should handle the scope of the gl context.
83  return true;
84 }

◆ GLContextFBO()

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

Implements flutter::GPUSurfaceGLDelegate.

Definition at line 54 of file ios_surface_gl.mm.

References IsValid().

54  {
55  return IsValid() ? render_target_->GetFramebuffer() : GL_NONE;
56 }
bool IsValid() const override

◆ GLContextMakeCurrent()

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

Implements flutter::GPUSurfaceGLDelegate.

Definition at line 69 of file ios_surface_gl.mm.

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

69  {
70  if (!IsValid()) {
71  return std::make_unique<GLContextDefaultResult>(false);
72  }
73  bool update_if_necessary = render_target_->UpdateStorageSizeIfNecessary();
74  if (!update_if_necessary) {
75  return std::make_unique<GLContextDefaultResult>(false);
76  }
77  return GetContext()->MakeCurrent();
78 }
std::shared_ptr< IOSContext > GetContext() const
Definition: ios_surface.mm:55
bool IsValid() const override

◆ GLContextPresent()

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

Implements flutter::GPUSurfaceGLDelegate.

Definition at line 87 of file ios_surface_gl.mm.

References IsValid(), and TRACE_EVENT0.

87  {
88  TRACE_EVENT0("flutter", "IOSSurfaceGL::GLContextPresent");
89  return IsValid() && render_target_->PresentRenderBuffer();
90 }
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:90
bool IsValid() const override

◆ IsValid()

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

Implements flutter::IOSSurface.

Definition at line 26 of file ios_surface_gl.mm.

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

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

◆ SurfaceSupportsReadback()

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

Reimplemented from flutter::GPUSurfaceGLDelegate.

Definition at line 59 of file ios_surface_gl.mm.

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

◆ UpdateStorageSizeIfNecessary()

void flutter::IOSSurfaceGL::UpdateStorageSizeIfNecessary ( )
overridevirtual

Implements flutter::IOSSurface.

Definition at line 31 of file ios_surface_gl.mm.

References IsValid().

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

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