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.
This commit is contained in:
N-R-K 2022-04-12 17:05:59 +00:00 committed by GitHub
parent ec5a51d798
commit f05165a77a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

10
image.c
View File

@ -604,9 +604,14 @@ void img_render(img_t *img)
imlib_context_set_anti_alias(img->aa);
imlib_context_set_drawable(win->buf.pm);
/* manual blending, for performance reasons.
* see https://phab.enlightenment.org/T8969#156167 for more details.
*/
if (imlib_image_has_alpha()) {
if ((bg = imlib_create_image(dw, dh)) == NULL)
error(EXIT_FAILURE, ENOMEM, NULL);
if ((bg = imlib_create_image(dw, dh)) == NULL) {
error(0, ENOMEM, "Failed to create image");
goto fallback;
}
imlib_context_set_image(bg);
imlib_image_set_has_alpha(0);
@ -636,6 +641,7 @@ void img_render(img_t *img)
imlib_free_image();
imlib_context_set_color_modifier(img->cmod);
} else {
fallback:
imlib_render_image_part_on_drawable_at_size(sx, sy, sw, sh, dx, dy, dw, dh);
}
img->dirty = false;