Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
flutter::AndroidContext Class Reference

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

#include <android_context.h>

Inheritance diagram for flutter::AndroidContext:
flutter::AndroidContextGLImpeller flutter::AndroidContextGLSkia flutter::AndroidContextVulkanImpeller flutter::testing::android::TestAndroidContext

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.
 
sk_sp< GrDirectContextGetMainSkiaContext () const
 Accessor for the Skia context associated with AndroidSurfaces and the raster thread.
 
std::shared_ptr< impeller::ContextGetImpellerContext () const
 Accessor for the Impeller context associated with AndroidSurfaces and the raster thread.
 

Protected Member Functions

void SetImpellerContext (const std::shared_ptr< impeller::Context > &context)
 

Detailed Description

Holds state that is shared across Android surfaces.

Definition at line 19 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 if (impeller_context_) {
17 impeller_context_->Shutdown();
18 }
19};
void releaseResourcesAndAbandonContext()

Member Function Documentation

◆ GetImpellerContext()

std::shared_ptr< impeller::Context > flutter::AndroidContext::GetImpellerContext ( ) const

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

Definition at line 38 of file android_context.cc.

38 {
39 return impeller_context_;
40}

◆ 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 34 of file android_context.cc.

34 {
35 return main_context_;
36}

◆ IsValid()

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

Reimplemented in flutter::AndroidContextGLImpeller, flutter::AndroidContextGLSkia, and flutter::AndroidContextVulkanImpeller.

Definition at line 25 of file android_context.cc.

25 {
26 return true;
27}

◆ RenderingApi()

AndroidRenderingAPI flutter::AndroidContext::RenderingApi ( ) const

Definition at line 21 of file android_context.cc.

21 {
22 return rendering_api_;
23}

◆ SetImpellerContext()

void flutter::AndroidContext::SetImpellerContext ( const std::shared_ptr< impeller::Context > &  context)
protected

Intended to be called from a subclass constructor after setup work for the context has completed.

Definition at line 42 of file android_context.cc.

43 {
44 impeller_context_ = context;
45}

◆ 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 29 of file android_context.cc.

30 {
31 main_context_ = main_context;
32}

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