dirty rect
This commit is contained in:
parent
285e8c9182
commit
6df6355ba7
2 changed files with 32 additions and 24 deletions
|
|
@ -212,25 +212,38 @@ 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; });
|
||||
|
||||
if (!dirtyRects.empty()) {
|
||||
for (ClipRect rect : dirtyRects) {
|
||||
for (std::int_fast32_t y = rect.top; y < rect.bottom; y++) {
|
||||
for (std::int_fast32_t x = rect.left; x < rect.right; x++) {
|
||||
framebuffer[y * width + x] = {0, 0, 0, 0};
|
||||
}
|
||||
for(uint_fast32_t i = 0; i < width*height; i++) {
|
||||
framebuffer[i] = {0, 0, 0, 255};
|
||||
}
|
||||
|
||||
for (ClipRect rect : dirtyRects) {
|
||||
//std::cout << std::format("{}, {}, {}, {}", rect.left, rect.top, rect.right, rect.bottom) << std::endl;
|
||||
for (std::int_fast32_t y = rect.top; y < rect.bottom; y++) {
|
||||
for (std::int_fast32_t x = rect.left; x < rect.right; x++) {
|
||||
framebuffer[y * width + x].r += 30;
|
||||
}
|
||||
}
|
||||
|
||||
for(Transform* child : elements) {
|
||||
RenderElement(child);
|
||||
}
|
||||
|
||||
for (ClipRect rect : dirtyRects) {
|
||||
wl_surface_damage(surface, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top);
|
||||
}
|
||||
dirtyRects.clear();
|
||||
}
|
||||
|
||||
// if (!dirtyRects.empty()) {
|
||||
// for (ClipRect rect : dirtyRects) {
|
||||
// for (std::int_fast32_t y = rect.top; y < rect.bottom; y++) {
|
||||
// for (std::int_fast32_t x = rect.left; x < rect.right; x++) {
|
||||
// framebuffer[y * width + x] = {0, 0, 0, 0};
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// for(Transform* child : elements) {
|
||||
// RenderElement(child);
|
||||
// }
|
||||
|
||||
// for (ClipRect rect : dirtyRects) {
|
||||
// wl_surface_damage(surface, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top);
|
||||
// }
|
||||
// dirtyRects.clear();
|
||||
// }
|
||||
|
||||
dirtyRects.clear();
|
||||
wl_surface_damage(surface, 0, 0, width, height);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue