Repository navigation
Fixes for texture-backed gradients - #191925
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the linear sampling interval check in the GLSL shader for decal mode to use a closed interval [0, 1] and refactors gradient texture size calculation in gradient.cc to limit texture sizes using a maximum threshold of 1024. Feedback on the changes points out a critical issue in gradient.cc where removing updates to next_color and next_stop when advancing the stop interval can lead to an infinite loop.
Contributor
|
autosubmit label was removed for flutter/flutter/191925, because - The status or check suite Dashboard Checks has failed. Please fix the issues identified (or deflake) before re-applying this label. |
Contributor
Author
|
PTAL: malioc |
Contributor
Author
@gaaclarke ping |
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Aug 29, 2026
This was referenced Aug 29, 2026
auto-submit Bot
pushed a commit
to flutter/packages
that referenced
this pull request
Aug 30, 2026
flutter/flutter@8d8c1aa...c978386 2026-08-30 [email protected] Roll Skia from ce359c7fbfe6 to 588b550a4dd8 (1 revision) (flutter/flutter#192040) 2026-08-30 [email protected] Roll Skia from 3ae8e3d1e335 to ce359c7fbfe6 (1 revision) (flutter/flutter#192037) 2026-08-30 [email protected] Roll Fuchsia Linux SDK from J123CwfDPYyVDpkMl... to o9DikEfRoFyVK3LKD... (flutter/flutter#192031) 2026-08-29 [email protected] Make the AbsorbPointer sample show the difference from IgnorePointer (flutter/flutter#188940) 2026-08-29 [email protected] Roll Dart SDK from 391ff83cd1d3 to 76abdf94faa8 (1 revision) (flutter/flutter#192021) 2026-08-29 [email protected] Roll Skia from b392fb672d13 to 3ae8e3d1e335 (1 revision) (flutter/flutter#192020) 2026-08-29 [email protected] Roll Skia from 0b4249b26b38 to b392fb672d13 (6 revisions) (flutter/flutter#192016) 2026-08-29 [email protected] Fixes for texture-backed gradients (flutter/flutter#191925) 2026-08-29 [email protected] Roll Dart SDK from ae63a6eca3f1 to 391ff83cd1d3 (3 revisions) (flutter/flutter#192010) 2026-08-29 [email protected] Fix Android license detection for cmdline-tools 23.0+ (flutter/flutter#191554) 2026-08-29 [email protected] [flutter_tools] Pause web server requests until initial compilation finishes (flutter/flutter#191990) 2026-08-28 [email protected] fix(workflow): Mac Verify Binaries needs `Linux mac_android_aot_engine` (flutter/flutter#191999) 2026-08-28 [email protected] Roll Fuchsia Linux SDK from dDxH8G5cDBP602eyG... to J123CwfDPYyVDpkMl... (flutter/flutter#191984) 2026-08-28 [email protected] Update scheduled workflow for more tasks, add goldctl update (flutter/flutter#191991) 2026-08-28 [email protected] Update no-main-prs to leave a comment (flutter/flutter#191973) 2026-08-28 [email protected] [AGP 9.1.0 Migration #4] Replace plugin build-type copy with initWith on public DSL (flutter/flutter#191606) 2026-08-28 [email protected] Roll Skia from fe0b9a5261f9 to 0b4249b26b38 (1 revision) (flutter/flutter#191974) 2026-08-28 [email protected] [UIScene] Migrate dev/benchmarks/macrobenchmarks to UIScene lifecycle (flutter/flutter#191648) 2026-08-28 [email protected] Uiscene migrate remaining apps (flutter/flutter#191652) 2026-08-28 [email protected] [tool] Migrate SymbolizeCommand to modular dependency injection (flutter/flutter#190744) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
11 tasks
pull Bot
pushed a commit
to mikeyhodl/flutter
that referenced
this pull request
Sep 3, 2026
flutter#192124) This re-implements flutter#190874, after landing: flutter#191925 - Separated out some of the fixes from the original PR flutter#191980 - Add support for wide gamut colors. This re-implements the rest of the original PR. This is the same exact code as the original PR, minus the changes that have already been merged in flutter#191925. Verified locally that the wide gamut test passes. Related: flutter#190401 Original PR description: ---- Adds direct support for linear and radial gradient color sources to UberSDF, enabling single-pass rendering of these gradients without the multi-pass blending that is currently used. - Adds a color_source_sampler input to UberSDF, which is used to sample a texture representing the gradient color ramp for a linear or radial gradient. This sampler may also be extended in the future for image-based color sources, but that is outside the scope of this PR. - Adds properties to UberSDFParameters and to UberSDF's FragInfo for specifying gradient properties. - Factors out code in `linear_gradient_fill.frag` and `radial_gradient_fill.frag` that samples a texture to get a color for linear and radial gradients. This logic is moved to functions in `gradient.glsl`, to share with `uber_sdf.frag`. - Updates `Canvas::AddRenderSDFEntityToCurrentPass` to fill in the gradient texture and gradient related properties when `paint.color_source` is a gradient supported by UberSDF. This supports only linear and radial gradients. It does not support conical and sweep gradients. According to Gemini, linear and radial gradients make up more than 99% of gradient usage. Supporting conical and sweep gradients would require additional complexity to UberSDF, so it may not be worth it. We can revisit optimizing these other gradients in the future if we see performance related to them in real world use cases. This change by itself speeds up gradient rendering significantly, according to the results below. This can be further improved in a follow up PR by adding caching for gradient textures, similar to TextShadowCache in ContentContext. Addresses flutter#190401. Results from the demo app in flutter#190401, run on my Windows VM. Note that my Windows VM may not necessarily reflect real-world performance, but these numbers still show significant improvements with this PR. Also, my Windows VM reports a refresh rate of 500 hz, so almost all frame render times are considered "over budget". So ignore the "over budget" percentages and just look at the raw timing numbers. before: ``` === Windows linear-gradient comparison === mode=profile speed=1400px/s Solid color | frames=953 fps=238.00 | ui p50/p95=0.669/1.231ms | raster p50/p90/p95/p99/max=4.131/5.154/5.519/6.192/6.830ms | raster_over_budget=949/953 (99.6%) Linear gradient | frames=204 fps=50.75 | ui p50/p95=1.231/1.658ms | raster p50/p90/p95/p99/max=19.094/23.040/23.982/26.812/32.019ms | raster_over_budget=204/204 (100.0%) ================================================ ``` after: ``` === Windows linear-gradient comparison === mode=profile speed=1400px/s Solid color | frames=833 fps=208.00 | ui p50/p95=0.635/1.033ms | raster p50/p90/p95/p99/max=4.752/5.570/5.732/6.134/7.504ms | raster_over_budget=833/833 (100.0%) Linear gradient | frames=687 fps=171.50 | ui p50/p95=1.187/1.804ms | raster p50/p90/p95/p99/max=5.665/7.414/7.925/8.951/12.153ms | raster_over_budget=687/687 (100.0%) ================================================ ``` Skia: ``` === Windows linear-gradient comparison === mode=profile speed=1400px/s Solid color | frames=1375 fps=343.50 | ui p50/p95=0.495/0.845ms | raster p50/p90/p95/p99/max=2.679/3.514/3.851/4.631/5.777ms | raster_over_budget=1160/1375 (84.4%) Linear gradient | frames=1234 fps=308.25 | ui p50/p95=1.087/1.645ms | raster p50/p90/p95/p99/max=1.731/2.251/2.445/2.960/3.903ms | raster_over_budget=319/1234 (25.9%) ================================================ ``` ---- ## Pre-launch Checklist - [ ] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [ ] I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools. - [ ] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [ ] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [ ] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [ ] I updated/added relevant in-code documentation (doc comments with `///`). - [ ] If this PR introduces a new feature or capability, I created and linked a website documentation issue or PR in [flutter/website] (or verified none is needed). - [ ] I added new tests to check the change I am making, or this PR is [test-exempt]. - [ ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [ ] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [AI contribution guidelines]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines [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 [flutter/website]: https://github.com/flutter/website [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
victorsanni
pushed a commit
to victorsanni/packages
that referenced
this pull request
Sep 9, 2026
…r#12693) flutter/flutter@8d8c1aa...c978386 2026-08-30 [email protected] Roll Skia from ce359c7fbfe6 to 588b550a4dd8 (1 revision) (flutter/flutter#192040) 2026-08-30 [email protected] Roll Skia from 3ae8e3d1e335 to ce359c7fbfe6 (1 revision) (flutter/flutter#192037) 2026-08-30 [email protected] Roll Fuchsia Linux SDK from J123CwfDPYyVDpkMl... to o9DikEfRoFyVK3LKD... (flutter/flutter#192031) 2026-08-29 [email protected] Make the AbsorbPointer sample show the difference from IgnorePointer (flutter/flutter#188940) 2026-08-29 [email protected] Roll Dart SDK from 391ff83cd1d3 to 76abdf94faa8 (1 revision) (flutter/flutter#192021) 2026-08-29 [email protected] Roll Skia from b392fb672d13 to 3ae8e3d1e335 (1 revision) (flutter/flutter#192020) 2026-08-29 [email protected] Roll Skia from 0b4249b26b38 to b392fb672d13 (6 revisions) (flutter/flutter#192016) 2026-08-29 [email protected] Fixes for texture-backed gradients (flutter/flutter#191925) 2026-08-29 [email protected] Roll Dart SDK from ae63a6eca3f1 to 391ff83cd1d3 (3 revisions) (flutter/flutter#192010) 2026-08-29 [email protected] Fix Android license detection for cmdline-tools 23.0+ (flutter/flutter#191554) 2026-08-29 [email protected] [flutter_tools] Pause web server requests until initial compilation finishes (flutter/flutter#191990) 2026-08-28 [email protected] fix(workflow): Mac Verify Binaries needs `Linux mac_android_aot_engine` (flutter/flutter#191999) 2026-08-28 [email protected] Roll Fuchsia Linux SDK from dDxH8G5cDBP602eyG... to J123CwfDPYyVDpkMl... (flutter/flutter#191984) 2026-08-28 [email protected] Update scheduled workflow for more tasks, add goldctl update (flutter/flutter#191991) 2026-08-28 [email protected] Update no-main-prs to leave a comment (flutter/flutter#191973) 2026-08-28 [email protected] [AGP 9.1.0 Migration flutter#4] Replace plugin build-type copy with initWith on public DSL (flutter/flutter#191606) 2026-08-28 [email protected] Roll Skia from fe0b9a5261f9 to 0b4249b26b38 (1 revision) (flutter/flutter#191974) 2026-08-28 [email protected] [UIScene] Migrate dev/benchmarks/macrobenchmarks to UIScene lifecycle (flutter/flutter#191648) 2026-08-28 [email protected] Uiscene migrate remaining apps (flutter/flutter#191652) 2026-08-28 [email protected] [tool] Migrate SymbolizeCommand to modular dependency injection (flutter/flutter#190744) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
victorsanni
pushed a commit
to victorsanni/packages
that referenced
this pull request
Sep 9, 2026
…r#12693) flutter/flutter@8d8c1aa...c978386 2026-08-30 [email protected] Roll Skia from ce359c7fbfe6 to 588b550a4dd8 (1 revision) (flutter/flutter#192040) 2026-08-30 [email protected] Roll Skia from 3ae8e3d1e335 to ce359c7fbfe6 (1 revision) (flutter/flutter#192037) 2026-08-30 [email protected] Roll Fuchsia Linux SDK from J123CwfDPYyVDpkMl... to o9DikEfRoFyVK3LKD... (flutter/flutter#192031) 2026-08-29 [email protected] Make the AbsorbPointer sample show the difference from IgnorePointer (flutter/flutter#188940) 2026-08-29 [email protected] Roll Dart SDK from 391ff83cd1d3 to 76abdf94faa8 (1 revision) (flutter/flutter#192021) 2026-08-29 [email protected] Roll Skia from b392fb672d13 to 3ae8e3d1e335 (1 revision) (flutter/flutter#192020) 2026-08-29 [email protected] Roll Skia from 0b4249b26b38 to b392fb672d13 (6 revisions) (flutter/flutter#192016) 2026-08-29 [email protected] Fixes for texture-backed gradients (flutter/flutter#191925) 2026-08-29 [email protected] Roll Dart SDK from ae63a6eca3f1 to 391ff83cd1d3 (3 revisions) (flutter/flutter#192010) 2026-08-29 [email protected] Fix Android license detection for cmdline-tools 23.0+ (flutter/flutter#191554) 2026-08-29 [email protected] [flutter_tools] Pause web server requests until initial compilation finishes (flutter/flutter#191990) 2026-08-28 [email protected] fix(workflow): Mac Verify Binaries needs `Linux mac_android_aot_engine` (flutter/flutter#191999) 2026-08-28 [email protected] Roll Fuchsia Linux SDK from dDxH8G5cDBP602eyG... to J123CwfDPYyVDpkMl... (flutter/flutter#191984) 2026-08-28 [email protected] Update scheduled workflow for more tasks, add goldctl update (flutter/flutter#191991) 2026-08-28 [email protected] Update no-main-prs to leave a comment (flutter/flutter#191973) 2026-08-28 [email protected] [AGP 9.1.0 Migration flutter#4] Replace plugin build-type copy with initWith on public DSL (flutter/flutter#191606) 2026-08-28 [email protected] Roll Skia from fe0b9a5261f9 to 0b4249b26b38 (1 revision) (flutter/flutter#191974) 2026-08-28 [email protected] [UIScene] Migrate dev/benchmarks/macrobenchmarks to UIScene lifecycle (flutter/flutter#191648) 2026-08-28 [email protected] Uiscene migrate remaining apps (flutter/flutter#191652) 2026-08-28 [email protected] [tool] Migrate SymbolizeCommand to modular dependency injection (flutter/flutter#190744) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
RickyvdBerg
added a commit
to avio-os/avio-flutter
that referenced
this pull request
Oct 2, 2026
…lutter#192124, flutter#192962) UberSDF in this fork cannot shade a color source, so every antialiased gradient rect, rrect, oval or circle (Avio's Shell and greeter run with use_sdfs) was blended through a white SDF mask: two snapshots and a blend target per draw, plus a deferred coverage pass in externalLinearBackdrop mode. Upstream fixed this in the owning layer: fdb1d09 (flutter#192124) shades linear and radial gradients inside UberSDF and 419f9dd (flutter#192962) adds the storage-buffer variant used on Vulkan, so no ramp texture is made per draw. Both upstream commits sit on intermediate UberSDF changes this fork does not carry (uniform reordering, rect-path derivatives, stroke pixel size, which would change other SDF output), and Avio's UberSDF carries patch 45's coverage fields, so this is an adapted backport in one commit, not literal cherry-picks: - uber_sdf.frag is split into uber_sdf_common.glsl (shape SDFs, getColor, main) plus uber_sdf.frag (ramp texture) and uber_sdf_ssbo.frag (gradient stops in a storage buffer, the same math as the SSBO gradient shaders). Wherever the backend supports SSBOs (Vulkan), every UberSDF draw uses the SSBO variant, as upstream does. - UberSDFParameters gains GradientParameters; UberSDFContents renders both variants from one FragInfo setup; color filters wrap on the GPU for a gradient, and a gradient is never a background color. - Canvas::AddRenderSDFEntityToCurrentPass shades a linear or radial gradient whose local matrix (with the inverse shape transform) is a similarity. Conical and sweep gradients, images and runtime effects keep the masked kSrcIn path patch 52 slims. Patch 52's no-mask rect still comes first. - A gradient shaded in UberSDF takes the coverage transfer in the shader; defer_coverage no longer includes the color source in that case. Avio deltas against upstream (decision D3, accepted on the condition that Avio's crisp look stays): - Edges keep the old response: a gradient's SDF alpha uses the light-foreground gamma correction of the white mask it was blended through before, not the gradient's luma; the SSBO variant dithers like the SSBO gradient shaders, and like the masked composite it dithers the gradient color before coverage scales it, so a pixel the shape does not cover (the AA band's outside, the quad corners around a rounded shape) stays exactly transparent and srcOver adds nothing to what lies underneath. Upstream does not dither in UberSDF. - Linear gradients also require a similarity matrix (upstream checks only affinity); mapping end points through a shear or non-uniform scale does not map the gradient's field. - flutter#191925 and flutter#191980 are not brought in: the ramp-texture variant uses the fork's current GradientData, and Avio's SDF users take the SSBO variant. - malioc.json is not updated. Nothing else on the branch depends on this commit; its tests use patch 52's Playground::EnsureContextUsesSDFs. Reverting it alone restores the masked path exactly. Tests: - UberSDFContentsTest.ApplyColorFilterWithGradient and AsBackgroundColorGradientReturnsNullopt (from upstream; red as compile failures on the base: GradientParameters did not exist). - On every playground that renders with SDFs (Playground:: EnsureContextUsesSDFs: Vulkan with SDFs enabled, which runs the storage-buffer variant Avio ships, and the OpenGL ES and Metal SDF backends, which run the ramp-texture variant; plain backends skip): AiksTest.SdfLinearGradientRectAllocatesNoOffscreen (expected red on the base: three offscreens), SdfRadialGradientCircleUnderNonUniformScale- AllocatesNoOffscreen, UnsupportedColorSourceStillBlends (a sweep gradient keeps exactly three offscreens), and SdfGradientEdgesMatchMaskedComposite: the pixel guard the user asked for. It renders rect, rounded rect, oval and circle with an opaque dark-to-light gradient and a translucent glass sheen, in platformDefault and externalLinearBackdrop, once shaded in UberSDF and once through the old masked composite (the same horizontal gradient with a y-scale local matrix, which leaves its field unchanged but routes it through the masked path). Every pixel, corners and antialiased edges included, must hold alpha within 2/255 and color within 2/255 (ramp texture, no dither) or 5/255 (storage buffer: the composite dithered in its snapshot's grid, then quantized once more); every pixel the composite leaves fully transparent must stay exactly zero. Green by construction on the base (both renders take the masked path there); after this patch it fails if edges, corners, glass coverage or uncovered pixels drift. - SdfGradientLeavesUncoveredQuadPixelsTransparent: the quad corners around a gradient circle are exactly zero in both coverage modes, opaque and glass. Red on the storage-buffer variant if the dither runs after coverage. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two fixes for texture-backed gradients:
Related: #190401
This re-implements part of #190874. That PR was reverted because it didn't handle wide gamut colors properly. I will re-implement a fixed version of it in multiple parts. In the original reviews for that PR, it was suggested that these self-contained gradient fixes could be put in their own separate PR. Now that the PR is reverted, we get our chance to put these fixes in their own PR.
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.