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

Conversation

@jonahwilliams
Copy link
Contributor

@jonahwilliams jonahwilliams commented Aug 29, 2022

Create a texture for linear/radial/sweep gradients. Currently the size of this texture is capped at 1024, which was arbitrarily chosen. At runtime we sample from this texture, which means for non-uniform stops we must compute the texture color lerping on the CPU

fixes flutter/flutter#109728

@flutter-dashboard flutter-dashboard bot changed the base branch from master to main August 29, 2022 17:18
@flutter-dashboard
Copy link

This pull request was opened against a branch other than main. Since Flutter pull requests should not normally be opened against branches other than main, I have changed the base to main. If this was intended, you may modify the base back to master. See the Release Process for information about how other branches get updated.

Reviewers: Use caution before merging pull requests to branches other than main, unless this is an intentional hotfix/cherrypick.

@jonahwilliams
Copy link
Contributor Author

Does sort of work. Need to research better ways to handle multiple stops

Impeller:

flutter_01

Skia:

flutter_02

@jonahwilliams

This comment was marked as off-topic.

@jonahwilliams jonahwilliams changed the title [Impeller] support N colors/stops on LinearGradient [Impeller] support many colors/stops on Linear/RadialGradient Aug 30, 2022
Comment on lines 63 to 64
auto gradient_snapshot =
gradient_generator_->RenderToSnapshot(renderer, placeholder);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we try to elide this if there are only two colors? This will mean we're always doing a RT switch even when we wouldn't otherwise need to, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added special two color versions. From some cursory searching in google3, almost all linear gradients are two color

@jonahwilliams

This comment was marked as outdated.

@jonahwilliams jonahwilliams changed the title [Impeller] support many colors/stops on Linear/RadialGradient [Impeller] support many colors/stops on Linear/Radial/SweepGradient Aug 30, 2022
@jonahwilliams

This comment was marked as outdated.

@jonahwilliams jonahwilliams marked this pull request as ready for review August 30, 2022 20:18
@jonahwilliams
Copy link
Contributor Author

This is hitting flutter/flutter#110800, but that repro's at ToT

@jonahwilliams jonahwilliams requested a review from bdero September 1, 2022 19:03
@jonahwilliams
Copy link
Contributor Author

Debugging in the wonders app, this may have some issues with certain stop values. Investigating

@jonahwilliams
Copy link
Contributor Author

and fixed .. classic off by one. The shimmer effect in the wonders app now functions as expected

Copy link
Contributor

@dnfield dnfield left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome. Nits about the include paths.


#include <algorithm>

#include "gradient_generator.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: impeller/renderer/gradient_generator.h

Comment on lines 10 to 11
#include "flutter/impeller/renderer/context.h"
#include "flutter/impeller/renderer/texture.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include "flutter/impeller/renderer/context.h"
#include "flutter/impeller/renderer/texture.h"
#include "impeller/renderer/context.h"
#include "impeller/renderer/texture.h"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(and elsewhere)

@jonahwilliams jonahwilliams added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 6, 2022
@auto-submit auto-submit bot merged commit 3af5d35 into flutter:main Sep 6, 2022
@jonahwilliams jonahwilliams deleted the multiple_stops branch September 6, 2022 20:02
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Sep 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App e: impeller

Projects

No open projects
Archived in project

Development

Successfully merging this pull request may close these issues.

[Impeller] Linear, Radial, and Sweep gradients only support two stops and only work on fills.

4 participants