From 7fa12ee4a601eb407de53b5044015ce688cee08a Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Tue, 16 May 2023 15:14:52 +0200 Subject: [PATCH] utils/edid: use the common Colorimetry class instead of a separate struct --- src/backends/drm/drm_pipeline.cpp | 8 ++++---- src/utils/edid.cpp | 19 ++++++++++--------- src/utils/edid.h | 8 +------- 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/src/backends/drm/drm_pipeline.cpp b/src/backends/drm/drm_pipeline.cpp index 5a397f9256..cee3b4d319 100644 --- a/src/backends/drm/drm_pipeline.cpp +++ b/src/backends/drm/drm_pipeline.cpp @@ -719,11 +719,11 @@ std::shared_ptr DrmPipeline::createHdrMetadata(NamedTransferFunction tr .metadata_type = 0, // in 0.00002 nits .display_primaries = { - {to16Bit(colorimetry.redPrimary.x()), to16Bit(colorimetry.redPrimary.y())}, - {to16Bit(colorimetry.greenPrimary.x()), to16Bit(colorimetry.greenPrimary.y())}, - {to16Bit(colorimetry.bluePrimary.x()), to16Bit(colorimetry.bluePrimary.y())}, + {to16Bit(colorimetry.red.x()), to16Bit(colorimetry.red.y())}, + {to16Bit(colorimetry.green.x()), to16Bit(colorimetry.green.y())}, + {to16Bit(colorimetry.blue.x()), to16Bit(colorimetry.blue.y())}, }, - .white_point = {to16Bit(colorimetry.whitePoint.x()), to16Bit(colorimetry.whitePoint.y())}, + .white_point = {to16Bit(colorimetry.white.x()), to16Bit(colorimetry.white.y())}, // in nits .max_display_mastering_luminance = uint16_t(std::round(metadata.desiredContentMaxLuminance)), // in 0.0001 nits diff --git a/src/utils/edid.cpp b/src/utils/edid.cpp index 9393cd9c4a..ea0c98a9b0 100644 --- a/src/utils/edid.cpp +++ b/src/utils/edid.cpp @@ -124,18 +124,19 @@ Edid::Edid(const void *data, uint32_t size) const auto chromaticity = di_edid_get_chromaticity_coords(edid); if (chromaticity) { m_colorimetry = { - .redPrimary = {chromaticity->red_x, chromaticity->red_y}, - .greenPrimary = {chromaticity->green_x, chromaticity->green_y}, - .bluePrimary = {chromaticity->blue_x, chromaticity->blue_y}, - .whitePoint = {chromaticity->white_x, chromaticity->white_y}, + .red = {chromaticity->red_x, chromaticity->red_y}, + .green = {chromaticity->green_x, chromaticity->green_y}, + .blue = {chromaticity->blue_x, chromaticity->blue_y}, + .white = {chromaticity->white_x, chromaticity->white_y}, }; } else { // assume sRGB m_colorimetry = { - .redPrimary = {0.64, 0.33}, - .greenPrimary = {0.30, 0.60}, - .bluePrimary = {0.15, 0.06}, - .whitePoint = {0.3127, 0.3290}, + .red = {0.64, 0.33}, + .green = {0.30, 0.60}, + .blue = {0.15, 0.06}, + .white = {0.3127, 0.3290}, + .name = NamedColorimetry::BT709, }; } @@ -240,7 +241,7 @@ QString Edid::hash() const return m_hash; } -Edid::Colorimetry Edid::colorimetry() const +Colorimetry Edid::colorimetry() const { return m_colorimetry; } diff --git a/src/utils/edid.h b/src/utils/edid.h index e76be081ea..6053c7705f 100644 --- a/src/utils/edid.h +++ b/src/utils/edid.h @@ -10,6 +10,7 @@ #pragma once #include "kwin_export.h" +#include "libkwineffects/colorspace.h" #include #include @@ -78,13 +79,6 @@ public: QString hash() const; - struct Colorimetry - { - QVector2D redPrimary; - QVector2D greenPrimary; - QVector2D bluePrimary; - QVector2D whitePoint; - }; Colorimetry colorimetry() const; struct HDRMetadata