1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/base/wayland/color_manager_util.h"
#include <cstdint>
#include "chrome-color-management-server-protocol.h"
namespace ui::wayland {
zcr_color_manager_v1_chromaticity_names ToColorManagerChromaticity(
gfx::ColorSpace::PrimaryID primaryID,
uint32_t version) {
for (const auto& it : kChromaticityMap) {
if (it.second.primary == primaryID) {
if (it.second.version <= version) {
return it.first;
}
return ZCR_COLOR_MANAGER_V1_CHROMATICITY_NAMES_BT709;
}
}
return ZCR_COLOR_MANAGER_V1_CHROMATICITY_NAMES_UNKNOWN;
}
zcr_color_manager_v1_matrix_names ToColorManagerMatrix(
gfx::ColorSpace::MatrixID matrixID,
uint32_t version) {
for (const auto& it : kMatrixMap) {
if (it.second.matrix == matrixID) {
if (it.second.version <= version) {
return it.first;
}
return ZCR_COLOR_MANAGER_V1_MATRIX_NAMES_RGB;
}
}
return ZCR_COLOR_MANAGER_V1_MATRIX_NAMES_UNKNOWN;
}
zcr_color_manager_v1_range_names ToColorManagerRange(
gfx::ColorSpace::RangeID rangeID,
uint32_t version) {
for (const auto& it : kRangeMap) {
if (it.second.range == rangeID) {
if (it.second.version <= version) {
return it.first;
}
return ZCR_COLOR_MANAGER_V1_RANGE_NAMES_FULL;
}
}
return ZCR_COLOR_MANAGER_V1_RANGE_NAMES_UNKNOWN;
}
zcr_color_manager_v1_eotf_names ToColorManagerEOTF(
gfx::ColorSpace::TransferID transferID,
uint32_t version) {
for (const auto& it : kEotfMap) {
if (it.second.transfer == transferID) {
if (it.second.version <= version) {
return it.first;
}
return ZCR_COLOR_MANAGER_V1_EOTF_NAMES_SRGB;
}
}
return ZCR_COLOR_MANAGER_V1_EOTF_NAMES_UNKNOWN;
}
zcr_color_manager_v1_eotf_names ToColorManagerEOTF(gfx::ColorSpace color_space,
uint32_t version) {
if (color_space.IsHDR()) {
for (const auto& it : kHDRTransferMap) {
if (color_space.IsTransferFunctionEqualTo(it.second.transfer_fn)) {
if (it.second.version <= version) {
return it.first;
}
return ZCR_COLOR_MANAGER_V1_EOTF_NAMES_SRGB;
}
}
}
return ToColorManagerEOTF(color_space.GetTransferID(), version);
}
} // namespace ui::wayland
|