-
Notifications
You must be signed in to change notification settings - Fork 6k
Implement Gradient Shaders and Fragment Shaders in Skwasm #41144
Conversation
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.
LGTM with some nits
Pointer<Float> convertDoublesToNative(Iterable<double> values) { | ||
final Pointer<Float> pointer = allocFloatArray(values.length); | ||
int i = 0; | ||
for (final double value in values) { | ||
pointer[i] = value; | ||
i++; | ||
} | ||
return pointer; | ||
} | ||
|
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.
Pointer<Float> convertDoublesToNative(Iterable<double> values) { | |
final Pointer<Float> pointer = allocFloatArray(values.length); | |
int i = 0; | |
for (final double value in values) { | |
pointer[i] = value; | |
i++; | |
} | |
return pointer; | |
} | |
Pointer<Float> convertDoublesToNative(List<double> values) { | |
final Pointer<Float> pointer = allocFloatArray(values.length); | |
for (int i = 0; i < values.length; i++) { | |
pointer[i] = value; | |
} | |
return pointer; | |
} | |
int i = 0; | ||
for (final SkwasmShader shader in _childShaders!) { | ||
childShaders[i] = shader.handle; | ||
i++; | ||
} | ||
} |
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.
here and elsewhere, this pattern seems like the worst of both worlds - you still have all the bookkeeping of a for loop, but with no syntax help. And all the overhead of a for-of loop
Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change). If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review. |
This implements gradient shaders (linear, radial, conical, and sweep) as well as custom fragment shaders in Skwasm.
Something is still up with the ShaderMask layer though, it doesn't quite render correctly on Skwasm.
Edit: fixed and it's rendering consistently with CanvasKit now.