Skip to content

TextureCache #209

@mitchmindtree

Description

@mitchmindtree

As discussed in #207 a TextureCache could be a good way of solving multiple problems in one hit, however it will take quite a bit of work and internal refactoring.

From #207:

At the moment the draw request is given to the Gl type directly in the .draw method uniquely for each rectangle/glyph. Rather than directly drawing, perhaps we should be building a single texture for each widget which we can then mask etc. This would also mean we could cache the texture and just continue to use the same texture for all widgets whose state does not change, saving a lot of processing while we're at it. I think this may also help us when it comes to dealing with the widget overlap issue (discussed a bit here #145).

Thoughts

  • Could be implemented as a Vec<Texture> (stored within the UiContext) where the len of the Vec is equal to the largest UIID
  • A widget's UIID is used as a key for retrieving/setting the associated texture.
  • If a widget's state has changed, construct a new Texture.
  • If a widget's state remains the same, simply use the pre-existing texture.

Benefits

  • Provide more control over the way in which widgets are drawn: i.e. clipping/masking. I don't have any experience with doing masking on textures but I'm just assuming that having a widget's view in the form of a texture will make it much easier than our current setup! It may also help us to resolve widget positioning conflicts Defer rendering of widgets in order to resolve drawing conflicts. #145
  • A significant improvement in performance as textures need only be updated when a widget is interacted with meaning in most cases only a single widget's texture will be updating at any point in time.

This will be a significant change and will require refactoring of all widgets.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions