[Optimization/Feature] Add ColorRectAndBorderTexture for combined rendering#111
[Optimization/Feature] Add ColorRectAndBorderTexture for combined rendering#111DeusSixik wants to merge 2 commits intoLow-Drag-MC:1.20.1from
ColorRectAndBorderTexture for combined rendering#111Conversation
|
So I'm wondering if this is really necessary. Why would you need to use a color rect in the middle? Why not just stretch a single pixel of across the entire middle, or if you edges are longer, just fill it with the desired color. Right now it feels like something either unnecessary, or something very specific to your project, that's not good justification to add it to the base mod. If your writing your project in (kube)JS or Java, you can make this feature your self. |
|
Thanks for the review and the valid questions! Let me clarify the motivation behind this PR, as I realize my initial description overemphasized the array allocation issue. 1. Why not just stretch a single pixel? (The procedural aspect)I completely agree that for sharp, rectangular boxes, stretching a 1x1 pixel is the best approach. However, this PR specifically targets procedural rounded corners. In modern UI design, a rounded panel with a background fill and a distinctly colored border stroke is a fundamental primitive (essentially standard CSS). 2. The real performance benefit: GPU Draw Calls, not GCYou are absolutely right about the array allocation - if the UI is properly cached during 3. Scope (Core vs Project-specific)I proposed this to the base mod because "Background + Border + Border Radius" is a universally standard UI component, not something specific to my project's business logic. It felt like a natural missing piece in the That being said, if you feel this feature is redundant or bloats the core library's scope, I completely understand! I can easily implement it as a custom |
|
Alright, I see now. I was not actually aware that you could do rounded corners in the ColorBoarderTexture! |
Problem:
Currently, rendering a standard UI panel with both a solid background and a border requires allocating and processing two separate textures (
ColorRectTextureandColorBorderTexture). This forces developers to useIGuiTexture[]arrays, creating unnecessary object allocations and adding overhead to the UI rendering hot path.Solution:
Introduced
ColorRectAndBorderTexture- a singleIGuiTextureimplementation that handles both the background fill and the border stroke in one pass.P.s. I might have made an incorrect translation into Chinese, so please check it for accuracy.