-
Notifications
You must be signed in to change notification settings - Fork 2
Fix tiled BackgroundPainter performance #2
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
Conversation
Juuxel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Some notes, and see my individual review comments as well.
TextureRegionshould be left intact along with the methods that use it.- This change can be completely done without breaking changes and without removing functionality in the form of removing
- texture regions
- computing edge texture regions automatically based on a
cornerUvbuilder method
| /** Regions of the texture are tiled to fill areas. The default value. */ | ||
| /** | ||
| * Regions of the texture are tiled to fill areas. The default value. | ||
| */ | ||
| TILING, | ||
| /** Regions of the texture are stretched to fill areas. */ | ||
| /** | ||
| * Regions of the texture are stretched to fill areas. | ||
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Existing code should not be reformatted.
| T topLeft, T topCenter, T topRight, | ||
| T centerLeft, T centerCenter, T centerRight, | ||
| T bottomLeft, T bottomCenter, T bottomRight) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The edge and corner textures should be optional additions in the builder.
| private float cornerU = 0f; | ||
| private float cornerV = 0f; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This functionality should remain as a fallback option for when texture regions for the sides and corners are not specified manually.
| T centerLeft, T centerCenter, T centerRight, | ||
| T bottomLeft, T bottomCenter, T bottomRight) { | ||
| //noinspection unchecked | ||
| this.textures = (T[][]) Array.newInstance(textureClass, 3, 3); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Separate fields for all of them would be better, no need to have an array.
|
While I believe that the TextureRegion is a concept that should not be forced onto TextureRenderer implementations, I understand wanting to avoid breaking changes. I'll have a look what I can do tomorrow-ish. |
|
TextureRegion is not really forced onto TextureRenderer implementations since the methods using it are |
|
Alright, I did a re-design with preservation of TextureRegion in mind. One crucial aspect here is eliminating all NinePatch specific UV coordinates before rendering occurs. (Once this PR reaches a merge-ready state in your eyes, I'll update the LibGUI PR) |
Juuxel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks a lot better, but still:
- I'm not planning to commit breaking changes. LNP is also part of LibGui's API, which would mean this change would be at earliest for MC 1.20 snapshots.
@NotNullshould not be used, it's considered the default unless there's@Nullable- Type variables should not be upper camel case (
TextureType) since they can be confused with actual types - I believe removing the UV coordinates will not allow drawing partial side textures like this:

As I see it, there are two remaining options:
I believe that single letter generic types lack descriptiveness.
True, the above mentioned option 1 could resolve that. |
|
The partial side textures are definitely a feature that needs to be kept, otherwise the tiles will be stretched (so there's no point in tiling to begin with) or will bleed over past the corners. As for the generic naming, |
|
Any comment on which of the 3 options you prefer? |
|
I'm actually looking into the shader approach - a bit more work on the LibGui side but really simple on LNP's and doesn't require any breaking (or otherwise major) changes. Seems to also be more performant than the current approach just like yours. On the LNP side it's just the new I'll open PRs to both projects to show my changes if you want to have a look. |
|
Superseded by #3. |
Wombo Combo Pull Request LibGui PR
I'm sorry this is such a massive change, but there was no fixing this without a sledgehammer.
The essence of the changes is to allow the GPU to handle tiling, rather than doing it on the CPU.
Why I believe you should merge this:
I'll let the screenshot speak for itself.
Before:

After:
