perf: smooth UI animations and reduce repaint overhead
Batch of performance and animation work: shared FadeHelper/MotionPrefs primitives, hover animators, shadow pixmap caching, smooth scrolling, seek time bubble, and widespread component repaint reductions.
This commit is contained in:
@@ -105,4 +105,41 @@ NinePatchShadow make(int blurRadius, int cornerRadius, const QColor &color, qrea
|
||||
baked.save(path, "PNG"); // best-effort cache; failure just re-bakes next time
|
||||
return result;
|
||||
}
|
||||
|
||||
void drawNinePatch(QPainter *painter, const QRect &target, const NinePatchShadow &patch)
|
||||
{
|
||||
if (!painter || patch.isNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const int b = patch.border;
|
||||
const int t = patch.total;
|
||||
const qreal s = patch.dpr;
|
||||
const QRect r = target;
|
||||
|
||||
// Degenerate target (smaller than the two fixed borders): nothing sensible
|
||||
// to slice, skip rather than draw garbage.
|
||||
if (r.width() < 2 * b || r.height() < 2 * b)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// 3x3 grid: corners fixed, edges/centre stretched. Target columns/rows are
|
||||
// logical; source columns/rows are physical (pixmap carries no dpr).
|
||||
const int xt[4] = {r.left(), r.left() + b, r.right() + 1 - b, r.right() + 1};
|
||||
const int yt[4] = {r.top(), r.top() + b, r.bottom() + 1 - b, r.bottom() + 1};
|
||||
const qreal xs[4] = {0.0, b * s, (t - b) * s, t * s};
|
||||
const qreal ys[4] = {0.0, b * s, (t - b) * s, t * s};
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
for (int j = 0; j < 3; ++j)
|
||||
{
|
||||
const QRectF targetCell(xt[i], yt[j], xt[i + 1] - xt[i], yt[j + 1] - yt[j]);
|
||||
const QRectF sourceCell(xs[i], ys[j], xs[i + 1] - xs[i], ys[j + 1] - ys[j]);
|
||||
painter->drawPixmap(targetCell, patch.pixmap, sourceCell);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace ShadowPixmap
|
||||
|
||||
Reference in New Issue
Block a user