diff --git a/core/java/android/content/pm/ActivityInfo.java b/core/java/android/content/pm/ActivityInfo.java index 45d6ddd1dc215..0c4c0f0afda8b 100644 --- a/core/java/android/content/pm/ActivityInfo.java +++ b/core/java/android/content/pm/ActivityInfo.java @@ -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); } diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index c76245b34c0d4..a64784a1f6df5 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -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); diff --git a/libs/hwui/ColorMode.h b/libs/hwui/ColorMode.h index 6d387f9ef43d6..3df5c3c9caed4 100644 --- a/libs/hwui/ColorMode.h +++ b/libs/hwui/ColorMode.h @@ -29,6 +29,8 @@ enum class ColorMode { Hdr = 2, // HDR Rec2020 + 1010102 Hdr10 = 3, + // Alpha 8 + A8 = 4, }; } // namespace android::uirenderer diff --git a/libs/hwui/pipeline/skia/SkiaPipeline.cpp b/libs/hwui/pipeline/skia/SkiaPipeline.cpp index 4e7471d5d8884..bc386feb2d6f5 100644 --- a/libs/hwui/pipeline/skia/SkiaPipeline.cpp +++ b/libs/hwui/pipeline/skia/SkiaPipeline.cpp @@ -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; } }