Skip to content

Resize raster icons to their physical draw size#1218

Closed
anthony-firn wants to merge 3 commits intopop-os:masterfrom
anthony-firn:anthony/raster-icon-resize
Closed

Resize raster icons to their physical draw size#1218
anthony-firn wants to merge 3 commits intopop-os:masterfrom
anthony-firn:anthony/raster-icon-resize

Conversation

@anthony-firn
Copy link
Copy Markdown

@anthony-firn anthony-firn commented Apr 3, 2026

Summary

Resize raster icons to their physical draw size in widget::icon.

This addresses the raster half of #565 without adding any surface-specific logic.

Why

Small raster app icons are currently filtered directly from their source image at draw time. On panel-sized surfaces that leaves some icons visibly rough and prone to shimmer.

Resizing once at the requested physical size produces a cleaner source image for the existing draw path, while keeping the change in the shared icon widget.

What changed

  • add a cached raster resize path in widget::icon
  • resize with premultiplied-alpha Lanczos filtering at the physical draw size
  • reuse the resized handle from both Icon::view and icon::draw
  • leave the SVG path unchanged for follow-up work

Validation

  • cargo check -p libcosmic
  • cargo test -p libcosmic lanczos_resize_produces_requested_dimensions --lib
  • cargo test -p libcosmic premultiplied_resize_avoids_transparent_color_bleed --lib
  • rebuilt cosmic-app-library against the patched libcosmic tree and verified smoother small raster app icons in a live COSMIC session

@mmstick
Copy link
Copy Markdown
Member

mmstick commented Apr 3, 2026

iced maintains its own image cache for the renderer and performs resizing itself, so this would duplicate that work.

@anthony-firn anthony-firn marked this pull request as ready for review April 3, 2026 16:04
@anthony-firn anthony-firn changed the title Resize raster icons to physical draw size Resize raster icons to their physical draw size Apr 3, 2026
@mmstick
Copy link
Copy Markdown
Member

mmstick commented Apr 3, 2026

@anthony-firn Can this be done in the iced renderer instead?

@anthony-firn
Copy link
Copy Markdown
Author

Thanks, that makes sense. I moved the follow-up into the renderer instead so the change lives at the cache/upload layer instead of : pop-os/iced#318

This keeps the raster fix in the renderer and leaves untouched.

@anthony-firn
Copy link
Copy Markdown
Author

Thanks, that makes sense. I moved the follow-up into the iced renderer instead so the change lives at the cache/upload layer instead of the libcosmic icon widget: pop-os/iced#318

This keeps the raster fix in the renderer and leaves libcosmic untouched.

@anthony-firn
Copy link
Copy Markdown
Author

Closing this one in favor of the renderer-side follow-up at pop-os/iced#318, per the review feedback here.

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.

2 participants