diff options
author | Steven Thomas <steventhomas@google.com> | 2020-01-14 11:37:21 -0800 |
---|---|---|
committer | Steven Thomas <steventhomas@google.com> | 2020-01-22 13:20:42 -0800 |
commit | 6cf051ef8909be67f3fa7d6212a510d58e63df35 (patch) | |
tree | 88aaca85cde72c9ea9b59f010eb0089961b6dc23 /native/android/surface_control.cpp | |
parent | 9f22c5356fe23446875a882295db00403e034aba (diff) |
Add setFrameRate() api
setFrameRate() is a new api in Android 11 that will enable apps to
specify their intended frame rate.
Bug: 143912624
Bug: 137287430
Test: Added a new CTS test - android.graphics.cts.SetFrameRateTest.
Change-Id: I922573c0d704e2e0ce4cfc2a462f14dce8cb7a79
Diffstat (limited to 'native/android/surface_control.cpp')
-rw-r--r-- | native/android/surface_control.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/native/android/surface_control.cpp b/native/android/surface_control.cpp index b34b31ac8439..392c9f6404ba 100644 --- a/native/android/surface_control.cpp +++ b/native/android/surface_control.cpp @@ -545,3 +545,18 @@ void ASurfaceTransaction_setColor(ASurfaceTransaction* aSurfaceTransaction, transaction->setBackgroundColor(surfaceControl, color, alpha, static_cast<ui::Dataspace>(dataspace)); } + +void ASurfaceTransaction_setFrameRate(ASurfaceTransaction* aSurfaceTransaction, + ASurfaceControl* aSurfaceControl, float frameRate) { + CHECK_NOT_NULL(aSurfaceTransaction); + CHECK_NOT_NULL(aSurfaceControl); + + sp<SurfaceControl> surfaceControl = ASurfaceControl_to_SurfaceControl(aSurfaceControl); + if (frameRate < 0) { + ALOGE("Failed to set frame ate - invalid frame rate"); + return; + } + + Transaction* transaction = ASurfaceTransaction_to_Transaction(aSurfaceTransaction); + transaction->setFrameRate(surfaceControl, frameRate); +} |