-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Made the warning about downgrading wide gamut happen at the correct time #46064
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -48,6 +48,8 @@ - (BOOL)isWideGamutSupported { | |||
return NO; | ||||
} | ||||
|
||||
FML_DCHECK(self.screen); | ||||
|
||||
// This predicates the decision on the capabilities of the iOS device's | ||||
// display. This means external displays will not support wide gamut if the | ||||
// device's display doesn't support it. It practice that should be never. | ||||
|
@@ -68,10 +70,6 @@ - (instancetype)initWithDelegate:(id<FlutterViewEngineDelegate>)delegate | |||
if (self) { | ||||
_delegate = delegate; | ||||
_isWideGamutEnabled = isWideGamutEnabled; | ||||
if (_isWideGamutEnabled && !self.isWideGamutSupported) { | ||||
FML_DLOG(WARNING) << "Rendering wide gamut colors is turned on but isn't " | ||||
"supported, downgrading the color gamut to sRGB."; | ||||
} | ||||
self.layer.opaque = opaque; | ||||
|
||||
// This line is necessary. CoreAnimation(or UIKit) may take this to do | ||||
|
@@ -84,6 +82,16 @@ - (instancetype)initWithDelegate:(id<FlutterViewEngineDelegate>)delegate | |||
return self; | ||||
} | ||||
|
||||
static void PrintWideGamutWarningOnce() { | ||||
static BOOL did_print = NO; | ||||
if (did_print) { | ||||
return; | ||||
} | ||||
FML_DLOG(WARNING) << "Rendering wide gamut colors is turned on but isn't " | ||||
"supported, downgrading the color gamut to sRGB."; | ||||
did_print = YES; | ||||
} | ||||
|
||||
- (void)layoutSubviews { | ||||
if ([self.layer isKindOfClass:NSClassFromString(@"CAMetalLayer")]) { | ||||
// It is a known Apple bug that CAMetalLayer incorrectly reports its supported | ||||
|
@@ -97,7 +105,8 @@ - (void)layoutSubviews { | |||
layer.contentsScale = screenScale; | ||||
layer.rasterizationScale = screenScale; | ||||
layer.framebufferOnly = flutter::Settings::kSurfaceDataAccessible ? NO : YES; | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. drive by comment: shouldn't this be NO always? We set it to NO here:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think so. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to be NO because of backdropfilters and platform views. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, for that layer. But is that layer just placed on top of this one? Or is it the same layer and that is just overriding the setting? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They're the same layer, so you're setting to YES and then its getting blown away. So just set it to NO here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I verified they are the same layer. This seems messy if we have setup in 2 different places for the layer. I guess this setting might be meaningful for the skia backend though? That could explain why the setup is in 2 places. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not going to touch it since it could potentially mess up the skia backend and I think touching it would mean cleaning it up even further to unify the setup. |
||||
if (_isWideGamutEnabled && self.isWideGamutSupported) { | ||||
BOOL isWideGamutSupported = self.isWideGamutSupported; | ||||
if (_isWideGamutEnabled && isWideGamutSupported) { | ||||
CGColorSpaceRef srgb = CGColorSpaceCreateWithName(kCGColorSpaceExtendedSRGB); | ||||
layer.colorspace = srgb; | ||||
CFRelease(srgb); | ||||
|
@@ -106,6 +115,8 @@ - (void)layoutSubviews { | |||
// F16 was chosen over BGRA10_XR since Skia does not support decoding | ||||
// BGRA10_XR. | ||||
layer.pixelFormat = MTLPixelFormatRGBA16Float; | ||||
} else if (_isWideGamutEnabled && !isWideGamutSupported) { | ||||
PrintWideGamutWarningOnce(); | ||||
} | ||||
} | ||||
|
||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nits:
maybe use dispatch_once_t?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had that at first but then decided the table stakes are so low that threading doesn't need to happen. Worst case scenario is that the print statement happens twice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sense. LGTM!