From 5b5d4e11949ae5fbd370927e721480f91c079857 Mon Sep 17 00:00:00 2001 From: Jiwen 'Steve' Cai Date: Wed, 30 Aug 2017 11:26:20 -0700 Subject: [PATCH] Rename WriteBufferQueueGetExternalSurface: Step 1 Add new API WriteBufferQueueGetANativeWindow and forward all calls to the old one with a warning. Bug: 65133502 Test: dvr_api-test Change-Id: I6787bc5d341f7e36a8a35102a5ce651c3aa296f8 --- libs/vr/libdvr/dvr_buffer_queue.cpp | 8 ++++++++ libs/vr/libdvr/include/dvr/dvr_api.h | 2 ++ libs/vr/libdvr/include/dvr/dvr_api_entries.h | 5 ++++- libs/vr/libdvr/include/dvr/dvr_buffer_queue.h | 4 ++++ libs/vr/libdvr/tests/dvr_buffer_queue-test.cpp | 6 +++--- 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/libs/vr/libdvr/dvr_buffer_queue.cpp b/libs/vr/libdvr/dvr_buffer_queue.cpp index e4e20f9700..4adb5d2da1 100644 --- a/libs/vr/libdvr/dvr_buffer_queue.cpp +++ b/libs/vr/libdvr/dvr_buffer_queue.cpp @@ -208,6 +208,14 @@ int dvrWriteBufferQueueGetId(DvrWriteBufferQueue* write_queue) { int dvrWriteBufferQueueGetExternalSurface(DvrWriteBufferQueue* write_queue, ANativeWindow** out_window) { + ALOGW( + "dvrWriteBufferQueueGetExternalSurface: This API has been deprecated and " + "renamed to dvrWriteBufferQueueGetANativeWindow."); + return dvrWriteBufferQueueGetANativeWindow(write_queue, out_window); +} + +int dvrWriteBufferQueueGetANativeWindow(DvrWriteBufferQueue* write_queue, + ANativeWindow** out_window) { if (!write_queue || !out_window) return -EINVAL; diff --git a/libs/vr/libdvr/include/dvr/dvr_api.h b/libs/vr/libdvr/include/dvr/dvr_api.h index 451d037352..e1dc58c2e2 100644 --- a/libs/vr/libdvr/include/dvr/dvr_api.h +++ b/libs/vr/libdvr/include/dvr/dvr_api.h @@ -171,6 +171,8 @@ typedef ssize_t (*DvrWriteBufferQueueGetCapacityPtr)( typedef int (*DvrWriteBufferQueueGetIdPtr)(DvrWriteBufferQueue* write_queue); typedef int (*DvrWriteBufferQueueGetExternalSurfacePtr)( DvrWriteBufferQueue* write_queue, ANativeWindow** out_window); +typedef int (*DvrWriteBufferQueueGetANativeWindowPtr)( + DvrWriteBufferQueue* write_queue, ANativeWindow** out_window); typedef int (*DvrWriteBufferQueueCreateReadQueuePtr)( DvrWriteBufferQueue* write_queue, DvrReadBufferQueue** out_read_queue); typedef int (*DvrWriteBufferQueueDequeuePtr)(DvrWriteBufferQueue* write_queue, diff --git a/libs/vr/libdvr/include/dvr/dvr_api_entries.h b/libs/vr/libdvr/include/dvr/dvr_api_entries.h index da12c13065..f65bd1c919 100644 --- a/libs/vr/libdvr/include/dvr/dvr_api_entries.h +++ b/libs/vr/libdvr/include/dvr/dvr_api_entries.h @@ -65,7 +65,7 @@ DVR_V1_API_ENTRY(BufferGlobalLayoutVersionGet); DVR_V1_API_ENTRY(WriteBufferQueueDestroy); DVR_V1_API_ENTRY(WriteBufferQueueGetCapacity); DVR_V1_API_ENTRY(WriteBufferQueueGetId); -DVR_V1_API_ENTRY(WriteBufferQueueGetExternalSurface); +DVR_V1_API_ENTRY(WriteBufferQueueGetExternalSurface); // deprecated DVR_V1_API_ENTRY(WriteBufferQueueCreateReadQueue); DVR_V1_API_ENTRY(WriteBufferQueueDequeue); DVR_V1_API_ENTRY(WriteBufferQueueResizeBuffer); @@ -163,3 +163,6 @@ DVR_V1_API_ENTRY(ReadBufferQueueGetEventFd); // Create write buffer queue locally DVR_V1_API_ENTRY(WriteBufferQueueCreate); + +// Gets an ANativeWindow from DvrWriteBufferQueue. +DVR_V1_API_ENTRY(WriteBufferQueueGetANativeWindow); diff --git a/libs/vr/libdvr/include/dvr/dvr_buffer_queue.h b/libs/vr/libdvr/include/dvr/dvr_buffer_queue.h index b3b41e2373..8b9e0482d9 100644 --- a/libs/vr/libdvr/include/dvr/dvr_buffer_queue.h +++ b/libs/vr/libdvr/include/dvr/dvr_buffer_queue.h @@ -73,6 +73,10 @@ int dvrWriteBufferQueueGetId(DvrWriteBufferQueue* write_queue); // the method call succeeds. // @return Zero on success; or -EINVAL if this DvrWriteBufferQueue does not // support being used as an android Surface. +int dvrWriteBufferQueueGetANativeWindow(DvrWriteBufferQueue* write_queue, + ANativeWindow** out_window); + +// @deprecated Please use dvrWriteBufferQueueGetANativeWindow instead. int dvrWriteBufferQueueGetExternalSurface(DvrWriteBufferQueue* write_queue, ANativeWindow** out_window); diff --git a/libs/vr/libdvr/tests/dvr_buffer_queue-test.cpp b/libs/vr/libdvr/tests/dvr_buffer_queue-test.cpp index 7520eee70e..0b30c3869a 100644 --- a/libs/vr/libdvr/tests/dvr_buffer_queue-test.cpp +++ b/libs/vr/libdvr/tests/dvr_buffer_queue-test.cpp @@ -232,7 +232,7 @@ TEST_F(DvrBufferQueueTest, TestDequeuePostDequeueRelease) { dvrReadBufferQueueDestroy(read_queue); } -TEST_F(DvrBufferQueueTest, TestGetExternalSurface) { +TEST_F(DvrBufferQueueTest, TestGetANativeWindow) { int ret = dvrWriteBufferQueueCreate( kBufferWidth, kBufferHeight, kBufferFormat, kLayerCount, kBufferUsage, /*capacity=*/0, sizeof(TestMeta), &write_queue_); @@ -242,7 +242,7 @@ TEST_F(DvrBufferQueueTest, TestGetExternalSurface) { // The |write_queue_| doesn't have proper metadata (must be // DvrNativeBufferMetadata) configured during creation. - ret = dvrWriteBufferQueueGetExternalSurface(write_queue_, &window); + ret = dvrWriteBufferQueueGetANativeWindow(write_queue_, &window); ASSERT_EQ(-EINVAL, ret); ASSERT_EQ(nullptr, window); dvrWriteBufferQueueDestroy(write_queue_); @@ -257,7 +257,7 @@ TEST_F(DvrBufferQueueTest, TestGetExternalSurface) { ASSERT_EQ(0, ret); ASSERT_NE(nullptr, write_queue_); - ret = dvrWriteBufferQueueGetExternalSurface(write_queue_, &window); + ret = dvrWriteBufferQueueGetANativeWindow(write_queue_, &window); ASSERT_EQ(0, ret); ASSERT_NE(nullptr, window); -- 2.11.0