diff options
| author | Marin Shalamanov <shalamanov@google.com> | 2020-10-13 12:35:20 +0200 |
|---|---|---|
| committer | Marin Shalamanov <shalamanov@google.com> | 2020-11-17 11:53:14 +0100 |
| commit | 41ffa8dd060015434131a6d4c2d248effe899202 (patch) | |
| tree | f37baab45654b67d45a592b722f988402a7ca136 /core/java/android/view/Surface.java | |
| parent | 660f7cd8f10eeddc85ffd84be4376e7a3beb9d83 (diff) | |
Add shouldBeSeamless param to Surface.setFrameRate
This CL adds a new parameter shouldBeSeamless to the existing
setFrameRate APIs. This parameter indicates whether the desired
refresh rate should be achieved only seamlessly or also switches
with visual interruptions for the user are allowed. The default
value of the new parameter is "true".
Test: atest SetFrameRateTest
Test: atest RefreshRateConfigsTest
Test: atest libsurfaceflinger_unittest
Bug: 161776961
Change-Id: Ic2446d278e4f57fe507d30a0a18ef7b85909da4b
Diffstat (limited to 'core/java/android/view/Surface.java')
| -rw-r--r-- | core/java/android/view/Surface.java | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/core/java/android/view/Surface.java b/core/java/android/view/Surface.java index 5b79174a6cd8..a2777fe985d5 100644 --- a/core/java/android/view/Surface.java +++ b/core/java/android/view/Surface.java @@ -97,7 +97,7 @@ public class Surface implements Parcelable { private static native int nativeSetAutoRefreshEnabled(long nativeObject, boolean enabled); private static native int nativeSetFrameRate( - long nativeObject, float frameRate, int compatibility); + long nativeObject, float frameRate, int compatibility, boolean shouldBeSeamless); public static final @android.annotation.NonNull Parcelable.Creator<Surface> CREATOR = new Parcelable.Creator<Surface>() { @@ -915,13 +915,20 @@ public class Surface implements Parcelable { * compatibility value may influence the system's choice of display frame rate. See * the FRAME_RATE_COMPATIBILITY_* values for more info. * + * @param shouldBeSeamless Whether display refresh rate transitions should be seamless. A + * seamless transition is one that doesn't have any visual interruptions, such as a black + * screen for a second or two. True indicates that any frame rate changes caused by this + * request should be seamless. False indicates that non-seamless refresh rates are also + * acceptable. + * * @throws IllegalArgumentException If frameRate or compatibility are invalid. */ - public void setFrameRate( - @FloatRange(from = 0.0) float frameRate, @FrameRateCompatibility int compatibility) { + public void setFrameRate(@FloatRange(from = 0.0) float frameRate, + @FrameRateCompatibility int compatibility, boolean shouldBeSeamless) { synchronized (mLock) { checkNotReleasedLocked(); - int error = nativeSetFrameRate(mNativeObject, frameRate, compatibility); + int error = nativeSetFrameRate(mNativeObject, frameRate, compatibility, + shouldBeSeamless); if (error == -EINVAL) { throw new IllegalArgumentException("Invalid argument to Surface.setFrameRate()"); } else if (error != 0) { @@ -931,6 +938,17 @@ public class Surface implements Parcelable { } /** + * Sets the intended frame rate for this surface. Any switching of refresh rates is + * most probably going to be seamless. + * + * @see #setFrameRate(float, int, boolean) + */ + public void setFrameRate( + @FloatRange(from = 0.0) float frameRate, @FrameRateCompatibility int compatibility) { + setFrameRate(frameRate, compatibility, /* shouldBeSeamless = */ true); + } + + /** * Exception thrown when a Canvas couldn't be locked with {@link Surface#lockCanvas}, or * when a SurfaceTexture could not successfully be allocated. */ |
