proposed fix: set curr_src.h to bottom_height before drawing bottom edges / corners in SDL_RenderTexture9Grid #12118
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
(...in order to avoid issue where inadvertently using top height, if the npatch existed on a larger texture than the drawn edge, would cause too many pixels to be included in the bottom part of the render.)
Description
There is a bug currently with
SDL_RenderTexture9Grid
, its hard to notice.Two (2) conditions are needed to trigger, that I noticed.
a) The 9Grid texture is larger in height than the full size of the 9Grid, for example, if there is empty space bellow due to the 9Grid being stored on a spritesheet (streaming texture in minimal reproduce provided).
b) The 9Grid texture has different top and bottom margins.
Then when drawing the 9Grid,
top_height
was inadvertently used ascurr_src.h
when drawinglower_left
andlower_right
, as well as bottom of the 9Grid, causing either extra pixels to be drawn (resulting in squished bottom part of the 9Grid) or cropped (haven't tested that second case).curr_src.h
should have been set tobottom_height
before these operations. If the 9Grid is stored on a perfectly sized texture, andtop_height> bottom_height
, then even if the issue was technically occuring, it wasn't having any visual impact due to the texture naturally "ending" when problem should arise...Anyway, hope I make myself clear. The fix is pretty simple.
This is a minimal example which demonstrates the problem:
https://pastecode.io/s/pi5qo9o1
I used a 50x50 image with margins L=10, R=10, T=14, B=10, placed on a larger 100x100 sheet, which demonstrates the problem.
Image if you want to test it :