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

Commit e0ff3779 authored by Peiyong Lin's avatar Peiyong Lin
Browse files

[EGL] Advertize DISPLAY_P3_PASSTHROUGH_EXT.

Make sure we advertize DISPLAY_P3_PASSTHROUGH_EXT extension, and add platform support.

BUG: b/111436479 b/117886297 b/120213877
Test: adb shell /data/nativetest/EGL_test/EGL_test
Change-Id: I9848a3502e6a3e416f70c7097c25b596d92aaf0a
parent 616aca2f
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -378,7 +378,8 @@ EGLBoolean egl_display_t::initialize(EGLint *major, EGLint *minor) {
        if (wideColorBoardConfig && hasColorSpaceSupport) {
            mExtensionString.append(
                    "EGL_EXT_gl_colorspace_scrgb EGL_EXT_gl_colorspace_scrgb_linear "
                    "EGL_EXT_gl_colorspace_display_p3_linear EGL_EXT_gl_colorspace_display_p3 ");
                    "EGL_EXT_gl_colorspace_display_p3_linear EGL_EXT_gl_colorspace_display_p3 "
                    "EGL_EXT_gl_colorspace_display_p3_passthrough ");
        }

        bool hasHdrBoardConfig =
+6 −0
Original line number Diff line number Diff line
@@ -466,6 +466,8 @@ static android_dataspace dataSpaceFromEGLColorSpace(EGLint colorspace) {
        return HAL_DATASPACE_DISPLAY_P3;
    } else if (colorspace == EGL_GL_COLORSPACE_DISPLAY_P3_LINEAR_EXT) {
        return HAL_DATASPACE_DISPLAY_P3_LINEAR;
    } else if (colorspace == EGL_GL_COLORSPACE_DISPLAY_P3_PASSTHROUGH_EXT) {
        return HAL_DATASPACE_DISPLAY_P3;
    } else if (colorspace == EGL_GL_COLORSPACE_SCRGB_EXT) {
        return HAL_DATASPACE_V0_SCRGB;
    } else if (colorspace == EGL_GL_COLORSPACE_SCRGB_LINEAR_EXT) {
@@ -510,6 +512,9 @@ static std::vector<EGLint> getDriverColorSpaces(egl_display_ptr dp) {
    if (findExtension(dp->disp.queryString.extensions, "EGL_EXT_gl_colorspace_display_p3_linear")) {
        colorSpaces.push_back(EGL_GL_COLORSPACE_DISPLAY_P3_LINEAR_EXT);
    }
    if (findExtension(dp->disp.queryString.extensions, "EGL_EXT_gl_colorspace_display_p3_passthrough")) {
        colorSpaces.push_back(EGL_GL_COLORSPACE_DISPLAY_P3_PASSTHROUGH_EXT);
    }
    return colorSpaces;
}

@@ -527,6 +532,7 @@ static EGLBoolean processAttributes(egl_display_ptr dp, ANativeWindow* window,
                case EGL_GL_COLORSPACE_LINEAR_KHR:
                case EGL_GL_COLORSPACE_SRGB_KHR:
                case EGL_GL_COLORSPACE_DISPLAY_P3_EXT:
                case EGL_GL_COLORSPACE_DISPLAY_P3_PASSTHROUGH_EXT:
                case EGL_GL_COLORSPACE_SCRGB_LINEAR_EXT:
                case EGL_GL_COLORSPACE_SCRGB_EXT:
                case EGL_GL_COLORSPACE_BT2020_LINEAR_EXT:
+55 −0
Original line number Diff line number Diff line
@@ -217,6 +217,7 @@ TEST_F(EGLTest, EGLDisplayP3) {
    // Test that display-p3 extensions exist
    ASSERT_TRUE(hasEglExtension(mEglDisplay, "EGL_EXT_gl_colorspace_display_p3"));
    ASSERT_TRUE(hasEglExtension(mEglDisplay, "EGL_EXT_gl_colorspace_display_p3_linear"));
    ASSERT_TRUE(hasEglExtension(mEglDisplay, "EGL_EXT_gl_colorspace_display_p3_passthrough"));

    // Use 8-bit to keep forcus on Display-P3 aspect
    EGLint attrs[] = {
@@ -289,6 +290,59 @@ TEST_F(EGLTest, EGLDisplayP3) {
    EXPECT_TRUE(eglDestroySurface(mEglDisplay, eglSurface));
}

TEST_F(EGLTest, EGLDisplayP3Passthrough) {
    EGLConfig config;
    EGLBoolean success;

    if (!hasWideColorDisplay) {
        // skip this test if device does not have wide-color display
        std::cerr << "[          ] Device does not support wide-color, test skipped" << std::endl;
        return;
    }

    // Test that display-p3 extensions exist
    ASSERT_TRUE(hasEglExtension(mEglDisplay, "EGL_EXT_gl_colorspace_display_p3"));
    ASSERT_TRUE(hasEglExtension(mEglDisplay, "EGL_EXT_gl_colorspace_display_p3_linear"));
    ASSERT_TRUE(hasEglExtension(mEglDisplay, "EGL_EXT_gl_colorspace_display_p3_passthrough"));

    get8BitConfig(config);

    struct DummyConsumer : public BnConsumerListener {
        void onFrameAvailable(const BufferItem& /* item */) override {}
        void onBuffersReleased() override {}
        void onSidebandStreamChanged() override {}
    };

    // Create a EGLSurface
    sp<IGraphicBufferProducer> producer;
    sp<IGraphicBufferConsumer> consumer;
    BufferQueue::createBufferQueue(&producer, &consumer);
    consumer->consumerConnect(new DummyConsumer, false);
    sp<Surface> mSTC = new Surface(producer);
    sp<ANativeWindow> mANW = mSTC;
    EGLint winAttrs[] = {
            // clang-format off
            EGL_GL_COLORSPACE_KHR, EGL_GL_COLORSPACE_DISPLAY_P3_PASSTHROUGH_EXT,
            EGL_NONE,              EGL_NONE
            // clang-format on
    };

    EGLSurface eglSurface = eglCreateWindowSurface(mEglDisplay, config, mANW.get(), winAttrs);
    ASSERT_EQ(EGL_SUCCESS, eglGetError());
    ASSERT_NE(EGL_NO_SURFACE, eglSurface);

    android_dataspace dataspace =
        static_cast<android_dataspace>(ANativeWindow_getBuffersDataSpace(mANW.get()));
    ASSERT_EQ(dataspace, HAL_DATASPACE_DISPLAY_P3);

    EGLint value;
    success = eglQuerySurface(mEglDisplay, eglSurface, EGL_GL_COLORSPACE_KHR, &value);
    ASSERT_EQ(EGL_UNSIGNED_TRUE, success);
    ASSERT_EQ(EGL_GL_COLORSPACE_DISPLAY_P3_PASSTHROUGH_EXT, value);

    EXPECT_TRUE(eglDestroySurface(mEglDisplay, eglSurface));
}

TEST_F(EGLTest, EGLDisplayP31010102) {
    EGLint numConfigs;
    EGLConfig config;
@@ -303,6 +357,7 @@ TEST_F(EGLTest, EGLDisplayP31010102) {
    // Test that display-p3 extensions exist
    ASSERT_TRUE(hasEglExtension(mEglDisplay, "EGL_EXT_gl_colorspace_display_p3"));
    ASSERT_TRUE(hasEglExtension(mEglDisplay, "EGL_EXT_gl_colorspace_display_p3_linear"));
    ASSERT_TRUE(hasEglExtension(mEglDisplay, "EGL_EXT_gl_colorspace_display_p3_passthrough"));

    // Use 8-bit to keep forcus on Display-P3 aspect
    EGLint attrs[] = {
+2 −0
Original line number Diff line number Diff line
@@ -280,6 +280,8 @@ String8 EGLUtils::decodeColorSpace(EGLint colorSpace) {
            return String8("EGL_GL_COLORSPACE_SRGB_KHR");
        case EGL_GL_COLORSPACE_DISPLAY_P3_EXT:
            return String8("EGL_GL_COLORSPACE_DISPLAY_P3_EXT");
        case EGL_GL_COLORSPACE_DISPLAY_P3_PASSTHROUGH_EXT:
            return String8("EGL_GL_COLORSPACE_DISPLAY_P3_PASSTHROUGH_EXT");
        case  EGL_GL_COLORSPACE_LINEAR_KHR:
            return String8("EGL_GL_COLORSPACE_LINEAR_KHR");
        default:
+12 −2
Original line number Diff line number Diff line
@@ -894,6 +894,11 @@
            <unused start="0x3481" end="0x348F"/>
    </enums>

    <enums namespace="EGL" start="0x3490" end="0x349F" vendor="EXT" comment="Reserved for Courtney Goeltzenleuchter - Android (gitlab EGL bug 69)">
        <enum value="0x3490" name="EGL_GL_COLORSPACE_DISPLAY_P3_PASSTHROUGH_EXT"/>
            <unused start="0x3491" end="0x349F"/>
    </enums>

<!-- Please remember that new enumerant allocations must be obtained by
     request to the Khronos API registrar (see comments at the top of this
     file) File requests in the Khronos Bugzilla, EGL project, Registry
@@ -903,8 +908,8 @@

<!-- Reservable for future use. To generate a new range, allocate multiples
     of 16 starting at the lowest available point in this block. -->
    <enums namespace="EGL" start="0x3490" end="0x3FFF" vendor="KHR" comment="Reserved for future use">
            <unused start="0x3490" end="0x3FFF"/>
    <enums namespace="EGL" start="0x34A0" end="0x3FFF" vendor="KHR" comment="Reserved for future use">
            <unused start="0x34A0" end="0x3FFF"/>
    </enums>

    <enums namespace="EGL" start="0x8F70" end="0x8F7F" vendor="HI" comment="For Mark Callow, Khronos bug 4055. Shared with GL.">
@@ -2250,6 +2255,11 @@
                <enum name="EGL_GL_COLORSPACE_DISPLAY_P3_EXT"/>
            </require>
        </extension>
        <extension name="EGL_EXT_gl_colorspace_display_p3_passthrough" supported="egl">
            <require>
                <enum name="EGL_GL_COLORSPACE_DISPLAY_P3_PASSTHROUGH_EXT"/>
            </require>
        </extension>
        <extension name="EGL_EXT_image_dma_buf_import" supported="egl">
            <require>
                <enum name="EGL_LINUX_DMA_BUF_EXT"/>