[ANativeWindow] allocateBuffers changes
* rename allocateBuffers to tryAllocateBuffers to reflect that its a
best-effort API
* promote to public NDK
Bug: 148962594
Test: builds
Change-Id: Iff73c2eb7bb07d28ef26b95202257950e9da4627
diff --git a/libs/nativewindow/ANativeWindow.cpp b/libs/nativewindow/ANativeWindow.cpp
index a1c9eb8..98b76fd 100644
--- a/libs/nativewindow/ANativeWindow.cpp
+++ b/libs/nativewindow/ANativeWindow.cpp
@@ -165,6 +165,14 @@
return native_window_set_frame_rate(window, frameRate);
}
+void ANativeWindow_tryAllocateBuffers(ANativeWindow* window) {
+ if (!window || !query(window, NATIVE_WINDOW_IS_VALID)) {
+ return;
+ }
+ window->perform(window, NATIVE_WINDOW_ALLOCATE_BUFFERS);
+}
+
+
/**************************************************************************************************
* vndk-stable
**************************************************************************************************/
@@ -328,10 +336,6 @@
return window->perform(window, NATIVE_WINDOW_SET_QUEUE_INTERCEPTOR, interceptor, data);
}
-void ANativeWindow_allocateBuffers(ANativeWindow* window) {
- window->perform(window, NATIVE_WINDOW_ALLOCATE_BUFFERS);
-}
-
int64_t ANativeWindow_getNextFrameId(ANativeWindow* window) {
return query64(window, NATIVE_WINDOW_GET_NEXT_FRAME_ID);
}
diff --git a/libs/nativewindow/include/android/native_window.h b/libs/nativewindow/include/android/native_window.h
index 262aee3..4b426c5 100644
--- a/libs/nativewindow/include/android/native_window.h
+++ b/libs/nativewindow/include/android/native_window.h
@@ -261,6 +261,17 @@
*/
int32_t ANativeWindow_setFrameRate(ANativeWindow* window, float frameRate) __INTRODUCED_IN(30);
+/**
+ * Provides a hint to the window that buffers should be preallocated ahead of
+ * time. Note that the window implementation is not guaranteed to preallocate
+ * any buffers, for instance if an implementation disallows allocation of new
+ * buffers, or if there is insufficient memory in the system to preallocate
+ * additional buffers
+ *
+ * Available since API level 30.
+ */
+void ANativeWindow_tryAllocateBuffers(ANativeWindow* window);
+
#endif // __ANDROID_API__ >= 30
#ifdef __cplusplus
diff --git a/libs/nativewindow/libnativewindow.map.txt b/libs/nativewindow/libnativewindow.map.txt
index e0e20c3..154eb8e 100644
--- a/libs/nativewindow/libnativewindow.map.txt
+++ b/libs/nativewindow/libnativewindow.map.txt
@@ -17,7 +17,6 @@
ANativeWindow_OemStorageGet; # llndk
ANativeWindow_OemStorageSet; # llndk
ANativeWindow_acquire;
- ANativeWindow_allocateBuffers; # apex # introduced=30
ANativeWindow_cancelBuffer; # llndk
ANativeWindow_dequeueBuffer; # llndk
ANativeWindow_getBuffersDataSpace; # introduced=28
@@ -51,6 +50,7 @@
ANativeWindow_setSwapInterval; # llndk
ANativeWindow_setFrameRate; # introduced=30
ANativeWindow_setUsage; # llndk
+ ANativeWindow_tryAllocateBuffers; # introduced=30
ANativeWindow_unlockAndPost;
local:
*;