Merge "Support HDR in skiagl" into udc-dev
This commit is contained in:
@@ -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;
|
||||||
const SkM44& getPixelSnapMatrix() const override;
|
const SkM44& getPixelSnapMatrix() const override;
|
||||||
|
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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 const SkM44& getPixelSnapMatrix() const = 0;
|
virtual const SkM44& getPixelSnapMatrix() const = 0;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user