From cc845eb463741acea0d4124c4bb50492d9489da8 Mon Sep 17 00:00:00 2001 From: gaaclarke <30870216+gaaclarke@users.noreply.github.com> Date: Tue, 25 Mar 2025 14:11:46 -0700 Subject: [PATCH] fixed premultiplied colors for antialiased colors (#165839) Previously line.frag was serving up unpremultiplied colors. This resulted in weird blending and the antialiasing not showing up in most cases. test: existing golden will change ## 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. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. [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 --- .../impeller/entity/contents/line_contents.cc | 2 +- .../flutter/impeller/entity/shaders/line.frag | 2 ++ engine/src/flutter/impeller/tools/malioc.json | 36 +++++++++---------- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/engine/src/flutter/impeller/entity/contents/line_contents.cc b/engine/src/flutter/impeller/entity/contents/line_contents.cc index 165645f97d..4c20026c41 100644 --- a/engine/src/flutter/impeller/entity/contents/line_contents.cc +++ b/engine/src/flutter/impeller/entity/contents/line_contents.cc @@ -162,7 +162,7 @@ bool LineContents::Render(const ContentContext& renderer, VS::FrameInfo frame_info; FS::FragInfo frag_info; - frag_info.color = color_.Premultiply(); + frag_info.color = color_; PipelineBuilderCallback pipeline_callback = [&renderer](ContentContextOptions options) { diff --git a/engine/src/flutter/impeller/entity/shaders/line.frag b/engine/src/flutter/impeller/entity/shaders/line.frag index 32455a713a..23baa9506d 100644 --- a/engine/src/flutter/impeller/entity/shaders/line.frag +++ b/engine/src/flutter/impeller/entity/shaders/line.frag @@ -4,6 +4,7 @@ precision mediump float; +#include #include uniform FragInfo { @@ -41,4 +42,5 @@ float CalculateLine() { void main() { float line = CalculateLine(); frag_color = vec4(frag_info.color.xyz, line); + frag_color = IPPremultiply(frag_color); } diff --git a/engine/src/flutter/impeller/tools/malioc.json b/engine/src/flutter/impeller/tools/malioc.json index 97ef7c75ec..040e32c074 100644 --- a/engine/src/flutter/impeller/tools/malioc.json +++ b/engine/src/flutter/impeller/tools/malioc.json @@ -4431,16 +4431,16 @@ "uses_late_zs_update": false, "variants": { "Main": { - "fp16_arithmetic": 6, + "fp16_arithmetic": 0, "has_stack_spilling": false, "performance": { "longest_path_bound_pipelines": [ "varying" ], "longest_path_cycles": [ - 0.21875, - 0.140625, - 0.21875, + 0.1875, + 0.1875, + 0.1875, 0.0, 0.0, 1.75, @@ -4459,9 +4459,9 @@ "varying" ], "shortest_path_cycles": [ - 0.140625, - 0.125, - 0.140625, + 0.171875, + 0.171875, + 0.109375, 0.0, 0.0, 1.75, @@ -4471,9 +4471,9 @@ "varying" ], "total_cycles": [ - 0.21875, - 0.140625, - 0.21875, + 0.1875, + 0.1875, + 0.1875, 0.0, 0.0, 1.75, @@ -8251,7 +8251,7 @@ "uses_late_zs_update": false, "variants": { "Main": { - "fp16_arithmetic": 15, + "fp16_arithmetic": 33, "has_stack_spilling": false, "performance": { "longest_path_bound_pipelines": [ @@ -8259,8 +8259,8 @@ ], "longest_path_cycles": [ 0.1875, - 0.140625, - 0.1875, + 0.171875, + 0.15625, 0.1875, 0.0, 1.75, @@ -8280,8 +8280,8 @@ ], "shortest_path_cycles": [ 0.1875, - 0.125, - 0.140625, + 0.15625, + 0.109375, 0.1875, 0.0, 1.75, @@ -8292,8 +8292,8 @@ ], "total_cycles": [ 0.1875, - 0.140625, - 0.1875, + 0.171875, + 0.15625, 0.1875, 0.0, 1.75, @@ -8302,7 +8302,7 @@ }, "stack_spill_bytes": 0, "thread_occupancy": 100, - "uniform_registers_used": 6, + "uniform_registers_used": 4, "work_registers_used": 18 } }