-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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 missing Blend Modes and expose BlendMode on Image Control #17903
base: master
Are you sure you want to change the base?
Conversation
Can you add a render test? https://github.com/AvaloniaUI/Avalonia/blob/master/tests/Avalonia.RenderTests/Controls/ImageTests.cs |
|
@cla-avalonia agree |
Isn't this overconstrained to the Skia backend now? We really shouldn't design for Skia by itself. That's caused problems other places already. IMO this should be abstracted rather than passed through. |
Direct2D version for reference: https://learn.microsoft.com/en-us/windows/win32/direct2d/blend#blend-modes |
I'll see what I can do about D2D, since I used avalonia's Enum for setting the image blend mode, should be straight forward to enable it in D2D too, maybe. On another note, I see some tests failing, Is the way I did the options push correct? I tried other methods and none worked, I also don't see what I did anywhere else in the code, which worries me I'm doing something not the intended way. Please advise |
Fix image blendMode change not triggering a re-render
You can test this PR using the following package version. |
Composite mode is required to use Blend Modes in D2D, implementing this would fall out of what I'm capable of, I think. I'll try tomorrow but no promises. Any pointers would be helpful. |
Just make sure Avalonia's blend modes are covering options that are supported by major drawing libraries. Don't just map Skia 1:1 You do not have to implement the D2D part |
Well, I believe that what I added to the Avalonia Enum are the blend modes basically everybody supports, a few modifications I'd want to do:
I'd also consider separating them into 2 enums, composition (alpha operations) and blend (pre alpha-mult color operations) - Skia bundles them all together, but D2D has them separate However, separating them would be a breaking change, your call. Here's how the current enums map to each other: Composite modes:
Blend Modes
These last blend modes are variations of other blend modes, mostly never used |
You can test this PR using the following package version. |
What does the pull request do?
This PR adds a few missing Blend Modes to the Avalonia blend modes Enum, which enables them to be used in the context render options directly.
This PR also exposes the Blend Mode render option in the
Image
Control as a StyledPropertyRenderMode
What is the current behavior?
Currently the only way to access some blend modes is to use Skia API directly on a custom control, this PR greatly simplifies this.
What is the updated/expected behavior with this PR?
Now simply setting the
BlendMode
property on the Image control draws the image as expectedHow was the solution implemented (if it's not obvious)?
I Added a
PushRenderOptions
in theRender
method of the Image ControlChecklist
Fixed issues
Possibly Closes #17901 (if closing discussions from a PR is a thing)