Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | List of all members
impeller::android::SurfaceControl Class Reference

A wrapper for ASurfaceControl. https://developer.android.com/ndk/reference/group/native-activity#asurfacecontrol. More...

#include <surface_control.h>

Public Member Functions

 SurfaceControl (ANativeWindow *window, const char *debug_name=nullptr)
 Creates a new surface control and adds it as a child of the given window.
 
 ~SurfaceControl ()
 Removes the surface control from the presentation hierarchy managed by the system compositor and release the client side reference to the control. At this point, it may be collected when the compositor is also done using it.
 
 SurfaceControl (const SurfaceControl &)=delete
 
SurfaceControloperator= (const SurfaceControl &)=delete
 
bool IsValid () const
 
ASurfaceControl * GetHandle () const
 
bool RemoveFromParent () const
 Remove the surface control from the hierarchy of nodes presented by the system compositor.
 

Static Public Member Functions

static bool IsAvailableOnPlatform ()
 

Detailed Description

A wrapper for ASurfaceControl. https://developer.android.com/ndk/reference/group/native-activity#asurfacecontrol.

Instances of this class represent a node in the hierarchy of surfaces sent to the system compositor for final composition.

This wrapper is only available on Android API 29 and above.

Definition at line 22 of file surface_control.h.

Constructor & Destructor Documentation

◆ SurfaceControl() [1/2]

impeller::android::SurfaceControl::SurfaceControl ( ANativeWindow window,
const char *  debug_name = nullptr 
)
explicit

Creates a new surface control and adds it as a child of the given window.

Parameters
windowThe window
[in]debug_nameA debug name. See it using adb shell dumpsys SurfaceFlinger along with other control properties. If no debug name is specified, the value "Impeller Layer" is used.

Definition at line 12 of file surface_control.cc.

12 {
13 if (window == nullptr) {
14 VALIDATION_LOG << "Parent window of surface was null.";
15 return;
16 }
17 if (debug_name == nullptr) {
18 debug_name = "Impeller Layer";
19 }
20 control_.reset(
21 GetProcTable().ASurfaceControl_createFromWindow(window, debug_name));
22}
void reset(const T &value=Traits::InvalidValue())
GLFWwindow * window
Definition main.cc:45
const ProcTable & GetProcTable()
Definition proc_table.cc:12
#define VALIDATION_LOG
Definition validation.h:73

◆ ~SurfaceControl()

impeller::android::SurfaceControl::~SurfaceControl ( )

Removes the surface control from the presentation hierarchy managed by the system compositor and release the client side reference to the control. At this point, it may be collected when the compositor is also done using it.

Definition at line 24 of file surface_control.cc.

24 {
25 if (IsValid() && !RemoveFromParent()) {
26 VALIDATION_LOG << "Surface control could not be removed from its parent. "
27 "Expect a leak.";
28 }
29}
bool RemoveFromParent() const
Remove the surface control from the hierarchy of nodes presented by the system compositor.

◆ SurfaceControl() [2/2]

impeller::android::SurfaceControl::SurfaceControl ( const SurfaceControl )
delete

Member Function Documentation

◆ GetHandle()

ASurfaceControl * impeller::android::SurfaceControl::GetHandle ( ) const

Definition at line 35 of file surface_control.cc.

35 {
36 return control_.get();
37}
const T & get() const

◆ IsAvailableOnPlatform()

bool impeller::android::SurfaceControl::IsAvailableOnPlatform ( )
static
Returns
true if any surface controls can be created on this platform.

Definition at line 50 of file surface_control.cc.

50 {
51 return GetProcTable().IsValid() &&
52 GetProcTable().ASurfaceControl_createFromWindow.IsAvailable();
53}
bool IsValid() const
If a valid proc table could be setup. This may fail in case of setup on non-Android platforms.
Definition proc_table.cc:65

◆ IsValid()

bool impeller::android::SurfaceControl::IsValid ( ) const

Definition at line 31 of file surface_control.cc.

31 {
32 return control_.is_valid();
33}
bool is_valid() const

◆ operator=()

SurfaceControl & impeller::android::SurfaceControl::operator= ( const SurfaceControl )
delete

◆ RemoveFromParent()

bool impeller::android::SurfaceControl::RemoveFromParent ( ) const

Remove the surface control from the hierarchy of nodes presented by the system compositor.

Returns
true If the control will be removed from the hierarchy of nodes presented by the system compositor.

Definition at line 39 of file surface_control.cc.

39 {
40 if (!IsValid()) {
41 return false;
42 }
43 SurfaceTransaction transaction;
44 if (!transaction.SetParent(*this, nullptr)) {
45 return false;
46 }
47 return transaction.Apply();
48}

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