From 5a4271ea98087626845254137e1b09b7f519ec80 Mon Sep 17 00:00:00 2001 From: Tommy Date: Sun, 5 Nov 2023 20:37:03 +1300 Subject: [PATCH] Regenerate blur effects if canvas screen location has changed. This should catch most cases of moving or resizing blurred windows. --- src/gui/core/canvas.cpp | 11 +++++++++++ src/gui/core/canvas.hpp | 3 +++ 2 files changed, 14 insertions(+) diff --git a/src/gui/core/canvas.cpp b/src/gui/core/canvas.cpp index 1a2eacee383..f7dfff9f61b 100644 --- a/src/gui/core/canvas.cpp +++ b/src/gui/core/canvas.cpp @@ -483,6 +483,7 @@ void text_shape::draw(wfl::map_formula_callable& variables) canvas::canvas() : shapes_() , blur_depth_(0) + , blur_region_(sdl::empty_rect) , deferred_(false) , w_(0) , h_(0) @@ -494,6 +495,7 @@ canvas::canvas() canvas::canvas(canvas&& c) noexcept : shapes_(std::move(c.shapes_)) , blur_depth_(c.blur_depth_) + , blur_region_(c.blur_region_) , deferred_(c.deferred_) , w_(c.w_) , h_(c.h_) @@ -510,6 +512,15 @@ bool canvas::update_blur(const rect& screen_region, bool force) // No blurring needed. return true; } + + if(screen_region != blur_region_) { + DBG_GUI_D << "blur region changed from " << blur_region_ + << " to " << screen_region; + // something has changed. regenerate the texture. + blur_texture_.reset(); + blur_region_ = screen_region; + } + if(blur_texture_ && !force) { // We already made the blur. It's expensive, so don't do it again. return true; diff --git a/src/gui/core/canvas.hpp b/src/gui/core/canvas.hpp index f316174aa22..637744a0fd7 100644 --- a/src/gui/core/canvas.hpp +++ b/src/gui/core/canvas.hpp @@ -173,6 +173,9 @@ private: /** Blurred background texture. */ texture blur_texture_; + /** The region of the screen we have blurred (if any). */ + rect blur_region_; + /** Whether we have deferred rendering so we can capture for blur. */ bool deferred_;