Skip to content
Myr

render: use the 'fast' filter to downscale "too large" PNG icons

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Lanczos3 is slow. Don't use it on "too large" PNGs. Closes #439

authored by Daniel Eklöf · committed by Daniel Eklöf · parent 65a037a · Browse files · 3 files+33 added−16 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+33 added−16 removed

  • other:+33 added−16 removed

3 files+33 added−16 removed

modified:application.h+3 added
42 unmodified lines
43 void *svg;44#endif45 };4647 /* Icon is "too large" and we've already warned about this */48 bool png_size_warned;4950 /* List of cached rasterizations (used with SVGs) */51 rasterized_list_t rasterized;52};53
55 unmodified lines
modified:CHANGELOG.md+3 added
34 unmodified lines
35* Take the matched sub-string's position into account when sorting36 matches; entries where the matched sub-string is closer to the37 beginning of the entry is sorted before entries where the sub-string38 is closer to the end of the entry ([#419][419]).39* "Too large" PNG icons are now downscaled using a less precise40 scaling filter, to improve performance ([#439][439]).4142[419]: https://codeberg.org/dnkl/fuzzel/issues/41943[439]: https://codeberg.org/dnkl/fuzzel/issues/439444546### Deprecated47### Removed
843 unmodified lines
modified:render.c+27 added-16 removed
852 unmodified lines
853 pixman_transform_from_pixman_f_transform(854 &scale_transform, &_scale_transform);855 pixman_image_set_transform(png, &scale_transform);856857 if (height >= 1000) {858 if (!icon->png_size_warned) {859 LOG_WARN(860 "%s: PNG is too large (%dx%d); "861 "downscaling using a less precise filter",862 icon->path, width, height);863 icon->png_size_warned = true;864 }865 pixman_image_set_filter(png, PIXMAN_FILTER_FAST, NULL, 0);866 } else {857 int param_count = 0;858 pixman_kernel_t kernel = PIXMAN_KERNEL_LANCZOS3;859 pixman_fixed_t *params = pixman_filter_create_separable_convolution(860 &param_count,861 pixman_double_to_fixed(1. / scale),862 pixman_double_to_fixed(1. / scale),863 kernel, kernel,864 kernel, kernel,865 pixman_int_to_fixed(1),866 pixman_int_to_fixed(1));867 int param_count = 0;868 pixman_kernel_t kernel = PIXMAN_KERNEL_LANCZOS3;869 pixman_fixed_t *params = pixman_filter_create_separable_convolution(870 &param_count,871 pixman_double_to_fixed(1. / scale),872 pixman_double_to_fixed(1. / scale),873 kernel, kernel,874 kernel, kernel,875 pixman_int_to_fixed(1),876 pixman_int_to_fixed(1));877868 if (params != NULL || param_count == 0) {869 pixman_image_set_filter(870 png, PIXMAN_FILTER_SEPARABLE_CONVOLUTION,871 params, param_count);878 if (params != NULL || param_count == 0) {879 pixman_image_set_filter(880 png, PIXMAN_FILTER_SEPARABLE_CONVOLUTION,881 params, param_count);882 }883884 free(params);885 }886874 free(params);875887 width *= scale;888 height *= scale;889890 int stride = stride_for_format_and_width(fmt, width);
578 unmodified lines