Merge "Add extended range brightness APIs"

This commit is contained in:
John Reck
2023-02-14 19:55:01 +00:00
committed by Android (Google) Code Review
5 changed files with 43 additions and 13 deletions

View File

@@ -50085,6 +50085,7 @@ package android.view {
method public int getDisplayId();
method public int getFlags();
method public android.view.Display.HdrCapabilities getHdrCapabilities();
method public float getHdrSdrRatio();
method @Deprecated public int getHeight();
method @Deprecated public void getMetrics(android.util.DisplayMetrics);
method public android.view.Display.Mode getMode();
@@ -50106,9 +50107,12 @@ package android.view {
method @Deprecated public float[] getSupportedRefreshRates();
method @Deprecated public int getWidth();
method public boolean isHdr();
method public boolean isHdrSdrRatioAvailable();
method public boolean isMinimalPostProcessingSupported();
method public boolean isValid();
method public boolean isWideColorGamut();
method public void registerHdrSdrRatioChangedListener(@NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<android.view.Display>);
method public void unregisterHdrSdrRatioChangedListener(@NonNull java.util.function.Consumer<android.view.Display>);
field public static final int DEFAULT_DISPLAY = 0; // 0x0
field public static final int FLAG_PRESENTATION = 8; // 0x8
field public static final int FLAG_PRIVATE = 4; // 0x4
@@ -51637,6 +51641,7 @@ package android.view {
method @NonNull public android.view.SurfaceControl.Transaction setCrop(@NonNull android.view.SurfaceControl, @Nullable android.graphics.Rect);
method @NonNull public android.view.SurfaceControl.Transaction setDamageRegion(@NonNull android.view.SurfaceControl, @Nullable android.graphics.Region);
method @NonNull public android.view.SurfaceControl.Transaction setDataSpace(@NonNull android.view.SurfaceControl, int);
method @NonNull public android.view.SurfaceControl.Transaction setExtendedRangeBrightness(@NonNull android.view.SurfaceControl, float, float);
method @NonNull public android.view.SurfaceControl.Transaction setFrameRate(@NonNull android.view.SurfaceControl, @FloatRange(from=0.0) float, int);
method @NonNull public android.view.SurfaceControl.Transaction setFrameRate(@NonNull android.view.SurfaceControl, @FloatRange(from=0.0) float, int, int);
method @Deprecated @NonNull public android.view.SurfaceControl.Transaction setGeometry(@NonNull android.view.SurfaceControl, @Nullable android.graphics.Rect, @Nullable android.graphics.Rect, int);

View File

@@ -1298,8 +1298,6 @@ public final class Display {
/**
* @return Whether the display supports reporting an hdr/sdr ratio. If this is false,
* {@link #getHdrSdrRatio()} will always be 1.0f
* @hide
* TODO: make public
*/
public boolean isHdrSdrRatioAvailable() {
synchronized (mLock) {
@@ -1312,9 +1310,6 @@ public final class Display {
* @return The current hdr/sdr ratio expressed as the ratio of targetHdrPeakBrightnessInNits /
* targetSdrWhitePointInNits. If {@link #isHdrSdrRatioAvailable()} is false, this
* always returns 1.0f.
*
* @hide
* TODO: make public
*/
public float getHdrSdrRatio() {
synchronized (mLock) {
@@ -1344,8 +1339,6 @@ public final class Display {
* @param executor The executor to invoke the listener on
* @param listener The listener to invoke when the HDR/SDR ratio changes
* @throws IllegalStateException if {@link #isHdrSdrRatioAvailable()} is false
* @hide
* TODO: Make public
*/
public void registerHdrSdrRatioChangedListener(@NonNull Executor executor,
@NonNull Consumer<Display> listener) {
@@ -1375,10 +1368,8 @@ public final class Display {
* hdr/sdr ratio listener to remove.
*
* @see #registerHdrSdrRatioChangedListener(Executor, Consumer)
* @hide
* TODO: Make public
*/
public void unregisterHdrSdrRatioChangedListener(Consumer<Display> listener) {
public void unregisterHdrSdrRatioChangedListener(@NonNull Consumer<Display> listener) {
HdrSdrRatioListenerWrapper toRemove = null;
synchronized (mLock) {
int index = findHdrSdrRatioListenerLocked(listener);

View File

@@ -3836,7 +3836,7 @@ public final class SurfaceControl implements Parcelable {
* whose dataspace has RANGE_EXTENDED.
*
* @param sc The layer whose extended range brightness is being specified
* @param currentBufferRatio The current sdr/hdr ratio of the current buffer. For example
* @param currentBufferRatio The current hdr/sdr ratio of the current buffer. For example
* if the buffer was rendered with a target SDR whitepoint of
* 100 nits and a max display brightness of 200 nits, this should
* be set to 2.0f.
@@ -3848,7 +3848,9 @@ public final class SurfaceControl implements Parcelable {
* communicate extended content brightness information via
* metadata such as CTA861_3 or SMPTE2086.
*
* @param desiredRatio The desired sdr/hdr ratio. This can be used to communicate the max
* Must be finite && >= 1.0f
*
* @param desiredRatio The desired hdr/sdr ratio. This can be used to communicate the max
* desired brightness range. This is similar to the "max luminance"
* value in other HDR metadata formats, but represented as a ratio of
* the target SDR whitepoint to the max display brightness. The system
@@ -3860,12 +3862,19 @@ public final class SurfaceControl implements Parcelable {
* voluntarily reducing the requested range can help improve battery
* life as well as can improve quality by ensuring greater bit depth
* is allocated to the luminance range in use.
*
* Must be finite && >= 1.0f
* @return this
* @hide
**/
public @NonNull Transaction setExtendedRangeBrightness(@NonNull SurfaceControl sc,
float currentBufferRatio, float desiredRatio) {
checkPreconditions(sc);
if (!Float.isFinite(currentBufferRatio) || currentBufferRatio < 1.0f) {
throw new IllegalArgumentException("currentBufferRatio must be finite && >= 1.0f");
}
if (!Float.isFinite(desiredRatio) || desiredRatio < 1.0f) {
throw new IllegalArgumentException("desiredRatio must be finite && >= 1.0f");
}
nativeSetExtendedRangeBrightness(mNativeObject, sc.mNativeObject, currentBufferRatio,
desiredRatio);
return this;

View File

@@ -275,6 +275,7 @@ LIBANDROID {
ASurfaceTransaction_setGeometry; # introduced=29
ASurfaceTransaction_setHdrMetadata_cta861_3; # introduced=29
ASurfaceTransaction_setHdrMetadata_smpte2086; # introduced=29
ASurfaceTransaction_setExtendedRangeBrightness; # introduced=UpsideDownCake
ASurfaceTransaction_setOnComplete; # introduced=29
ASurfaceTransaction_setOnCommit; # introduced=31
ASurfaceTransaction_setPosition; # introduced=31

View File

@@ -621,6 +621,30 @@ void ASurfaceTransaction_setHdrMetadata_cta861_3(ASurfaceTransaction* aSurfaceTr
transaction->setHdrMetadata(surfaceControl, hdrMetadata);
}
void ASurfaceTransaction_setExtendedRangeBrightness(ASurfaceTransaction* aSurfaceTransaction,
ASurfaceControl* aSurfaceControl,
float currentBufferRatio, float desiredRatio) {
CHECK_NOT_NULL(aSurfaceTransaction);
CHECK_NOT_NULL(aSurfaceControl);
if (!isfinite(currentBufferRatio) || currentBufferRatio < 1.0f) {
ALOGE("Ignore setExtendedRangeBrightness, currentBufferRatio %f isn't finite or >= 1.0f",
currentBufferRatio);
return;
}
if (!isfinite(desiredRatio) || desiredRatio < 1.0f) {
ALOGE("Ignore setExtendedRangeBrightness, desiredRatio %f isn't finite or >= 1.0f",
desiredRatio);
return;
}
sp<SurfaceControl> surfaceControl = ASurfaceControl_to_SurfaceControl(aSurfaceControl);
Transaction* transaction = ASurfaceTransaction_to_Transaction(aSurfaceTransaction);
transaction->setExtendedRangeBrightness(surfaceControl, currentBufferRatio, desiredRatio);
}
void ASurfaceTransaction_setColor(ASurfaceTransaction* aSurfaceTransaction,
ASurfaceControl* aSurfaceControl,
float r, float g, float b, float alpha,