Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit eff1b76

Browse files
authored
Reland: Framework wide color (#54415) (#54737) (#54905)
[This PR](#54415) was reverted because it required customer testing updates. issue: flutter/flutter#127855 integration test: #54415 This does the preliminary work for implementing wide gamut colors in the Flutter framework. Here are the following changes: 1) colors now specify a colorspace with which they are to be interpreted 1) colors now store their components as floats to accommodate bit depths more than 8 The storage of this Color class is weird with float/int storage but that is a temporary solution to support a smooth transition. Here is the plan for landing this: 1) Land this PR 1) Wait for it to roll into the Framework 1) Land flutter/flutter#153938 which will make CupertinoDynamicColor implement Color 1) Land another engine PR that rips out the int storage: #54714 Here are follow up PRs: 1) #54473 - changes DlColor so the wide gamut colors are rendered 1) #54567 - Hooks up these changes to take advantage of wide DlColor 1) flutter/flutter#153319 - the integration test for the framework repo There are some things that have been left as follow up PRs since they are technically breaking: 1) The math on `lerp` hasn't been updated to take advantage of the higher bit depth 1) `operator==` hasn't been updated to take advantage of the higher bit depth 1) `hashCode` hasn't been updated to take advantage of the higher bit depth 1) `alphaBlend` hasn't been updated to take advantage of the higher bit depth 1) `toString` hasn't been updated to take advantage of the higher bit depth ## Reland 2 notes This was reverted because it changes the math on `_lerpDouble`. While those changes were mathematcially equivalent, they had different behaviors when working with non-numbers which created unexpected changes. The change has been reverted and a test added. ## 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]. <!-- Links --> [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
1 parent 98c26dd commit eff1b76

File tree

7 files changed

+824
-79
lines changed

7 files changed

+824
-79
lines changed

lib/gpu/lib/src/render_pass.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,15 @@ base class RenderTarget {
9595
final DepthStencilAttachment? depthStencilAttachment;
9696
}
9797

98+
// TODO(gaaclarke): Refactor this to support wide gamut colors.
99+
int _colorToInt(ui.Color color) {
100+
assert(color.colorSpace == ui.ColorSpace.sRGB);
101+
return ((color.a * 255.0).round() << 24) |
102+
((color.r * 255.0).round() << 16) |
103+
((color.g * 255.0).round() << 8) |
104+
((color.b * 255.0).round() << 0);
105+
}
106+
98107
base class RenderPass extends NativeFieldWrapperClass1 {
99108
/// Creates a new RenderPass.
100109
RenderPass._(CommandBuffer commandBuffer, RenderTarget renderTarget) {
@@ -105,7 +114,7 @@ base class RenderPass extends NativeFieldWrapperClass1 {
105114
index,
106115
color.loadAction.index,
107116
color.storeAction.index,
108-
color.clearValue.value,
117+
_colorToInt(color.clearValue),
109118
color.texture,
110119
color.resolveTexture);
111120
if (error != null) {

lib/ui/lerp.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ double? lerpDouble(num? a, num? b, double t) {
2626
///
2727
/// Same as [lerpDouble] but specialized for non-null `double` type.
2828
double _lerpDouble(double a, double b, double t) {
29+
// This doesn't match _lerpInt to preserve specific behaviors when dealing
30+
// with infinity and nan.
2931
return a * (1.0 - t) + b * t;
3032
}
3133

0 commit comments

Comments
 (0)