~zsombi/ubuntu-ui-toolkit/pleaseBottomEdgePreloadUrl

Viewing all changes in revision 2014.

[UbuntuShape] Use reference counting to handle shape textures.

The current shape textures handling system requires to search for the textures associated to the current graphics context by doing a search in an array for each item at each updatePaintNode() call. It also deletes the textures on OpenGLContext::aboutToBeDestroyed() signal emission, which appears in some cases to not have any OpenGL context bound.

We propose an alternative to create and destroy shape textures per material creation and destruction with a reference counting mechanism to minimise costly calls. We search for the shape textures (hash lookup with an OpenGL context pointer as the key) only when a texture material is created or deleted, which is much more occasional compared to updatePaintNode() calls. That also ensures textures are deleted with the proper OpenGL context bound.

The only drawback is that shape textures are deleted when there is no shape items anymore in a scene and recreated when there is a new one appearing. These operations being quite uncommon and relatively fast, the advantages seem to be higher than the drawbacks.

Approved by ubuntu-sdk-build-bot, Tim Peeters.

expand all expand all

Show diffs side-by-side

added added

removed removed

Lines of Context: