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-28 20:51:17 +00:00
Родитель cb853b7f77
Коммит bfde7b9df5
4 изменённых файлов: 30 добавлений и 8 удалений

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

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

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

@ -996,6 +996,24 @@ gfxPlatformMac::CreateGlobalHardwareVsyncSource() {
return osxVsyncSource.forget(); 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();
#endif
// Definitely supported in Big Sur.
return nsCocoaFeatures::OnBigSurOrLater();
}
nsTArray<uint8_t> gfxPlatformMac::GetPlatformCMSOutputProfileData() { nsTArray<uint8_t> gfxPlatformMac::GetPlatformCMSOutputProfileData() {
nsTArray<uint8_t> prefProfileData = GetPrefCMSOutputProfileData(); nsTArray<uint8_t> prefProfileData = GetPrefCMSOutputProfileData();
if (!prefProfileData.IsEmpty()) { if (!prefProfileData.IsEmpty()) {

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

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

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

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