Add COLOR_MODE_A8/ColorMode::A8

Currently unused. This will allow rending into A8 with HWUI

Bug: 193170859
Test: TODO
Change-Id: Ic1e1cb94dfa3dc08cbb174f0a38345d724570372
This commit is contained in:
Leon Scroggins III
2021-11-30 13:59:00 -05:00
parent b0c9cf5cfc
commit cbdbb66d8f
4 changed files with 22 additions and 2 deletions

View File

@@ -304,12 +304,23 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
* @see android.R.attr#colorMode
*/
public static final int COLOR_MODE_HDR = 2;
// 3 Corresponds to android::uirenderer::ColorMode::Hdr10.
/**
* Value of {@link #colorMode} indicating that the activity should use an
* 8 bit alpha buffer if the presentation display supports it.
*
* @see android.R.attr#colorMode
* @hide
*/
public static final int COLOR_MODE_A8 = 4;
/** @hide */
@IntDef(prefix = { "COLOR_MODE_" }, value = {
COLOR_MODE_DEFAULT,
COLOR_MODE_WIDE_COLOR_GAMUT,
COLOR_MODE_HDR,
COLOR_MODE_A8,
})
@Retention(RetentionPolicy.SOURCE)
public @interface ColorMode {}
@@ -1682,6 +1693,8 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
return "COLOR_MODE_WIDE_COLOR_GAMUT";
case COLOR_MODE_HDR:
return "COLOR_MODE_HDR";
case COLOR_MODE_A8:
return "COLOR_MODE_A8";
default:
return Integer.toString(colorMode);
}

View File

@@ -4916,13 +4916,14 @@ public final class ViewRootImpl implements ViewParent,
}
}
private void updateColorModeIfNeeded(int colorMode) {
private void updateColorModeIfNeeded(@ActivityInfo.ColorMode int colorMode) {
if (mAttachInfo.mThreadedRenderer == null) {
return;
}
// TODO: Centralize this sanitization? Why do we let setting bad modes?
// Alternatively, can we just let HWUI figure it out? Do we need to care here?
if (!getConfiguration().isScreenWideColorGamut()) {
if (colorMode != ActivityInfo.COLOR_MODE_A8
&& !getConfiguration().isScreenWideColorGamut()) {
colorMode = ActivityInfo.COLOR_MODE_DEFAULT;
}
mAttachInfo.mThreadedRenderer.setColorMode(colorMode);

View File

@@ -29,6 +29,8 @@ enum class ColorMode {
Hdr = 2,
// HDR Rec2020 + 1010102
Hdr10 = 3,
// Alpha 8
A8 = 4,
};
} // namespace android::uirenderer

View File

@@ -613,6 +613,10 @@ void SkiaPipeline::setSurfaceColorProperties(ColorMode colorMode) {
mSurfaceColorType = SkColorType::kRGBA_1010102_SkColorType;
mSurfaceColorSpace = SkColorSpace::MakeRGB(GetPQSkTransferFunction(), SkNamedGamut::kRec2020);
break;
case ColorMode::A8:
mSurfaceColorType = SkColorType::kAlpha_8_SkColorType;
mSurfaceColorSpace = nullptr;
break;
}
}