Skip to content

Commit

Permalink
Remove 10.13, 10.14 support from ui/
Browse files Browse the repository at this point in the history
These macOS releases are no longer supported by Chromium.

Bug: 1410851
Change-Id: Ib973c3ee1af4d156c2e614bd255eacbf4e963fe3
Cq-Include-Trybots: luci.chrome.try:mac-chrome
Validate-Test-Flakiness: skip
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4676452
Auto-Submit: Avi Drissman <avi@chromium.org>
Reviewed-by: Leonard Grey <lgrey@chromium.org>
Code-Coverage: Findit <findit-for-me@appspot.gserviceaccount.com>
Commit-Queue: Leonard Grey <lgrey@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1168713}
  • Loading branch information
Avi Drissman authored and Chromium LUCI CQ committed Jul 11, 2023
1 parent 9eab4ab commit 88d368a
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 154 deletions.
12 changes: 4 additions & 8 deletions ui/accelerated_widget_mac/ca_layer_tree_unittest_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1090,8 +1090,7 @@ void RunTest(bool allow_solid_color_layers) {

// Validate that the root layer has is triggering HDR.
CALayer* content_layer = GetOnlyContentLayer();
if (@available(macos 10.15, *))
EXPECT_TRUE([content_layer wantsExtendedDynamicRangeContent]);
EXPECT_TRUE([content_layer wantsExtendedDynamicRangeContent]);

// Commit the SDR layer.
properties.io_surface = sdr_image;
Expand All @@ -1106,8 +1105,7 @@ void RunTest(bool allow_solid_color_layers) {
// un-parented.
EXPECT_EQ([content_layer superlayer], nil);
content_layer = GetOnlyContentLayer();
if (@available(macos 10.15, *))
EXPECT_FALSE([content_layer wantsExtendedDynamicRangeContent]);
EXPECT_FALSE([content_layer wantsExtendedDynamicRangeContent]);

// Commit the tricky SDR layer.
properties.io_surface = tricky_sdr_image;
Expand All @@ -1120,8 +1118,7 @@ void RunTest(bool allow_solid_color_layers) {

// Validate that HDR is still off, and that the content layer hasn't changed.
EXPECT_EQ(content_layer, GetOnlyContentLayer());
if (@available(macos 10.15, *))
EXPECT_FALSE([content_layer wantsExtendedDynamicRangeContent]);
EXPECT_FALSE([content_layer wantsExtendedDynamicRangeContent]);

// Commit the HDR layer.
properties.io_surface = hdr_image;
Expand All @@ -1136,8 +1133,7 @@ void RunTest(bool allow_solid_color_layers) {
// been un-parented.
EXPECT_EQ([content_layer superlayer], nil);
content_layer = GetOnlyContentLayer();
if (@available(macos 10.15, *))
EXPECT_TRUE([content_layer wantsExtendedDynamicRangeContent]);
EXPECT_TRUE([content_layer wantsExtendedDynamicRangeContent]);
}

} // namespace gpu
129 changes: 9 additions & 120 deletions ui/display/mac/screen_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
#import <AppKit/AppKit.h>
#import <ApplicationServices/ApplicationServices.h>
#include <Foundation/Foundation.h>
#include <IOKit/IOKitLib.h>
#include <IOKit/graphics/IOGraphicsLib.h>
#include <QuartzCore/CVDisplayLink.h>
#include <stdint.h>

Expand All @@ -22,7 +20,6 @@
#include "base/mac/foundation_util.h"
#include "base/mac/mac_util.h"
#include "base/mac/scoped_cftyperef.h"
#include "base/mac/scoped_ioobject.h"
#include "base/strings/sys_string_conversions.h"
#include "base/timer/timer.h"
#include "base/trace_event/trace_event.h"
Expand Down Expand Up @@ -80,107 +77,6 @@
return displays;
}

// Mac OS < 10.15 does not have a good way to get the name for a particular
// display. This method queries IOService to try to find a display matching the
// product and vendor ID of the passed in Core Graphics display, and returns a
// CFDictionary created using IODisplayCreateInfoDictionary for that display.
// If multiple identical screens are present this might return the info for the
// wrong display.
//
// If no matching screen is found in IOService, this returns null.
base::ScopedCFTypeRef<CFDictionaryRef> GetDisplayInfoFromIOService(
CGDirectDisplayID display_id) {
const uint32_t cg_vendor_number = CGDisplayVendorNumber(display_id);
const uint32_t cg_model_number = CGDisplayModelNumber(display_id);

// If display is unknown or not connected to a monitor, return an empty
// string.
if (cg_vendor_number == kDisplayVendorIDUnknown ||
cg_vendor_number == 0xFFFFFFFF) {
return base::ScopedCFTypeRef<CFDictionaryRef>();
}

// IODisplayConnect is only supported in Intel-powered Macs. On ARM based
// Macs this returns an empty list. Fortunately we only use this code when
// the OS is older than 10.15, and those OS versions don't support ARM anyway.
base::mac::ScopedIOObject<io_iterator_t> it;
if (IOServiceGetMatchingServices(kIOMasterPortDefault,
IOServiceMatching("IODisplayConnect"),
it.InitializeInto()) != 0) {
// This may happen if a desktop Mac is running headless.
return base::ScopedCFTypeRef<CFDictionaryRef>();
}

base::ScopedCFTypeRef<CFDictionaryRef> found_display;
while (auto service = base::mac::ScopedIOObject<io_service_t>(
IOIteratorNext(it.get()))) {
auto info =
base::ScopedCFTypeRef<CFDictionaryRef>(IODisplayCreateInfoDictionary(
service.get(), kIODisplayOnlyPreferredName));

CFNumberRef vendorIDRef = base::mac::GetValueFromDictionary<CFNumberRef>(
info.get(), CFSTR(kDisplayVendorID));
CFNumberRef productIDRef = base::mac::GetValueFromDictionary<CFNumberRef>(
info.get(), CFSTR(kDisplayProductID));
if (!vendorIDRef || !productIDRef)
continue;

long long vendorID, productID;
CFNumberGetValue(vendorIDRef, kCFNumberLongLongType, &vendorID);
CFNumberGetValue(productIDRef, kCFNumberLongLongType, &productID);
if (cg_vendor_number == vendorID && cg_model_number == productID)
return info;
}

return base::ScopedCFTypeRef<CFDictionaryRef>();
}

// Extract the (localized) name from a dictionary created by
// IODisplayCreateInfoDictionary. If `info` is null, or if no names are found
// in the dictionary, this returns an empty string.
std::string DisplayNameFromDisplayInfo(
base::ScopedCFTypeRef<CFDictionaryRef> info) {
if (!info)
return std::string();

NSDictionary* names = base::apple::CFToNSPtrCast(
base::mac::GetValueFromDictionary<CFDictionaryRef>(
info.get(), CFSTR(kDisplayProductName)));
if (!names)
return std::string();

// The `names` dictionary maps locale strings to localized product names for
// the display. Find a key in the returned dictionary that best matches the
// current locale. Since this doesn't need to be perfect (display names are
// unlikely to be localize), we use the number of initial matching characters
// as an approximation for how well two locale strings match. This way
// countries and variants are ignored if they don't exist in one or the other,
// but taken into account if they are present in both. If no match is found,
// the first entry is used.
std::string configured_locale = base::i18n::GetConfiguredLocale();

NSString* name = nil;
int match_size = -1;
for (NSString* key in names) {
NSString* value = base::mac::ObjCCast<NSString>(names[key]);
if (!value) {
continue;
}
std::string locale =
base::i18n::GetCanonicalLocale(base::SysNSStringToUTF8(key));
int match = base::ranges::mismatch(locale, configured_locale).first -
locale.begin();
if (match > match_size) {
name = value;
}
}

if (!name) {
return std::string();
}
return base::SysNSStringToUTF8(name);
}

DisplayMac BuildDisplayForScreen(NSScreen* screen) {
TRACE_EVENT0("ui", "BuildDisplayForScreen");
NSRect frame = screen.frame;
Expand Down Expand Up @@ -212,16 +108,14 @@ DisplayMac BuildDisplayForScreen(NSScreen* screen) {
// Examine the presence of HDR.
bool enable_hdr = false;
float hdr_max_lum_relative = 1.f;
if (@available(macOS 10.15, *)) {
const float max_potential_edr_value =
screen.maximumPotentialExtendedDynamicRangeColorComponentValue;
const float max_edr_value =
screen.maximumExtendedDynamicRangeColorComponentValue;
if (max_potential_edr_value > 1.f) {
enable_hdr = true;
hdr_max_lum_relative =
std::max(kMinHDRCapableMaxLuminanceRelative, max_edr_value);
}
const float max_potential_edr_value =
screen.maximumPotentialExtendedDynamicRangeColorComponentValue;
const float max_edr_value =
screen.maximumExtendedDynamicRangeColorComponentValue;
if (max_potential_edr_value > 1.f) {
enable_hdr = true;
hdr_max_lum_relative =
std::max(kMinHDRCapableMaxLuminanceRelative, max_edr_value);
}

// Compute DisplayColorSpaces.
Expand Down Expand Up @@ -296,12 +190,7 @@ DisplayMac BuildDisplayForScreen(NSScreen* screen) {
if (CGDisplayIsBuiltin(display_id))
SetInternalDisplayIds({display_id});

if (@available(macOS 10.15, *)) {
display.set_label(base::SysNSStringToUTF8(screen.localizedName));
} else {
display.set_label(
DisplayNameFromDisplayInfo(GetDisplayInfoFromIOService(display_id)));
}
display.set_label(base::SysNSStringToUTF8(screen.localizedName));

return DisplayMac{display, screen};
}
Expand Down
36 changes: 17 additions & 19 deletions ui/gfx/mac/io_surface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -172,25 +172,23 @@ bool IOSurfaceSetColorSpace(IOSurfaceRef io_surface,
// also not available in some SDK versions.
// https://crbug.com/1101041: Introduces the HDR copier.
// https://crbug.com/1061723: Discussion of issues related to HLG.
if (__builtin_available(macos 10.15, *)) {
if (color_space == ColorSpace(ColorSpace::PrimaryID::BT2020,
ColorSpace::TransferID::PQ,
ColorSpace::MatrixID::BT2020_NCL,
ColorSpace::RangeID::LIMITED)) {
if (__builtin_available(macos 11.0, *)) {
color_space_name = kCGColorSpaceITUR_2100_PQ;
} else {
return true;
}
} else if (color_space == ColorSpace(ColorSpace::PrimaryID::BT2020,
ColorSpace::TransferID::HLG,
ColorSpace::MatrixID::BT2020_NCL,
ColorSpace::RangeID::LIMITED)) {
if (__builtin_available(macos 11.0, *)) {
color_space_name = kCGColorSpaceITUR_2100_HLG;
} else {
return true;
}
if (color_space == ColorSpace(ColorSpace::PrimaryID::BT2020,
ColorSpace::TransferID::PQ,
ColorSpace::MatrixID::BT2020_NCL,
ColorSpace::RangeID::LIMITED)) {
if (__builtin_available(macos 11.0, *)) {
color_space_name = kCGColorSpaceITUR_2100_PQ;
} else {
return true;
}
} else if (color_space == ColorSpace(ColorSpace::PrimaryID::BT2020,
ColorSpace::TransferID::HLG,
ColorSpace::MatrixID::BT2020_NCL,
ColorSpace::RangeID::LIMITED)) {
if (__builtin_available(macos 11.0, *)) {
color_space_name = kCGColorSpaceITUR_2100_HLG;
} else {
return true;
}
}
if (color_space_name) {
Expand Down
10 changes: 3 additions & 7 deletions ui/shell_dialogs/select_file_dialog_mac_unittest.mm
Original file line number Diff line number Diff line change
Expand Up @@ -457,15 +457,11 @@ void ResetDialog() {

// In 10.15, file picker dialogs are remote, and the restriction of apps not
// being allowed to OK their own file requests has been extended from just
// sandboxed apps to all apps. If we can test OK-ing our own dialogs, sure,
// but if not, at least try to close them all.
// sandboxed apps to all apps. Since the dialogs can't be OKed, at least close
// them all.
base::RunLoop run_loop2;
SetDialogClosedCallback(run_loop2.QuitClosure());
if (base::mac::IsAtMostOS10_14()) {
[panel2 ok:nil];
} else {
[panel2 cancel:nil];
}
[panel2 cancel:nil];
run_loop2.Run();
EXPECT_EQ(0lu, GetActivePanelCount());

Expand Down

0 comments on commit 88d368a

Please sign in to comment.