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

Reland: Framework wide color (#54415) (#54737) #54905

Merged
merged 3 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
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
11 changes: 10 additions & 1 deletion lib/gpu/lib/src/render_pass.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ base class RenderTarget {
final DepthStencilAttachment? depthStencilAttachment;
}

// TODO(gaaclarke): Refactor this to support wide gamut colors.
int _colorToInt(ui.Color color) {
assert(color.colorSpace == ui.ColorSpace.sRGB);
return ((color.a * 255.0).round() << 24) |
((color.r * 255.0).round() << 16) |
((color.g * 255.0).round() << 8) |
((color.b * 255.0).round() << 0);
}

base class RenderPass extends NativeFieldWrapperClass1 {
/// Creates a new RenderPass.
RenderPass._(CommandBuffer commandBuffer, RenderTarget renderTarget) {
Expand All @@ -105,7 +114,7 @@ base class RenderPass extends NativeFieldWrapperClass1 {
index,
color.loadAction.index,
color.storeAction.index,
color.clearValue.value,
_colorToInt(color.clearValue),
color.texture,
color.resolveTexture);
if (error != null) {
Expand Down
2 changes: 2 additions & 0 deletions lib/ui/lerp.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ double? lerpDouble(num? a, num? b, double t) {
///
/// Same as [lerpDouble] but specialized for non-null `double` type.
double _lerpDouble(double a, double b, double t) {
// This doesn't match _lerpInt to preserve specific behaviors when dealing
// with infinity and nan.
return a * (1.0 - t) + b * t;
}

Expand Down
Loading