Bug 1798067 Part 1: Add SupportsHDR to gfxPlatform, refactor macOS to use it. r=gfx-reviewers,lsalzman

Differential Revision: https://phabricator.services.mozilla.com/D161364
This commit is contained in:
Brad Werth 2022-11-29 02:31:18 +00:00
Родитель 75900f7ade
Коммит e2e3323a40
4 изменённых файлов: 30 добавлений и 8 удалений

Просмотреть файл

@ -805,6 +805,8 @@ class gfxPlatform : public mozilla::layers::MemoryPressureListener {
static bool UseDesktopZoomingScrollbars();
virtual bool SupportsHDR() { return false; }
protected:
gfxPlatform();
virtual ~gfxPlatform();

Просмотреть файл

@ -996,6 +996,24 @@ gfxPlatformMac::CreateGlobalHardwareVsyncSource() {
return osxVsyncSource.forget();
}
bool gfxPlatformMac::SupportsHDR() {
// HDR has 3 requirements:
// 1) high peak brightness
// 2) high contrast ratio
// 3) color depth > 24
if (GetScreenDepth() <= 24) {
return false;
}
// Screen is capable. Is the OS capable?
#ifdef EARLY_BETA_OR_EARLIER
// More-or-less supported in Catalina.
return nsCocoaFeatures::OnCatalinaOrLater();
#else
// Definitely supported in Big Sur.
return nsCocoaFeatures::OnBigSurOrLater();
#endif
}
nsTArray<uint8_t> gfxPlatformMac::GetPlatformCMSOutputProfileData() {
nsTArray<uint8_t> prefProfileData = GetPrefCMSOutputProfileData();
if (!prefProfileData.IsEmpty()) {

Просмотреть файл

@ -76,6 +76,8 @@ class gfxPlatformMac : public gfxPlatform {
static bool CheckVariationFontSupport();
bool SupportsHDR() override;
protected:
bool AccelerateLayersByDefault() override;

Просмотреть файл

@ -484,13 +484,13 @@ nsresult nsLookAndFeel::NativeGetInt(IntID aID, int32_t& aResult) {
case IntID::UseAccessibilityTheme:
aResult = NSWorkspace.sharedWorkspace.accessibilityDisplayShouldIncreaseContrast;
break;
case IntID::VideoDynamicRange:
#ifdef EARLY_BETA_OR_EARLIER
aResult = nsCocoaFeatures::OnCatalinaOrLater();
#else
aResult = nsCocoaFeatures::OnBigSurOrLater();
#endif
case IntID::VideoDynamicRange: {
// If the platform says it supports HDR, then we claim to support video-dynamic-range.
gfxPlatform* platform = gfxPlatform::GetPlatform();
MOZ_ASSERT(platform);
aResult = platform->SupportsHDR();
break;
}
case IntID::PanelAnimations:
aResult = 1;
break;
@ -687,8 +687,8 @@ void nsLookAndFeel::RecordAccessibilityTelemetry() {
}
- (void)cachedValuesChanged {
// We only need to re-cache (and broadcast) updated LookAndFeel values, so that they're up-to-date
// the next time they're queried. No further change handling is needed.
// We only need to re-cache (and broadcast) updated LookAndFeel values, so that they're
// up-to-date the next time they're queried. No further change handling is needed.
// TODO: Add a change hint for this which avoids the unnecessary media query invalidation.
LookAndFeel::NotifyChangedAllWindows(widget::ThemeChangeKind::MediaQueriesOnly);
}