Stop position-only animations from invalidating the texture caches
ChromePassElement::draw() rounded its device-space box with CBox::round(), which derives the size from the two rounded corners - round(x + w) - round(x) - making the rounded width and height a function of the *position's* fractional part. A box merely sliding at a constant size therefore has its size flip by a pixel every few frames. Every one of those flips misses the cachedTexSize check in GetBorderTexture, GetShadowTexture and GetTitleTexture alike, and each miss is a full cairo re-render plus a fresh GPU texture allocation and upload for content that did not change appearance at all. That is exactly what a workspace switch, a window move, or any other position-only animation does - every frame, for every window on screen - and it is why those animations stutter. Measured against hyprutils, a sliding window resized nothing yet rebuilt its textures on 18-40% of frames at scale 1.0/1.25/1.5/1.6 (integer scales happened to be stable); rounding the size on its own takes all of those to zero. What round()'s coupling buys is a far edge landing on the same device pixel as an adjacent box's near edge. Nothing abuts this box - it is a free-floating decoration drawn over everything - so there is no seam here to keep closed. damageEntire() gains a one-pixel margin to match: with position and size now rounded separately, the drawn box's far edge can land up to a device pixel past where the logical damage box scales to. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -21,7 +21,26 @@ std::vector<UP<IPassElement>> ChromePassElement::draw() {
|
||||
return {};
|
||||
|
||||
auto box = data.decoration->FullDecorationExtentGlobal();
|
||||
box.translate(-monitor->m_position).scale(monitor->m_scale).round();
|
||||
box.translate(-monitor->m_position).scale(monitor->m_scale);
|
||||
|
||||
// Round the position and the size independently, rather than via
|
||||
// CBox::round(). That derives the size from the two *rounded corners*
|
||||
// (round(x + w) - round(x)), which makes it a function of the position's
|
||||
// fractional part - so a box that is merely sliding, at a perfectly
|
||||
// constant size, has its rounded w/h flip by a pixel every few frames.
|
||||
// Every one of those flips misses the caches in GetBorderTexture /
|
||||
// GetShadowTexture / GetTitleTexture, each miss being a full cairo
|
||||
// re-render plus a GPU re-upload of a texture that didn't actually change
|
||||
// appearance - which is precisely what a workspace switch, a window move,
|
||||
// or any other position-only animation does, every frame, for every window
|
||||
// on screen. Rounded on its own, the size stays a pure function of the
|
||||
// window's own size and can't be perturbed by translation at all.
|
||||
//
|
||||
// What round()'s coupling buys is a far edge that lands on the same device
|
||||
// pixel as an adjacent box's near edge. Nothing abuts this box - it's a
|
||||
// free-floating decoration drawn over everything - so there is no seam here
|
||||
// to keep closed.
|
||||
box = CBox{box.pos().round(), box.size().round()};
|
||||
|
||||
if (box.w < 1 || box.h < 1)
|
||||
return {};
|
||||
|
||||
Reference in New Issue
Block a user