Flutter Engine
flutter::AndroidContext Class Reference

Holds state that is shared across Android surfaces. More...

#include <android_context.h>

Inheritance diagram for flutter::AndroidContext:
flutter::AndroidContextGL

Public Member Functions

 AndroidContext (AndroidRenderingAPI rendering_api)
 
virtual ~AndroidContext ()
 
AndroidRenderingAPI RenderingApi () const
 
virtual bool IsValid () const
 
void SetMainSkiaContext (const sk_sp< GrDirectContext > &main_context)
 Setter for the Skia context to be used by subsequent AndroidSurfaces. More...
 
sk_sp< GrDirectContext > GetMainSkiaContext () const
 Accessor for the Skia context associated with AndroidSurfaces and the raster thread. More...
 

Detailed Description

Holds state that is shared across Android surfaces.

Definition at line 22 of file android_context.h.

Constructor & Destructor Documentation

◆ AndroidContext()

flutter::AndroidContext::AndroidContext ( AndroidRenderingAPI  rendering_api)
explicit

Definition at line 9 of file android_context.cc.

10  : rendering_api_(rendering_api) {}

◆ ~AndroidContext()

flutter::AndroidContext::~AndroidContext ( )
virtual

Definition at line 12 of file android_context.cc.

12  {
13  if (main_context_) {
14  main_context_->releaseResourcesAndAbandonContext();
15  }
16 };

Member Function Documentation

◆ GetMainSkiaContext()

sk_sp< GrDirectContext > flutter::AndroidContext::GetMainSkiaContext ( ) const

Accessor for the Skia context associated with AndroidSurfaces and the raster thread.

This context is created lazily by the AndroidSurface based on their respective rendering backend and set on this AndroidContext to share via SetMainSkiaContext.

Returns
nullptr when no Skia context has been set yet by its AndroidSurface via SetMainSkiaContext.
Attention
The software context doesn't have a Skia context, so this value will be nullptr.

Definition at line 31 of file android_context.cc.

Referenced by flutter::AndroidSurfaceGL::CreateGPUSurface(), flutter::AndroidSurfaceGL::CreatePbufferSurface(), and flutter::AndroidContextGL::~AndroidContextGL().

31  {
32  return main_context_;
33 }

◆ IsValid()

bool flutter::AndroidContext::IsValid ( ) const
virtual

Reimplemented in flutter::AndroidContextGL.

Definition at line 22 of file android_context.cc.

22  {
23  return true;
24 }

◆ RenderingApi()

AndroidRenderingAPI flutter::AndroidContext::RenderingApi ( ) const

Definition at line 18 of file android_context.cc.

18  {
19  return rendering_api_;
20 }

◆ SetMainSkiaContext()

void flutter::AndroidContext::SetMainSkiaContext ( const sk_sp< GrDirectContext > &  main_context)

Setter for the Skia context to be used by subsequent AndroidSurfaces.

This is useful to reduce memory consumption when creating multiple AndroidSurfaces for the same AndroidContext.

The first AndroidSurface should set this for the AndroidContext if the AndroidContext does not yet have a Skia context to share via GetMainSkiaContext.

Definition at line 26 of file android_context.cc.

Referenced by flutter::AndroidSurfaceGL::CreateGPUSurface(), flutter::AndroidSurfaceGL::CreatePbufferSurface(), and flutter::AndroidContextGL::~AndroidContextGL().

27  {
28  main_context_ = main_context;
29 }

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