| Flutter Impeller |

Namespaces | Classes | Typedefs | Enumerations | Functions
impeller::android Namespace Reference

## Namespaces
| testing

## Classes
struct | AndroidProc
class | Choreographer
| This class describes access to the choreographer instance for the current thread. Choreographers are only available on API levels above 24. On levels below 24, an invalid choreographer will be returned. More...
class | HardwareBuffer
| A wrapper for AHardwareBuffer https://developer.android.com/ndk/reference/group/a-hardware-buffer. More...
struct | HardwareBufferDescriptor
| A descriptor use to specify hardware buffer allocations. More...
class | NativeWindow
| A wrapper for ANativeWindow https://developer.android.com/ndk/reference/group/a-native-window. More...
struct | ProcTable
| The table of Android procs that are resolved dynamically. More...
class | SurfaceControl
| A wrapper for ASurfaceControl. https://developer.android.com/ndk/reference/group/native-activity#asurfacecontrol. More...
class | SurfaceTransaction
| A wrapper for ASurfaceTransaction. https://developer.android.com/ndk/reference/group/native-activity#asurfacetransaction. More...
struct | TransactionInFlightData

## Typedefs
using | HardwareBufferUsage = Mask< HardwareBufferUsageFlags >

## Enumerations
enum | HardwareBufferFormat { HardwareBufferFormat::kR8G8B8A8UNormInt }
enum | HardwareBufferUsageFlags { HardwareBufferUsageFlags::kNone = 0u, HardwareBufferUsageFlags::kFrameBufferAttachment = 1u << 0u, HardwareBufferUsageFlags::kCompositorOverlay = 1u << 1u, HardwareBufferUsageFlags::kSampledImage = 1u << 2u, HardwareBufferUsageFlags::kCPUReadRarely = 1u << 3u, HardwareBufferUsageFlags::kCPUReadOften = 1u << 4u, HardwareBufferUsageFlags::kCPUWriteRarely = 1u << 5u, HardwareBufferUsageFlags::kCPUWriteOften = 1u << 6u }

## Functions
static Choreographer::FrameTimePoint | ClockMonotonicNanosToFrameTimePoint (int64_t p_nanos)
static AHardwareBuffer_Format | ToAHardwareBufferFormat (HardwareBufferFormat format)
static AHardwareBuffer_Desc | ToAHardwareBufferDesc (const HardwareBufferDescriptor &desc)
const ProcTable & | GetProcTable ()
ProcTable & | GetMutableProcTable ()
template<class T >
void | ResolveAndroidProc (AndroidProc< T > &proc, const std::vector< fml::RefPtr< fml::NativeLibrary >> &libs)
fml::UniqueFD | CreatePreviousReleaseFence (const SurfaceControl &control, ASurfaceTransactionStats *stats)

## Typedef Documentation

## ◆ HardwareBufferUsage

using impeller::android::HardwareBufferUsage = typedef Mask<HardwareBufferUsageFlags>

Definition at line 42 of file hardware_buffer.h.

## Enumeration Type Documentation

## ◆ HardwareBufferFormat

enum impeller::android::HardwareBufferFormat
| strong

Enumerator
kR8G8B8A8UNormInt | This format is guaranteed to be supported on all versions of Android. This format can also be converted to an Impeller and Vulkan format. See also Vulkan Format: VK_FORMAT_R8G8B8A8_UNORM OpenGL ES Format: GL_RGBA8 Why have many format when one format do trick?

Definition at line 18 of file hardware_buffer.h.

18 {
19 //----------------------------------------------------------------------------
20 /// This format is guaranteed to be supported on all versions of Android. This
21 /// format can also be converted to an Impeller and Vulkan format.
22 ///
23 /// @see Vulkan Format: VK_FORMAT_R8G8B8A8_UNORM
24 /// @see OpenGL ES Format: GL_RGBA8
25 ///
26 /// Why have many format when one format do trick?
27 ///
28 kR8G8B8A8UNormInt,
29 };

## ◆ HardwareBufferUsageFlags

enum impeller::android::HardwareBufferUsageFlags
| strong

Enumerator
kNone |
kFrameBufferAttachment |
kCompositorOverlay |
kSampledImage |
kCPUReadRarely |
kCPUReadOften |
kCPUWriteRarely |
kCPUWriteOften |

Definition at line 31 of file hardware_buffer.h.

31 {
32 kNone = 0u,
33 kFrameBufferAttachment = 1u << 0u,
34 kCompositorOverlay = 1u << 1u,
35 kSampledImage = 1u << 2u,
36 kCPUReadRarely = 1u << 3u,
37 kCPUReadOften = 1u << 4u,
38 kCPUWriteRarely = 1u << 5u,
39 kCPUWriteOften = 1u << 6u,
40 };

## Function Documentation

## ◆ ClockMonotonicNanosToFrameTimePoint()

static Choreographer::FrameTimePoint impeller::android::ClockMonotonicNanosToFrameTimePoint | ( | int64_t | p_nanos | ) |
| static

Definition at line 33 of file choreographer.cc.

34 {
35 return Choreographer::FrameTimePoint{std::chrono::nanoseconds(p_nanos)};
36 }

Referenced by impeller::android::Choreographer::PostFrameCallback().

## ◆ CreatePreviousReleaseFence()

fml::UniqueFD impeller::android::CreatePreviousReleaseFence | ( | const SurfaceControl & | control,
|  | ASurfaceTransactionStats * | stats
| ) |  |

Definition at line 11 of file surface_transaction_stats.cc.

12 {
13 const auto fd =
14 GetProcTable().ASurfaceTransactionStats_getPreviousReleaseFenceFd(
15 stats, control.GetHandle());
16 if (fd == -1) {
17 // The previous buffer has already been released. This is not an error.
18 return {};
19 }
20 return fml::UniqueFD{fd};
21 }

References impeller::android::SurfaceControl::GetHandle(), and GetProcTable().

## ◆ GetMutableProcTable()

ProcTable& impeller::android::GetMutableProcTable | ( |  | ) |

Definition at line 18 of file proc_table.cc.

18 {
19 return const_cast<ProcTable&>(GetProcTable());
20 }

References GetProcTable().

## ◆ GetProcTable()

const ProcTable & impeller::android::GetProcTable | ( |  | ) |

Definition at line 12 of file proc_table.cc.

12 {
13 static ProcTable gProcTable;
14 return gProcTable;
15 }

Referenced by impeller::android::SurfaceTransaction::Apply(), CreatePreviousReleaseFence(), impeller::android::HardwareBuffer::Describe(), GetMutableProcTable(), impeller::android::HardwareBuffer::GetSystemUniqueID(), impeller::android::HardwareBuffer::HardwareBuffer(), impeller::android::HardwareBufferDescriptor::IsAllocatable(), impeller::android::Choreographer::IsAvailableOnPlatform(), impeller::android::SurfaceControl::IsAvailableOnPlatform(), impeller::android::SurfaceTransaction::IsAvailableOnPlatform(), impeller::android::HardwareBuffer::IsAvailableOnPlatform(), impeller::android::HardwareBuffer::Lock(), impeller::android::NativeWindow::NativeWindow(), impeller::android::Choreographer::PostFrameCallback(), impeller::android::SurfaceTransaction::SetBackgroundColor(), impeller::android::SurfaceTransaction::SetContents(), impeller::android::SurfaceTransaction::SetParent(), impeller::android::SurfaceControl::SurfaceControl(), impeller::android::testing::TEST(), and impeller::android::HardwareBuffer::Unlock().

## ◆ ResolveAndroidProc()

template<class T >

void impeller::android::ResolveAndroidProc | ( | AndroidProc< T > & | proc,
|  | const std::vector< fml::RefPtr< fml::NativeLibrary >> & | libs
| ) |  |

Definition at line 23 of file proc_table.cc.

25 {
26 for (const auto& lib : libs) {
27 proc.proc = lib->ResolveFunction<T*>(proc.proc_name).value_or(nullptr);
28 if (proc.proc) {
29 break;
30 }
31 }
32 }

References impeller::android::AndroidProc< T >::proc, and impeller::android::AndroidProc< T >::proc_name.

## ◆ ToAHardwareBufferDesc()

static AHardwareBuffer_Desc impeller::android::ToAHardwareBufferDesc | ( | const HardwareBufferDescriptor & | desc | ) |
| static

Definition at line 20 of file hardware_buffer.cc.

21 {
22 AHardwareBuffer_Desc ahb_desc = {};
23 ahb_desc.width = desc.size.width;
24 ahb_desc.height = desc.size.height;
25 ahb_desc.format = ToAHardwareBufferFormat(desc.format);
26 ahb_desc.layers = 1u;
27 if (desc.usage & HardwareBufferUsageFlags::kFrameBufferAttachment) {
28 ahb_desc.usage |= (AHARDWAREBUFFER_USAGE_GPU_FRAMEBUFFER |
29 AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT);
30 }
31 if (desc.usage & HardwareBufferUsageFlags::kCompositorOverlay) {
32 ahb_desc.usage |= AHARDWAREBUFFER_USAGE_COMPOSER_OVERLAY;
33 }
34 if (desc.usage & HardwareBufferUsageFlags::kSampledImage) {
35 ahb_desc.usage |= AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE;
36 }
37 if (desc.usage & HardwareBufferUsageFlags::kCPUReadRarely) {
38 ahb_desc.usage |= AHARDWAREBUFFER_USAGE_CPU_READ_RARELY;
39 }
40 if (desc.usage & HardwareBufferUsageFlags::kCPUReadOften) {
41 ahb_desc.usage |= AHARDWAREBUFFER_USAGE_CPU_READ_OFTEN;
42 }
43 if (desc.usage & HardwareBufferUsageFlags::kCPUWriteRarely) {
44 ahb_desc.usage |= AHARDWAREBUFFER_USAGE_CPU_WRITE_RARELY;
45 }
46 if (desc.usage & HardwareBufferUsageFlags::kCPUWriteOften) {
47 ahb_desc.usage |= AHARDWAREBUFFER_USAGE_CPU_WRITE_OFTEN;
48 }
49 return ahb_desc;
50 }

References impeller::android::HardwareBufferDescriptor::format, impeller::TSize< T >::height, kCompositorOverlay, kCPUReadOften, kCPUReadRarely, kCPUWriteOften, kCPUWriteRarely, kFrameBufferAttachment, kSampledImage, impeller::android::HardwareBufferDescriptor::size, ToAHardwareBufferFormat(), impeller::android::HardwareBufferDescriptor::usage, and impeller::TSize< T >::width.

Referenced by impeller::android::HardwareBufferDescriptor::IsAllocatable().

## ◆ ToAHardwareBufferFormat()

static AHardwareBuffer_Format impeller::android::ToAHardwareBufferFormat | ( | HardwareBufferFormat | format | ) |
| static

Definition at line 11 of file hardware_buffer.cc.

12 {
13 switch (format) {
14 case HardwareBufferFormat::kR8G8B8A8UNormInt:
15 return AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM;
16 }
17 FML_UNREACHABLE();
18 }

References kR8G8B8A8UNormInt.

Referenced by ToAHardwareBufferDesc().

impeller::PixelFormat::kR8G8B8A8UNormInt
@ kR8G8B8A8UNormInt
impeller::kSampledImage
@ kSampledImage
Definition: runtime_types.h:24
impeller::android::HardwareBufferUsageFlags::kCPUWriteOften
@ kCPUWriteOften
impeller::CullMode::kNone
@ kNone
impeller::android::HardwareBufferUsageFlags::kCPUReadOften
@ kCPUReadOften
impeller::android::ToAHardwareBufferFormat
static AHardwareBuffer_Format ToAHardwareBufferFormat(HardwareBufferFormat format)
Definition: hardware_buffer.cc:11
impeller::android::HardwareBufferUsageFlags::kFrameBufferAttachment
@ kFrameBufferAttachment
impeller::android::HardwareBufferUsageFlags::kCompositorOverlay
@ kCompositorOverlay
impeller::android::HardwareBufferUsageFlags::kCPUWriteRarely
@ kCPUWriteRarely
impeller::android::GetProcTable
const ProcTable & GetProcTable()
Definition: proc_table.cc:12
impeller::android::HardwareBufferUsageFlags::kCPUReadRarely
@ kCPUReadRarely