Skip to content
Myr

render.c

This file

Path

render.c

1,890 lines · 60.0 KiB · C

Last changed by

render: fix crash: don't assume render->selection_corners has been initializedDaniel Eklöfbefore adoption6f40720

History of this file

Take it

The walk stopped after 200 commits: lines older than 99f03a9 point at it.

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 1–2why, one step back
1#include "render.h"
2

render: font-shape the input stringDaniel Eklöfbefore adoption3ba23e1

line 3why, one step back
3#include <limits.h>

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

lines 4–6why, one step back
4#include <pthread.h>
5#include <semaphore.h>6#include <signal.h>

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 7why, one step back
7#include <stdio.h>

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

line 8why, one step back
8#include <stdlib.h>

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 9why, one step back
9#include <string.h>

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

line 10why, one step back
10#include <threads.h>

Add `--accept-nth` command line option to select column to outputbbb651before adoption33c9b8e

line 11why, one step back
11#include <uchar.h>

debug: add a --print-timing-info command line optionDaniel Eklöfbefore adoption1ea01b1

line 12why, one step back
12#include <sys/time.h>

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 13why, one step back
13

Add `--accept-nth` command line option to select column to outputbbb651before adoption33c9b8e

line 14why, one step back
14#include "column.h"

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

lines 15–25why, one step back
15#include "macros.h"
16#if HAS_INCLUDE(<pthread_np.h>)17#include <pthread_np.h>18#define pthread_setname_np(thread, name) (pthread_set_name_np(thread, name), 0)19#elif defined(__NetBSD__)20#define pthread_setname_np(thread, name) pthread_setname_np(thread, "%s", (void *)name)21#endif2223#if defined(FUZZEL_ENABLE_CAIRO)24#include <cairo.h>25#else

Fix compilation with librsvg after adding threading renderingDaniel Eklöfbefore adoption3d8da6f

line 26why, one step back
26#define cairo_t void

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

lines 27–28why, one step back
27#endif
28

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 29–39why, one step back
29#include <fcft/fcft.h>
3031#if defined(FUZZEL_ENABLE_SVG_NANOSVG)32 #include <nanosvg/nanosvgrast.h>33#endif3435#define LOG_MODULE "render"36#define LOG_ENABLE_DBG 037#include "log.h"38#include "char32.h"39#include "icon.h"

Implement gamma-correct blendingDaniel Eklöfbefore adoption2d19826

line 40why, one step back
40#include "srgb.h"

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 41why, one step back
41#include "stride.h"

Add xmalloc.h and xsnprintf.h and use to improve/simplify error handlingCraig Barnesbefore adoption539d514

lines 42–43why, one step back
42#include "xmalloc.h"
43#include "xsnprintf.h"

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 44–47why, one step back
44
45#define min(x, y) ((x) < (y) ? (x) : (y))46#define max(x, y) ((x) > (y) ? (x) : (y))47

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

lines 48–53why, one step back
48struct render;
49struct thread_context {50 struct render *render;51 int my_id;52};53

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 54–56why, one step back
54struct render {
55 const struct config *conf;56 struct fcft_font *font;

render: add support for rendering the selected entry in boldDaniel Eklöfbefore adoption8d77e69

line 57why, one step back
57 struct fcft_font *font_bold;

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 58–59why, one step back
58 enum fcft_subpixel subpixel;
59

render: font-shape the input stringDaniel Eklöfbefore adoption3ba23e1

lines 60–63why, one step back
60 /* Cached fcft text runs */
61 struct fcft_text_run *prompt_text_run;62 struct fcft_text_run *placeholder_text_run;63

feat: border radius for selected entrieswisplbefore adoption9836d81

lines 64–66why, one step back
64 /* Cached selection corners */
65 pixman_image_t *selection_corners;66

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 67–70why, one step back
67 float scale;
68 float dpi;69 bool size_font_by_dpi;70

Implement gamma-correct blendingDaniel Eklöfbefore adoption2d19826

line 71why, one step back
71 bool gamma_correct;

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 72–80why, one step back
72 pixman_color_t pix_background_color;
73 pixman_color_t pix_border_color;74 pixman_color_t pix_text_color;75 pixman_color_t pix_prompt_color;76 pixman_color_t pix_input_color;77 pixman_color_t pix_match_color;78 pixman_color_t pix_selection_color;79 pixman_color_t pix_selection_text_color;80 pixman_color_t pix_selection_match_color;

config: add 'match-counter' option, allowing you to disable the match counterDaniel Eklöfbefore adoption6a99846

line 81why, one step back
81 pixman_color_t pix_counter_color;

render: add support for a placeholder text, in the input boxDaniel Eklöfbefore adoption9e615ce

line 82why, one step back
82 pixman_color_t pix_placeholder_color;

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 83–87why, one step back
83
84 unsigned x_margin;85 unsigned y_margin;86 unsigned inner_pad;87 unsigned border_size;

render: fix border width and border radius scalingKonstantin Pospelovbefore adoption1b05c80

line 88why, one step back
88 unsigned border_radius;

feat: border radius for selected entrieswisplbefore adoption9836d81

line 89why, one step back
89 unsigned selection_border_radius;

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 90–92why, one step back
90 unsigned row_height;
91 unsigned icon_height;92

render: scroll input to ensure cursor is always visibleDaniel Eklöfbefore adoption544c59a

lines 93–94why, one step back
93 unsigned input_glyph_offset; /* At which glyph to start rendering input */
94

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

lines 95–107why, one step back
95 struct {
96 uint16_t count;97 sem_t start;98 sem_t done;99 mtx_t lock;100 tll(int) queue;101 thrd_t *threads;102103 const struct matches *matches;104 struct buffer *buf;105 bool render_icons;106 } workers;107

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 108–111why, one step back
108 mtx_t *icon_lock;
109};110111static pixman_color_t

Implement gamma-correct blendingDaniel Eklöfbefore adoption2d19826

line 112why, one step back
112rgba2pixman(bool gamma_correct, struct rgba rgba)

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 113why, one step back
113{

Implement gamma-correct blendingDaniel Eklöfbefore adoption2d19826

lines 114–118why, one step back
114 pixman_color_t pix_color = {
115 .alpha = rgba.a * 65535. + 0.5,116 .red = gamma_correct ? srgb_decode_8_to_16(rgba.r * 255 + 0.5) : rgba.r * 65535. + 0.5,117 .green = gamma_correct ? srgb_decode_8_to_16(rgba.g * 255 + 0.5) : rgba.g * 65535. + 0.5,118 .blue = gamma_correct ? srgb_decode_8_to_16(rgba.b * 255 + 0.5) : rgba.b * 65535. + 0.5,

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 119why, one step back
119 };

Implement gamma-correct blendingDaniel Eklöfbefore adoption2d19826

lines 120–125why, one step back
120
121 pix_color.red = (uint32_t)pix_color.red * pix_color.alpha / 0xffff;122 pix_color.green = (uint32_t)pix_color.green * pix_color.alpha / 0xffff;123 pix_color.blue = (uint32_t)pix_color.blue * pix_color.alpha / 0xffff;124125 return pix_color;

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 126–138why, one step back
126}
127128static int129pt_or_px_as_pixels(const struct render *render, const struct pt_or_px *pt_or_px)130{131 double scale = !render->size_font_by_dpi ? render->scale : 1.;132 double dpi = render->size_font_by_dpi ? render->dpi : 96.;133134 return pt_or_px->px == 0135 ? round(pt_or_px->pt * scale * dpi / 72.)136 : pt_or_px->px;137}138

render: sync rounded corners implementation with fnott'sDaniel Eklöfbefore adoptionaa29ae8

lines 139–140why, one step back
139static pixman_region32_t
140rounded_rectangle_region(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t radius)

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 141why, one step back
141{

render: sync rounded corners implementation with fnott'sDaniel Eklöfbefore adoptionaa29ae8

line 142why, one step back
142

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 143why, one step back
143 int rect_count = ( radius + radius ) + 1;

render: sync rounded corners implementation with fnott'sDaniel Eklöfbefore adoptionaa29ae8

line 144why, one step back
144 pixman_box32_t rects[rect_count];

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 145why, one step back
145

render: sync rounded corners implementation with fnott'sDaniel Eklöfbefore adoptionaa29ae8

line 146why, one step back
146 for (int i = 0; i <= radius; i++) {

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 147–149why, one step back
147 uint16_t ydist = radius - i;
148 uint16_t curve = sqrt(radius * radius - ydist * ydist);149

render: sync rounded corners implementation with fnott'sDaniel Eklöfbefore adoptionaa29ae8

lines 150–154why, one step back
150 rects[i] = (pixman_box32_t) {
151 x + radius - curve,152 y + i,153 x + width - radius + curve,154 y + i + 1

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 155–156why, one step back
155 };
156

render: sync rounded corners implementation with fnott'sDaniel Eklöfbefore adoptionaa29ae8

lines 157–161why, one step back
157 rects[radius + i] = (pixman_box32_t) {
158 x + radius - curve,159 y + height - i,160 x + width - radius + curve,161 y + height - i + 1

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 162–164why, one step back
162 };
163 }164

render: sync rounded corners implementation with fnott'sDaniel Eklöfbefore adoptionaa29ae8

lines 165–169why, one step back
165 rects[(radius * 2)] = (pixman_box32_t){
166 x,167 y + radius,168 x + width,169 y + height + 1 - radius

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 170why, one step back
170 };

render: sync rounded corners implementation with fnott'sDaniel Eklöfbefore adoptionaa29ae8

lines 171–174why, one step back
171
172 pixman_region32_t region;173 pixman_region32_init_rects(&region, rects, rect_count);174 return region;

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 175–176why, one step back
175}
176

render: sync rounded corners implementation with fnott'sDaniel Eklöfbefore adoptionaa29ae8

lines 177–196why, one step back
177static inline void
178fill_region32(pixman_op_t op, pixman_image_t* dest,179 const pixman_color_t* color, pixman_region32_t* region)180{181 int rectc;182 pixman_box32_t *rects = pixman_region32_rectangles(region, &rectc);183 pixman_image_fill_boxes(op, dest, color, rectc, rects);184185}186187static inline void188fill_rounded_rectangle(pixman_op_t op, pixman_image_t* dest,189 const pixman_color_t* color, int16_t x, int16_t y,190 uint16_t width, uint16_t height, uint16_t radius)191{192 pixman_region32_t region = rounded_rectangle_region(x, y, width, height, radius);193 fill_region32(op, dest, color, &region);194 pixman_region32_fini(&region);195}196

feat: border radius for selected entrieswisplbefore adoption9836d81

lines 197–200why, one step back
197static void
198render_rounded_rectangle(pixman_image_t* dest, pixman_color_t* background,199 pixman_color_t* border, unsigned int radius, unsigned bw,200 int16_t x, int16_t y, uint16_t width, uint16_t height)

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 201why, one step back
201{

render: only do a full background fill on fresh buffersDaniel Eklöfbefore adoption01471e3

line 202why, one step back
202 if (radius == 0) {

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 203why, one step back
203 pixman_image_fill_rectangles(

feat: border radius for selected entrieswisplbefore adoption9836d81

line 204why, one step back
204 PIXMAN_OP_SRC, dest, background,

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 205why, one step back
205 1, &(pixman_rectangle16_t){

feat: border radius for selected entrieswisplbefore adoption9836d81

line 206why, one step back
206 x + bw, y + bw, width - 2 * bw, height - 2 * bw});

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 207–208why, one step back
207
208 pixman_image_fill_rectangles(

feat: border radius for selected entrieswisplbefore adoption9836d81

line 209why, one step back
209 PIXMAN_OP_SRC, dest, border,

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 210why, one step back
210 4, (pixman_rectangle16_t[]){

feat: border radius for selected entrieswisplbefore adoption9836d81

lines 211–214why, one step back
211 {x, y, width, bw}, /* top */
212 {x, y + bw, bw, height - 2 * bw}, /* left */213 {x + width - bw, y + bw, bw, height - 2 * bw}, /* right */214 {x, y + height - bw, width, bw} /* bottom */

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 215–218why, one step back
215 });
216 } else {217 const int msaa_scale = 2;218 const double brd_sz_scaled = bw * msaa_scale;

render: only do a full background fill on fresh buffersDaniel Eklöfbefore adoption01471e3

line 219why, one step back
219 const double brd_rad_scaled = radius * msaa_scale;

feat: border radius for selected entrieswisplbefore adoption9836d81

lines 220–221why, one step back
220 int w = width * msaa_scale;
221 int h = height * msaa_scale;

render: sync rounded corners implementation with fnott'sDaniel Eklöfbefore adoptionaa29ae8

line 222why, one step back
222 int bg_rad = brd_rad_scaled * (1.0 - (float)brd_sz_scaled / (float)brd_rad_scaled);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 223–224why, one step back
223
224 pixman_image_t *bg_img;

feat: border radius for selected entrieswisplbefore adoption9836d81

line 225why, one step back
225 if (msaa_scale != 1) {

render: rounded-corners: don't hardcode a8r8g8b8 for the msaa interim bufferDaniel Eklöfbefore adoptionab66010

line 226why, one step back
226 bg_img = pixman_image_create_bits(

feat: border radius for selected entrieswisplbefore adoption9836d81

line 227why, one step back
227 pixman_image_get_format(dest), w, h, NULL, w*4);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 228why, one step back
228 } else {

feat: border radius for selected entrieswisplbefore adoption9836d81

line 229why, one step back
229 bg_img = dest;

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 230–233why, one step back
230 }
231232 /* Border */233 fill_rounded_rectangle(

feat: border radius for selected entrieswisplbefore adoption9836d81

line 234why, one step back
234 PIXMAN_OP_SRC, bg_img, border, 0, 0, w, h, brd_rad_scaled);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 235–237why, one step back
235
236 /* Background */237 fill_rounded_rectangle(

feat: border radius for selected entrieswisplbefore adoption9836d81

line 238why, one step back
238 PIXMAN_OP_SRC, bg_img, background, brd_sz_scaled, brd_sz_scaled,

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 239–240why, one step back
239 w-(brd_sz_scaled*2),
240 h-(brd_sz_scaled*2),

render: sync rounded corners implementation with fnott'sDaniel Eklöfbefore adoptionaa29ae8

line 241why, one step back
241 bg_rad);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 242why, one step back
242

feat: border radius for selected entrieswisplbefore adoption9836d81

line 243why, one step back
243 if (msaa_scale != 1) {

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 244–251why, one step back
244 pixman_f_transform_t ftrans;
245 pixman_transform_t trans;246 pixman_f_transform_init_scale(&ftrans, msaa_scale, msaa_scale);247 pixman_transform_from_pixman_f_transform(&trans, &ftrans);248 pixman_image_set_transform(bg_img, &trans);249 pixman_image_set_filter(bg_img, PIXMAN_FILTER_BILINEAR, NULL, 0);250251 pixman_image_composite32(

feat: border radius for selected entrieswisplbefore adoption9836d81

lines 252–253why, one step back
252 PIXMAN_OP_OVER, bg_img, NULL, dest, 0, 0, 0, 0, x, y,
253 width, height);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 254–258why, one step back
254 pixman_image_unref(bg_img);
255 }256 }257}258

feat: border radius for selected entrieswisplbefore adoption9836d81

lines 259–282why, one step back
259void
260render_background(const struct render *render, struct buffer *buf)261{262 unsigned bw = render->border_size;263264 pixman_color_t bg = render->pix_background_color;265 pixman_color_t border_color = render->pix_border_color;266267 if (buf->age == 0) {268 /* Each sub-part of the window erases itself */269 return;270 }271272 /* Limit radius if the margins are very small, to prevent e.g. the273 selection "box" from overlapping the corners */274 const unsigned int radius =275 min(render->border_radius,276 max(render->x_margin,277 render->y_margin));278279 render_rounded_rectangle(buf->pix[0], &bg, &border_color, radius, bw,280 0, 0, buf->width, buf->height);281}282

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 283–303why, one step back
283static void
284render_glyph(pixman_image_t *pix, const struct fcft_glyph *glyph, int x, int y,285 const pixman_color_t *color)286{287 if (pixman_image_get_format(glyph->pix) == PIXMAN_a8r8g8b8) {288 /* Glyph surface is a pre-rendered image (typically a color emoji...) */289 pixman_image_composite32(290 PIXMAN_OP_OVER, glyph->pix, NULL, pix, 0, 0, 0, 0,291 x + glyph->x, y - glyph->y,292 glyph->width, glyph->height);293 } else {294 /* Glyph surface is an alpha mask */295 pixman_image_t *src = pixman_image_create_solid_fill(color);296 pixman_image_composite32(297 PIXMAN_OP_OVER, src, glyph->pix, pix, 0, 0, 0, 0,298 x + glyph->x, y - glyph->y,299 glyph->width, glyph->height);300 pixman_image_unref(src);301 }302}303

render: display match+total entry countDaniel Eklöfbefore adoptionb32836d

line 304why, one step back
304static int

render: regression: cursor alignment with custom line-heightDaniel Eklöfbefore adoption20660ef

lines 305–315why, one step back
305render_baseline(const struct render *render)
306{307 const struct fcft_font *font = render->font;308 const int line_height = render->row_height;309 const int font_height = font->ascent + font->descent;310311 /*312 * Center glyph on the line *if* using a custom line height,313 * otherwise the baseline is simply 'descent' pixels above the314 * bottom of the cell315 */

render: fix cursor glitches with custom line heightsDaniel Eklöfbefore adoptione39571a

lines 316–319why, one step back
316 const int glyph_top_y =
317 render->conf->line_height.px >= 0 && line_height >= font_height318 ? round((line_height - font_height) / 2.)319 : 0;

render: regression: cursor alignment with custom line-heightDaniel Eklöfbefore adoption20660ef

lines 320–324why, one step back
320
321 return line_height - glyph_top_y - font->descent;322}323324static int

render: display match+total entry countDaniel Eklöfbefore adoptionb32836d

lines 325–337why, one step back
325render_match_count(const struct render *render, struct buffer *buf,
326 const struct prompt *prompt, const struct matches *matches)327{328 struct fcft_font *font = render->font;329 assert(font != NULL);330331 const struct config *conf = render->conf;332333 const enum fcft_subpixel subpixel =334 conf->colors.background.a == 1. && conf->colors.selection.a == 1.335 ? render->subpixel336 : FCFT_SUBPIXEL_NONE;337

xdg: don't count NoDisplay=true apps towards the match counter's totalChristian Fillionbefore adoptiondb12816

line 338why, one step back
338 size_t total_count = matches_get_application_visible_count(matches);

render: display match+total entry countDaniel Eklöfbefore adoptionb32836d

lines 339–341why, one step back
339 size_t match_count = matches_get_total_count(matches);
340 const char32_t *ptext = prompt_text(prompt);341

Add xmalloc.h and xsnprintf.h and use to improve/simplify error handlingCraig Barnesbefore adoption539d514

lines 342–344why, one step back
342 char text[64];
343 size_t count = (ptext[0] == U'\0') ? total_count : match_count;344 size_t chars = xsnprintf(text, sizeof(text), "%zu/%zu", count, total_count);

render: display match+total entry countDaniel Eklöfbefore adoptionb32836d

lines 345–346why, one step back
345
346 /* fcft wants UTF-32. Since we only use ASCII... */

Add xmalloc.h and xsnprintf.h and use to improve/simplify error handlingCraig Barnesbefore adoption539d514

line 347why, one step back
347 uint32_t wtext[64];

render: display match+total entry countDaniel Eklöfbefore adoptionb32836d

lines 348–351why, one step back
348 for (size_t i = 0; i < chars; i++)
349 wtext[i] = (uint32_t)(unsigned char)text[i];350351 int width = -1;

Add xmalloc.h and xsnprintf.h and use to improve/simplify error handlingCraig Barnesbefore adoption539d514

line 352why, one step back
352 int x = buf->width - render->border_size - render->x_margin;

render: display match+total entry countDaniel Eklöfbefore adoptionb32836d

lines 353–370why, one step back
353 int y = render->border_size + render->y_margin +
354 (render->row_height + font->height) / 2 - font->descent;355356 if (fcft_capabilities() & FCFT_CAPABILITY_TEXT_RUN_SHAPING) {357 struct fcft_text_run *run = fcft_rasterize_text_run_utf32(358 font, chars, wtext, subpixel);359360 if (run != NULL) {361 width = 0;362363 for (size_t i = 0; i < run->count; i++) {364 const struct fcft_glyph *glyph = run->glyphs[i];365 width += glyph->advance.x;366 }367368 x -= width;369 for (size_t i = 0; i < run->count; i++) {370 const struct fcft_glyph *glyph = run->glyphs[i];

config: add 'match-counter' option, allowing you to disable the match counterDaniel Eklöfbefore adoption6a99846

line 371why, one step back
371 render_glyph(buf->pix[0], glyph, x, y, &render->pix_counter_color);

render: display match+total entry countDaniel Eklöfbefore adoptionb32836d

lines 372–379why, one step back
372 x += glyph->advance.x;
373 }374375 fcft_text_run_destroy(run);376 return width;377 }378 }379

Add xmalloc.h and xsnprintf.h and use to improve/simplify error handlingCraig Barnesbefore adoption539d514

lines 380–381why, one step back
380 const struct fcft_glyph **glyphs = xmalloc(chars * sizeof(glyphs[0]));
381 long *x_kern = xmalloc(chars * sizeof(x_kern[0]));

render: fix "error: 'prev' may be used uninitialized"Daniel Eklöfbefore adoption173bf04

line 382why, one step back
382 char32_t prev = 0;

render: display match+total entry countDaniel Eklöfbefore adoptionb32836d

lines 383–410why, one step back
383
384 width = 0;385 for (size_t i = 0; i < (size_t)chars; i++) {386 x_kern[i] = 0;387388 const struct fcft_glyph *glyph =389 fcft_rasterize_char_utf32(font, wtext[i], subpixel);390 glyphs[i] = glyph;391392 if (glyph == NULL)393 continue;394395 if (i > 0) {396 if (fcft_kerning(font, prev, wtext[i], &x_kern[i], NULL))397 width += x_kern[i];398 }399 width += glyph->advance.x;400 prev = wtext[i];401 }402403 x -= width;404405 for (size_t i = 0; i < (size_t)chars; i++) {406 const struct fcft_glyph *glyph = glyphs[i];407 if (glyph == NULL)408 continue;409410 x += x_kern[i];

config: add 'match-counter' option, allowing you to disable the match counterDaniel Eklöfbefore adoption6a99846

line 411why, one step back
411 render_glyph(buf->pix[0], glyph, x, y, &render->pix_counter_color);

render: display match+total entry countDaniel Eklöfbefore adoptionb32836d

lines 412–420why, one step back
412 x += glyph->advance.x;
413 prev = wtext[i];414 }415416 free(x_kern);417 free(glyphs);418 return width;419}420

render: font-shape the input stringDaniel Eklöfbefore adoption3ba23e1

line 421why, one step back
421static void

render: regression: cursor alignment with custom line-heightDaniel Eklöfbefore adoption20660ef

line 422why, one step back
422render_cursor(const struct render *render, int x, int baseline, pixman_image_t *pix)

render: font-shape the input stringDaniel Eklöfbefore adoption3ba23e1

lines 423–427why, one step back
423{
424 struct fcft_font *font = render->font;425426 if (true) {427 /* Bar cursor */

render: regression: cursor alignment with custom line-heightDaniel Eklöfbefore adoption20660ef

lines 428–429why, one step back
428 const int height = min(font->ascent + font->descent, render->row_height);
429

render: font-shape the input stringDaniel Eklöfbefore adoption3ba23e1

lines 430–433why, one step back
430 pixman_image_fill_rectangles(
431 PIXMAN_OP_SRC, pix, &render->pix_input_color,432 1, &(pixman_rectangle16_t){433 x,

render: fix cursor glitches with custom line heightsDaniel Eklöfbefore adoptione39571a

line 434why, one step back
434 baseline + render->font->descent - height,

render: font-shape the input stringDaniel Eklöfbefore adoption3ba23e1

line 435why, one step back
435 font->underline.thickness,

render: regression: cursor alignment with custom line-heightDaniel Eklöfbefore adoption20660ef

line 436why, one step back
436 height});

render: font-shape the input stringDaniel Eklöfbefore adoption3ba23e1

lines 437–441why, one step back
437 } else {
438 /* TODO: future: underline cursor */439 pixman_image_fill_rectangles(440 PIXMAN_OP_SRC, pix, &render->pix_input_color,441 1, &(pixman_rectangle16_t){

render: regression: cursor alignment with custom line-heightDaniel Eklöfbefore adoption20660ef

line 442why, one step back
442 x, baseline - font->underline.position,

render: font-shape the input stringDaniel Eklöfbefore adoption3ba23e1

lines 443–447why, one step back
443 font->max_advance.x,
444 font->underline.thickness});445 }446}447

render: scroll input to ensure cursor is always visibleDaniel Eklöfbefore adoption544c59a

lines 448–546why, one step back
448static void
449adjust_input_glyph_offset(struct render *render, const struct prompt *prompt,450 size_t count,451 const struct fcft_glyph *glyphs[static count],452 long kerning[static count],453 int start_x, int max_x)454{455 struct fcft_font *font = render->font;456 const size_t cursor_location = prompt_cursor(prompt);457458 if (cursor_location == 0)459 render->input_glyph_offset = 0;460461 /* Clamp to input string's length */462 render->input_glyph_offset = min(render->input_glyph_offset, count - 1);463464 /* If cursor position is before the current offset, adjust the465 offset backward */466 for (size_t i = 0; i < render->input_glyph_offset; i++) {467 if (cursor_location == i + 1) {468 render->input_glyph_offset = i + 1;469 break;470 }471 }472473 /* If cursor position is after the current visible portion, adjust the offset forward */474 int pos = start_x;475476 for (size_t i = render->input_glyph_offset; i < count; i++) {477478 const struct fcft_glyph *glyph = glyphs[i];479 if (glyph == NULL)480 continue;481482 const int pixels_needed = max(glyph->x + glyph->width, glyph->advance.x);483484 /* Cursor is after this glyph? */485 if (cursor_location == i + 1) {486 /* If current glyph doesn't fit, adjust offset so that it does */487 if (pos + kerning[i] + pixels_needed > max_x) {488 int needed = (pos + kerning[i] + pixels_needed) - max_x;489490 /* Font may be variable width, meaning we may have to scroll multiple characters */491 while (needed > 0 && render->input_glyph_offset + 1 < count) {492 long scrolled_kerning;493 fcft_kerning(494 font,495 glyphs[render->input_glyph_offset]->cp,496 glyphs[render->input_glyph_offset + 1]->cp,497 &scrolled_kerning, NULL);498499 const int gained =500 scrolled_kerning +501 glyphs[render->input_glyph_offset]->advance.x;502503 needed -= gained;504 pos -= gained;505 render->input_glyph_offset++;506 }507 }508 }509510 pos += kerning[i] + glyph->advance.x;511 }512513 /* Pull in glyphs from the left, if there's space left */514 while (render->input_glyph_offset > 0 && max_x > pos) {515 int total_width = start_x;516517 for (size_t i = render->input_glyph_offset; i < count; i++) {518 const struct fcft_glyph *g = glyphs[i];519 if (g == NULL)520 continue;521522 const int w = max(g->width, g->advance.x);523524 if (total_width + kerning[i] + w > max_x) {525 break;526 }527528 total_width += kerning[i] + (i + 1 == count ? w : g->advance.x);529 }530531 const struct fcft_glyph *glyph = glyphs[render->input_glyph_offset - 1];532 const int pixels_needed = max(glyph->x + glyph->width, glyph->advance.x);533534 assert(render->input_glyph_offset > 0);535 assert(render->input_glyph_offset < count);536537 const long kern = kerning[render->input_glyph_offset];538 const int available = max_x - total_width;539 if (kern + pixels_needed > available)540 break;541542 render->input_glyph_offset--;543 pos += kern + glyph->advance.x;544 }545}546

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 547why, one step back
547void

render: font-shape the input stringDaniel Eklöfbefore adoption3ba23e1

line 548why, one step back
548render_prompt(struct render *render, struct buffer *buf,

render: display match+total entry countDaniel Eklöfbefore adoptionb32836d

line 549why, one step back
549 const struct prompt *prompt, const struct matches *matches)

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 550–557why, one step back
550{
551 struct fcft_font *font = render->font;552 assert(font != NULL);553554 const struct config *conf = render->conf;555556 const char32_t *pprompt = prompt_prompt(prompt);557 size_t prompt_len = c32len(pprompt);

render: font-shape the input stringDaniel Eklöfbefore adoption3ba23e1

line 558why, one step back
558 const size_t cursor_location = prompt_cursor(prompt);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 559–560why, one step back
559
560 const char32_t *ptext = prompt_text(prompt);

render: add support for a placeholder text, in the input boxDaniel Eklöfbefore adoption9e615ce

line 561why, one step back
561 size_t text_len = c32len(ptext);

render: don't render placeholder text as password charactersDaniel Eklöfbefore adoptione4b0d41

line 562why, one step back
562 bool use_placeholder = text_len == 0;

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 563–568why, one step back
563
564 const enum fcft_subpixel subpixel =565 (render->conf->colors.background.a == 1. &&566 render->conf->colors.selection.a == 1.)567 ? render->subpixel : FCFT_SUBPIXEL_NONE;568

render: scroll input to ensure cursor is always visibleDaniel Eklöfbefore adoption544c59a

lines 569–584why, one step back
569 const struct fcft_glyph *input_glyphs[text_len];
570 long input_kerning[text_len];571572 for (size_t i = 0; i < text_len; i++) {573 input_glyphs[i] = fcft_rasterize_char_utf32(font, ptext[i], subpixel);574 if (i == 0)575 input_kerning[0] = 0;576 else577 fcft_kerning(font, ptext[i - 1], ptext[i], &input_kerning[i], NULL);578 }579580 if (use_placeholder) {581 ptext = prompt_placeholder(prompt);582 text_len = c32len(ptext);583 }584

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 585why, one step back
585 int x = render->border_size + render->x_margin;

render: regression: cursor alignment with custom line-heightDaniel Eklöfbefore adoption20660ef

line 586why, one step back
586 int y = render->border_size + render->y_margin + render_baseline(render);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 587why, one step back
587

render: only do a full background fill on fresh buffersDaniel Eklöfbefore adoption01471e3

lines 588–589why, one step back
588 /* Erase background */
589 pixman_color_t bg = render->pix_background_color;

render: scroll input to ensure cursor is always visibleDaniel Eklöfbefore adoption544c59a

line 590why, one step back
590 //pixman_color_t bg = (pixman_color_t){0xffff, 0, 0, 0xffff};

render: only do a full background fill on fresh buffersDaniel Eklöfbefore adoption01471e3

lines 591–593why, one step back
591 pixman_image_fill_rectangles(
592 PIXMAN_OP_SRC, buf->pix[0], &bg, 1,593 &(pixman_rectangle16_t){

render: scroll input to ensure cursor is always visibleDaniel Eklöfbefore adoption544c59a

lines 594–603why, one step back
594 render->border_size + render->x_margin - render->x_margin / 3,
595 render->border_size + render->y_margin,596 buf->width - 2 * (render->border_size + render->x_margin - render->x_margin / 3),597 render->row_height});598599#if 0600 bg = (pixman_color_t){0, 0xffff, 0, 0xffff};601 pixman_image_fill_rectangles(602 PIXMAN_OP_SRC, buf->pix[0], &bg, 1,603 &(pixman_rectangle16_t){

render: only do a full background fill on fresh buffersDaniel Eklöfbefore adoption01471e3

lines 604–607why, one step back
604 render->border_size + render->x_margin,
605 render->border_size + render->y_margin,606 buf->width - 2 * (render->border_size + render->x_margin),607 render->row_height});

render: scroll input to ensure cursor is always visibleDaniel Eklöfbefore adoption544c59a

line 608why, one step back
608#endif

render: only do a full background fill on fresh buffersDaniel Eklöfbefore adoption01471e3

line 609why, one step back
609

config: add 'match-counter' option, allowing you to disable the match counterDaniel Eklöfbefore adoption6a99846

lines 610–612why, one step back
610 int stats_width = conf->match_counter
611 ? render_match_count(render, buf, prompt, matches)612 : 0;

render: display match+total entry countDaniel Eklöfbefore adoptionb32836d

lines 613–616why, one step back
613
614 const int max_x =615 buf->width - render->border_size - render->x_margin - stats_width;616

render: font-shape the input stringDaniel Eklöfbefore adoption3ba23e1

lines 617–620why, one step back
617 struct fcft_text_run *prompt_run = render->prompt_text_run;
618 struct fcft_text_run *input_run =619 use_placeholder ? render->placeholder_text_run : NULL;620

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 621why, one step back
621 if (fcft_capabilities() & FCFT_CAPABILITY_TEXT_RUN_SHAPING) {

render: font-shape the input stringDaniel Eklöfbefore adoption3ba23e1

lines 622–625why, one step back
622 if (prompt_run == NULL) {
623 prompt_run = fcft_rasterize_text_run_utf32(624 font, prompt_len, pprompt, subpixel);625 }

render: scroll input to ensure cursor is always visibleDaniel Eklöfbefore adoption544c59a

line 626why, one step back
626 if (input_run == NULL && use_placeholder) {

render: font-shape the input stringDaniel Eklöfbefore adoption3ba23e1

lines 627–630why, one step back
627 input_run = fcft_rasterize_text_run_utf32(
628 font, text_len, ptext, subpixel);629 }630 }

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 631why, one step back
631

render: font-shape the input stringDaniel Eklöfbefore adoption3ba23e1

lines 632–634why, one step back
632 if (prompt_run != NULL) {
633 for (size_t i = 0; i < prompt_run->count; i++) {634 const struct fcft_glyph *glyph = prompt_run->glyphs[i];

render: scroll input to ensure cursor is always visibleDaniel Eklöfbefore adoption544c59a

lines 635–637why, one step back
635 const int pixels_needed = max(glyph->x + glyph->width, glyph->advance.x);
636637 if (x + pixels_needed > max_x)

render: font-shape the input stringDaniel Eklöfbefore adoption3ba23e1

line 638why, one step back
638 goto out;

render: display match+total entry countDaniel Eklöfbefore adoptionb32836d

line 639why, one step back
639

render: font-shape the input stringDaniel Eklöfbefore adoption3ba23e1

lines 640–647why, one step back
640 render_glyph(buf->pix[0], glyph, x, y, &render->pix_prompt_color);
641 x += glyph->advance.x;642 }643 } else {644 char32_t prev = 0;645 for (size_t i = 0; i < prompt_len; i++) {646 const char32_t wc = pprompt[i];647 const struct fcft_glyph *glyph = fcft_rasterize_char_utf32(font, wc, subpixel);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 648why, one step back
648

render: font-shape the input stringDaniel Eklöfbefore adoption3ba23e1

lines 649–651why, one step back
649 if (glyph == NULL) {
650 prev = wc;651 continue;

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 652–653why, one step back
652 }
653

render: font-shape the input stringDaniel Eklöfbefore adoption3ba23e1

lines 654–658why, one step back
654 long x_kern;
655 fcft_kerning(font, prev, wc, &x_kern, NULL);656657 x += x_kern;658

render: scroll input to ensure cursor is always visibleDaniel Eklöfbefore adoption544c59a

lines 659–660why, one step back
659 const int pixels_needed = max(glyph->x + glyph->width, glyph->advance.x);
660 if (x + pixels_needed > max_x)

render: font-shape the input stringDaniel Eklöfbefore adoption3ba23e1

lines 661–668why, one step back
661 goto out;
662663 render_glyph(664 buf->pix[0], glyph, x, y, &render->pix_prompt_color);665 x += glyph->advance.x;666 x += pt_or_px_as_pixels(render, &render->conf->letter_spacing);667668 prev = wc;

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 669–671why, one step back
669 }
670 }671

render: scroll input to ensure cursor is always visibleDaniel Eklöfbefore adoption544c59a

lines 672–680why, one step back
672 /*
673 * Adjust glyph offset (i.e. where in the input string we start674 * rendering), to ensure the portion containing the cursor is675 * always visible.676 */677 adjust_input_glyph_offset(678 render, prompt, !use_placeholder ? text_len : 0,679 input_glyphs, input_kerning, x, max_x);680

render: font-shape the input stringDaniel Eklöfbefore adoption3ba23e1

lines 681–682why, one step back
681 /* Cursor, if right after the prompt. In all other cases, the
682 * cursor will be rendered by the loop below */

render: scroll input to ensure cursor is always visibleDaniel Eklöfbefore adoption544c59a

lines 683–685why, one step back
683 if (cursor_location == render->input_glyph_offset
684 || (conf->password_mode.enabled &&685 conf->password_mode.character == U'\0'))

render: font-shape the input stringDaniel Eklöfbefore adoption3ba23e1

lines 686–688why, one step back
686 {
687 render_cursor(render, x, y, buf->pix[0]);688 }

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 689why, one step back
689

render: font-shape the input stringDaniel Eklöfbefore adoption3ba23e1

line 690why, one step back
690 if (input_run != NULL && !(conf->password_mode.enabled && !use_placeholder)) {

render: scroll input to ensure cursor is always visibleDaniel Eklöfbefore adoption544c59a

lines 691–694why, one step back
691 /* We only shape the placeholder string */
692 assert(use_placeholder);693694 for (size_t i = render->input_glyph_offset; i < input_run->count; i++) {

render: font-shape the input stringDaniel Eklöfbefore adoption3ba23e1

line 695why, one step back
695 const struct fcft_glyph *glyph = input_run->glyphs[i];

render: scroll input to ensure cursor is always visibleDaniel Eklöfbefore adoption544c59a

lines 696–698why, one step back
696 const int pixels_needed = max(glyph->x + glyph->width, glyph->advance.x);
697698 if (x + pixels_needed > max_x) {

render: font-shape the input stringDaniel Eklöfbefore adoption3ba23e1

line 699why, one step back
699 goto out;

render: scroll input to ensure cursor is always visibleDaniel Eklöfbefore adoption544c59a

line 700why, one step back
700 }

render: font-shape the input stringDaniel Eklöfbefore adoption3ba23e1

lines 701–717why, one step back
701
702 render_glyph(buf->pix[0], glyph, x, y,703 use_placeholder704 ? &render->pix_placeholder_color705 : &render->pix_input_color);706 x += glyph->advance.x;707708 /* Cursor */709 const int cur_cluster = input_run->cluster[i];710 const int next_cluster = i + 1 < input_run->count711 ? input_run->cluster[i + 1] : INT_MAX;712713 if (cursor_location > cur_cluster &&714 cursor_location <= next_cluster)715 {716 render_cursor(render, x, y, buf->pix[0]);717 }

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 718why, one step back
718 }

render: font-shape the input stringDaniel Eklöfbefore adoption3ba23e1

lines 719–720why, one step back
719 } else {
720 char32_t prev = 0;

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 721why, one step back
721

render: scroll input to ensure cursor is always visibleDaniel Eklöfbefore adoption544c59a

line 722why, one step back
722 for (size_t i = render->input_glyph_offset; i < text_len; i++) {

render: font-shape the input stringDaniel Eklöfbefore adoption3ba23e1

lines 723–729why, one step back
723 if (conf->password_mode.enabled &&
724 conf->password_mode.character == U'\0' &&725 !use_placeholder)726 {727 continue;728 }729

render: scroll input to ensure cursor is always visibleDaniel Eklöfbefore adoption544c59a

line 730why, one step back
730 const struct fcft_glyph *glyph = input_glyphs[i];

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 731why, one step back
731

render: font-shape the input stringDaniel Eklöfbefore adoption3ba23e1

line 732why, one step back
732 if (glyph == NULL) {

render: scroll input to ensure cursor is always visibleDaniel Eklöfbefore adoption544c59a

line 733why, one step back
733 prev = 0;

render: font-shape the input stringDaniel Eklöfbefore adoption3ba23e1

lines 734–735why, one step back
734 continue;
735 }

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 736why, one step back
736

render: font-shape the input stringDaniel Eklöfbefore adoption3ba23e1

line 737why, one step back
737 long x_kern;

render: scroll input to ensure cursor is always visibleDaniel Eklöfbefore adoption544c59a

line 738why, one step back
738 fcft_kerning(font, prev, glyph->cp, &x_kern, NULL);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 739why, one step back
739

render: font-shape the input stringDaniel Eklöfbefore adoption3ba23e1

line 740why, one step back
740 x += x_kern;

render: display match+total entry countDaniel Eklöfbefore adoptionb32836d

line 741why, one step back
741

render: scroll input to ensure cursor is always visibleDaniel Eklöfbefore adoption544c59a

lines 742–744why, one step back
742 const int pixels_needed = max(glyph->x + glyph->width, glyph->advance.x);
743744 if (x + pixels_needed > max_x)

render: font-shape the input stringDaniel Eklöfbefore adoption3ba23e1

line 745why, one step back
745 goto out;

render: display match+total entry countDaniel Eklöfbefore adoptionb32836d

line 746why, one step back
746

render: font-shape the input stringDaniel Eklöfbefore adoption3ba23e1

lines 747–752why, one step back
747 render_glyph(
748 buf->pix[0], glyph, x, y,749 use_placeholder750 ? &render->pix_placeholder_color751 : &render->pix_input_color);752 x += glyph->advance.x;

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 753–754why, one step back
753 x += pt_or_px_as_pixels(render, &render->conf->letter_spacing);
754

render: font-shape the input stringDaniel Eklöfbefore adoption3ba23e1

lines 755–757why, one step back
755 /* Cursor */
756 if (cursor_location > 0 && cursor_location - 1 == i)757 render_cursor(render, x, y, buf->pix[0]);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 758why, one step back
758

render: scroll input to ensure cursor is always visibleDaniel Eklöfbefore adoption544c59a

line 759why, one step back
759 prev = glyph->cp;

render: font-shape the input stringDaniel Eklöfbefore adoption3ba23e1

line 760why, one step back
760 }

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 761why, one step back
761 }

render: font-shape the input stringDaniel Eklöfbefore adoption3ba23e1

lines 762–771why, one step back
762
763out:764 if (render->prompt_text_run == NULL)765 render->prompt_text_run = prompt_run;766 else if (prompt_run != render->prompt_text_run)767 fcft_text_run_destroy(prompt_run);768 if (use_placeholder && render->placeholder_text_run == NULL)769 render->placeholder_text_run = input_run;770 else if (!use_placeholder || input_run != render->placeholder_text_run)771 fcft_text_run_destroy(input_run);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 772–774why, one step back
772}
773774static void

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

line 775why, one step back
775render_match_text(pixman_image_t *pix, double *_x, double _y, double max_x,

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 776–803why, one step back
776 const char32_t *text, size_t match_count,
777 const struct match_substring matches[static match_count],778 struct fcft_font *font, enum fcft_subpixel subpixel,779 int letter_spacing, int tabs,780 pixman_color_t regular_color, pixman_color_t match_color,781 struct fcft_text_run **run)782{783 int x = *_x;784 int y = _y;785786 const struct fcft_glyph **glyphs = NULL;787 int *clusters = NULL;788 long *kern = NULL;789 size_t count = 0;790791 if (*run == NULL &&792 (fcft_capabilities() & FCFT_CAPABILITY_TEXT_RUN_SHAPING))793 {794 *run = fcft_rasterize_text_run_utf32(795 font, c32len(text), text, subpixel);796 }797798 if (*run != NULL) {799 glyphs = (*run)->glyphs;800 clusters = (*run)->cluster;801 count = (*run)->count;802 } else {803 count = c32len(text);

Add xmalloc.h and xsnprintf.h and use to improve/simplify error handlingCraig Barnesbefore adoption539d514

lines 804–806why, one step back
804 glyphs = xmalloc(count * sizeof(glyphs[0]));
805 clusters = xmalloc(count * sizeof(clusters[0]));806 kern = xmalloc(count * sizeof(kern[0]));

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 807–853why, one step back
807
808 for (size_t i = 0; i < count; i++) {809 const struct fcft_glyph *glyph = fcft_rasterize_char_utf32(810 font, text[i], subpixel);811 if (glyph == NULL) {812 glyphs[i] = NULL;813 continue;814 }815816 if (i > 0)817 fcft_kerning(font, text[i - 1], text[i], &kern[i], NULL);818 else819 kern[i] = 0;820821 glyphs[i] = glyph;822 clusters[i] = i;823 }824 }825826 for (size_t i = 0; i < count; i++) {827 if (text[clusters[i]] == U'\t') {828 const struct fcft_glyph *space =829 fcft_rasterize_char_utf32(font, U' ', subpixel);830831 if (space != NULL) {832 const size_t chars_to_next_tab_stop = tabs == 0833 ? 0834 : tabs - (clusters[i] % tabs);835 x += chars_to_next_tab_stop * space->advance.x;836 }837838 continue;839 }840841 bool is_match = false;842 for (size_t j = 0; j < match_count; j++) {843 const struct match_substring *match = &matches[j];844 assert(match->start >= 0);845846 if (clusters[i] >= match->start &&847 clusters[i] < match->start + match->len)848 {849 is_match = true;850 break;851 }852 }853

render: scroll input to ensure cursor is always visibleDaniel Eklöfbefore adoption544c59a

line 854why, one step back
854 if (x + (kern != NULL ? kern[i] : 0) + glyphs[i]->advance.x > max_x) {

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 855–858why, one step back
855 const struct fcft_glyph *ellipses =
856 fcft_rasterize_char_utf32(font, U'…', subpixel);857858 if (ellipses != NULL)

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

line 859why, one step back
859 render_glyph(pix, ellipses, x, y, &regular_color);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 860–864why, one step back
860
861 break;862 }863864 x += kern != NULL ? kern[i] : 0;

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

line 865why, one step back
865 render_glyph(pix, glyphs[i], x, y, is_match ? &match_color : &regular_color);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 866–880why, one step back
866 x += glyphs[i]->advance.x + letter_spacing;
867 y += glyphs[i]->advance.y;868 }869870 if (*run == NULL) {871 free(kern);872 free(clusters);873 free(glyphs);874 }875876 *_x = x;877}878879#if defined(FUZZEL_ENABLE_SVG_LIBRSVG)880static void

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

line 881why, one step back
881render_svg_librsvg(const struct icon *icon, int x, int y, int size,

Fix compilation with librsvg after adding threading renderingDaniel Eklöfbefore adoption3d8da6f

line 882why, one step back
882 cairo_t *cairo)

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 883–885why, one step back
883{
884 RsvgHandle *svg = icon->svg;885

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

lines 886–887why, one step back
886 cairo_save(cairo);
887 cairo_set_operator(cairo, CAIRO_OPERATOR_ATOP);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 888–889why, one step back
888
889 #if LIBRSVG_CHECK_VERSION(2, 46, 0)

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

line 890why, one step back
890 if (cairo_status(cairo) == CAIRO_STATUS_SUCCESS) {

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 891–897why, one step back
891 const RsvgRectangle viewport = {
892 .x = x,893 .y = y,894 .width = size,895 .height = size,896 };897

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

lines 898–899why, one step back
898 cairo_rectangle(cairo, x, y, size, size);
899 cairo_clip(cairo);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 900why, one step back
900

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

line 901why, one step back
901 rsvg_handle_render_document(svg, cairo, &viewport, NULL);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 902–913why, one step back
902 }
903 #else904 RsvgDimensionData dim;905 rsvg_handle_get_dimensions(svg, &dim);906907 const double scale_x = size / dim.width;908 const double scale_y = size / dim.height;909 const double scale = scale_x < scale_y ? scale_x : scale_y;910911 const double height = dim.height * scale;912 const double width = dim.width * scale;913

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

lines 914–915why, one step back
914 cairo_rectangle(cairo, x, y, height, width);
915 cairo_clip(cairo);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 916–917why, one step back
916
917 /* Translate + scale. Note: order matters! */

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

lines 918–919why, one step back
918 cairo_translate(cairo, x, y);
919 cairo_scale(cairo, scale, scale);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 920why, one step back
920

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

lines 921–922why, one step back
921 if (cairo_status(cairo) == CAIRO_STATUS_SUCCESS)
922 rsvg_handle_render_cairo(svg, cairo);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 923why, one step back
923 #endif

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

line 924why, one step back
924 cairo_restore(cairo);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 925–929why, one step back
925}
926#endif /* FUZZEL_ENABLE_SVG_LIBRSVG */927928#if defined(FUZZEL_ENABLE_SVG_NANOSVG)929static void

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

line 930why, one step back
930render_svg_nanosvg(struct icon *icon, int x, int y, int size,

Implement gamma-correct blendingDaniel Eklöfbefore adoption2d19826

line 931why, one step back
931 pixman_image_t *pix, cairo_t *cairo, bool gamma_correct)

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 932–933why, one step back
932{
933#if defined(FUZZEL_ENABLE_CAIRO)

Fix compilation with librsvg after adding threading renderingDaniel Eklöfbefore adoption3d8da6f

line 934why, one step back
934 cairo_surface_flush(cairo_get_target(cairo));

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 935–953why, one step back
935#endif
936937 pixman_image_t *img = NULL;938939 /* Look for a cached image, at the correct size */940 tll_foreach(icon->rasterized, it) {941 if (it->item.size == size) {942 img = it->item.pix;943 break;944 }945 }946947 if (img == NULL) {948 NSVGimage *svg = icon->svg;949 struct NSVGrasterizer *rast = nsvgCreateRasterizer();950951 if (rast == NULL)952 return;953

Implement gamma-correct blendingDaniel Eklöfbefore adoption2d19826

lines 954–958why, one step back
954 /* For gamma-correct blending */
955 uint8_t *data_16bit = NULL;956 pixman_image_t *img_16bit = NULL;957 uint64_t *abgr16 = NULL;958

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 959–960why, one step back
959 float scale = svg->width > svg->height ? size / svg->width : size / svg->height;
960

render: nanosvg: don't assume image is squareDaniel Eklöfbefore adoptioncb796a5

lines 961–962why, one step back
961 const int width = roundf(svg->width * scale);
962 const int height = roundf(svg->height * scale);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 963why, one step back
963

render: nanosvg: don't assume image is squareDaniel Eklöfbefore adoptioncb796a5

line 964why, one step back
964 uint8_t *data_8bit = xmalloc(width * height * 4);

Implement gamma-correct blendingDaniel Eklöfbefore adoption2d19826

line 965why, one step back
965

render: nanosvg: don't assume image is squareDaniel Eklöfbefore adoptioncb796a5

lines 966–967why, one step back
966 nsvgRasterize(rast, svg, 0, 0, scale, data_8bit, width, height, width * 4);
967

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 968why, one step back
968 img = pixman_image_create_bits_no_clear(

render: nanosvg: don't assume image is squareDaniel Eklöfbefore adoptioncb796a5

line 969why, one step back
969 PIXMAN_a8b8g8r8, width, height, (uint32_t *)data_8bit, width * 4);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 970why, one step back
970

Implement gamma-correct blendingDaniel Eklöfbefore adoption2d19826

line 971why, one step back
971 if (gamma_correct) {

render: nanosvg: don't assume image is squareDaniel Eklöfbefore adoptioncb796a5

line 972why, one step back
972 data_16bit = xmalloc(width * height * 8);

Implement gamma-correct blendingDaniel Eklöfbefore adoption2d19826

lines 973–975why, one step back
973 abgr16 = (uint64_t *)data_16bit;
974975 img_16bit = pixman_image_create_bits_no_clear(

render: nanosvg: don't assume image is squareDaniel Eklöfbefore adoptioncb796a5

lines 976–977why, one step back
976 PIXMAN_a16b16g16r16, width, height, (uint32_t *)data_16bit,
977 width * 8);

Implement gamma-correct blendingDaniel Eklöfbefore adoption2d19826

lines 978–979why, one step back
978 }
979

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 980–981why, one step back
980 /* Nanosvg produces non-premultiplied ABGR, while pixman expects
981 * premultiplied */

Implement gamma-correct blendingDaniel Eklöfbefore adoption2d19826

lines 982–983why, one step back
982
983 for (uint32_t *abgr = (uint32_t *)data_8bit;

render: nanosvg: don't assume image is squareDaniel Eklöfbefore adoptioncb796a5

line 984why, one step back
984 abgr < (uint32_t *)(data_8bit + width * height * 4);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 985–986why, one step back
985 abgr++)
986 {

Implement gamma-correct blendingDaniel Eklöfbefore adoption2d19826

lines 987–990why, one step back
987 uint16_t alpha = (*abgr >> 24) & 0xff;
988 uint16_t blue = (*abgr >> 16) & 0xff;989 uint16_t green = (*abgr >> 8) & 0xff;990 uint16_t red = (*abgr >> 0) & 0xff;

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 991why, one step back
991

Implement gamma-correct blendingDaniel Eklöfbefore adoption2d19826

lines 992–997why, one step back
992 /*
993 * TODO: decode sRGB -> linear here994 *995 * We should decode to 16-bit, meaning we have to prepare996 * a 16-bit buffer before looping the pixels.997 */

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 998why, one step back
998

Implement gamma-correct blendingDaniel Eklöfbefore adoption2d19826

lines 999–1024why, one step back
999 if (gamma_correct) {
1000 if (alpha == 0x00)1001 blue = green = red = 0x00;1002 else {1003 alpha |= alpha << 8; /* Alpha already linear, expand to 16-bit */1004 blue = srgb_decode_8_to_16(blue);1005 green = srgb_decode_8_to_16(green);1006 red = srgb_decode_8_to_16(red);10071008 blue = blue * alpha / 0xffff;1009 green = green * alpha / 0xffff;1010 red = red * alpha / 0xffff;1011 }10121013 *abgr16 = (uint64_t)alpha << 48 | (uint64_t)blue << 32 | (uint64_t)green << 16 | (uint64_t)red;1014 abgr16++;1015 } else {1016 if (alpha == 0x00)1017 blue = green = red = 0x00;1018 else {1019 blue = (uint8_t)(blue * alpha / 0xff);1020 green = (uint8_t)(green * alpha / 0xff);1021 red = (uint8_t)(red * alpha / 0xff);1022 }10231024 *abgr = (uint32_t)alpha << 24 | blue << 16 | green << 8 | red;

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1025why, one step back
1025 }

Implement gamma-correct blendingDaniel Eklöfbefore adoption2d19826

line 1026why, one step back
1026 }

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1027why, one step back
1027

Implement gamma-correct blendingDaniel Eklöfbefore adoption2d19826

lines 1028–1032why, one step back
1028 if (gamma_correct) {
1029 /* Replace default image buffer with 16-bit linear buffer */1030 pixman_image_unref(img);1031 free(data_8bit);1032 img = img_16bit;

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 1033–1035why, one step back
1033 }
10341035 nsvgDeleteRasterizer(rast);

Implement gamma-correct blendingDaniel Eklöfbefore adoption2d19826

line 1036why, one step back
1036

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 1037–1039why, one step back
1037 tll_push_back(icon->rasterized, ((struct rasterized){img, size}));
1038 }1039

render: nanosvg: don't assume image is squareDaniel Eklöfbefore adoptioncb796a5

lines 1040–1042why, one step back
1040 const int w = pixman_image_get_width(img);
1041 const int h = pixman_image_get_height(img);1042

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1043why, one step back
1043 pixman_image_composite32(

render: nanosvg: don't assume image is squareDaniel Eklöfbefore adoptioncb796a5

lines 1044–1047why, one step back
1044 PIXMAN_OP_OVER, img, NULL, pix, 0, 0, 0, 0,
1045 x + (size - w) / 2,1046 y + (size - h) / 2,1047 w, h);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 1048–1049why, one step back
1048
1049#if defined(FUZZEL_ENABLE_CAIRO)

Fix compilation with librsvg after adding threading renderingDaniel Eklöfbefore adoption3d8da6f

line 1050why, one step back
1050 cairo_surface_mark_dirty(cairo_get_target(cairo));

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 1051–1055why, one step back
1051#endif
1052}1053#endif /* FUZZEL_ENABLE_SVG_NANOSVG */10541055static void

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

line 1056why, one step back
1056render_svg(struct icon *icon, int x, int y, int size,

debug: add a --print-timing-info command line optionDaniel Eklöfbefore adoption1ea01b1

lines 1057–1058why, one step back
1057 pixman_image_t *pix, cairo_t *cairo, bool gamma_correct,
1058 bool print_timing_info)

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 1059–1062why, one step back
1059{
1060 assert(icon->type == ICON_SVG);10611062 if (icon->svg == NULL) {

debug: add a --print-timing-info command line optionDaniel Eklöfbefore adoption1ea01b1

lines 1063–1065why, one step back
1063 struct timeval start, stop, diff;
1064 gettimeofday(&start, NULL);1065

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 1066–1067why, one step back
1066 if (!icon_from_svg(icon, icon->path))
1067 return;

debug: add a --print-timing-info command line optionDaniel Eklöfbefore adoption1ea01b1

lines 1068–1078why, one step back
1068
1069 if (print_timing_info) {1070 gettimeofday(&stop, NULL);1071 timersub(&stop, &start, &diff);10721073 LOG_WARN("%s loaded in %llus %lluµs",1074 icon->path,1075 (unsigned long long)diff.tv_sec,1076 (unsigned long long)diff.tv_usec);1077 }1078

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 1079–1081why, one step back
1079 LOG_DBG("%s", icon->path);
1080 }1081

debug: add a --print-timing-info command line optionDaniel Eklöfbefore adoption1ea01b1

lines 1082–1084why, one step back
1082 struct timeval start, stop, diff;
1083 gettimeofday(&start, NULL);1084

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1085why, one step back
1085#if defined(FUZZEL_ENABLE_SVG_LIBRSVG)

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

line 1086why, one step back
1086 render_svg_librsvg(icon, x, y, size, cairo);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1087why, one step back
1087#elif defined(FUZZEL_ENABLE_SVG_NANOSVG)

Implement gamma-correct blendingDaniel Eklöfbefore adoption2d19826

line 1088why, one step back
1088 render_svg_nanosvg(icon, x, y, size, pix, cairo, gamma_correct);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1089why, one step back
1089#endif

debug: add a --print-timing-info command line optionDaniel Eklöfbefore adoption1ea01b1

lines 1090–1099why, one step back
1090
1091 if (print_timing_info) {1092 gettimeofday(&stop, NULL);1093 timersub(&stop, &start, &diff);10941095 LOG_WARN("%s rendered in %llus %lluµs",1096 icon->path,1097 (unsigned long long)diff.tv_sec,1098 (unsigned long long)diff.tv_usec);1099 }

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 1100–1103why, one step back
1100}
11011102#if defined(FUZZEL_ENABLE_PNG_LIBPNG)1103static void

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

line 1104why, one step back
1104render_png_libpng(struct icon *icon, int x, int y, int size,

config: add scaling-filter optionDaniel Eklöfbefore adoption3866f60

lines 1105–1106why, one step back
1105 pixman_image_t *pix, cairo_t *cairo,
1106 enum scaling_filter scaling_filter)

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 1107–1108why, one step back
1107{
1108#if defined(FUZZEL_ENABLE_CAIRO)

Fix compilation with librsvg after adding threading renderingDaniel Eklöfbefore adoption3d8da6f

line 1109why, one step back
1109 cairo_surface_flush(cairo_get_target(cairo));

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 1110–1116why, one step back
1110#endif
11111112 pixman_image_t *png = icon->png;1113 pixman_format_code_t fmt = pixman_image_get_format(png);1114 int height = pixman_image_get_height(png);1115 int width = pixman_image_get_width(png);1116

render: use the larger value of width/height when scaling too large PNGsDaniel Eklöfbefore adoption80947e5

lines 1117–1118why, one step back
1117 if (height > size || width > size) {
1118 double scale = (double)size / (height > width ? height : width);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 1119–1127why, one step back
1119
1120 pixman_f_transform_t _scale_transform;1121 pixman_f_transform_init_scale(&_scale_transform, 1. / scale, 1. / scale);11221123 pixman_transform_t scale_transform;1124 pixman_transform_from_pixman_f_transform(1125 &scale_transform, &_scale_transform);1126 pixman_image_set_transform(png, &scale_transform);1127

config: add scaling-filter optionDaniel Eklöfbefore adoption3866f60

lines 1128–1130why, one step back
1128 const int largest_side = max(width, height);
11291130 if (largest_side >= 1024) {

render: use the 'fast' filter to downscale "too large" PNG iconsDaniel Eklöfbefore adoptionfe2a08d

lines 1131–1133why, one step back
1131 if (!icon->png_size_warned) {
1132 LOG_WARN(1133 "%s: PNG is too large (%dx%d); "

config: add scaling-filter optionDaniel Eklöfbefore adoption3866f60

line 1134why, one step back
1134 "downscaling using a less precise filter (fast)",

render: use the 'fast' filter to downscale "too large" PNG iconsDaniel Eklöfbefore adoptionfe2a08d

lines 1135–1137why, one step back
1135 icon->path, width, height);
1136 icon->png_size_warned = true;1137 }

config: add scaling-filter optionDaniel Eklöfbefore adoption3866f60

line 1138why, one step back
1138

render: use the 'fast' filter to downscale "too large" PNG iconsDaniel Eklöfbefore adoptionfe2a08d

line 1139why, one step back
1139 pixman_image_set_filter(png, PIXMAN_FILTER_FAST, NULL, 0);

config: add scaling-filter optionDaniel Eklöfbefore adoption3866f60

line 1140why, one step back
1140 }

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1141why, one step back
1141

config: add scaling-filter optionDaniel Eklöfbefore adoption3866f60

lines 1142–1160why, one step back
1142 else {
11431144 bool slow_scaling_filter = false;11451146 switch (scaling_filter) {1147 case SCALING_FILTER_NONE:1148 case SCALING_FILTER_NEAREST:1149 case SCALING_FILTER_BILINEAR:1150 case SCALING_FILTER_BOX:1151 slow_scaling_filter = false;1152 break;11531154 case SCALING_FILTER_CUBIC:1155 case SCALING_FILTER_LANCZOS3:1156 case SCALING_FILTER_LINEAR:1157 case SCALING_FILTER_LANCZOS2:1158 case SCALING_FILTER_LANCZOS3_STRETCHED:1159 slow_scaling_filter = true;1160 break;

render: use the 'fast' filter to downscale "too large" PNG iconsDaniel Eklöfbefore adoptionfe2a08d

line 1161why, one step back
1161 }

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1162why, one step back
1162

config: add scaling-filter optionDaniel Eklöfbefore adoption3866f60

lines 1163–1232why, one step back
1163 if (slow_scaling_filter && largest_side >= 256) {
1164 if (!icon->png_size_warned) {1165 LOG_WARN(1166 "%s: PNG is too large (%dx%d); "1167 "downscaling using a less precise filter (box)",1168 icon->path, width, height);1169 icon->png_size_warned = true;1170 }11711172 scaling_filter = SCALING_FILTER_BOX;1173 }11741175 switch (scaling_filter) {1176 case SCALING_FILTER_NONE:1177 break;11781179 /*1180 * "simple" filters1181 */11821183 case SCALING_FILTER_NEAREST:1184 pixman_image_set_filter(png, PIXMAN_FILTER_NEAREST, NULL, 0);1185 break;11861187 case SCALING_FILTER_BILINEAR:1188 pixman_image_set_filter(png, PIXMAN_FILTER_BILINEAR, NULL, 0);1189 break;11901191 /*1192 * Separable convolution filters1193 */1194 case SCALING_FILTER_CUBIC:1195 case SCALING_FILTER_LANCZOS3:1196 case SCALING_FILTER_BOX:1197 case SCALING_FILTER_LINEAR:1198 case SCALING_FILTER_LANCZOS2:1199 case SCALING_FILTER_LANCZOS3_STRETCHED: {12001201 pixman_kernel_t kernel;12021203 switch (scaling_filter) {1204 case SCALING_FILTER_CUBIC: kernel = PIXMAN_KERNEL_CUBIC; break;1205 case SCALING_FILTER_LANCZOS3: kernel = PIXMAN_KERNEL_LANCZOS3; break;1206 case SCALING_FILTER_BOX: kernel = PIXMAN_KERNEL_BOX; break;1207 case SCALING_FILTER_LINEAR: kernel = PIXMAN_KERNEL_LINEAR; break;1208 case SCALING_FILTER_LANCZOS2: kernel = PIXMAN_KERNEL_LANCZOS2; break;1209 case SCALING_FILTER_LANCZOS3_STRETCHED: kernel = PIXMAN_KERNEL_LANCZOS3_STRETCHED; break;1210 default: assert(false); kernel = PIXMAN_KERNEL_CUBIC; break;1211 }12121213 int param_count = 0;1214 pixman_fixed_t *params = pixman_filter_create_separable_convolution(1215 &param_count,1216 pixman_double_to_fixed(1. / scale),1217 pixman_double_to_fixed(1. / scale),1218 kernel, kernel,1219 kernel, kernel,1220 pixman_int_to_fixed(1),1221 pixman_int_to_fixed(1));12221223 if (params != NULL || param_count == 0) {1224 pixman_image_set_filter(1225 png, PIXMAN_FILTER_SEPARABLE_CONVOLUTION,1226 params, param_count);1227 }12281229 free(params);1230 break;1231 }1232 }

render: use the 'fast' filter to downscale "too large" PNG iconsDaniel Eklöfbefore adoptionfe2a08d

line 1233why, one step back
1233 }

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 1234–1238why, one step back
1234
1235 width *= scale;1236 height *= scale;12371238 int stride = stride_for_format_and_width(fmt, width);

Add xmalloc.h and xsnprintf.h and use to improve/simplify error handlingCraig Barnesbefore adoption539d514

line 1239why, one step back
1239 uint8_t *data = xmalloc(height * stride);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 1240–1252why, one step back
1240 pixman_image_t *scaled_png = pixman_image_create_bits_no_clear(
1241 fmt, width, height, (uint32_t *)data, stride);1242 pixman_image_composite32(1243 PIXMAN_OP_SRC, png, NULL, scaled_png, 0, 0, 0, 0, 0, 0, width, height);12441245 free(pixman_image_get_data(png));1246 pixman_image_unref(png);12471248 png = scaled_png;1249 icon->png = png;1250 }12511252 pixman_image_composite32(

render: use the larger value of width/height when scaling too large PNGsDaniel Eklöfbefore adoption80947e5

lines 1253–1256why, one step back
1253 PIXMAN_OP_OVER, png, NULL, pix, 0, 0, 0, 0,
1254 x + (size - width) / 2,1255 y + (size - height) / 2,1256 width, height);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 1257–1258why, one step back
1257
1258#if defined(FUZZEL_ENABLE_CAIRO)

Fix compilation with librsvg after adding threading renderingDaniel Eklöfbefore adoption3d8da6f

line 1259why, one step back
1259 cairo_surface_mark_dirty(cairo_get_target(cairo));

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 1260–1264why, one step back
1260#endif
1261}1262#endif /* FUZZEL_ENABLE_PNG_LIBPNG */12631264static void

Fix compilation with librsvg after adding threading renderingDaniel Eklöfbefore adoption3d8da6f

line 1265why, one step back
1265render_png(struct icon *icon, int x, int y, int size, pixman_image_t *pix,

config: add scaling-filter optionDaniel Eklöfbefore adoption3866f60

lines 1266–1267why, one step back
1266 cairo_t *cairo, bool gamma_correct, bool print_timing_info,
1267 enum scaling_filter scaling_filter)

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 1268–1271why, one step back
1268{
1269 assert(icon->type == ICON_PNG);12701271 if (icon->png == NULL) {

debug: add a --print-timing-info command line optionDaniel Eklöfbefore adoption1ea01b1

lines 1272–1274why, one step back
1272 struct timeval start, stop, diff;
1273 gettimeofday(&start, NULL);1274

Implement gamma-correct blendingDaniel Eklöfbefore adoption2d19826

line 1275why, one step back
1275 if (!icon_from_png(icon, icon->path, gamma_correct))

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1276why, one step back
1276 return;

debug: add a --print-timing-info command line optionDaniel Eklöfbefore adoption1ea01b1

lines 1277–1286why, one step back
1277
1278 if (print_timing_info) {1279 gettimeofday(&stop, NULL);1280 timersub(&stop, &start, &diff);1281 LOG_WARN("%s loaded in %llus %lluµs",1282 icon->path,1283 (unsigned long long)diff.tv_sec,1284 (unsigned long long)diff.tv_usec);1285 }1286

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 1287–1289why, one step back
1287 LOG_DBG("%s", icon->path);
1288 }1289

debug: add a --print-timing-info command line optionDaniel Eklöfbefore adoption1ea01b1

lines 1290–1292why, one step back
1290 struct timeval start, stop, diff;
1291 gettimeofday(&start, NULL);1292

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1293why, one step back
1293#if defined(FUZZEL_ENABLE_PNG_LIBPNG)

config: add scaling-filter optionDaniel Eklöfbefore adoption3866f60

line 1294why, one step back
1294 render_png_libpng(icon, x, y, size, pix, cairo, scaling_filter);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1295why, one step back
1295#endif

debug: add a --print-timing-info command line optionDaniel Eklöfbefore adoption1ea01b1

lines 1296–1304why, one step back
1296
1297 if (print_timing_info) {1298 gettimeofday(&stop, NULL);1299 timersub(&stop, &start, &diff);1300 LOG_WARN("%s rendered in %llus %lluµs",1301 icon->path,1302 (unsigned long long)diff.tv_sec,1303 (unsigned long long)diff.tv_usec);1304 }

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 1305–1306why, one step back
1305}
1306

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

lines 1307–1308why, one step back
1307static int
1308first_row_y(const struct render *render)

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1309why, one step back
1309{

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

lines 1310–1311why, one step back
1310 return (render->border_size +
1311 render->y_margin +

✨ New Feature: Hide Input Line (#597)Mark Stosbergbefore adoption1ea0283

lines 1312–1313why, one step back
1312 (render->conf->hide_prompt ? 0 : render->row_height) +
1313 (render->conf->hide_prompt ? 0 : render->inner_pad));

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

line 1314why, one step back
1314}

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1315why, one step back
1315

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

line 1316why, one step back
1316static void

render: only do a full background fill on fresh buffersDaniel Eklöfbefore adoption01471e3

line 1317why, one step back
1317render_match_entry_background(const struct render *render,

render: regression: selected entry's background not rendered on top of regular backgroundDaniel Eklöfbefore adoption0e0ece6

line 1318why, one step back
1318 int idx, int row_count,

render: only do a full background fill on fresh buffersDaniel Eklöfbefore adoption01471e3

lines 1319–1320why, one step back
1319 pixman_image_t *pix, int width)
1320{

render: regression: selected entry's background not rendered on top of regular backgroundDaniel Eklöfbefore adoption0e0ece6

line 1321why, one step back
1321 pixman_color_t bg = render->pix_background_color;

render: only do a full background fill on fresh buffersDaniel Eklöfbefore adoption01471e3

lines 1322–1334why, one step back
1322
1323 const int sel_margin = render->x_margin / 3;13241325 const int x = render->border_size + render->x_margin - sel_margin;1326 const int y = first_row_y(render) + idx * render->row_height;1327 const int w = width - 2 * (render->border_size + render->x_margin - sel_margin);1328 const int h = row_count * render->row_height;13291330 pixman_image_fill_rectangles(1331 PIXMAN_OP_SRC, pix, &bg, 1, &(pixman_rectangle16_t){x, y, w, h});1332}13331334static void

feat: border radius for selected entrieswisplbefore adoption9836d81

line 1335why, one step back
1335render_selected_match_entry_background(struct render *render,

render: regression: selected entry's background not rendered on top of regular backgroundDaniel Eklöfbefore adoption0e0ece6

lines 1336–1346why, one step back
1336 int idx, pixman_image_t *pix, int width)
1337{1338 pixman_color_t bg = render->pix_selection_color;13391340 const int sel_margin = render->x_margin / 3;13411342 const int x = render->border_size + render->x_margin - sel_margin;1343 const int y = first_row_y(render) + idx * render->row_height;1344 const int w = width - 2 * (render->border_size + render->x_margin - sel_margin);1345 const int h = 1 * render->row_height;1346

feat: border radius for selected entrieswisplbefore adoption9836d81

lines 1347–1359why, one step back
1347 // limit radius to half of height, any larger and it causes weird shapes
1348 // also limit it when horizontal padding is small, to prevent icon pop out1349 const unsigned int radius = min(1350 min(render->selection_border_radius, h / 2), render->x_margin);13511352 if (render->selection_corners == NULL) {1353 render->selection_corners = pixman_image_create_bits(1354 pixman_image_get_format(pix), w, h, NULL, w * 4);1355 render_rounded_rectangle(render->selection_corners, &bg, &bg, radius, 0, 0, 0, w, h);1356 }1357 pixman_image_composite(1358 PIXMAN_OP_OVER, render->selection_corners, NULL, pix,1359 0, 0, 0, 0, x, y, w, h);

render: regression: selected entry's background not rendered on top of regular backgroundDaniel Eklöfbefore adoption0e0ece6

lines 1360–1362why, one step back
1360}
13611362static void

feat: border radius for selected entrieswisplbefore adoption9836d81

line 1363why, one step back
1363render_one_match_entry(struct render *render, const struct matches *matches,

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

lines 1364–1365why, one step back
1364 const struct match *match, bool render_icons,
1365 int idx, bool is_selected, int width, int height,

Fix compilation with librsvg after adding threading renderingDaniel Eklöfbefore adoption3d8da6f

line 1366why, one step back
1366 pixman_image_t *pix, cairo_t *cairo)

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

line 1367why, one step back
1367{

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 1368–1370why, one step back
1368 const enum fcft_subpixel subpixel =
1369 (render->conf->colors.background.a == 1. &&1370 render->conf->colors.selection.a == 1.)

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

line 1371why, one step back
1371 ? render->subpixel : FCFT_SUBPIXEL_NONE;

render: add support for rendering the selected entry in boldDaniel Eklöfbefore adoption8d77e69

lines 1372–1374why, one step back
1372
1373 struct fcft_font *font =1374 is_selected ? render->font_bold : render->font;

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1375why, one step back
1375 const struct fcft_glyph *ellipses =

render: add support for rendering the selected entry in boldDaniel Eklöfbefore adoption8d77e69

line 1376why, one step back
1376 fcft_rasterize_char_utf32(font, U'…', subpixel);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1377why, one step back
1377

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

lines 1378–1380why, one step back
1378 const int first_row = first_row_y(render);
1379 double cur_x = render->border_size + render->x_margin;1380 double max_x = width - render->border_size - render->x_margin;

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1381why, one step back
1381

render: regression: selected entry's background not rendered on top of regular backgroundDaniel Eklöfbefore adoption0e0ece6

line 1382why, one step back
1382 render_match_entry_background(render, idx, 1, pix, width);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1383why, one step back
1383

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

line 1384why, one step back
1384 if (is_selected) {

render: regression: selected entry's background not rendered on top of regular backgroundDaniel Eklöfbefore adoption0e0ece6

lines 1385–1386why, one step back
1385 render_selected_match_entry_background(render, idx, pix, width);
1386

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

lines 1387–1389why, one step back
1387 /* If currently selected item has a scalable icon, and if
1388 * there's "enough" free space, render a large representation1389 * of the icon */

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1390why, one step back
1390

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

lines 1391–1397why, one step back
1391 const double ratio = render->conf->image_size_ratio;
1392 const double size = min(height * ratio, width * ratio);1393 const double img_x = (width - size) / 2.;1394 const double img_y_bottom = max(height - first_row, 0.);1395 const double img_y = max(img_y_bottom - size, 0.);1396 const size_t match_count = matches_get_count(matches);1397 const double list_end = first_row + match_count * render->row_height;

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1398why, one step back
1398

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

line 1399why, one step back
1399 LOG_DBG("img_y=%f, list_end=%f", img_y, list_end);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1400why, one step back
1400

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

lines 1401–1404why, one step back
1401 if (render_icons &&
1402 match->application->icon.type == ICON_SVG &&1403 img_y > list_end + render->row_height)1404 {

debug: add a --print-timing-info command line optionDaniel Eklöfbefore adoption1ea01b1

lines 1405–1406why, one step back
1405 render_svg(&match->application->icon, img_x, img_y, size, pix, cairo,
1406 render->gamma_correct, render->conf->print_timing_info);

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

lines 1407–1408why, one step back
1407 }
1408 }

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1409why, one step back
1409

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

lines 1410–1414why, one step back
1410 if (render_icons) {
1411 struct icon *icon = &match->application->icon;1412 const int size = render->icon_height;1413 const int img_x = cur_x;1414 const int img_y = first_row + idx * render->row_height + (render->row_height - size) / 2;

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1415why, one step back
1415

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

lines 1416–1418why, one step back
1416 switch (icon->type) {
1417 case ICON_NONE:1418 break;

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1419why, one step back
1419

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

line 1420why, one step back
1420 case ICON_PNG:

debug: add a --print-timing-info command line optionDaniel Eklöfbefore adoption1ea01b1

line 1421why, one step back
1421 render_png(icon, img_x, img_y, size, pix, cairo,

config: add scaling-filter optionDaniel Eklöfbefore adoption3866f60

lines 1422–1423why, one step back
1422 render->gamma_correct, render->conf->print_timing_info,
1423 render->conf->png_scaling_filter);

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

lines 1424–1426why, one step back
1424 break;
14251426 case ICON_SVG:

debug: add a --print-timing-info command line optionDaniel Eklöfbefore adoption1ea01b1

lines 1427–1428why, one step back
1427 render_svg(icon, img_x, img_y, size, pix, cairo,
1428 render->gamma_correct, render->conf->print_timing_info);

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

line 1429why, one step back
1429 break;

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1430why, one step back
1430 }

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

line 1431why, one step back
1431 }

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1432why, one step back
1432

render: display match+total entry countDaniel Eklöfbefore adoptionb32836d

lines 1433–1434why, one step back
1433 const struct fcft_glyph *space =
1434 fcft_rasterize_char_utf32(render->font, U' ', subpixel);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1435why, one step back
1435

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

lines 1436–1441why, one step back
1436 cur_x +=
1437 (render->conf->icons_enabled && matches_have_icons(matches)1438 ? (render->row_height +1439 (space != NULL ? space->advance.x : render->font->max_advance.x))1440 : 0) +1441 pt_or_px_as_pixels(render, &render->conf->letter_spacing);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1442why, one step back
1442

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

lines 1443–1446why, one step back
1443 /* Replace newlines in title, with spaces (basic support for
1444 * multiline entries) */1445 if (match->application->render_title == NULL) {1446 char32_t *newline = c32chr(match->application->title, U'\n');

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1447why, one step back
1447

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

line 1448why, one step back
1448 if (newline != NULL) {

Add xmalloc.h and xsnprintf.h and use to improve/simplify error handlingCraig Barnesbefore adoption539d514

line 1449why, one step back
1449 char32_t *render_title = xc32dup(match->application->title);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1450why, one step back
1450

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

lines 1451–1452why, one step back
1451 newline = render_title + (newline - match->application->title);
1452 *newline = U' ';

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1453why, one step back
1453

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

lines 1454–1460why, one step back
1454 while ((newline = c32chr(newline, U'\n')) != NULL)
1455 *newline = U' ';14561457 match->application->render_title = render_title;1458 } else {1459 /* No newlines, use title as-is */1460 match->application->render_title = match->application->title;

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1461why, one step back
1461 }

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

line 1462why, one step back
1462 }

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1463why, one step back
1463

render: regression: cursor alignment with custom line-heightDaniel Eklöfbefore adoption20660ef

line 1464why, one step back
1464 const int y = first_row + render_baseline(render) + idx * render->row_height;

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1465why, one step back
1465

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

lines 1466–1469why, one step back
1466 /* Application title */
1467 render_match_text(1468 pix, &cur_x, y, max_x - (ellipses != NULL ? ellipses->width : 0),1469 match->application->render_title, match->pos_count, match->pos,

render: add support for rendering the selected entry in boldDaniel Eklöfbefore adoption8d77e69

line 1470why, one step back
1470 font, subpixel,

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

lines 1471–1478why, one step back
1471 pt_or_px_as_pixels(render, &render->conf->letter_spacing),
1472 render->conf->tabs,1473 (is_selected1474 ? render->pix_selection_text_color1475 : render->pix_text_color),1476 (is_selected1477 ? render->pix_selection_match_color1478 : render->pix_match_color),

render: add support for rendering the selected entry in boldDaniel Eklöfbefore adoption8d77e69

lines 1479–1481why, one step back
1479 (is_selected
1480 ? &match->application->shaped_bold1481 : &match->application->shaped));

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

line 1482why, one step back
1482}

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1483why, one step back
1483

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

lines 1484–1489why, one step back
1484void
1485render_match_list(struct render *render, struct buffer *buf,1486 const struct prompt *prompt, const struct matches *matches)1487{1488 const size_t match_count = matches_get_count(matches);1489 const size_t selected = matches_get_match_index(matches);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1490why, one step back
1490

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

line 1491why, one step back
1491 assert(match_count == 0 || selected < match_count);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1492why, one step back
1492

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

line 1493why, one step back
1493 bool render_icons = mtx_trylock(render->icon_lock) == thrd_success;

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1494why, one step back
1494

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

lines 1495–1499why, one step back
1495 if (render->workers.count > 0) {
1496 mtx_lock(&render->workers.lock);1497 render->workers.matches = matches;1498 render->workers.buf = buf;1499 render->workers.render_icons= render_icons;

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1500why, one step back
1500

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

lines 1501–1505why, one step back
1501 for (size_t i = 0; i < render->workers.count; i++)
1502 sem_post(&render->workers.start);15031504 assert(tll_length(render->workers.queue) == 0);1505 }

render: only do a full background fill on fresh buffersDaniel Eklöfbefore adoption01471e3

lines 1506–1507why, one step back
1506
1507 /* Erase background of the "empty" area, after the last match */

Add new --minimal-flag optionMark Stosbergbefore adoption6200008

line 1508why, one step back
1508 const size_t effective_lines = matches_max_matches_per_page(matches);

render: only do a full background fill on fresh buffersDaniel Eklöfbefore adoption01471e3

line 1509why, one step back
1509 render_match_entry_background(

Add new --minimal-flag optionMark Stosbergbefore adoption6200008

line 1510why, one step back
1510 render, match_count, effective_lines - match_count,

render: only do a full background fill on fresh buffersDaniel Eklöfbefore adoption01471e3

line 1511why, one step back
1511 buf->pix[0], buf->width);

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

lines 1512–1519why, one step back
1512
1513 for (size_t i = 0; i < match_count; i++) {1514 if (render->workers.count == 0) {1515 const struct match *match = matches_get(matches, i);1516 render_one_match_entry(1517 render, matches, match, render_icons, i, i == selected,1518 buf->width, buf->height, buf->pix[0],1519#if defined(FUZZEL_ENABLE_CAIRO)

Fix compilation with librsvg after adding threading renderingDaniel Eklöfbefore adoption3d8da6f

line 1520why, one step back
1520 buf->cairo[0]

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

lines 1521–1526why, one step back
1521#else
1522 NULL1523#endif1524 );1525 } else {1526 tll_push_back(render->workers.queue, i);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1527why, one step back
1527 }

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

line 1528why, one step back
1528 }

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1529why, one step back
1529

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

lines 1530–1533why, one step back
1530 if (render->workers.count > 0) {
1531 for (size_t i = 0; i < render->workers.count; i++)1532 tll_push_back(render->workers.queue, -1);1533 mtx_unlock(&render->workers.lock);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1534why, one step back
1534

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

lines 1535–1540why, one step back
1535 for (size_t i = 0; i < render->workers.count; i++)
1536 sem_wait(&render->workers.done);15371538 render->workers.matches = NULL;1539 render->workers.buf = NULL;1540 render->workers.render_icons = false;

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 1541–1546why, one step back
1541 }
15421543 if (render_icons)1544 mtx_unlock(render->icon_lock);1545}1546

render: add THREAD comment to render_worker_thread()Daniel Eklöfbefore adoption886d9c5

line 1547why, one step back
1547/* THREAD */

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

lines 1548–1560why, one step back
1548static int
1549render_worker_thread(void *_ctx)1550{1551 struct thread_context *ctx = _ctx;1552 struct render *render = ctx->render;1553 const int my_id = ctx->my_id;1554 free(ctx);15551556 sigset_t mask;1557 sigfillset(&mask);1558 pthread_sigmask(SIG_SETMASK, &mask, NULL);15591560 char proc_title[16];

xmalloc/xsnprintf: use x-wrapper functions in a few more placesCraig Barnesbefore adoptiondfed80e

line 1561why, one step back
1561 xsnprintf(proc_title, sizeof(proc_title), "fuzzel:rend:%d", my_id);

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

lines 1562–1598why, one step back
1562
1563 if (pthread_setname_np(pthread_self(), proc_title) < 0)1564 LOG_ERRNO("render worker %d: failed to set process title", my_id);15651566 sem_t *start = &render->workers.start;1567 sem_t *done = &render->workers.done;1568 mtx_t *lock = &render->workers.lock;15691570 while (true) {1571 sem_wait(start);15721573 const struct matches *matches = render->workers.matches;1574 struct buffer *buf = render->workers.buf;1575 const bool render_icons = render->workers.render_icons;1576 const size_t selected = matches != NULL1577 ? matches_get_match_index(matches)1578 : 0;15791580 bool frame_done = false;15811582 while (!frame_done) {1583 mtx_lock(lock);1584 assert(tll_length(render->workers.queue) > 0);15851586 int row_no = tll_pop_front(render->workers.queue);1587 mtx_unlock(lock);15881589 switch (row_no) {1590 default: {1591 assert(buf != NULL);15921593 const struct match *match = matches_get(matches, row_no);1594 render_one_match_entry(1595 render, matches, match, render_icons,1596 row_no, row_no == selected, buf->width, buf->height,1597 buf->pix[my_id],1598#if defined(FUZZEL_ENABLE_CAIRO)

Fix compilation with librsvg after adding threading renderingDaniel Eklöfbefore adoption3d8da6f

line 1599why, one step back
1599 buf->cairo[my_id]

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

lines 1600–1621why, one step back
1600#else
1601 NULL1602#endif1603 );16041605 break;1606 }16071608 case -1:1609 frame_done = true;1610 sem_post(done);1611 break;16121613 case -2:1614 return 0;1615 }1616 }1617 }16181619 return -1;1620}1621

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 1622–1624why, one step back
1622struct render *
1623render_init(const struct config *conf, mtx_t *icon_lock)1624{

Add xmalloc.h and xsnprintf.h and use to improve/simplify error handlingCraig Barnesbefore adoption539d514

line 1625why, one step back
1625 struct render *render = xcalloc(1, sizeof(*render));

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 1626–1630why, one step back
1626 *render = (struct render){
1627 .conf = conf,1628 .icon_lock = icon_lock,1629 };1630

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

lines 1631–1643why, one step back
1631 if (sem_init(&render->workers.start, 0, 0) < 0 ||
1632 sem_init(&render->workers.done, 0, 0) < 0)1633 {1634 LOG_ERRNO("failed to instantiate render worker semaphores");1635 goto err_free_render;1636 }16371638 int err;1639 if ((err = mtx_init(&render->workers.lock, mtx_plain)) != thrd_success) {1640 LOG_ERR("failed to instantiate render worker mutex: %d", err);1641 goto err_free_semaphores;1642 }1643

render: limit number of worker threads to --linesDaniel Eklöfbefore adoptiona8e0ddf

line 1644why, one step back
1644 const size_t num_workers = min(conf->render_worker_count, conf->lines);

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

line 1645why, one step back
1645

render: limit number of worker threads to --linesDaniel Eklöfbefore adoptiona8e0ddf

lines 1646–1649why, one step back
1646 render->workers.threads = xcalloc(
1647 num_workers, sizeof(render->workers.threads[0]));16481649 for (size_t i = 0; i < num_workers; i++) {

Add xmalloc.h and xsnprintf.h and use to improve/simplify error handlingCraig Barnesbefore adoption539d514

line 1650why, one step back
1650 struct thread_context *ctx = xmalloc(sizeof(*ctx));

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

lines 1651–1667why, one step back
1651 *ctx = (struct thread_context){
1652 .render = render,1653 .my_id = 1 + i,1654 };16551656 int ret = thrd_create(1657 &render->workers.threads[i], &render_worker_thread, ctx);16581659 if (ret != thrd_success) {1660 LOG_ERR("failed to create render worker thread: %d", ret);1661 render->workers.threads[i] = 0;1662 goto err_free_semaphores_and_lock;1663 }16641665 render->workers.count++;1666 }1667

match+render: log number of worker threads (at info level)Daniel Eklöfbefore adoption7835e25

lines 1668–1669why, one step back
1668 LOG_INFO("using %hu render worker threads", render->workers.count);
1669

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1670why, one step back
1670 return render;

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

lines 1671–1679why, one step back
1671
1672err_free_semaphores_and_lock:1673 mtx_destroy(&render->workers.lock);1674err_free_semaphores:1675 sem_destroy(&render->workers.start);1676 sem_destroy(&render->workers.done);1677err_free_render:1678 free(render);1679 return NULL;

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1680why, one step back
1680}

Implement gamma-correct blendingDaniel Eklöfbefore adoption2d19826

lines 1681–1699why, one step back
1681
1682void1683render_initialize_colors(struct render *render, const struct config *conf,1684 bool gamma_correct)1685{1686 render->gamma_correct = gamma_correct;1687 render->pix_background_color = rgba2pixman(gamma_correct, conf->colors.background);1688 render->pix_border_color = rgba2pixman(gamma_correct, conf->colors.border);1689 render->pix_text_color = rgba2pixman(gamma_correct, conf->colors.text);1690 render->pix_prompt_color = rgba2pixman(gamma_correct, conf->colors.prompt);1691 render->pix_input_color = rgba2pixman(gamma_correct, conf->colors.input);1692 render->pix_match_color = rgba2pixman(gamma_correct, conf->colors.match);1693 render->pix_selection_color = rgba2pixman(gamma_correct, conf->colors.selection);1694 render->pix_selection_text_color = rgba2pixman(gamma_correct, conf->colors.selection_text);1695 render->pix_selection_match_color = rgba2pixman(gamma_correct, conf->colors.selection_match);1696 render->pix_counter_color = rgba2pixman(gamma_correct, conf->colors.counter);1697 render->pix_placeholder_color = rgba2pixman(gamma_correct, conf->colors.placeholder);1698}1699

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 1700–1705why, one step back
1700void
1701render_set_subpixel(struct render *render, enum fcft_subpixel subpixel)1702{1703 render->subpixel = subpixel;1704}1705

Add new --minimal-flag optionMark Stosbergbefore adoption6200008

lines 1706–1707why, one step back
1706void
1707render_resized(struct render *render, int *new_width, int *new_height)

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1708why, one step back
1708{

Add new --minimal-flag optionMark Stosbergbefore adoption6200008

lines 1709–1710why, one step back
1709 struct fcft_font *font = render->font;
1710 const float scale = render->scale;

render: add support for rendering the selected entry in boldDaniel Eklöfbefore adoption8d77e69

line 1711why, one step back
1711

Add new --minimal-flag optionMark Stosbergbefore adoption6200008

lines 1712–1713why, one step back
1712 assert(font != NULL);
1713 assert(render->font_bold != NULL);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 1714–1715why, one step back
1714
1715 const struct fcft_glyph *W = fcft_rasterize_char_utf32(

render: use the width of 'o' instead of 'W' when calculating window widthDaniel Eklöfbefore adoption5b90bed

line 1716why, one step back
1716 font, U'o', render->subpixel);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 1717–1719why, one step back
1717
1718 const unsigned x_margin = render->conf->pad.x * scale;1719 const unsigned y_margin = render->conf->pad.y * scale;

render: ignore custom inner padding when --prompt-only is usedDaniel Eklöfbefore adoptionb9b34d4

lines 1720–1722why, one step back
1720 const unsigned inner_pad = render->conf->lines > 0
1721 ? render->conf->pad.inner * scale1722 : 0;

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 1723–1724why, one step back
1723
1724 const unsigned border_size = render->conf->border.size * scale;

render: fix border width and border radius scalingKonstantin Pospelovbefore adoption1b05c80

line 1725why, one step back
1725 const unsigned border_radius = render->conf->border.radius * scale;

feat: border radius for selected entrieswisplbefore adoption9836d81

line 1726why, one step back
1726 const unsigned selection_border_radius = render->conf->selection_border.radius * scale;

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 1727–1729why, one step back
1727
1728 const unsigned row_height = render->conf->line_height.px >= 01729 ? pt_or_px_as_pixels(render, &render->conf->line_height)

render: regression: cursor alignment with custom line-heightDaniel Eklöfbefore adoption20660ef

line 1730why, one step back
1730 : max(font->height, font->ascent + font->descent);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 1731–1736why, one step back
1731
1732 const unsigned icon_height = max(0, row_height - font->descent);17331734 const unsigned height =1735 border_size + /* Top border */1736 y_margin +

✨ New Feature: Hide Input Line (#597)Mark Stosbergbefore adoption1ea0283

lines 1737–1738why, one step back
1737 (render->conf->hide_prompt ? 0 : row_height) + /* The prompt (hidden if hide_prompt) */
1738 (render->conf->hide_prompt ? 0 : inner_pad) + /* Padding between prompt and matches (only if prompt shown) */

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 1739–1743why, one step back
1739 render->conf->lines * row_height + /* Matches */
1740 y_margin +1741 border_size; /* Bottom border */17421743 const unsigned width =

Add new --minimal-flag optionMark Stosbergbefore adoption6200008

line 1744why, one step back
1744 border_size + /* Top border */

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 1745–1752why, one step back
1745 x_margin +
1746 (max((W->advance.x + pt_or_px_as_pixels(1747 render, &render->conf->letter_spacing)),1748 0)1749 * render->conf->chars) +1750 x_margin +1751 border_size;1752

render: fix border width and border radius scalingKonstantin Pospelovbefore adoption1b05c80

lines 1753–1756why, one step back
1753 LOG_DBG("x-margin: %d, y-margin: %d, border-size: %d, border-radius: %d, "
1754 "row-height: %d, icon-height: %d, height: %d, width: %d, scale: %f",1755 x_margin, y_margin, border_size, border_radius,1756 row_height, icon_height, height, width, scale);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 1757–1761why, one step back
1757
1758 render->y_margin = y_margin;1759 render->x_margin = x_margin;1760 render->inner_pad = inner_pad;1761 render->border_size = border_size;

render: fix border width and border radius scalingKonstantin Pospelovbefore adoption1b05c80

line 1762why, one step back
1762 render->border_radius = border_radius;

feat: border radius for selected entrieswisplbefore adoption9836d81

line 1763why, one step back
1763 render->selection_border_radius = selection_border_radius;

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 1764–1770why, one step back
1764 render->row_height = row_height;
1765 render->icon_height = icon_height;17661767 if (new_width != NULL)1768 *new_width = width;1769 if (new_height != NULL)1770 *new_height = height;

feat: border radius for selected entrieswisplbefore adoption9836d81

lines 1771–1776why, one step back
1771
1772 /* invalidate cached corners since the size could have changed */1773 if (render->selection_corners != NULL) {1774 pixman_image_unref(render->selection_corners);1775 render->selection_corners = NULL;1776 }

Add new --minimal-flag optionMark Stosbergbefore adoption6200008

line 1777why, one step back
1777}

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1778why, one step back
1778

Add new --minimal-flag optionMark Stosbergbefore adoption6200008

lines 1779–1805why, one step back
1779bool
1780render_set_font_and_update_sizes(struct render *render, struct fcft_font *font,1781 struct fcft_font *font_bold,1782 float scale, float dpi, bool size_font_by_dpi,1783 int *new_width, int *new_height)1784{1785 if (font != NULL) {1786 fcft_destroy(render->font);1787 render->font = font;1788 } else {1789 assert(render->font != NULL);1790 font = render->font;1791 }17921793 if (font_bold != NULL) {1794 fcft_destroy(render->font_bold);1795 render->font_bold = font_bold;1796 } else {1797 assert(render->font_bold != NULL);1798 font_bold = render->font_bold;1799 }18001801 render->scale = scale;1802 render->dpi = dpi;1803 render->size_font_by_dpi = size_font_by_dpi;18041805 render_resized(render, new_width, new_height);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 1806–1819why, one step back
1806 return true;
1807}18081809int1810render_icon_size(const struct render *render)1811{1812 return render->icon_height;1813}18141815void1816render_destroy(struct render *render)1817{1818 if (render == NULL)1819 return;

render: render match list using multiple rendering threadsDaniel Eklöfbefore adoption20e0530

lines 1820–1843why, one step back
1820
1821 mtx_lock(&render->workers.lock);1822 {1823 assert(tll_length(render->workers.queue) == 0);18241825 for (size_t i = 0; i < render->workers.count; i++) {1826 assert(render->workers.threads[i] != 0);1827 sem_post(&render->workers.start);1828 tll_push_back(render->workers.queue, -2);1829 }1830 }1831 mtx_unlock(&render->workers.lock);18321833 for (size_t i = 0; i < render->workers.count; i++) {1834 assert(render->workers.threads[i] != 0);1835 thrd_join(render->workers.threads[i], NULL);1836 }18371838 free(render->workers.threads);1839 mtx_destroy(&render->workers.lock);1840 sem_destroy(&render->workers.start);1841 sem_destroy(&render->workers.done);1842 assert(tll_length(render->workers.queue) == 0);1843 tll_free(render->workers.queue);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1844why, one step back
1844

render: font-shape the input stringDaniel Eklöfbefore adoption3ba23e1

lines 1845–1846why, one step back
1845 fcft_text_run_destroy(render->prompt_text_run);
1846 fcft_text_run_destroy(render->placeholder_text_run);

feat: border radius for selected entrieswisplbefore adoption9836d81

line 1847why, one step back
1847

render: fix crash: don't assume render->selection_corners has been initializedDaniel Eklöfbefore adoption6f40720

lines 1848–1849why, one step back
1848 if (render->selection_corners != NULL)
1849 pixman_image_unref(render->selection_corners);

render: font-shape the input stringDaniel Eklöfbefore adoption3ba23e1

line 1850why, one step back
1850

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1851why, one step back
1851 fcft_destroy(render->font);

🐛 Fix memory leak with font_boldMark Stosbergbefore adoption6fd584b

line 1852why, one step back
1852 fcft_destroy(render->font_bold);

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 1853–1855why, one step back
1853 free(render);
1854}1855

wayland: don't ignore the mouse's X coordinate when selectingDaniel Eklöfbefore adoption1f6e155

lines 1856–1857why, one step back
1856ssize_t
1857render_get_row_num(const struct render *render, int width, int x, int y,

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 1858–1863why, one step back
1858 const struct matches *matches)
1859{1860 const int y_margin = render->y_margin;1861 const int inner_pad = render->inner_pad;1862 const int border_size = render->border_size;1863 const int row_height = render->row_height;

wayland: don't ignore the mouse's X coordinate when selectingDaniel Eklöfbefore adoption1f6e155

lines 1864–1867why, one step back
1864
1865 const int min_x = render->border_size + render->x_margin - render->x_margin / 3;1866 const int max_x = width - (min_x);1867

✨ New Feature: Hide Input Line (#597)Mark Stosbergbefore adoption1ea0283

lines 1868–1870why, one step back
1868 const int first_row = 1 * border_size + y_margin +
1869 (render->conf->hide_prompt ? 0 : row_height) +1870 (render->conf->hide_prompt ? 0 : inner_pad);

wayland: don't ignore the mouse's X coordinate when selectingDaniel Eklöfbefore adoption1f6e155

line 1871why, one step back
1871

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 1872–1874why, one step back
1872 const size_t match_count = matches_get_count(matches);
1873 const size_t last_row = first_row + match_count * row_height;1874

wayland: don't ignore the mouse's X coordinate when selectingDaniel Eklöfbefore adoption1f6e155

line 1875why, one step back
1875 ssize_t row = -1;

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1876why, one step back
1876

wayland: don't ignore the mouse's X coordinate when selectingDaniel Eklöfbefore adoption1f6e155

line 1877why, one step back
1877 if (y >= first_row && y < last_row && x >= min_x && x < max_x)

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

lines 1878–1880why, one step back
1878 row = (y - first_row) / row_height;
18791880 return row;

render: font-shape the input stringDaniel Eklöfbefore adoption3ba23e1

lines 1881–1889why, one step back
1881}
18821883void1884render_flush_text_run_cache(struct render *render)1885{1886 fcft_text_run_destroy(render->prompt_text_run);1887 fcft_text_run_destroy(render->placeholder_text_run);1888 render->prompt_text_run = NULL;1889 render->placeholder_text_run = NULL;

wayland: performance: render frames on-demand, rather than eagrlyDaniel Eklöfbefore adoption99f03a9

line 1890why, one step back
1890}