A wrapper for ASurfaceTransaction. https://developer.android.com/ndk/reference/group/native-activity#asurfacetransaction.
More...
#include <surface_transaction.h>
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.
- Note
- Transactions should be short lived objects (create, apply, collect). But, if these are used on multiple threads, they must be externally synchronized.
Definition at line 35 of file surface_transaction.h.
◆ OnCompleteCallback
◆ SurfaceTransaction() [1/2]
impeller::android::SurfaceTransaction::SurfaceTransaction |
( |
| ) |
|
◆ ~SurfaceTransaction()
impeller::android::SurfaceTransaction::~SurfaceTransaction |
( |
| ) |
|
|
default |
◆ SurfaceTransaction() [2/2]
◆ Apply()
bool impeller::android::SurfaceTransaction::Apply |
( |
OnCompleteCallback |
callback = nullptr | ) |
|
Applies the updated encoded in the transaction and invokes the callback when the updated are complete.
- Warning
- The callback will be invoked on a system managed thread.
- Note
- It is fine to immediately destroy the transaction after the call to apply. It is not necessary to wait for transaction completion to collect the transaction handle.
- Parameters
-
- Returns
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 26 of file surface_transaction.cc.
26 {
28 return false;
29 }
30
33 }
34
36
37 auto data = std::make_unique<TransactionInFlightData>();
39 proc_table.ASurfaceTransaction_setOnComplete(
42 [](
void* context, ASurfaceTransactionStats*
stats) ->
void {
43 auto data = reinterpret_cast<TransactionInFlightData*>(context);
44 data->callback(stats);
45 delete data;
46 });
47 proc_table.ASurfaceTransaction_apply(transaction_.
get());
48
49
51 return true;
52}
void reset(const T &value=Traits::InvalidValue())
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
std::shared_ptr< const fml::Mapping > data
◆ IsAvailableOnPlatform()
bool impeller::android::SurfaceTransaction::IsAvailableOnPlatform |
( |
| ) |
|
|
static |
- Returns
true
if any surface transactions can be created on this platform.
Definition at line 108 of file surface_transaction.cc.
108 {
110 GetProcTable().ASurfaceTransaction_create.IsAvailable();
111}
bool IsValid() const
If a valid proc table could be setup. This may fail in case of setup on non-Android platforms.
◆ IsValid()
bool impeller::android::SurfaceTransaction::IsValid |
( |
| ) |
const |
◆ operator=()
◆ SetBackgroundColor()
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.
- See also
SurfaceTransaction::Apply
.
- Parameters
-
[in] | control | The control |
[in] | color | The color |
- Returns
true
if the background control will be set when transaction is applied.
Definition at line 76 of file surface_transaction.cc.
77 {
78 if (!
IsValid() || !control.IsValid()) {
79 return false;
80 }
82 control.GetHandle(),
87 ADATASPACE_SRGB_LINEAR
88 );
89 return true;
90}
◆ SetContents()
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.
- See also
SurfaceTransaction::Apply
.
- Parameters
-
[in] | control | The control. |
[in] | buffer | The hardware buffer. |
[in] | acquire_fence | The fence to wait on before setting the contents. |
- Returns
- If the update was encoded in the transaction.
Definition at line 54 of file surface_transaction.cc.
56 {
57 if (control ==
nullptr ||
buffer ==
nullptr) {
59 return false;
60 }
61
63
64 proc_table.ASurfaceTransaction_setEnableBackPressure(
65 transaction_.
get(), control->GetHandle(),
true);
66
67 proc_table.ASurfaceTransaction_setBuffer(
69 control->GetHandle(),
72 );
73 return true;
74}
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
◆ SetParent()
Set the new parent control of the given control. If the new parent is null, it is removed from the control hierarchy.
- Parameters
-
[in] | control | The control |
[in] | new_parent | The new parent |
- Returns
true
if the control will be re-parented when the transaction is applied.
Definition at line 92 of file surface_transaction.cc.
93 {
94 if (!
IsValid() || !control.IsValid()) {
95 return false;
96 }
97 if (new_parent && !new_parent->IsValid()) {
98 return false;
99 }
102 control.GetHandle(),
103 new_parent == nullptr ? nullptr : new_parent->GetHandle()
104 );
105 return true;
106}
The documentation for this class was generated from the following files: