From 273f039dc7ffcc4df458bbeaa7fdf7d8f34d582b Mon Sep 17 00:00:00 2001 From: Aaron <10217842+byteduck@users.noreply.github.com> Date: Thu, 23 Feb 2023 21:06:34 -0800 Subject: [PATCH] Pond: Redraw entire blurred window if something touching it is invalidated --- services/pond/Display.cpp | 14 +++++++++++--- services/pond/Display.h | 4 ++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/services/pond/Display.cpp b/services/pond/Display.cpp index 9d718541..2197048c 100644 --- a/services/pond/Display.cpp +++ b/services/pond/Display.cpp @@ -34,6 +34,8 @@ using namespace Gfx; using Duck::Log, Duck::Config, Duck::ResultRet; +constexpr int BLUR_RADIUS = 4; + Display* Display::_inst = nullptr; Display::Display(): _dimensions({0, 0, 0, 0}) { @@ -159,7 +161,7 @@ void Display::remove_window(Window* window) { } } -void Display::invalidate(const Gfx::Rect& rect) { +void Display::invalidate(Gfx::Rect rect) { if(!rect.empty()) invalid_areas.push_back(rect); } @@ -183,9 +185,15 @@ void Display::repaint() { auto& fb = _buffer_mode == BufferMode::Single ? _framebuffer : _root_window->framebuffer(); - //Combine areas that overlap + // Combine areas that overlap auto it = invalid_areas.begin(); while(it != invalid_areas.end()) { + // If the area collides with a window that blurs behind it, we need to redraw that entire window's area + for(auto& window : _windows) { + if(window->blurs_behind() && it->collides(window->absolute_shadow_rect())) + *it = it->combine(window->absolute_shadow_rect()); + } + bool remove_area = false; for(auto & other_area : invalid_areas) { if(&*it != &other_area && it->collides(other_area)) { @@ -227,7 +235,7 @@ void Display::repaint() { auto transformed_overlap = overlap_abs.transform({-window_abs.x, -window_abs.y}); if(window->uses_alpha()) { if(window->blurs_behind()) - fb.blur(overlap_abs); + fb.blur(overlap_abs, BLUR_RADIUS); fb.copy_blitting(window->framebuffer(), transformed_overlap, overlap_abs.position()); } else { fb.copy(window->framebuffer(), transformed_overlap, overlap_abs.position()); diff --git a/services/pond/Display.h b/services/pond/Display.h index 31cfcfca..d4355bff 100644 --- a/services/pond/Display.h +++ b/services/pond/Display.h @@ -74,9 +74,9 @@ class Display { /** * Marks a portion of the display to be redrawn - * @param Gfx::Rect the absolute rect to be redrawn + * @param rect the absolute rect to be redrawn */ - void invalidate(const Gfx::Rect& rect); + void invalidate(Gfx::Rect rect); /** * Repaints the needed areas of the screen to the hidden screen buffer.