Krolyxon
Commit f05165a

Branches

Refs →

nsxivf05165a

don't quit if imlib_create_image() fails (#248)

...simply print an error msg and try (slower) fallback.

also adds a useful comment explaining why we're doing manual blending.
Author
N-R-K
Date
2022-04-12 17:05 +0000
Committer
GitHub · 2022-04-12 17:05 +0000
Parent
ec5a51d
Commit
f05165a77a538b42ffd2d473eded25188cb56ea0

+8 −2

1 file changed

  1. M image.c +8 −2
M image.c View
@@ -604,9 +604,14 @@ void img_render(img_t *img)
604604 imlib_context_set_anti_alias(img->aa);
605605 imlib_context_set_drawable(win->buf.pm);
606606
607+ /* manual blending, for performance reasons.
608+ * see https://phab.enlightenment.org/T8969#156167 for more details.
609+ */
607610 if (imlib_image_has_alpha()) {
608− if ((bg = imlib_create_image(dw, dh)) == NULL)
609− error(EXIT_FAILURE, ENOMEM, NULL);
611+ if ((bg = imlib_create_image(dw, dh)) == NULL) {
612+ error(0, ENOMEM, "Failed to create image");
613+ goto fallback;
614+ }
610615 imlib_context_set_image(bg);
611616 imlib_image_set_has_alpha(0);
612617
@@ -636,6 +641,7 @@ void img_render(img_t *img)
636641 imlib_free_image();
637642 imlib_context_set_color_modifier(img->cmod);
638643 } else {
644+fallback:
639645 imlib_render_image_part_on_drawable_at_size(sx, sy, sw, sh, dx, dy, dw, dh);
640646 }
641647 img->dirty = false;