diff options
author | 2023-04-06 16:57:49 +0000 | |
---|---|---|
committer | 2023-04-06 16:57:49 +0000 | |
commit | adddf618845c5a6ea705d7c3f3d3e9cdd510105a (patch) | |
tree | ac8912b767ea28c014da803bce86be24d59d272d | |
parent | 138683c165c22976ad1f039ffbe158e85d33771a (diff) | |
parent | 52d4595ed7470b676077aaf469c3ff131f369bf0 (diff) |
Merge "Support HDR in skiagl" into udc-dev
-rw-r--r-- | libs/hwui/pipeline/skia/SkiaVulkanPipeline.h | 1 | ||||
-rw-r--r-- | libs/hwui/renderthread/CanvasContext.cpp | 5 | ||||
-rw-r--r-- | libs/hwui/renderthread/EglManager.cpp | 20 | ||||
-rw-r--r-- | libs/hwui/renderthread/IRenderPipeline.h | 1 |
4 files changed, 16 insertions, 11 deletions
diff --git a/libs/hwui/pipeline/skia/SkiaVulkanPipeline.h b/libs/hwui/pipeline/skia/SkiaVulkanPipeline.h index 01a93c7218d9..cce5468e68f0 100644 --- a/libs/hwui/pipeline/skia/SkiaVulkanPipeline.h +++ b/libs/hwui/pipeline/skia/SkiaVulkanPipeline.h @@ -53,7 +53,6 @@ public: void onStop() override; bool isSurfaceReady() override; bool isContextReady() override; - bool supportsExtendedRangeHdr() const override { return true; } void setTargetSdrHdrRatio(float ratio) override; const SkM44& getPixelSnapMatrix() const override; diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp index 1b9d41a73f46..f60c1f3c6ad8 100644 --- a/libs/hwui/renderthread/CanvasContext.cpp +++ b/libs/hwui/renderthread/CanvasContext.cpp @@ -236,7 +236,6 @@ void CanvasContext::setupPipelineSurface() { if (mNativeSurface && !mNativeSurface->didSetExtraBuffers()) { setBufferCount(mNativeSurface->getNativeWindow()); - } mFrameNumber = 0; @@ -301,10 +300,6 @@ void CanvasContext::setOpaque(bool opaque) { float CanvasContext::setColorMode(ColorMode mode) { if (mode != mColorMode) { - const bool isHdr = mode == ColorMode::Hdr || mode == ColorMode::Hdr10; - if (isHdr && !mRenderPipeline->supportsExtendedRangeHdr()) { - mode = ColorMode::WideColorGamut; - } mColorMode = mode; mRenderPipeline->setSurfaceColorProperties(mode); setupPipelineSurface(); diff --git a/libs/hwui/renderthread/EglManager.cpp b/libs/hwui/renderthread/EglManager.cpp index 4fb114b71bf5..94f35fd9eaf2 100644 --- a/libs/hwui/renderthread/EglManager.cpp +++ b/libs/hwui/renderthread/EglManager.cpp @@ -423,6 +423,7 @@ Result<EGLSurface, EGLint> EglManager::createSurface(EGLNativeWindowType window, EGLint attribs[] = {EGL_NONE, EGL_NONE, EGL_NONE}; EGLConfig config = mEglConfig; + bool overrideWindowDataSpaceForHdr = false; if (colorMode == ColorMode::A8) { // A8 doesn't use a color space if (!mEglConfigA8) { @@ -450,12 +451,13 @@ Result<EGLSurface, EGLint> EglManager::createSurface(EGLNativeWindowType window, case ColorMode::Default: attribs[1] = EGL_GL_COLORSPACE_LINEAR_KHR; break; - // Extended Range HDR requires being able to manipulate the dataspace in ways - // we cannot easily do while going through EGLSurface. Given this requires - // composer3 support, just treat HDR as equivalent to wide color gamut if - // the GLES path is still being hit + // We don't have an EGL colorspace for extended range P3 that's used for HDR + // So override it after configuring the EGL context case ColorMode::Hdr: case ColorMode::Hdr10: + overrideWindowDataSpaceForHdr = true; + attribs[1] = EGL_GL_COLORSPACE_DISPLAY_P3_PASSTHROUGH_EXT; + break; case ColorMode::WideColorGamut: { skcms_Matrix3x3 colorGamut; LOG_ALWAYS_FATAL_IF(!colorSpace->toXYZD50(&colorGamut), @@ -491,6 +493,16 @@ Result<EGLSurface, EGLint> EglManager::createSurface(EGLNativeWindowType window, (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; } diff --git a/libs/hwui/renderthread/IRenderPipeline.h b/libs/hwui/renderthread/IRenderPipeline.h index 9ebad81c5c81..6c2cb9d71c55 100644 --- a/libs/hwui/renderthread/IRenderPipeline.h +++ b/libs/hwui/renderthread/IRenderPipeline.h @@ -95,7 +95,6 @@ public: virtual void setPictureCapturedCallback( const std::function<void(sk_sp<SkPicture>&&)>& callback) = 0; - virtual bool supportsExtendedRangeHdr() const { return false; } virtual void setTargetSdrHdrRatio(float ratio) = 0; virtual const SkM44& getPixelSnapMatrix() const = 0; |