selective clearing
This commit is contained in:
parent
483131062f
commit
9bb36c990d
7 changed files with 98 additions and 30 deletions
|
|
@ -192,7 +192,6 @@ void WindowWayland::RenderElement(Transform* transform) {
|
|||
|
||||
// Bounds check for source buffer
|
||||
if (src_x >= 0 && src_x < static_cast<std::int_fast32_t>(src_width) && src_y >= 0 && src_y < static_cast<std::int_fast32_t>(src_height)) {
|
||||
|
||||
// Direct copy for opaque elements (skip blending)
|
||||
framebuffer[y * width + x] = src_buffer[src_y * src_width + src_x];
|
||||
}
|
||||
|
|
@ -232,15 +231,27 @@ void WindowWayland::Render() {
|
|||
elements.erase(std::remove(elements.begin(), elements.end(), static_cast<Transform*>(nullptr)), elements.end());
|
||||
std::sort(elements.begin(), elements.end(), [](Transform* a, Transform* b){ return a->z < b->z; });
|
||||
|
||||
// Clear screen efficiently using memset
|
||||
memset(framebuffer, 0, width * height * sizeof(Pixel_BU8_GU8_RU8_AU8));
|
||||
|
||||
for(Transform* child : elements) {
|
||||
RenderElement(child);
|
||||
if (!dirtyRects.empty()) {
|
||||
for (const ScaleData& rect : dirtyRects) {
|
||||
for (std::int_fast32_t y = rect.y; y < rect.y + rect.height && y < height; y++) {
|
||||
for (std::int_fast32_t x = rect.x; x < rect.x + rect.width && x < width; x++) {
|
||||
framebuffer[y * width + x] = {0, 0, 0, 0};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(Transform* child : elements) {
|
||||
RenderElement(child);
|
||||
}
|
||||
|
||||
for (const ScaleData& rect : dirtyRects) {
|
||||
wl_surface_damage(surface, rect.x, rect.y, rect.width, rect.height);
|
||||
}
|
||||
dirtyRects.clear();
|
||||
}
|
||||
|
||||
|
||||
wl_surface_attach(surface, buffer, 0, 0);
|
||||
wl_surface_damage(surface, 0, 0, width, height);
|
||||
wl_surface_commit(surface);
|
||||
}
|
||||
|
||||
|
|
@ -267,7 +278,7 @@ void WindowWayland::Write(Pixel_BU8_GU8_RU8_AU8* pixels) {
|
|||
}
|
||||
|
||||
void WindowWayland::Write(std::uint_fast32_t x, std::uint_fast32_t y, Pixel_BU8_GU8_RU8_AU8 pixel) {
|
||||
framebuffer[y * width + x] = pixel;
|
||||
framebuffer[y * width + x] = pixel;
|
||||
}
|
||||
|
||||
Pixel_BU8_GU8_RU8_AU8 WindowWayland::Read(std::uint_fast32_t x, std::uint_fast32_t y) const{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue