wayland: set renderer's subpixel from 'current' monitor
Before adoption: this commit came in with the history the project adopted, so no landing records it.
This fixes a regression where the subpixel mode wasn't propagated to the renderer, which thus rendered everything using grayscale antialiasing.
authored by Daniel Eklöf · committed by Daniel Eklöf · parent 0369bd6 · Browse files · 4 files·+23 added−15 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+23 added−15 removed
- other:+23 added−15 removed
Provenance
- Commit
02b96dc- Tree
c5ea83b- Author
Daniel Eklöf <daniel@ekloef.se>- Committer
Daniel Eklöf <daniel@ekloef.se>- Parent
0369bd6
4 files changed+23 added−15 removed
modified:CHANGELOG.md+6 added
7 unmodified lines891011121314151617181920215 unmodified lines7 unmodified lines### Added### Deprecated### Removed### Changed### Fixed
* Subpixel antialiasing was not applied correctly on opaque backgrounds.
### Security### Contributors
5 unmodified linesmodified:render.c+7 added-6 removed
126 unmodified lines127 128 const wchar_t *ptext = prompt_text(prompt);129 const size_t text_len = wcslen(ptext);130 131- const bool subpixel_antialias =132- render->options.background_color.a == 1. &&133- render->options.selection_color.a == 1.;131+ const enum fcft_subpixel subpixel =132+ (render->options.background_color.a == 1. &&133+ render->options.selection_color.a == 1.)134+ ? render->subpixel : FCFT_SUBPIXEL_NONE;135 136 int x = render->border_size + render->x_margin;137 int y = render->border_size + render->y_margin + font->ascent;138 139 wchar_t prev = 0;140 141 for (size_t i = 0; i < prompt_len + text_len; i++) {142 wchar_t wc = i < prompt_len ? pprompt[i] : ptext[i - prompt_len];142- const struct fcft_glyph *glyph = fcft_glyph_rasterize(font, wc, subpixel_antialias);143+ const struct fcft_glyph *glyph = fcft_glyph_rasterize(font, wc, subpixel);144 if (glyph == NULL) {145 prev = wc;146 continue;147 }20 unmodified lines168 169 static void170 render_match_text(struct buffer *buf, double *_x, double _y,171 const wchar_t *text, ssize_t start, size_t length,171- struct fcft_font *font, bool subpixel_antialias,172+ struct fcft_font *font, enum fcft_subpixel subpixel,173 pixman_color_t regular_color, pixman_color_t match_color)174 {175 int x = *_x;176 int y = _y;177 178 for (size_t i = 0; i < wcslen(text); i++) {178- const struct fcft_glyph *glyph = fcft_glyph_rasterize(font, text[i], subpixel_antialias);179+ const struct fcft_glyph *glyph = fcft_glyph_rasterize(font, text[i], subpixel);180 if (glyph == NULL)181 continue;182 183 long x_kern = 0, y_kern = 0;259 unmodified linesmodified:wayland.c+10 added-8 removed
143 unmodified lines144 int width;145 int height;146 int scale;147 unsigned dpi;148+ enum fcft_subpixel subpixel;149 150 enum { KEEP_RUNNING, EXIT_UPDATE_CACHE, EXIT} status;151 int exit_code;152 bool dmenu_mode;1137 unmodified lines1290 wayl_refresh(struct wayland *wayl)1291 {1292 struct buffer *buf = shm_get_buffer(wayl->shm, wayl->width, wayl->height);1293 1294+ render_set_subpixel(wayl->render, wayl->subpixel);1295+1296 /* Background + border */1297 render_background(wayl->render, buf);1298 1299 /* Window content */48 unmodified lines1348 tll_foreach(wayl->monitors, it) {1349 if (it->item.output != wl_output)1350 continue;1351 1352+ enum fcft_subpixel old_subpixel = wayl->subpixel;1353 int old_scale = wayl->scale;1354 int old_dpi = wayl->dpi;1355 1356 wayl->monitor = &it->item;1357+ wayl->subpixel = wayl->monitor->subpixel;1358 update_size(wayl);1359 1355- if (wayl->scale != old_scale || wayl->dpi != old_dpi)1360+ if (wayl->scale != old_scale ||1361+ wayl->dpi != old_dpi ||1362+ wayl->subpixel != old_subpixel)1363+ {1364 wayl_refresh(wayl);1365+ }1366 break;1367 }1368 }1369 185 unmodified lines1555 {1556 wl_display_flush(wayl->display);1557 }1558 1550-enum fcft_subpixel1551-wayl_subpixel(const struct wayland *wayl)1552-{1553- return wayl->monitor != NULL1554- ? wayl->monitor->subpixel : FCFT_SUBPIXEL_DEFAULT;1555-}1556-1559 bool1560 wayl_exit_code(const struct wayland *wayl)1561 {1562 return wayl->exit_code;7 unmodified linesmodified:wayland.h-1 removed
25 unmodified lines26 27 void wayl_refresh(struct wayland *wayl);28 void wayl_flush(struct wayland *wayl);29 30-enum fcft_subpixel wayl_subpixel(const struct wayland *wayl);30 bool wayl_exit_code(const struct wayland *wayl);31 bool wayl_update_cache(const struct wayland *wayl);