Unfortunately, NewImageOp does need to make a copy, see
There are three reasons to make a copy, two important and
one less so:
First, the ImageOp.src field is used as a key in an image=>texture map to
quickly determine whether we can reuse an existing texture for an image. There
is no efficient way to know whether the user has mutated an image, which should
replace the cached texture.
Second, even if we somehow detected image mutations, letting the program use
the image contents while the GPU goroutine is accessing it leads to race
Third, and less importantly, sometimes the image contents is not in a GPU
friendly format and a copy is needed anyway.
That said, I might have missed a better design for efficient drawing of images.
Please let me know.
On Thu Nov 7, 2019 at 3:32 PM aarzilli wrote: