Loading libs/nativewindow/ANativeWindow.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -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); } libs/nativewindow/include/apex/window.h +8 −0 Original line number Diff line number Diff line Loading @@ -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 libs/nativewindow/libnativewindow.map.txt +1 −0 Original line number Diff line number Diff line Loading @@ -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 Loading libs/nativewindow/tests/ANativeWindowTest.cpp +35 −0 Original line number Diff line number Diff line Loading @@ -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 { Loading Loading @@ -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); } Loading
libs/nativewindow/ANativeWindow.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -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); }
libs/nativewindow/include/apex/window.h +8 −0 Original line number Diff line number Diff line Loading @@ -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
libs/nativewindow/libnativewindow.map.txt +1 −0 Original line number Diff line number Diff line Loading @@ -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 Loading
libs/nativewindow/tests/ANativeWindowTest.cpp +35 −0 Original line number Diff line number Diff line Loading @@ -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 { Loading Loading @@ -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); }