summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author John Reck <jreck@google.com> 2023-04-05 15:36:15 -0400
committer John Reck <jreck@google.com> 2023-04-05 16:54:39 -0400
commit52d4595ed7470b676077aaf469c3ff131f369bf0 (patch)
tree867e2a75a7f287de8d46db211ec26889271cf2f8
parent0c02452b81a3d896efd00ccc7fc200cd53a68f39 (diff)
Support HDR in skiagl
Fixes: 276807477 Bug: 276385232 Test: setprop debug.hwui.renderer skiagl && silkfx Change-Id: I173ca5ee3a28b274ffd33f11d67fbee73ce1ff20
-rw-r--r--libs/hwui/pipeline/skia/SkiaVulkanPipeline.h1
-rw-r--r--libs/hwui/renderthread/CanvasContext.cpp5
-rw-r--r--libs/hwui/renderthread/EglManager.cpp20
-rw-r--r--libs/hwui/renderthread/IRenderPipeline.h1
4 files changed, 16 insertions, 11 deletions
diff --git a/libs/hwui/pipeline/skia/SkiaVulkanPipeline.h b/libs/hwui/pipeline/skia/SkiaVulkanPipeline.h
index d921ddb0d0fb..bab729e8a2a8 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;
static void invokeFunctor(const renderthread::RenderThread& thread, Functor* functor);
diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp
index 6b2c99534a4c..504c0de9daa0 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 c68fcdfc76f2..68d0944c9daf 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 ~IRenderPipeline() {}