#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "ui/gfx/color_space.h"
#include <iomanip>
#include <limits>
#include <map>
#include <sstream>
#include "base/atomic_sequence_num.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/notreached.h"
#include "base/synchronization/lock.h"
#include "skia/ext/skcolorspace_primaries.h"
#include "skia/ext/skcolorspace_trfn.h"
#include "skia/ext/skia_utils_base.h"
#include "third_party/skia/include/core/SkColorSpace.h"
#include "third_party/skia/include/core/SkData.h"
#include "third_party/skia/include/core/SkImageInfo.h"
#include "third_party/skia/include/core/SkM44.h"
#include "third_party/skia/modules/skcms/skcms.h"
#include "ui/gfx/display_color_spaces.h"
#include "ui/gfx/icc_profile.h"
#include "ui/gfx/skia_color_space_util.h"
namespace gfx {
namespace {
static bool FloatsEqualWithinTolerance(const float* a,
const float* b,
int n,
float tol) { … }
skcms_TransferFunction GetPQSkTransferFunction(float sdr_white_level) { … }
skcms_TransferFunction GetHLGSkTransferFunction(float sdr_white_level) { … }
bool PrimaryIdContainsSRGB(ColorSpace::PrimaryID id) { … }
float GetSDRWhiteLevelFromPQSkTransferFunction(
const skcms_TransferFunction& fn) { … }
}
constexpr float ColorSpace::kDefaultSDRWhiteLevel;
ColorSpace::ColorSpace(PrimaryID primaries,
TransferID transfer,
MatrixID matrix,
RangeID range,
const skcms_Matrix3x3* custom_primary_matrix,
const skcms_TransferFunction* custom_transfer_fn)
: … { … }
ColorSpace::ColorSpace(const SkColorSpace& sk_color_space, bool is_hdr)
: … { … }
bool ColorSpace::IsValid() const { … }
ColorSpace ColorSpace::CreateExtendedSRGB10Bit() { … }
ColorSpace ColorSpace::CreatePiecewiseHDR(
PrimaryID primaries,
float sdr_joint,
float hdr_level,
const skcms_Matrix3x3* custom_primary_matrix) { … }
ColorSpace ColorSpace::CreateCustom(const skcms_Matrix3x3& to_XYZD50,
const skcms_TransferFunction& fn) { … }
ColorSpace ColorSpace::CreateCustom(const skcms_Matrix3x3& to_XYZD50,
TransferID transfer) { … }
void ColorSpace::SetCustomPrimaries(const skcms_Matrix3x3& to_XYZD50) { … }
void ColorSpace::SetCustomTransferFunction(const skcms_TransferFunction& fn) { … }
size_t ColorSpace::TransferParamCount(TransferID transfer) { … }
bool ColorSpace::operator==(const ColorSpace& other) const { … }
bool ColorSpace::IsWide() const { … }
bool ColorSpace::IsHDR() const { … }
bool ColorSpace::IsToneMappedByDefault() const { … }
bool ColorSpace::IsAffectedBySDRWhiteLevel() const { … }
bool ColorSpace::FullRangeEncodedValues() const { … }
bool ColorSpace::operator!=(const ColorSpace& other) const { … }
bool ColorSpace::operator<(const ColorSpace& other) const { … }
size_t ColorSpace::GetHash() const { … }
#define PRINT_ENUM_CASE …
std::string ColorSpace::ToString() const { … }
#undef PRINT_ENUM_CASE
ColorSpace ColorSpace::GetAsFullRangeRGB() const { … }
ContentColorUsage ColorSpace::GetContentColorUsage() const { … }
ColorSpace ColorSpace::GetAsRGB() const { … }
ColorSpace ColorSpace::GetScaledColorSpace(float factor) const { … }
bool ColorSpace::IsSuitableForBlending() const { … }
ColorSpace ColorSpace::GetWithMatrixAndRange(MatrixID matrix,
RangeID range) const { … }
ColorSpace ColorSpace::GetWithSdrWhiteLevel(float sdr_white_level) const { … }
sk_sp<SkColorSpace> ColorSpace::ToSkColorSpace(
std::optional<float> sdr_white_level) const { … }
const struct _GLcolorSpace* ColorSpace::AsGLColorSpace() const { … }
ColorSpace::PrimaryID ColorSpace::GetPrimaryID() const { … }
ColorSpace::TransferID ColorSpace::GetTransferID() const { … }
ColorSpace::MatrixID ColorSpace::GetMatrixID() const { … }
ColorSpace::RangeID ColorSpace::GetRangeID() const { … }
bool ColorSpace::HasExtendedSkTransferFn() const { … }
bool ColorSpace::IsTransferFunctionEqualTo(
const skcms_TransferFunction& fn) const { … }
bool ColorSpace::Contains(const ColorSpace& other) const { … }
SkColorSpacePrimaries ColorSpace::GetColorSpacePrimaries(
PrimaryID primary_id,
const skcms_Matrix3x3* custom_primary_matrix = nullptr) { … }
SkColorSpacePrimaries ColorSpace::GetPrimaries() const { … }
void ColorSpace::GetPrimaryMatrix(PrimaryID primary_id,
skcms_Matrix3x3* to_XYZD50) { … }
void ColorSpace::GetPrimaryMatrix(skcms_Matrix3x3* to_XYZD50) const { … }
SkM44 ColorSpace::GetPrimaryMatrix() const { … }
bool ColorSpace::GetTransferFunction(TransferID transfer,
skcms_TransferFunction* fn) { … }
bool ColorSpace::GetTransferFunction(
skcms_TransferFunction* fn,
std::optional<float> sdr_white_level) const { … }
bool ColorSpace::GetInverseTransferFunction(
skcms_TransferFunction* fn,
std::optional<float> sdr_white_level) const { … }
bool ColorSpace::GetPiecewiseHDRParams(float* sdr_joint,
float* hdr_level) const { … }
SkM44 ColorSpace::GetTransferMatrix(int bit_depth) const { … }
SkM44 ColorSpace::GetRangeAdjustMatrix(int bit_depth) const { … }
bool ColorSpace::ToSkYUVColorSpace(int bit_depth, SkYUVColorSpace* out) const { … }
std::ostream& operator<<(std::ostream& out, const ColorSpace& color_space) { … }
}