Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batching - Protection against zero and small sized ninepatches #44340

Merged
merged 1 commit into from
Dec 20, 2020

Conversation

lawnjelly
Copy link
Member

Although the minimum size of ninepatches is set to the sum of the margins in normal use (through gdscript etc) it turns out that it is possible to programmatically create ninepatches that are small than this minimum - in particular zero size is used in sliders to not draw items.

This PR deals with zero sized ninepatches by not drawing anything, and has some basic protection for ninepatches smaller than the margins. Whether these occur in the wild is not clear but is put in for completeness.

Fixes @oeleo1's slider issue in #42899

Notes

  • Although it is good putting these in for protection, it would be more efficient for sliders (and other items) not wishing to draw themselves, to not issue draw commands, rather than set ninepatch size to zero.
  • On the other hand it may be that it makes the UI code simpler doing it like this, and this may outweigh efficiency concerns in the rendering. I haven't examined the UI code.

Although the minimum size of ninepatches is set to the sum of the margins in normal use (through gdscript etc) it turns out that it is possible to programmatically create ninepatches that are small than this minimum - in particular zero size is used in sliders to not draw items.

This PR deals with zero sized ninepatches by not drawing anything, and has some basic protection for ninepatches smaller than the margins. Whether these occur in the wild is not clear but is put in for completeness.
@akien-mga akien-mga merged commit 542acc8 into godotengine:3.2 Dec 20, 2020
@akien-mga
Copy link
Member

Thanks!

@lawnjelly lawnjelly deleted the ninepatch_zerosize branch December 20, 2020 19:01
@akien-mga akien-mga modified the milestones: 3.2, 3.3 Apr 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants