Skip to content

Commit

Permalink
Pond: Redraw entire blurred window if something touching it is invali…
Browse files Browse the repository at this point in the history
…dated
  • Loading branch information
byteduck committed Feb 24, 2023
1 parent c39f43b commit 273f039
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
14 changes: 11 additions & 3 deletions services/pond/Display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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}) {
Expand Down Expand Up @@ -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);
}
Expand All @@ -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)) {
Expand Down Expand Up @@ -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());
Expand Down
4 changes: 2 additions & 2 deletions services/pond/Display.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 273f039

Please sign in to comment.