-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add IConicGradientBrush and a drawing implemention for Skia. #4745
Add IConicGradientBrush and a drawing implemention for Skia. #4745
Conversation
I've refactored to name the brush ConicGradient to match the CSS name, and to default to angle 0 as being 12 on the clockface, again like CSS. |
I've looked at how to implement this for Direct2D but it's not a simple thing, the Mozilla Direct2D renderer has an implementation that uses a pixel shader which might be usable? I'm unsure of how to make this work. |
You could disable the test for the Direct2D1 backend. Still, it should not crash when the brush is being used in combination with the Direct2D1 backend. You can use a fallback for the Direct2D1 backend. |
I've added a D2D rendering implementation which is just a copy of the RadialGradientImpl - not sure how else to do this? |
…on for Direct2D using SolidColorBrushImpl.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Sorry for the delay.
Add render tests and expected results graphics.
What does the pull request do?
Currently supported gradient brushes are Linear and Radial. Skia and CSS both have support for so called Conic Gradient (CSS) and Sweep Gradient (Skia).
This type of gradient has equal colours for each angle around the center point - whereas a radial gradient has equal colours for each distance from the centerpoint - an example graphic can be seen here: https://css-tricks.com/snippets/css/css-conic-gradient/.
What is the updated/expected behavior with this PR?
This PR adds
ISweepGradientIConicGradient and a Skia drawing implementation.I have added rendering tests with expected results.
How was the solution implemented (if it's not obvious)?
The implementation closely matches existing gradient implementations. It passes through rendering straight to Skia via SKShader.
I added an additional property for Angle which allows you to set the angle that the gradient should start at, in Skia this is achieved via a rotation matrix.
I chose to specify the angle in degrees rather than radians, and I chose the default rotation value of 0 to conform to the Skia standard of the gradient stop at offset 0 runs horizontally from the center point to the right hand side. In CSS the default is for the first gradient stop to be vertical.I chose to specify the angle in degrees rather than radians, and I chose the default rotation value of 0 to conform to the CSS standard of the gradient stop at offset 0 runs vertically from the center point.
Checklist