Fix compilation with librsvg after adding threading rendering
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Daniel Eklöf · committed by Daniel Eklöf · parent 563b48c · Browse files · 4 files·+42 added−21 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+42 added−21 removed
- other:+42 added−21 removed
Provenance
- Commit
3d8da6f- Tree
30575fc- Author
Daniel Eklöf <daniel@ekloef.se>- Committer
Daniel Eklöf <daniel@ekloef.se>- Parent
563b48c
4 files changed+42 added−21 removed
modified:render.c+14 added-13 removed
17 unmodified lines18 19 #if defined(FUZZEL_ENABLE_CAIRO)20 #include <cairo.h>21 #else22-#define cairo_surface_t void22+#define cairo_t void23 #endif24 25 #include <fcft/fcft.h>26 401 unmodified lines428 429 #if defined(FUZZEL_ENABLE_SVG_LIBRSVG)430 static void431 render_svg_librsvg(const struct icon *icon, int x, int y, int size,432- cairo_surface_t *cairo)432+ cairo_t *cairo)433 {434 RsvgHandle *svg = icon->svg;435 436 cairo_save(cairo);40 unmodified lines477 478 #if defined(FUZZEL_ENABLE_SVG_NANOSVG)479 static void480 render_svg_nanosvg(struct icon *icon, int x, int y, int size,481- pixman_image_t *pix, cairo_surface_t *cairo)481+ pixman_image_t *pix, cairo_t *cairo)482 {483 #if defined(FUZZEL_ENABLE_CAIRO)484- cairo_surface_flush(cairo);484+ cairo_surface_flush(cairo_get_target(cairo));485 #endif486 487 pixman_image_t *img = NULL;488 52 unmodified lines541 pixman_image_composite32(542 PIXMAN_OP_OVER, img, NULL, pix, 0, 0, 0, 0, x, y, size, size);543 544 #if defined(FUZZEL_ENABLE_CAIRO)545- cairo_surface_mark_dirty(cairo);545+ cairo_surface_mark_dirty(cairo_get_target(cairo));546 #endif547 }548 #endif /* FUZZEL_ENABLE_SVG_NANOSVG */549 550 static void551 render_svg(struct icon *icon, int x, int y, int size,552- pixman_image_t *pix, cairo_surface_t *cairo)552+ pixman_image_t *pix, cairo_t *cairo)553 {554 assert(icon->type == ICON_SVG);555 556 if (icon->svg == NULL) {11 unmodified lines568 569 #if defined(FUZZEL_ENABLE_PNG_LIBPNG)570 static void571 render_png_libpng(struct icon *icon, int x, int y, int size,572- pixman_image_t *pix, cairo_surface_t *cairo)572+ pixman_image_t *pix, cairo_t *cairo)573 {574 #if defined(FUZZEL_ENABLE_CAIRO)575- cairo_surface_flush(cairo);575+ cairo_surface_flush(cairo_get_target(cairo));576 #endif577 578 pixman_image_t *png = icon->png;579 pixman_format_code_t fmt = pixman_image_get_format(png);50 unmodified lines630 pixman_image_composite32(631 PIXMAN_OP_OVER, png, NULL, pix, 0, 0, 0, 0, x, y, width, height);632 633 #if defined(FUZZEL_ENABLE_CAIRO)634- cairo_surface_mark_dirty(cairo);634+ cairo_surface_mark_dirty(cairo_get_target(cairo));635 #endif636 }637 #endif /* FUZZEL_ENABLE_PNG_LIBPNG */638 639 static void640-render_png(struct icon *icon, int x, int y, int size, pixman_image_t *pix, cairo_surface_t *cairo)640+render_png(struct icon *icon, int x, int y, int size, pixman_image_t *pix,641+ cairo_t *cairo)642 {643 assert(icon->type == ICON_PNG);644 645 if (icon->png == NULL) {19 unmodified lines665 static void666 render_one_match_entry(const struct render *render, const struct matches *matches,667 const struct match *match, bool render_icons,668 int idx, bool is_selected, int width, int height,668- pixman_image_t *pix, cairo_surface_t *cairo)669+ pixman_image_t *pix, cairo_t *cairo)670 {671 const enum fcft_subpixel subpixel =672 (render->conf->colors.background.a == 1. &&673 render->conf->colors.selection.a == 1.)148 unmodified lines822 render_one_match_entry(823 render, matches, match, render_icons, i, i == selected,824 buf->width, buf->height, buf->pix[0],825 #if defined(FUZZEL_ENABLE_CAIRO)825- buf->cairo_surfaces[0]826+ buf->cairo[0]827 #else828 NULL829 #endif830 );69 unmodified lines900 render, matches, match, render_icons,901 row_no, row_no == selected, buf->width, buf->height,902 buf->pix[my_id],903 #if defined(FUZZEL_ENABLE_CAIRO)903- buf->cairo_surfaces[my_id]904+ buf->cairo[my_id]905 #else906 NULL907 #endif908 );234 unmodified linesmodified:shm.c+25 added-6 removed
116 unmodified lines117 }118 free(buf->pix);119 120 #if defined(FUZZEL_ENABLE_CAIRO)121- if (buf->cairo_surfaces != NULL) {121+ if (buf->cairo != NULL) {122 for (size_t i = 0; i < buf->pix_instances; i++) {123- if (buf->cairo_surfaces[i] != NULL)124- cairo_surface_destroy(buf->cairo_surfaces[i]);123+ if (buf->cairo[i] != NULL) {124+ cairo_surface_destroy(cairo_get_target(buf->cairo[i]));125+ cairo_destroy(buf->cairo[i]);126+ }127 }128+129+ free(buf->cairo);130 }127- free(buf->cairo_surfaces);131 #endif132 133 if (buf->wl_buf != NULL)134 wl_buffer_destroy(buf->wl_buf);136 unmodified lines271 struct wl_buffer *wl_buf = NULL;272 pixman_image_t **pix = calloc(buf->public.pix_instances, sizeof(pix[0]));273 274 #if defined(FUZZEL_ENABLE_CAIRO)275+ cairo_t **cairos = calloc(buf->public.pix_instances, sizeof(cairos[0]));276 cairo_surface_t **cairo_surfs =277 calloc(buf->public.pix_instances, sizeof(cairo_surfs[0]));278 #endif279 31 unmodified lines311 "failed to create cairo surface: %s",312 cairo_status_to_string(cairo_surface_status(cairo_surfs[i])));313 goto err;314 }315+316+ cairos[i] = cairo_create(cairo_surfs[i]);317+ if (cairo_status(cairos[i]) != CAIRO_STATUS_SUCCESS) {318+ LOG_ERR("failed to create cairo context: %s",319+ cairo_status_to_string(cairo_status(cairos[i])));320+ goto err;321+ }322 #endif323 }324 325 buf->public.data = mmapped;1 unmodified line327 buf->public.pix = pix;328 buf->offset = new_offset;329 330 #if defined(FUZZEL_ENABLE_CAIRO)320- buf->public.cairo_surfaces = cairo_surfs;331+ buf->public.cairo = cairos;332+ free(cairo_surfs);333 #endif334 335 wl_buffer_add_listener(wl_buf, &buffer_listener, buf);336 return true;7 unmodified lines344 }345 free(pix);346 347 #if defined(FUZZEL_ENABLE_CAIRO)348+ if (cairos != NULL) {349+ for (size_t i = 0; i < buf->public.pix_instances; i++) {350+ if (cairos[i] != NULL)351+ cairo_destroy(cairos[i]);352+ }353+ free(cairos);354+ }355 if (cairo_surfs != NULL) {356 for (size_t i = 0; i < buf->public.pix_instances; i++) {357 if (cairo_surfs[i] != NULL)358 cairo_surface_destroy(cairo_surfs[i]);359 }360+ free(cairo_surfs);361 }342- free(cairo_surfs);362 #endif363 364 if (wl_buf != NULL)365 wl_buffer_destroy(wl_buf);688 unmodified linesmodified:shm.h+1 added-1 removed
23 unmodified lines24 25 struct wl_buffer *wl_buf;26 pixman_image_t **pix;27 #if defined(FUZZEL_ENABLE_CAIRO)28- cairo_surface_t **cairo_surfaces;28+ cairo_t **cairo;29 #endif30 size_t pix_instances;31 32 unsigned age;64 unmodified linesmodified:wayland.c+2 added-1 removed
2049 unmodified lines2050 render_prompt(wayl->render, buf, wayl->prompt);2051 render_match_list(wayl->render, buf, wayl->prompt, wayl->matches);2052 2053 #if defined(FUZZEL_ENABLE_CAIRO)2054- cairo_surface_flush(buf->cairo_surfaces[0]);2054+ for (size_t i = 0; i < buf->pix_instances; i++)2055+ cairo_surface_flush(cairo_get_target(buf->cairo[0]));2056 #endif2057 2058 commit:2059 /* No pending frames - render immediately */423 unmodified lines