slight optimization

This commit is contained in:
Jorijn van der Graaf 2025-11-25 02:10:18 +01:00
commit 4793d6f26a
6 changed files with 39 additions and 25 deletions

View file

@ -20,6 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
module Crafter.Graphics:UiElementBufferBuffer_impl;
import :UiElement;
import :Window;
import std;
using namespace Crafter;
@ -30,4 +31,22 @@ UiElementBufferBuffer::UiElementBufferBuffer(std::int_fast32_t anchorX, std::int
UiElementBufferBuffer::UiElementBufferBuffer(std::uint_fast32_t width, std::uint_fast32_t height, std::int_fast32_t anchorX, std::int_fast32_t anchorY, std::uint_fast32_t relativeWidth, std::uint_fast32_t relativeHeight, std::int_fast32_t anchorOffsetX, std::int_fast32_t anchorOffsetY, std::int_fast32_t z, bool ignoreScaling) : UiElement(anchorX, anchorY, relativeWidth, relativeHeight, anchorOffsetX, anchorOffsetY, z, ignoreScaling), UiElementBufferBufferBase(width, height){
}
void UiElementBufferBuffer::UpdatePosition(WindowFramebuffer& window) {
window.ScaleElement(transform);
scaled.resize(transform.scaled.width*transform.scaled.height);
CopyNearestNeighbour(scaled.data(), transform.scaled.width, transform.scaled.height);
for(UiElement* child : children) {
child->UpdatePosition(window, *this);
}
}
void UiElementBufferBuffer::UpdatePosition(WindowFramebuffer& window, UiElement& parent) {
window.ScaleElement(transform, parent.transform);
scaled.resize(transform.scaled.width*transform.scaled.height);
CopyNearestNeighbour(scaled.data(),transform.scaled.width, transform.scaled.height);
for(UiElement* child : children) {
UpdatePosition(window, *child);
}
}