Use bitmap skin for video preview #2292
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves
What Github issue does this resolve (please include link)?
Resolves scratchfoundation/scratch-gui#4888
Proposed Changes
Describe what this Pull Request does
Use the BitmapSkin type for the video layer instead of the PenSkin, because the PenSkin cannot have the ghost effect applied to it due to using premultiplied alpha blending modes.
This is the solution I wanted to implement #2291, but was concerned with the performance of silhouette updates. I was concerned that the bitmap skin was too slow to update because updating the silhouette required a slow canvas -> ImageData conversion. After more digging, it turns out, we are actually already doing that conversion in the video motion extension in a similarly timed loop, and so we can take advantage of the caching mechanism in the VideoProvider and request the cached ImageData. sometimes the extension loop freshens the cache, sometimes this preview updater loop does, but either way it only gets done once every 30ms, which is as good as we are going to get performance-wise since the extension requires ImageData for computation.
So no fancy silhouette deferral is needed! Although i did look into that also... we can talk about framebuffers later... @cwillisf
Reason for Changes
Explain why these changes should be made
We were using private APIs, and public APIs in unexpected ways, to get the result we wanted from the renderer. Now just use the public APIs in totally expected ways. :)
Test Coverage
Please show how you have added tests to cover your changes
To test manually, add the video extension and see how adjusting the transparency displays correct colors. Turning transparency up to 100 should make you completely disappear.