-
Notifications
You must be signed in to change notification settings - Fork 29.7k
ColorFilter.saturation #167898
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
ColorFilter.saturation #167898
Conversation
28ae2f1 to
081ab97
Compare
|
This pull request has been changed to a draft. The currently pending flutter-gold status will not be able to resolve until a new commit is pushed or the change is marked ready for review again. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
trying to understand the intricacies of what parts of the codebase need to be updated. builds are failing on web and it's not clear to me what the next steps are. will keep trying to apply pressure on this |
|
There's also this file where a test could be added: Unfortunately it's in the engine and running the test isn't as easy as pressing the run button in VSCode (and setting everything up correctly seems really complicated), so I can' confirm, but I think this would do: /// [red] with a 0.5 saturation adjustment layer in Affinity Photo
// Might not match up with the result of the matrix calc exactly
const int redHalfSaturation = 0xFF853F2D;
....
group('ColorFilter - saturation', () {
test('saturation - 0', () async {
final Paint paint =
Paint()
..color = green
..colorFilter = const ColorFilter.saturation(0);
Uint32List bytes = await getBytesForPaint(paint);
expect(bytes[0], greenGreyscaled);
// TODO(135699): enable this
if (impellerEnabled) {
return;
}
paint.invertColors = true;
bytes = await getBytesForPaint(paint);
expect(bytes[0], greenInvertedGreyscaled);
});
test('saturation - 1 - transparent', () async {
final Paint paint =
Paint()
..color = transparent
..colorFilter = const ColorFilter.saturation(1);
Uint32List bytes = await getBytesForPaint(paint);
expect(bytes[0], transparent);
});
test('saturation - 1 - green', () async {
final Paint paint =
Paint()
..color = green
..colorFilter = const ColorFilter.saturation(1);
Uint32List bytes = await getBytesForPaint(paint);
expect(bytes[0], green);
});
test('saturation - 1 - red', () async {
final Paint paint =
Paint()
..color = red
..colorFilter = const ColorFilter.saturation(1);
Uint32List bytes = await getBytesForPaint(paint);
expect(bytes[0], red);
});
test('saturation - 0.5 - red', () async {
final Paint paint =
Paint()
..color = red
..colorFilter = const ColorFilter.saturation(0.5);
Uint32List bytes = await getBytesForPaint(paint);
expect(bytes[0], redHalfSaturation);
});
}); |
This is what's failing which is fair, because there is indeed no such thing https://github.com/lukepighetti/flutter/blob/1e29389a7c1b0456feadf74914fb6de05e34e048/engine/src/flutter/lib/web_ui/lib/src/engine/color_filter.dart#L110 But this class is really curious, it seems to be a copy paste of the section from |
Piinks
left a comment
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.
Thanks for sending a PR! 🎊
See comment below to get this working on web.
| const factory ColorFilter.matrix(List<double> matrix) = engine.EngineColorFilter.matrix; | ||
| const factory ColorFilter.linearToSrgbGamma() = engine.EngineColorFilter.linearToSrgbGamma; | ||
| const factory ColorFilter.srgbToLinearGamma() = engine.EngineColorFilter.srgbToLinearGamma; | ||
| const factory ColorFilter.saturation(double saturation) = engine.EngineColorFilter.saturation; |
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.
Would be great if Github did not lose said comment. 😅
See engine/src/flutter/lib/web_ui/lib/src/engine/color_filter.dart
You need to define EngineColorFilter.saturation
Search for EngineColorFilter.srgbToLinearGamma as an example.
Once CI is green, the bot will check for golden file changes and leave a comment to the dashboard where we can check them out. 👍 |
|
Hey @lukepighetti! Greetings from stale PR triage 👋 |
|
Unfortunately since we have not heard back we'll have to regrettably close this PR. I have marked the issue with a the partial patch label in case anyone wants to pick this up and address the feedback. Thanks! |
Closes #166589 This PR is a continuation of #167898, which was closed due to the lack of web implementation. Thanks to @lukepighetti and @benthillerkus for their work on the closed PR. ### Description - Adds `ColorFilter.saturation` https://github.com/user-attachments/assets/67d8acf0-35d0-42de-a24b-f24eed14e9a8 ## 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], including [Features we expect every widget to implement]. - [X] I signed the [CLA]. - [X] I listed at least one issue that this PR fixes in the description above. - [X] I updated/added relevant documentation (doc comments with `///`). - [X] I added new tests to check the change I am making, or this PR is [test-exempt]. - [X] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [X] All existing and new tests are passing. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Closes flutter#166589 This PR is a continuation of flutter#167898, which was closed due to the lack of web implementation. Thanks to @lukepighetti and @benthillerkus for their work on the closed PR. ### Description - Adds `ColorFilter.saturation` https://github.com/user-attachments/assets/67d8acf0-35d0-42de-a24b-f24eed14e9a8 ## 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], including [Features we expect every widget to implement]. - [X] I signed the [CLA]. - [X] I listed at least one issue that this PR fixes in the description above. - [X] I updated/added relevant documentation (doc comments with `///`). - [X] I added new tests to check the change I am making, or this PR is [test-exempt]. - [X] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [X] All existing and new tests are passing. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Resolves #166589
I'm not sure how to update the Goldens but here are the three I have locally. Test was written to ensure that transparency is preserved.
golden files
ColorFilter.saturation(1)ColorFilter.saturation(0.5)ColorFilter.saturation(0)Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.