Regenerate blur effects if canvas screen location has changed.

This should catch most cases of moving or resizing blurred windows.
This commit is contained in:
Tommy 2023-11-05 20:37:03 +13:00
parent 990e25f9e2
commit 5a4271ea98
2 changed files with 14 additions and 0 deletions

View File

@ -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;

View File

@ -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_;