Flutter Engine
 
Loading...
Searching...
No Matches
flutter::AndroidContext Class Reference

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

#include <android_context.h>

Inheritance diagram for flutter::AndroidContext:
flutter::AndroidContextDynamicImpeller flutter::AndroidContextGLImpeller flutter::AndroidContextGLSkia flutter::AndroidContextVKImpeller flutter::testing::android::TestAndroidContext

Classes

struct  ContextSettings
 

Public Member Functions

 AndroidContext (AndroidRenderingAPI rendering_api)
 
virtual ~AndroidContext ()
 
virtual AndroidRenderingAPI RenderingApi () const
 
virtual bool IsDynamicSelection () 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< GrDirectContext > GetMainSkiaContext () const
 Accessor for the Skia context associated with AndroidSurfaces and the raster thread.
 
virtual std::shared_ptr< impeller::ContextGetImpellerContext () const
 Accessor for the Impeller context associated with AndroidSurfaces and the raster thread.
 
virtual void SetupImpellerContext ()
 Perform deferred setup for the impeller Context.
 

Protected Member Functions

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

Detailed Description

Holds state that is shared across Android surfaces.

Definition at line 26 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 !SLIMPELLER
14 if (main_context_) {
15 main_context_->releaseResourcesAndAbandonContext();
16 }
17#endif // !SLIMPELLER
18 if (impeller_context_) {
19 impeller_context_->Shutdown();
20 }
21};

Member Function Documentation

◆ GetImpellerContext()

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

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

Reimplemented in flutter::AndroidContextDynamicImpeller.

Definition at line 49 of file android_context.cc.

49 {
50 return impeller_context_;
51}

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

36 {
37#if !SLIMPELLER
38 return main_context_;
39#else
40 return nullptr;
41#endif // !SLIMPELLER
42}

Referenced by flutter::AndroidContextGLSkia::~AndroidContextGLSkia().

◆ IsDynamicSelection()

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

Reimplemented in flutter::AndroidContextDynamicImpeller.

Definition at line 53 of file android_context.cc.

53 {
54 return false;
55}

◆ IsValid()

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

◆ RenderingApi()

AndroidRenderingAPI flutter::AndroidContext::RenderingApi ( ) const
virtual

Reimplemented in flutter::AndroidContextDynamicImpeller, flutter::AndroidContextGLImpeller, and flutter::AndroidContextVKImpeller.

Definition at line 23 of file android_context.cc.

23 {
24 return rendering_api_;
25}

◆ SetImpellerContext()

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

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

32 {
33 NOT_SLIMPELLER(main_context_ = main_context);
34}
#define NOT_SLIMPELLER(code)
Definition macros.h:16

References NOT_SLIMPELLER.

Referenced by flutter::AndroidContextGLSkia::~AndroidContextGLSkia().

◆ SetupImpellerContext()

virtual void flutter::AndroidContext::SetupImpellerContext ( )
inlinevirtual

Perform deferred setup for the impeller Context.

Reimplemented in flutter::AndroidContextDynamicImpeller.

Definition at line 80 of file android_context.h.

80{}

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