Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Impeller] adds hardware gate for wide gamut #46051

Merged
merged 3 commits into from
Sep 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <syslog.h>

#import <Metal/Metal.h>
#include <sstream>
#include <string>

Expand All @@ -22,6 +23,8 @@
#import "flutter/shell/platform/darwin/common/command_line.h"
#import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h"

FLUTTER_ASSERT_NOT_ARC

extern "C" {
#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG
// Used for debugging dart:* sources.
Expand All @@ -32,6 +35,23 @@

static const char* kApplicationKernelSnapshotFileName = "kernel_blob.bin";

static BOOL DoesHardwareSupportWideGamut() {
static BOOL result = NO;
static dispatch_once_t once_token = 0;
dispatch_once(&once_token, ^{
id<MTLDevice> device = MTLCreateSystemDefaultDevice();
if (@available(iOS 13.0, *)) {
// MTLGPUFamilyApple2 = A9/A10
result = [device supportsFamily:MTLGPUFamilyApple2];
} else {
// A9/A10 on iOS 10+
result = [device supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily3_v2];
}
[device release];
});
return result;
}

flutter::Settings FLTDefaultSettingsForBundle(NSBundle* bundle, NSProcessInfo* processInfoOrNil) {
auto command_line = flutter::CommandLineFromNSProcessInfo(processInfoOrNil);

Expand Down Expand Up @@ -153,9 +173,12 @@
// As of Xcode 14.1, the wide gamut surface pixel formats are not supported by
// the simulator.
settings.enable_wide_gamut = false;
// Removes unused function warning.
(void)DoesHardwareSupportWideGamut;
#else
NSNumber* nsEnableWideGamut = [mainBundle objectForInfoDictionaryKey:@"FLTEnableWideGamut"];
BOOL enableWideGamut = nsEnableWideGamut ? nsEnableWideGamut.boolValue : YES;
BOOL enableWideGamut =
(nsEnableWideGamut ? nsEnableWideGamut.boolValue : YES) && DoesHardwareSupportWideGamut();
settings.enable_wide_gamut = enableWideGamut;
#endif

Expand Down