summaryrefslogtreecommitdiff
path: root/native
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2023-02-10 02:17:44 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2023-02-10 02:17:44 +0000
commit2ddc0b227ec60e48401e8ec7288feed96d3d4ebf (patch)
treed699ce83377cd0fe6a346d31a269fa8d599d071a /native
parenta9530eeb38ec2f8ed1ee9db48dad21f9b230693b (diff)
parent54fe60932a6848c68f7d64f11be548137a09e1e9 (diff)
Merge changes from topic "psc-ndk"
* changes: NDK attached choreographer tests NDK attached Choreographer from SurfaceControl.
Diffstat (limited to 'native')
-rw-r--r--native/android/libandroid.map.txt1
-rw-r--r--native/android/surface_control.cpp12
2 files changed, 13 insertions, 0 deletions
diff --git a/native/android/libandroid.map.txt b/native/android/libandroid.map.txt
index 987b23fdd1fd..f258c27aa070 100644
--- a/native/android/libandroid.map.txt
+++ b/native/android/libandroid.map.txt
@@ -345,6 +345,7 @@ LIBANDROID_PLATFORM {
extern "C++" {
ASurfaceControl_registerSurfaceStatsListener*;
ASurfaceControl_unregisterSurfaceStatsListener*;
+ ASurfaceControl_getChoreographer*;
ASurfaceControlStats_getAcquireTime*;
ASurfaceControlStats_getFrameNumber*;
};
diff --git a/native/android/surface_control.cpp b/native/android/surface_control.cpp
index ea20c6c9e0b1..b7f359602a5d 100644
--- a/native/android/surface_control.cpp
+++ b/native/android/surface_control.cpp
@@ -180,6 +180,18 @@ void ASurfaceControl_unregisterSurfaceStatsListener(void* context,
reinterpret_cast<void*>(func));
}
+AChoreographer* ASurfaceControl_getChoreographer(ASurfaceControl* aSurfaceControl) {
+ LOG_ALWAYS_FATAL_IF(aSurfaceControl == nullptr, "aSurfaceControl should not be nullptr");
+ SurfaceControl* surfaceControl =
+ ASurfaceControl_to_SurfaceControl(reinterpret_cast<ASurfaceControl*>(aSurfaceControl));
+ if (!surfaceControl->isValid()) {
+ ALOGE("Attempted to get choreographer from invalid surface control");
+ return nullptr;
+ }
+ SurfaceControl_acquire(surfaceControl);
+ return reinterpret_cast<AChoreographer*>(surfaceControl->getChoreographer().get());
+}
+
int64_t ASurfaceControlStats_getAcquireTime(ASurfaceControlStats* stats) {
if (const auto* fence = std::get_if<sp<Fence>>(&stats->acquireTimeOrFence)) {
// We got a fence instead of the acquire time due to latch unsignaled.