Render from tree of primitives
bvssvni opened this issue · 2 comments
See @mitchmindtree's comment PistonDevelopers/conrod#830 (comment)
The idea is to render primitives from a tree structure. This means passing around GraphicsTree
instead of G: Graphics
. The benefit of this approach is that widgets can cache their representation.
Some ideas:
- Draw state can be checked for changes and remove duplicates to reduce memory usage
- Provide a helper function for triangulation (used by simple graphics backends)
Easier way to deal with textures
One idea is to wrap RgbaImage
in a type that keeps track of when the image changes. This means you do not have to use two objects to draw images, and you can modify the pixels directly to update the image.
Could use Arc<RwLock>
. The backend uses an id to identify the texture. Before the texture is created, it is set to None
. When rendering, the backend checks whether it needs to create the texture, and sets the id to Some(<id>)
. Next time, the backend can check for id and look up the texture.
The backend keeps an extra copy of the smart pointers, and releases the memory of those who only have one reference.
To keep backward compatibility, we could implement this as a new create "piston2d-graphics_tree". This way we can keep existing code from breaking, and we can test the designs side by side.
Here are some ideas:
GraphicsTree
implementsGraphics
, so it can be used with existing codeTextureBuffer
keeps track of textures by creating and updating fromRgbaImage
wrapperGraphicsTree
can render to anyGraphics
backend using a matchingTextureBuffer
objectGraphicsTree
reorders non-overlapping commands to improve performance in Conrod- Use RustType for font rendering
Created https://github.com/PistonDevelopers/graphics_tree.
We will continue development on the new repo.
Closing.