selective clearing

This commit is contained in:
Jorijn van der Graaf 2025-11-26 18:48:58 +01:00
commit 9bb36c990d
7 changed files with 98 additions and 30 deletions

View file

@ -59,24 +59,36 @@ RenderingElementScaling::RenderingElementScaling(bool opaque, std::uint_fast32_t
void RenderingElementPreScaled::UpdatePosition(Window& window) {
std::uint_fast32_t oldWidth = scaled.width;
std::uint_fast32_t oldHeight = scaled.height;
ScaleData oldScale = scaled;
window.ScaleElement(*this);
if(oldWidth != scaled.width || oldHeight && scaled.height) {
if(oldScale.width != scaled.width || oldScale.height != scaled.height) {
bufferScaled.resize(scaled.width * scaled.height);
window.AddDirtyRect(oldScale);
window.AddDirtyRect(scaled);
} else if(oldScale.x != scaled.x || oldScale.y != scaled.y) {
window.AddDirtyRect(oldScale);
window.AddDirtyRect(scaled);
}
for(Transform* child : children) {
child->UpdatePosition(window, *this);
}
}
void RenderingElementPreScaled::UpdatePosition(Window& window, Transform& parent) {
std::uint_fast32_t oldWidth = scaled.width;
std::uint_fast32_t oldHeight = scaled.height;
ScaleData oldScale = scaled;
window.ScaleElement(*this, parent);
if(oldWidth != scaled.width || oldHeight && scaled.height) {
if(oldScale.width != scaled.width || oldScale.height != scaled.height) {
bufferScaled.resize(scaled.width * scaled.height);
window.AddDirtyRect(oldScale);
window.AddDirtyRect(scaled);
} else if(oldScale.x != scaled.x || oldScale.y != scaled.y) {
window.AddDirtyRect(oldScale);
window.AddDirtyRect(scaled);
}
for(Transform* child : children) {
child->UpdatePosition(window, *this);
}
@ -103,26 +115,39 @@ void RenderingElementScaling::CopyNearestNeighbour(Pixel_BU8_GU8_RU8_AU8* dst, s
}
void RenderingElementScaling::UpdatePosition(Window& window) {
std::uint_fast32_t oldWidth = scaled.width;
std::uint_fast32_t oldHeight = scaled.height;
ScaleData oldScale = scaled;
window.ScaleElement(*this);
if(oldWidth != scaled.width || oldHeight && scaled.height) {
if(oldScale.width != scaled.width || oldScale.height != scaled.height) {
bufferScaled.resize(scaled.width * scaled.height);
CopyNearestNeighbour(bufferScaled.data(), scaled.width, scaled.height);
window.AddDirtyRect(oldScale);
window.AddDirtyRect(scaled);
} else if(oldScale.x != scaled.x || oldScale.y != scaled.y) {
window.AddDirtyRect(oldScale);
window.AddDirtyRect(scaled);
}
for(Transform* child : children) {
child->UpdatePosition(window, *this);
}
}
void RenderingElementScaling::UpdatePosition(Window& window, Transform& parent) {
std::uint_fast32_t oldWidth = scaled.width;
std::uint_fast32_t oldHeight = scaled.height;
ScaleData oldScale = scaled;
window.ScaleElement(*this, parent);
if(oldWidth != scaled.width || oldHeight && scaled.height) {
if(oldScale.width != scaled.width || oldScale.height != scaled.height) {
bufferScaled.resize(scaled.width * scaled.height);
CopyNearestNeighbour(bufferScaled.data(), scaled.width, scaled.height);
window.AddDirtyRect(oldScale);
window.AddDirtyRect(scaled);
} else if(oldScale.x != scaled.x || oldScale.y != scaled.y) {
window.AddDirtyRect(oldScale);
window.AddDirtyRect(scaled);
}
for(Transform* child : children) {
child->UpdatePosition(window, *this);
}