ruffle
ruffle copied to clipboard
avm2: Implement `BitmapData.draw` for `wgpu` backend
This method requires us to have the ability to render directly to a
texture. Fortunately, the wgpu backend already supports this in
the form of TextureTarget. However, the rendering code required
some refactoring in order to avoid creating duplicate wgpu resources.
The current implementation blocks on copying the pixels back
from the GPU to the CPU, so that we can immediately set them in
the Ruffle BitmapData. This is likely very inefficient, but will
work for a first implementation.
In the future, we could explore allowing the CPU image data and GPU
texture to be out of sync, and only synchronized when explicitly
necessary (e.g. on getPixel or setPixel calls).