A wrapper for ASurfaceTransaction. https://developer.android.com/ndk/reference/group/native-activity#asurfacetransaction. More...
#include <surface_transaction.h>
Public Types | |
using | OnCompleteCallback = std::function< void(ASurfaceTransactionStats *)> |
Public Member Functions | |
SurfaceTransaction () | |
~SurfaceTransaction () | |
SurfaceTransaction (const SurfaceTransaction &)=delete | |
SurfaceTransaction & | operator= (const SurfaceTransaction &)=delete |
SurfaceTransaction (ASurfaceTransaction *transaction) | |
bool | IsValid () const |
bool | SetContents (const SurfaceControl *control, const HardwareBuffer *buffer, fml::UniqueFD acquire_fence={}) |
Encodes that the updated contents of a surface control are specified by the given hardware buffer. The update will not be committed till the call to Apply however. More... | |
bool | SetBackgroundColor (const SurfaceControl &control, const Color &color) |
Encodes the updated background color of the surface control. The update will not be committed till the call to Apply however. More... | |
bool | Apply (OnCompleteCallback callback=nullptr) |
Applies the updated encoded in the transaction and invokes the callback when the updated are complete. More... | |
bool | SetParent (const SurfaceControl &control, const SurfaceControl *new_parent=nullptr) |
Set the new parent control of the given control. If the new parent is null, it is removed from the control hierarchy. More... | |
Static Public Member Functions | |
static bool | IsAvailableOnPlatform () |
A wrapper for ASurfaceTransaction. https://developer.android.com/ndk/reference/group/native-activity#asurfacetransaction.
A surface transaction is a collection of updates to the hierarchy of surfaces (represented by ASurfaceControl
instances) that are applied atomically in the compositor.
This wrapper is only available on Android API 29 and above.
Definition at line 54 of file surface_transaction.h.
using impeller::android::SurfaceTransaction::OnCompleteCallback = std::function<void(ASurfaceTransactionStats*)> |
Definition at line 108 of file surface_transaction.h.
impeller::android::SurfaceTransaction::SurfaceTransaction | ( | ) |
Definition at line 13 of file surface_transaction.cc.
|
default |
|
delete |
|
explicit |
Definition at line 18 of file surface_transaction.cc.
bool impeller::android::SurfaceTransaction::Apply | ( | OnCompleteCallback | callback = nullptr | ) |
Applies the updated encoded in the transaction and invokes the callback when the updated are complete.
[in] | callback | The callback |
true
if the surface transaction was applied. true
does not indicate the application was completed however. Only the invocation of the callback denotes transaction completion. Definition at line 31 of file surface_transaction.cc.
References data, impeller::android::GetProcTable(), and IsValid().
Referenced by impeller::android::SurfaceControl::RemoveFromParent(), and impeller::android::testing::TEST().
|
static |
true
if any surface transactions can be created on this platform. Definition at line 115 of file surface_transaction.cc.
References impeller::android::GetProcTable(), and impeller::android::ProcTable::IsValid().
Referenced by impeller::android::testing::TEST().
bool impeller::android::SurfaceTransaction::IsValid | ( | ) | const |
Definition at line 23 of file surface_transaction.cc.
Referenced by Apply(), SetBackgroundColor(), SetParent(), and impeller::android::testing::TEST().
|
delete |
bool impeller::android::SurfaceTransaction::SetBackgroundColor | ( | const SurfaceControl & | control, |
const Color & | color | ||
) |
Encodes the updated background color of the surface control. The update will not be committed till the call to Apply
however.
SurfaceTransaction::Apply
.[in] | control | The control |
[in] | color | The color |
true
if the background control will be set when transaction is applied. Definition at line 83 of file surface_transaction.cc.
References impeller::Color::alpha, impeller::Color::blue, impeller::android::SurfaceControl::GetHandle(), impeller::android::GetProcTable(), impeller::Color::green, impeller::android::SurfaceControl::IsValid(), IsValid(), and impeller::Color::red.
bool impeller::android::SurfaceTransaction::SetContents | ( | const SurfaceControl * | control, |
const HardwareBuffer * | buffer, | ||
fml::UniqueFD | acquire_fence = {} |
||
) |
Encodes that the updated contents of a surface control are specified by the given hardware buffer. The update will not be committed till the call to Apply
however.
SurfaceTransaction::Apply
.[in] | control | The control. |
[in] | buffer | The hardware buffer. |
[in] | acquire_fence | The fence to wait on before setting the contents. |
Definition at line 67 of file surface_transaction.cc.
References impeller::android::HardwareBuffer::GetHandle(), impeller::android::SurfaceControl::GetHandle(), impeller::android::GetProcTable(), and VALIDATION_LOG.
bool impeller::android::SurfaceTransaction::SetParent | ( | const SurfaceControl & | control, |
const SurfaceControl * | new_parent = nullptr |
||
) |
Set the new parent control of the given control. If the new parent is null, it is removed from the control hierarchy.
[in] | control | The control |
[in] | new_parent | The new parent |
true
if the control will be re-parented when the transaction is applied. Definition at line 99 of file surface_transaction.cc.
References impeller::android::SurfaceControl::GetHandle(), impeller::android::GetProcTable(), impeller::android::SurfaceControl::IsValid(), and IsValid().
Referenced by impeller::android::SurfaceControl::RemoveFromParent().