Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d9d8572a authored by Alec Mouri's avatar Alec Mouri
Browse files

[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
parent 612231d2
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -165,6 +165,14 @@ int32_t ANativeWindow_setFrameRate(ANativeWindow* window, float frameRate) {
    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 @@ int ANativeWindow_setQueueBufferInterceptor(ANativeWindow* window,
    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);
}
+11 −0
Original line number Diff line number Diff line
@@ -261,6 +261,17 @@ int32_t ANativeWindow_getBuffersDataSpace(ANativeWindow* window) __INTRODUCED_IN
 */
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
+1 −1
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@ LIBNATIVEWINDOW {
    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 @@ LIBNATIVEWINDOW {
    ANativeWindow_setSwapInterval; # llndk
    ANativeWindow_setFrameRate; # introduced=30
    ANativeWindow_setUsage; # llndk
    ANativeWindow_tryAllocateBuffers; # introduced=30
    ANativeWindow_unlockAndPost;
  local:
    *;