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

Commit 52d4595e authored by John Reck's avatar John Reck
Browse files

Support HDR in skiagl

Fixes: 276807477
Bug: 276385232
Test: setprop debug.hwui.renderer skiagl && silkfx
Change-Id: I173ca5ee3a28b274ffd33f11d67fbee73ce1ff20
parent 0c02452b
Loading
Loading
Loading
Loading
+0 −1
Original line number Original line Diff line number Diff line
@@ -53,7 +53,6 @@ public:
    void onStop() override;
    void onStop() override;
    bool isSurfaceReady() override;
    bool isSurfaceReady() override;
    bool isContextReady() override;
    bool isContextReady() override;
    bool supportsExtendedRangeHdr() const override { return true; }
    void setTargetSdrHdrRatio(float ratio) override;
    void setTargetSdrHdrRatio(float ratio) override;


    static void invokeFunctor(const renderthread::RenderThread& thread, Functor* functor);
    static void invokeFunctor(const renderthread::RenderThread& thread, Functor* functor);
+0 −5
Original line number Original line Diff line number Diff line
@@ -236,7 +236,6 @@ void CanvasContext::setupPipelineSurface() {


    if (mNativeSurface && !mNativeSurface->didSetExtraBuffers()) {
    if (mNativeSurface && !mNativeSurface->didSetExtraBuffers()) {
        setBufferCount(mNativeSurface->getNativeWindow());
        setBufferCount(mNativeSurface->getNativeWindow());

    }
    }


    mFrameNumber = 0;
    mFrameNumber = 0;
@@ -301,10 +300,6 @@ void CanvasContext::setOpaque(bool opaque) {


float CanvasContext::setColorMode(ColorMode mode) {
float CanvasContext::setColorMode(ColorMode mode) {
    if (mode != mColorMode) {
    if (mode != mColorMode) {
        const bool isHdr = mode == ColorMode::Hdr || mode == ColorMode::Hdr10;
        if (isHdr && !mRenderPipeline->supportsExtendedRangeHdr()) {
            mode = ColorMode::WideColorGamut;
        }
        mColorMode = mode;
        mColorMode = mode;
        mRenderPipeline->setSurfaceColorProperties(mode);
        mRenderPipeline->setSurfaceColorProperties(mode);
        setupPipelineSurface();
        setupPipelineSurface();
+16 −4
Original line number Original line Diff line number Diff line
@@ -423,6 +423,7 @@ Result<EGLSurface, EGLint> EglManager::createSurface(EGLNativeWindowType window,
    EGLint attribs[] = {EGL_NONE, EGL_NONE, EGL_NONE};
    EGLint attribs[] = {EGL_NONE, EGL_NONE, EGL_NONE};


    EGLConfig config = mEglConfig;
    EGLConfig config = mEglConfig;
    bool overrideWindowDataSpaceForHdr = false;
    if (colorMode == ColorMode::A8) {
    if (colorMode == ColorMode::A8) {
        // A8 doesn't use a color space
        // A8 doesn't use a color space
        if (!mEglConfigA8) {
        if (!mEglConfigA8) {
@@ -450,12 +451,13 @@ Result<EGLSurface, EGLint> EglManager::createSurface(EGLNativeWindowType window,
                case ColorMode::Default:
                case ColorMode::Default:
                    attribs[1] = EGL_GL_COLORSPACE_LINEAR_KHR;
                    attribs[1] = EGL_GL_COLORSPACE_LINEAR_KHR;
                    break;
                    break;
                // Extended Range HDR requires being able to manipulate the dataspace in ways
                // We don't have an EGL colorspace for extended range P3 that's used for HDR
                // we cannot easily do while going through EGLSurface. Given this requires
                // So override it after configuring the EGL context
                // composer3 support, just treat HDR as equivalent to wide color gamut if
                // the GLES path is still being hit
                case ColorMode::Hdr:
                case ColorMode::Hdr:
                case ColorMode::Hdr10:
                case ColorMode::Hdr10:
                    overrideWindowDataSpaceForHdr = true;
                    attribs[1] = EGL_GL_COLORSPACE_DISPLAY_P3_PASSTHROUGH_EXT;
                    break;
                case ColorMode::WideColorGamut: {
                case ColorMode::WideColorGamut: {
                    skcms_Matrix3x3 colorGamut;
                    skcms_Matrix3x3 colorGamut;
                    LOG_ALWAYS_FATAL_IF(!colorSpace->toXYZD50(&colorGamut),
                    LOG_ALWAYS_FATAL_IF(!colorSpace->toXYZD50(&colorGamut),
@@ -491,6 +493,16 @@ Result<EGLSurface, EGLint> EglManager::createSurface(EGLNativeWindowType window,
                            (void*)window, eglErrorString());
                            (void*)window, eglErrorString());
    }
    }


    if (overrideWindowDataSpaceForHdr) {
        // This relies on knowing that EGL will not re-set the dataspace after the call to
        // eglCreateWindowSurface. Since the handling of the colorspace extension is largely
        // implemented in libEGL in the platform, we can safely assume this is the case
        int32_t err = ANativeWindow_setBuffersDataSpace(
                window,
                static_cast<android_dataspace>(STANDARD_DCI_P3 | TRANSFER_SRGB | RANGE_EXTENDED));
        LOG_ALWAYS_FATAL_IF(err, "Failed to ANativeWindow_setBuffersDataSpace %d", err);
    }

    return surface;
    return surface;
}
}


+0 −1
Original line number Original line Diff line number Diff line
@@ -95,7 +95,6 @@ public:
    virtual void setPictureCapturedCallback(
    virtual void setPictureCapturedCallback(
            const std::function<void(sk_sp<SkPicture>&&)>& callback) = 0;
            const std::function<void(sk_sp<SkPicture>&&)>& callback) = 0;


    virtual bool supportsExtendedRangeHdr() const { return false; }
    virtual void setTargetSdrHdrRatio(float ratio) = 0;
    virtual void setTargetSdrHdrRatio(float ratio) = 0;


    virtual ~IRenderPipeline() {}
    virtual ~IRenderPipeline() {}