Skip to content

perf(pixmap): unify the registry on get() and bound the caches by bytes - #326

Open
gmmcosta15 wants to merge 1 commit into
refactor/blocks-pixmap-panelsfrom
perf/pixmap-scaled-cache
Open

perf(pixmap): unify the registry on get() and bound the caches by bytes#326
gmmcosta15 wants to merge 1 commit into
refactor/blocks-pixmap-panelsfrom
perf/pixmap-scaled-cache

Conversation

@gmmcosta15

@gmmcosta15 gmmcosta15 commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

Description

  • Feature
  • Bug fix
  • Code refactor
  • Documentation

Last PR of the BlocksPixmap stack. Collapses the registry to a single entry point and
replaces the entry-count caps with byte budgets.

  • scaled() folded into get(): one call takes an Icon or an existing QPixmap, and any QSize/QSizeF/QRect/QRectF as the target.
  • _as_size() normalises the target in one place; 4 call sites move from truncate to round (1px max).
  • The three caches are byte-bounded LRU (_pixmaps 12 MiB, _scaled 8 MiB, _tints 8 MiB) instead of entry-capped.
  • tinted() takes a composition mode, so blocks_button stops allocating a pixmap per paint.
  • source() added for the three call sites that need the intrinsic size.
  • Icon.LOGO_BLOCKS replaces a raw filesystem path that resolved to nothing on device.
  • Drops Antialiasing + SmoothPixmapTransform from blocks_button._paint_pixmap.

Motivation

An entry cap cannot bound a mixed-size cache. A 64px icon rescale is 16 KiB and a 400x300 thumbnail is 480 KiB, so a 64-entry cap ranges 2-60 MiB purely on how the user browses. Qt bounds QPixmapCache by bytes for the same reason. On a 2 GB box with 209 MiB free that variance is the whole budget.

The two render hints are no-ops on a 1:1 integer-offset blit, which is the only thing _paint_pixmap does now that the scale happens in the cache.

Tests

New coverage: byte-bounded eviction on both caches, LRU order (a FIFO would drop the startup icons first), aspect-mode and colour key separation, and every QSize/QSizeF/QRect/QRectF target normalising to one cache entry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant