Merge "Prevent hdrSdrRatio from being <1.f" into udc-dev

This commit is contained in:
John Reck
2023-03-21 19:32:59 +00:00
committed by Android (Google) Code Review
2 changed files with 6 additions and 3 deletions

View File

@@ -3896,10 +3896,12 @@ public final class SurfaceControl implements Parcelable {
float currentBufferRatio, float desiredRatio) {
checkPreconditions(sc);
if (!Float.isFinite(currentBufferRatio) || currentBufferRatio < 1.0f) {
throw new IllegalArgumentException("currentBufferRatio must be finite && >= 1.0f");
throw new IllegalArgumentException(
"currentBufferRatio must be finite && >= 1.0f; got " + currentBufferRatio);
}
if (!Float.isFinite(desiredRatio) || desiredRatio < 1.0f) {
throw new IllegalArgumentException("desiredRatio must be finite && >= 1.0f");
throw new IllegalArgumentException(
"desiredRatio must be finite && >= 1.0f; got " + desiredRatio);
}
nativeSetExtendedRangeBrightness(mNativeObject, sc.mNativeObject, currentBufferRatio,
desiredRatio);

View File

@@ -911,7 +911,8 @@ final class LocalDisplayAdapter extends DisplayAdapter {
final float newHdrSdrRatio;
if (displayNits != DisplayDeviceConfig.NITS_INVALID
&& sdrNits != DisplayDeviceConfig.NITS_INVALID) {
newHdrSdrRatio = displayNits / sdrNits;
// Ensure the ratio stays >= 1.0f as values below that are nonsensical
newHdrSdrRatio = Math.max(1.f, displayNits / sdrNits);
} else {
newHdrSdrRatio = Float.NaN;
}