From 7a4d6f1b6a7a0482a67f4f07ee7612b37c9065cb Mon Sep 17 00:00:00 2001 From: gaaclarke <30870216+gaaclarke@users.noreply.github.com> Date: Mon, 22 Jan 2024 14:42:36 -0800 Subject: [PATCH] [Impeller] fixed colorspace for metal screenshots (flutter/engine#49941) fixes https://github.com/flutter/flutter/issues/141903 The golden tests were generating images in the wrong colorspace which left things brighter than they should have been. This fixes that issue. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide] and the [C++, Objective-C, Java style guides]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I added new tests to check the change I am making or feature I am adding, or the PR is [test-exempt]. See [testing the engine] for instructions on writing and running engine tests. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I signed the [CLA]. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [test-exempt]: https://github.com/flutter/flutter/wiki/Tree-hygiene#tests [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style [testing the engine]: https://github.com/flutter/flutter/wiki/Testing-the-engine [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat --- .../flutter/impeller/golden_tests/metal_screenshotter.mm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/engine/src/flutter/impeller/golden_tests/metal_screenshotter.mm b/engine/src/flutter/impeller/golden_tests/metal_screenshotter.mm index 7e17b3f7b0..534884078a 100644 --- a/engine/src/flutter/impeller/golden_tests/metal_screenshotter.mm +++ b/engine/src/flutter/impeller/golden_tests/metal_screenshotter.mm @@ -37,8 +37,11 @@ std::unique_ptr MetalScreenshotter::MakeScreenshot( return {}; } - CIImage* ciImage = [[CIImage alloc] initWithMTLTexture:metal_texture - options:@{}]; + CGColorSpaceRef color_space = CGColorSpaceCreateDeviceRGB(); + CIImage* ciImage = [[CIImage alloc] + initWithMTLTexture:metal_texture + options:@{kCIImageColorSpace : (__bridge id)color_space}]; + CGColorSpaceRelease(color_space); FML_CHECK(ciImage); std::shared_ptr context = playground_->GetContext();