aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYAMAMOTO Mitsuharu2019-05-29 10:43:01 +0900
committerYAMAMOTO Mitsuharu2019-05-29 10:43:23 +0900
commit09dce0fd391571ab1b580d2818689d596a8b99de (patch)
tree9bb019e96b05313ef04a55e6b429ca0f6d18a88c
parent146486f8a63d03c39770c0ef8c2b67175ef9b906 (diff)
downloademacs-09dce0fd391571ab1b580d2818689d596a8b99de.tar.gz
emacs-09dce0fd391571ab1b580d2818689d596a8b99de.zip
Improve previous change for tool bar image support on GTK+2 with cairo
* src/gtkutil.c (xg_get_pixbuf_from_surface) [USE_CAIRO && !HAVE_GTK3]: Remove unused argument f. All callers changed. Handle general alpha value.
-rw-r--r--src/gtkutil.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/gtkutil.c b/src/gtkutil.c
index c6534585f8d..59e4328a6fc 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -281,7 +281,7 @@ xg_get_pixbuf_from_pix_and_mask (struct frame *f,
281 281
282#if defined USE_CAIRO && !defined HAVE_GTK3 282#if defined USE_CAIRO && !defined HAVE_GTK3
283static GdkPixbuf * 283static GdkPixbuf *
284xg_get_pixbuf_from_surface (struct frame *f, cairo_surface_t *surface) 284xg_get_pixbuf_from_surface (cairo_surface_t *surface)
285{ 285{
286 int width = cairo_image_surface_get_width (surface); 286 int width = cairo_image_surface_get_width (surface);
287 int height = cairo_image_surface_get_height (surface); 287 int height = cairo_image_surface_get_height (surface);
@@ -306,15 +306,20 @@ xg_get_pixbuf_from_surface (struct frame *f, cairo_surface_t *surface)
306 for (int x = 0; x < width; x++) 306 for (int x = 0; x < width; x++)
307 { 307 {
308 guint32 argb = ((guint32 *) pixels)[x]; 308 guint32 argb = ((guint32 *) pixels)[x];
309#ifdef WORDS_BIGENDIAN 309 int alpha = argb >> 24;
310 /* ARGB -> RGBA (gdk_pixbuf, big endian) */ 310
311 ((guint32 *) pixels)[x] = (argb << 8) | (argb >> 24); 311 if (alpha == 0)
312#else /* !WORDS_BIGENDIAN */ 312 ((guint32 *) pixels)[x] = 0;
313 /* ARGB -> ABGR (gdk_pixbuf, little endian) */ 313 else
314 ((guint32 *) pixels)[x] = (( argb & 0xff00ff00) 314 {
315 | ((argb << 16) & 0x00ff0000) 315 int red = (argb >> 16) & 0xff, green = (argb >> 8) & 0xff;
316 | ((argb >> 16) & 0x000000ff)); 316 int blue = argb & 0xff;
317#endif /* !WORDS_BIGENDIAN */ 317
318 pixels[x * 4 ] = red * 0xff / alpha;
319 pixels[x * 4 + 1] = green * 0xff / alpha;
320 pixels[x * 4 + 2] = blue * 0xff / alpha;
321 pixels[x * 4 + 3] = alpha;
322 }
318 } 323 }
319 pixels += rowstride; 324 pixels += rowstride;
320 } 325 }
@@ -399,7 +404,7 @@ xg_get_image_for_pixmap (struct frame *f,
399 else 404 else
400 gtk_image_set_from_surface (old_widget, surface); 405 gtk_image_set_from_surface (old_widget, surface);
401#else /* !HAVE_GTK3 */ 406#else /* !HAVE_GTK3 */
402 GdkPixbuf *icon_buf = xg_get_pixbuf_from_surface (f, surface); 407 GdkPixbuf *icon_buf = xg_get_pixbuf_from_surface (surface);
403 408
404 if (icon_buf) 409 if (icon_buf)
405 { 410 {