The Texture::draw() takes a DrawParams as a value. Which makes it impossible to reuse the DrawParams object.
Motivation/Examples
I was optimizing my program by reusing the same objects. I was able to reuse the Texture objects by calling the replace_data instead of creating a new object every frame. But I couldn't do the same for the DrawParams object because the draw method takes ownership of it. I also don't know the reason behind the use of generics in this case. Because I made a small change to code by eliminating the generics and accepting a reference instead of a value and it worked.
Summary
The Texture::draw() takes a DrawParams as a value. Which makes it impossible to reuse the DrawParams object.
Motivation/Examples
I was optimizing my program by reusing the same objects. I was able to reuse the Texture objects by calling the
replace_data
instead of creating a new object every frame. But I couldn't do the same for the DrawParams object because the draw method takes ownership of it. I also don't know the reason behind the use of generics in this case. Because I made a small change to code by eliminating the generics and accepting a reference instead of a value and it worked.My changes:
Textures::draw()
Canvas::draw()
Alternatives Considered
No response