diff options
author | 2019-08-14 10:53:50 -0700 | |
---|---|---|
committer | 2019-09-06 11:36:14 -0700 | |
commit | 0d1398b2da8aee028c52a90be6d3b75b4f12b9d6 (patch) | |
tree | 4b573dc1557b9de88d595bdc81048066cae65297 | |
parent | 4ab80de6ba40c4668956b60c8d8e28bbb6ebbdc9 (diff) |
[ANativeWindow] Add apex header for getLastQueueDuration
Bug: 137012798
Test: libnativewindow_test
Change-Id: I46d5ab9c11161923ebbbc67400b10b2e7c0c6b61
-rw-r--r-- | libs/nativewindow/ANativeWindow.cpp | 4 | ||||
-rw-r--r-- | libs/nativewindow/include/apex/window.h | 8 | ||||
-rw-r--r-- | libs/nativewindow/libnativewindow.map.txt | 1 | ||||
-rw-r--r-- | libs/nativewindow/tests/ANativeWindowTest.cpp | 35 |
4 files changed, 48 insertions, 0 deletions
diff --git a/libs/nativewindow/ANativeWindow.cpp b/libs/nativewindow/ANativeWindow.cpp index 4c59e6ce98..5c91d587bc 100644 --- a/libs/nativewindow/ANativeWindow.cpp +++ b/libs/nativewindow/ANativeWindow.cpp @@ -274,3 +274,7 @@ int ANativeWindow_setAutoPrerotation(ANativeWindow* window, bool autoPrerotation int ANativeWindow_getLastDequeueDuration(ANativeWindow* window) { return query(window, NATIVE_WINDOW_LAST_DEQUEUE_DURATION); } + +int ANativeWindow_getLastQueueDuration(ANativeWindow* window) { + return query(window, NATIVE_WINDOW_LAST_QUEUE_DURATION); +} diff --git a/libs/nativewindow/include/apex/window.h b/libs/nativewindow/include/apex/window.h index 0260cbcfb4..82ff50d2d5 100644 --- a/libs/nativewindow/include/apex/window.h +++ b/libs/nativewindow/include/apex/window.h @@ -31,4 +31,12 @@ __BEGIN_DECLS */ int ANativeWindow_getLastDequeueDuration(ANativeWindow* window); +/** + * Retrieves how long it took for the last time a buffer was queued. + * + * \return a negative value on error, otherwise returns the duration in + * microseconds + */ +int ANativeWindow_getLastQueueDuration(ANativeWindow* window); + __END_DECLS diff --git a/libs/nativewindow/libnativewindow.map.txt b/libs/nativewindow/libnativewindow.map.txt index 7fe4df0606..b8b45ae62b 100644 --- a/libs/nativewindow/libnativewindow.map.txt +++ b/libs/nativewindow/libnativewindow.map.txt @@ -23,6 +23,7 @@ LIBNATIVEWINDOW { ANativeWindow_getFormat; ANativeWindow_getHeight; ANativeWindow_getLastDequeueDuration; # apex # introduced=30 + ANativeWindow_getLastQueueDuration; # apex # introduced=30 ANativeWindow_getWidth; ANativeWindow_lock; ANativeWindow_query; # vndk diff --git a/libs/nativewindow/tests/ANativeWindowTest.cpp b/libs/nativewindow/tests/ANativeWindowTest.cpp index 5247e04c32..9b358da4b5 100644 --- a/libs/nativewindow/tests/ANativeWindowTest.cpp +++ b/libs/nativewindow/tests/ANativeWindowTest.cpp @@ -36,6 +36,9 @@ public: // Exposes the internal last dequeue duration that's stored on the Surface. nsecs_t getLastDequeueDuration() const { return mLastDequeueDuration; } + + // Exposes the internal last queue duration that's stored on the Surface. + nsecs_t getLastQueueDuration() const { return mLastQueueDuration; } }; class ANativeWindowTest : public ::testing::Test { @@ -82,3 +85,35 @@ TEST_F(ANativeWindowTest, getLastDequeueDuration_withDequeue_returnsTime) { EXPECT_GT(result, 0); EXPECT_EQ(result, mWindow->getLastDequeueDuration() / 1000); } + +TEST_F(ANativeWindowTest, getLastQueueDuration_noDequeue_returnsZero) { + int result = ANativeWindow_getLastQueueDuration(mWindow.get()); + EXPECT_EQ(0, result); + EXPECT_EQ(0, mWindow->getLastQueueDuration()); +} + +TEST_F(ANativeWindowTest, getLastQueueDuration_noQueue_returnsZero) { + ANativeWindowBuffer* buffer; + int fd; + int result = ANativeWindow_dequeueBuffer(mWindow.get(), &buffer, &fd); + close(fd); + EXPECT_EQ(0, result); + + result = ANativeWindow_getLastQueueDuration(mWindow.get()); + EXPECT_EQ(result, 0); + EXPECT_EQ(result, mWindow->getLastQueueDuration()); +} + +TEST_F(ANativeWindowTest, getLastQueueDuration_withQueue_returnsTime) { + ANativeWindowBuffer* buffer; + int fd; + int result = ANativeWindow_dequeueBuffer(mWindow.get(), &buffer, &fd); + close(fd); + EXPECT_EQ(0, result); + + result = ANativeWindow_queueBuffer(mWindow.get(), buffer, 0); + + result = ANativeWindow_getLastQueueDuration(mWindow.get()); + EXPECT_GT(result, 0); + EXPECT_EQ(result, mWindow->getLastQueueDuration() / 1000); +} |