Skip to content

element/image: include the fit mode in the cache key#97

Closed
UncleJ4ck wants to merge 1 commit into
hyprwm:mainfrom
UncleJ4ck:image-fitmode-cache-key
Closed

element/image: include the fit mode in the cache key#97
UncleJ4ck wants to merge 1 commit into
hyprwm:mainfrom
UncleJ4ck:image-fitmode-cache-key

Conversation

@UncleJ4ck

Copy link
Copy Markdown
Contributor

the cached texture bakes in the fit mode, but the cache key was just the path (plus the svg/icon size), so two image elements sharing a path with different fit modes collided on one cache entry and the second drew with the first's fit. shows up with hyprpaper putting one image on two monitors with different fit_mode.

CAssetCache::get matches by source() equality and getCacheString omitted the fit mode, so the second element reused the first's texture (fitMode is baked in at uploadTexture). appending sc<int>(data.fitMode) to the key gives each fit mode its own entry while keeping in-flight dedup for elements that share path and fit mode.

STextureData carries only resource and fitMode, so that one field is the whole class; rounding and alpha are draw-time shader uniforms and need no key change.

added a unit test asserting the key differs across fit modes and matches for the same one. alternative to #96, which guarded the cache hit instead of the key.

build-tested + unit suite (37/37); the two-monitor pixel repro needs two outputs.

the cached texture bakes in the fit mode, but the cache key was just the path
(plus the svg/icon size), so two image elements sharing a path with different
fit modes collided on one cache entry and the second drew with the first's fit.
shows up with hyprpaper putting one image on two monitors with different fit_mode.
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