Add clearFrameRate API in ndk
This API is same as using setFrameRate with 0 as frame-rate value. But
this causes confusion, as the remaining two arguments are ignored, when
frame-rate is 0.
Bug: 241096917
Test: android.graphics.cts.SetFrameRateTest#testClearFrameRate
Change-Id: I469e41cc1a15abf4c0b402caca12a9f6db4cdb71
diff --git a/libs/nativewindow/ANativeWindow.cpp b/libs/nativewindow/ANativeWindow.cpp
index 731f989..b075080 100644
--- a/libs/nativewindow/ANativeWindow.cpp
+++ b/libs/nativewindow/ANativeWindow.cpp
@@ -220,6 +220,15 @@
return native_window_set_frame_rate(window, frameRate, compatibility, changeFrameRateStrategy);
}
+int32_t ANativeWindow_clearFrameRate(ANativeWindow* window) {
+ if (!window || !query(window, NATIVE_WINDOW_IS_VALID)) {
+ return -EINVAL;
+ }
+ return native_window_set_frame_rate(window, 0,
+ ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT,
+ ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS);
+}
+
/**************************************************************************************************
* vndk-stable
**************************************************************************************************/