Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit b646857

Browse files
committed
Pond: Redraw entire blurred window if something touching it is invalidated
1 parent d876f1f commit b646857

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

services/pond/Display.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
using namespace Gfx;
3535
using Duck::Log, Duck::Config, Duck::ResultRet;
3636

37+
constexpr int BLUR_RADIUS = 4;
38+
3739
Display* Display::_inst = nullptr;
3840

3941
Display::Display(): _dimensions({0, 0, 0, 0}) {
@@ -159,7 +161,7 @@ void Display::remove_window(Window* window) {
159161
}
160162
}
161163

162-
void Display::invalidate(const Gfx::Rect& rect) {
164+
void Display::invalidate(Gfx::Rect rect) {
163165
if(!rect.empty())
164166
invalid_areas.push_back(rect);
165167
}
@@ -183,9 +185,15 @@ void Display::repaint() {
183185

184186
auto& fb = _buffer_mode == BufferMode::Single ? _framebuffer : _root_window->framebuffer();
185187

186-
//Combine areas that overlap
188+
// Combine areas that overlap
187189
auto it = invalid_areas.begin();
188190
while(it != invalid_areas.end()) {
191+
// If the area collides with a window that blurs behind it, we need to redraw that entire window's area
192+
for(auto& window : _windows) {
193+
if(window->blurs_behind() && it->collides(window->absolute_shadow_rect()))
194+
*it = it->combine(window->absolute_shadow_rect());
195+
}
196+
189197
bool remove_area = false;
190198
for(auto & other_area : invalid_areas) {
191199
if(&*it != &other_area && it->collides(other_area)) {
@@ -227,7 +235,7 @@ void Display::repaint() {
227235
auto transformed_overlap = overlap_abs.transform({-window_abs.x, -window_abs.y});
228236
if(window->uses_alpha()) {
229237
if(window->blurs_behind())
230-
fb.blur(overlap_abs);
238+
fb.blur(overlap_abs, BLUR_RADIUS);
231239
fb.copy_blitting(window->framebuffer(), transformed_overlap, overlap_abs.position());
232240
} else {
233241
fb.copy(window->framebuffer(), transformed_overlap, overlap_abs.position());

services/pond/Display.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ class Display {
7474

7575
/**
7676
* Marks a portion of the display to be redrawn
77-
* @param Gfx::Rect the absolute rect to be redrawn
77+
* @param rect the absolute rect to be redrawn
7878
*/
79-
void invalidate(const Gfx::Rect& rect);
79+
void invalidate(Gfx::Rect rect);
8080

8181
/**
8282
* Repaints the needed areas of the screen to the hidden screen buffer.

0 commit comments

Comments
 (0)