#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "ui/display/util/display_util.h"
#include <stddef.h>
#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/logging.h"
#include "base/metrics/histogram_functions.h"
#include "base/no_destructor.h"
#include "base/notreached.h"
#include "components/device_event_log/device_event_log.h"
#include "ui/display/types/display_snapshot.h"
#include "ui/display/util/edid_parser.h"
#include "ui/gfx/icc_profile.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "ui/display/display_features.h"
#endif
namespace display {
namespace {
base::flat_set<int64_t>* internal_display_ids() { … }
constexpr int kInvalidDisplaySizeList[][2] = …;
void EmitEdidColorSpaceChecksOutcomeUma(EdidColorSpaceChecksOutcome outcome) { … }
bool NearlyEqual(const skcms_Matrix3x3& lhs,
const skcms_Matrix3x3& rhs,
float epsilon) { … }
}
bool IsDisplaySizeValid(const gfx::Size& physical_size) { … }
int64_t GenerateDisplayID(uint16_t manufacturer_id,
uint32_t product_code_hash,
uint8_t output_index) { … }
gfx::ColorSpace GetColorSpaceFromEdid(const display::EdidParser& edid_parser) { … }
bool CompareDisplayIds(int64_t id1, int64_t id2) { … }
bool IsInternalDisplayId(int64_t display_id) { … }
const base::flat_set<int64_t>& GetInternalDisplayIds() { … }
bool HasInternalDisplay() { … }
void SetInternalDisplayIds(base::flat_set<int64_t> display_ids) { … }
gfx::ColorSpace ForcedColorProfileStringToColorSpace(const std::string& value) { … }
gfx::ColorSpace GetForcedDisplayColorProfile() { … }
bool HasForceDisplayColorProfile() { … }
#if BUILDFLAG(IS_CHROMEOS)
gfx::DisplayColorSpaces CreateDisplayColorSpaces(
const gfx::ColorSpace& snapshot_color_space,
bool allow_high_bit_depth,
const std::optional<gfx::HDRStaticMetadata>& hdr_static_metadata) {
if (HasForceDisplayColorProfile()) {
return gfx::DisplayColorSpaces(GetForcedDisplayColorProfile(),
DisplaySnapshot::PrimaryFormat());
}
if (!snapshot_color_space.IsValid()) {
return gfx::DisplayColorSpaces(snapshot_color_space,
DisplaySnapshot::PrimaryFormat());
}
skcms_Matrix3x3 primary_matrix = SkNamedGamut::kSRGB;
gfx::ColorSpace sdr_color_space = gfx::ColorSpace::CreateCustom(
primary_matrix, gfx::ColorSpace::TransferID::SRGB);
gfx::DisplayColorSpaces display_color_spaces = gfx::DisplayColorSpaces(
sdr_color_space, DisplaySnapshot::PrimaryFormat());
if (allow_high_bit_depth && snapshot_color_space.IsHDR()) {
gfx::ColorSpace hdr_color_space = gfx::ColorSpace::CreateCustom(
primary_matrix, gfx::ColorSpace::TransferID::SRGB_HDR);
display_color_spaces.SetOutputColorSpaceAndBufferFormat(
gfx::ContentColorUsage::kHDR, false , hdr_color_space,
gfx::BufferFormat::RGBA_1010102);
display_color_spaces.SetOutputColorSpaceAndBufferFormat(
gfx::ContentColorUsage::kHDR, true , hdr_color_space,
gfx::BufferFormat::RGBA_1010102);
display_color_spaces.SetHDRMaxLuminanceRelative(1.1f);
}
#if BUILDFLAG(IS_CHROMEOS_ASH)
if (allow_high_bit_depth &&
snapshot_color_space == gfx::ColorSpace::CreateHDR10() &&
base::FeatureList::IsEnabled(
display::features::kEnableExternalDisplayHDR10Mode)) {
display_color_spaces = gfx::DisplayColorSpaces(
gfx::ColorSpace::CreateHDR10(), gfx::BufferFormat::RGBA_1010102);
display_color_spaces.SetHDRMaxLuminanceRelative(
hdr_static_metadata->max /
display_color_spaces.GetSDRMaxLuminanceNits());
}
#endif
return display_color_spaces;
}
#endif
int ConnectorIndex8(int device_index, int display_index) { … }
uint16_t ConnectorIndex16(uint8_t device_index, uint8_t display_index) { … }
}