Skip to content

Commit 8d82def

Browse files
gaaclarkeyuuangzhang
authored andcommitted
fixed premultiplied colors for antialiased colors (flutter#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]. <!-- 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
1 parent 5b842b5 commit 8d82def

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed

engine/src/flutter/impeller/entity/contents/line_contents.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ bool LineContents::Render(const ContentContext& renderer,
162162

163163
VS::FrameInfo frame_info;
164164
FS::FragInfo frag_info;
165-
frag_info.color = color_.Premultiply();
165+
frag_info.color = color_;
166166

167167
PipelineBuilderCallback pipeline_callback =
168168
[&renderer](ContentContextOptions options) {

engine/src/flutter/impeller/entity/shaders/line.frag

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
precision mediump float;
66

7+
#include <impeller/color.glsl>
78
#include <impeller/types.glsl>
89

910
uniform FragInfo {
@@ -41,4 +42,5 @@ float CalculateLine() {
4142
void main() {
4243
float line = CalculateLine();
4344
frag_color = vec4(frag_info.color.xyz, line);
45+
frag_color = IPPremultiply(frag_color);
4446
}

engine/src/flutter/impeller/tools/malioc.json

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4431,16 +4431,16 @@
44314431
"uses_late_zs_update": false,
44324432
"variants": {
44334433
"Main": {
4434-
"fp16_arithmetic": 6,
4434+
"fp16_arithmetic": 0,
44354435
"has_stack_spilling": false,
44364436
"performance": {
44374437
"longest_path_bound_pipelines": [
44384438
"varying"
44394439
],
44404440
"longest_path_cycles": [
4441-
0.21875,
4442-
0.140625,
4443-
0.21875,
4441+
0.1875,
4442+
0.1875,
4443+
0.1875,
44444444
0.0,
44454445
0.0,
44464446
1.75,
@@ -4459,9 +4459,9 @@
44594459
"varying"
44604460
],
44614461
"shortest_path_cycles": [
4462-
0.140625,
4463-
0.125,
4464-
0.140625,
4462+
0.171875,
4463+
0.171875,
4464+
0.109375,
44654465
0.0,
44664466
0.0,
44674467
1.75,
@@ -4471,9 +4471,9 @@
44714471
"varying"
44724472
],
44734473
"total_cycles": [
4474-
0.21875,
4475-
0.140625,
4476-
0.21875,
4474+
0.1875,
4475+
0.1875,
4476+
0.1875,
44774477
0.0,
44784478
0.0,
44794479
1.75,
@@ -8251,16 +8251,16 @@
82518251
"uses_late_zs_update": false,
82528252
"variants": {
82538253
"Main": {
8254-
"fp16_arithmetic": 15,
8254+
"fp16_arithmetic": 33,
82558255
"has_stack_spilling": false,
82568256
"performance": {
82578257
"longest_path_bound_pipelines": [
82588258
"varying"
82598259
],
82608260
"longest_path_cycles": [
82618261
0.1875,
8262-
0.140625,
8263-
0.1875,
8262+
0.171875,
8263+
0.15625,
82648264
0.1875,
82658265
0.0,
82668266
1.75,
@@ -8280,8 +8280,8 @@
82808280
],
82818281
"shortest_path_cycles": [
82828282
0.1875,
8283-
0.125,
8284-
0.140625,
8283+
0.15625,
8284+
0.109375,
82858285
0.1875,
82868286
0.0,
82878287
1.75,
@@ -8292,8 +8292,8 @@
82928292
],
82938293
"total_cycles": [
82948294
0.1875,
8295-
0.140625,
8296-
0.1875,
8295+
0.171875,
8296+
0.15625,
82978297
0.1875,
82988298
0.0,
82998299
1.75,
@@ -8302,7 +8302,7 @@
83028302
},
83038303
"stack_spill_bytes": 0,
83048304
"thread_occupancy": 100,
8305-
"uniform_registers_used": 6,
8305+
"uniform_registers_used": 4,
83068306
"work_registers_used": 18
83078307
}
83088308
}

0 commit comments

Comments
 (0)