-
Notifications
You must be signed in to change notification settings - Fork 29.8k
[Android] SurfaceTransaction updates for HC++. #162405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
8c78ea4
02a76c2
2d34031
d3e6f2c
52e0aa4
84e42b2
d1b9f97
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,22 @@ namespace impeller::android { | |
| class SurfaceControl; | ||
| class HardwareBuffer; | ||
|
|
||
| /// @brief A wrapper class that indicates whether a SurfaceTransaction was | ||
| /// created by the flutter engine or was borrowed from Java for platform | ||
| /// interop. | ||
| struct WrappedSurfaceTransaction { | ||
| ASurfaceTransaction* tx; | ||
|
||
| bool owned; | ||
|
||
|
|
||
| constexpr bool operator==(const WrappedSurfaceTransaction& other) const { | ||
| return other.tx == tx; | ||
| } | ||
|
|
||
| constexpr bool operator!=(const WrappedSurfaceTransaction& other) const { | ||
| return !(*this == other); | ||
| } | ||
| }; | ||
|
|
||
| //------------------------------------------------------------------------------ | ||
| /// @brief A wrapper for ASurfaceTransaction. | ||
| /// https://developer.android.com/ndk/reference/group/native-activity#asurfacetransaction | ||
|
|
@@ -48,6 +64,8 @@ class SurfaceTransaction { | |
|
|
||
| SurfaceTransaction& operator=(const SurfaceTransaction&) = delete; | ||
|
|
||
| explicit SurfaceTransaction(ASurfaceTransaction* transaction); | ||
|
|
||
| bool IsValid() const; | ||
|
|
||
| //---------------------------------------------------------------------------- | ||
|
|
@@ -119,18 +137,20 @@ class SurfaceTransaction { | |
|
|
||
| private: | ||
| struct UniqueASurfaceTransactionTraits { | ||
| static ASurfaceTransaction* InvalidValue() { return nullptr; } | ||
| static WrappedSurfaceTransaction InvalidValue() { return {}; } | ||
|
|
||
| static bool IsValid(ASurfaceTransaction* value) { | ||
| return value != InvalidValue(); | ||
| static bool IsValid(const WrappedSurfaceTransaction& value) { | ||
| return value.tx != nullptr; | ||
| } | ||
|
|
||
| static void Free(ASurfaceTransaction* value) { | ||
| GetProcTable().ASurfaceTransaction_delete(value); | ||
| static void Free(const WrappedSurfaceTransaction& value) { | ||
| if (value.owned && value.tx) { | ||
| GetProcTable().ASurfaceTransaction_delete(value.tx); | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| fml::UniqueObject<ASurfaceTransaction*, UniqueASurfaceTransactionTraits> | ||
| fml::UniqueObject<WrappedSurfaceTransaction, UniqueASurfaceTransactionTraits> | ||
| transaction_; | ||
| }; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/java/Java