-
Notifications
You must be signed in to change notification settings - Fork 561
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 RuntimeShader Support. #3141
base: main
Are you sure you want to change the base?
Conversation
@dotnet-policy-service agree |
Here is a demo. |
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.
Thanks for this PR. This looks like a good feature to get in. Sorry about the long wait for a review @kkwpsv. 😞
I know the C++ API has this different way to make the "shader", but it always felt a bit odd to have this in sort of separate locations when the Shader, Blender and ColorFilter were all in SKRuntimeEffect.
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 CreateImageFilter
method that just calls into CreateShader
. And then also make a BuildImageFilter
that then calls that - which would mean it really is just a shader. The Build()
method on this would then call the image filter code in the C API and return a new SKImageFilter
They dropped the different builders in C++, so we might avoid exposing this at all in the C API: https://github.com/google/skia/blob/main/include/effects/SkImageFilters.h#L458. I would think we could rather do what we did for all the others and just pass the values all in as args:
sk_shader_t* sk_runtimeeffect_make_shader(sk_runtimeeffect_t* effect, sk_data_t* uniforms, sk_flattenable_t** children, size_t childCount, const sk_matrix_t* localMatrix)
They have this PR where they removed the builders and just have the base one: google/skia@0b776ce. I don't think we should do that as the separate builders are OK and also allow for a more fluent style code. But, that is also up for discussion.
Let me know what you think about these ideas!
I think there is no problem with your idea. |
@kkwpsv are you able to make the changes? |
Description of Change
Add RuntimeShader support.
See #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
mono/skia#145
PR Checklist