Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cbdbb66d authored by Leon Scroggins III's avatar Leon Scroggins III
Browse files

Add COLOR_MODE_A8/ColorMode::A8

Currently unused. This will allow rending into A8 with HWUI

Bug: 193170859
Test: TODO
Change-Id: Ic1e1cb94dfa3dc08cbb174f0a38345d724570372
parent b0c9cf5c
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -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);
        }
+3 −2
Original line number Diff line number Diff line
@@ -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);
+2 −0
Original line number Diff line number Diff line
@@ -29,6 +29,8 @@ enum class ColorMode {
    Hdr = 2,
    // HDR Rec2020 + 1010102
    Hdr10 = 3,
    // Alpha 8
    A8 = 4,
};

} // namespace android::uirenderer
+4 −0
Original line number Diff line number Diff line
@@ -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;
    }
}