SkiaSharp
SkiaSharp copied to clipboard
Add RuntimeShader Support.
Description of Change
Add RuntimeShader support. See https://github.com/mono/SkiaSharp/issues/3137.
Bugs Fixed
None.
API Changes
Added:
SKImageFilter SKImageFilter.CreateRuntimeShader(SKRuntimeShaderBuilder builder, string childShaderName, SKImageFilter? input)SKImageFilter SKImageFilter.CreateRuntimeShader (SKRuntimeShaderBuilder builder, float maxSampleRadius, string childShaderName, SKImageFilter? input)SKImageFilter SKImageFilter.CreateRuntimeShader (SKRuntimeShaderBuilder builder, float maxSampleRadius, string[] childShaderNames, SKImageFilter?[] inputs)SKRuntimeEffectUniforms (SKRuntimeEffectUniforms effectUniforms)SKRuntimeEffectChildren (SKRuntimeEffectChildren effectChildren)SKRuntimeEffectBuilder (SKRuntimeEffectBuilder builder)SKRuntimeShaderBuilder (SKRuntimeShaderBuilder builder)
Behavioral Changes
None.
Required skia PR
https://github.com/mono/skia/pull/145
PR Checklist
- [ ] Has tests (if omitted, state reason in description)
- [ ] Rebased on top of main at time of PR
- [ ] Merged related skia PRs
- [ ] Changes adhere to coding standard
- [ ] Updated documentation
@dotnet-policy-service agree
Here is a demo. https://github.com/kkwpsv/AvaloniaSkiaRuntimeShaderDemo
I wonder if instead of putting the code in SKImageFilter, we rather add a SKRuntimeImageFilterBuilder and in fact mirror most of what we do for SKShader but instead of using the word shader like in C++ we use the word ImageFilter. I would even go so far as to add a
CreateImageFiltermethod that just calls intoCreateShader. And then also make aBuildImageFilterthat then calls that - which would mean it really is just a shader. TheBuild()method on this would then call the image filter code in the C API and return a newSKImageFilter
I think there is no problem with your idea. What I am doing now is just to make the API close to C++.
@kkwpsv are you able to make the changes?
Need any help? This all sounds very exciting!
Any updates? I tried the example repo, curious if it could handle the Balatro background effect shader.
https://github.com/kkwpsv/AvaloniaSkiaRuntimeShaderDemo/pull/1
Works super well :)