Merge "Add Display.getPreferredWideGamutColorSpace()."

This commit is contained in:
Peiyong Lin
2019-01-26 22:10:16 +00:00
committed by Android (Google) Code Review
5 changed files with 64 additions and 1 deletions

View File

@@ -20,6 +20,7 @@ import android.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.content.pm.ParceledListSlice;
import android.content.res.Resources;
import android.graphics.ColorSpace;
import android.graphics.Point;
import android.hardware.display.DisplayManager.DisplayListener;
import android.media.projection.IMediaProjection;
@@ -80,12 +81,20 @@ public final class DisplayManagerGlobal {
new ArrayList<DisplayListenerDelegate>();
private final SparseArray<DisplayInfo> mDisplayInfoCache = new SparseArray<DisplayInfo>();
private final ColorSpace mWideColorSpace;
private int[] mDisplayIdCache;
private int mWifiDisplayScanNestCount;
private DisplayManagerGlobal(IDisplayManager dm) {
mDm = dm;
try {
mWideColorSpace =
ColorSpace.get(
ColorSpace.Named.values()[mDm.getPreferredWideGamutColorSpaceId()]);
} catch (RemoteException ex) {
throw ex.rethrowFromSystemServer();
}
}
/**
@@ -494,6 +503,17 @@ public final class DisplayManagerGlobal {
}
}
/**
* Gets the preferred wide gamut color space for all displays.
* The wide gamut color space is returned from composition pipeline
* based on hardware capability.
*
* @hide
*/
public ColorSpace getPreferredWideGamutColorSpace() {
return mWideColorSpace;
}
/**
* Sets the global brightness configuration for a given user.
*

View File

@@ -116,4 +116,9 @@ interface IDisplayManager {
// Get the minimum brightness curve.
Curve getMinimumBrightnessCurve();
// Gets the id of the preferred wide gamut color space for all displays.
// The wide gamut color space is returned from composition pipeline
// based on hardware capability.
int getPreferredWideGamutColorSpaceId();
}

View File

@@ -26,6 +26,7 @@ import android.app.KeyguardManager;
import android.content.res.CompatibilityInfo;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.ColorSpace;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.graphics.Rect;
@@ -952,6 +953,24 @@ public final class Display {
}
}
/**
* Returns the preferred wide color space of the Display.
* The returned wide gamut color space is based on hardware capability and
* is preferred by the composition pipeline.
* Returns null if the display doesn't support wide color gamut.
* {@link Display#isWideColorGamut()}.
*/
@Nullable
public ColorSpace getPreferredWideGamutColorSpace() {
synchronized (this) {
updateDisplayInfoLocked();
if (mDisplayInfo.isWideColorGamut()) {
return mGlobal.getPreferredWideGamutColorSpace();
}
return null;
}
}
/**
* Gets the supported color modes of this device.
* @hide