aboutsummaryrefslogtreecommitdiffstats
path: root/src/image.c
diff options
context:
space:
mode:
authorPaul Eggert2016-02-26 08:22:36 -0800
committerPaul Eggert2016-02-26 08:23:26 -0800
commite35f99f2dd35a89b42961fc63c7e2772fb03c792 (patch)
tree42737bbd0e7f64d9b6840516b202f0aa914db098 /src/image.c
parent9583b9e871f89bdc1bf30c24a2090c08ed87e1b5 (diff)
downloademacs-e35f99f2dd35a89b42961fc63c7e2772fb03c792.tar.gz
emacs-e35f99f2dd35a89b42961fc63c7e2772fb03c792.zip
--enable-gcc-warnings now uses -Wjump-misses-init
When configuring with --enable-gcc-warnings, also enable -Wjump-misses-init, as it’s confusing to use a goto to skip over an initialization. Fix the few places in the code that run afoul of this warning. * configure.ac (WERROR_CFLAGS): Add -Wjump-misses-init. * src/doc.c (Fsubstitute_command_keys): * src/image.c (svg_load_image): * src/regex.c (re_match_2_internal): * src/xdisp.c (redisplay_internal, redisplay_window): Don’t jump over initialization.
Diffstat (limited to 'src/image.c')
-rw-r--r--src/image.c125
1 files changed, 60 insertions, 65 deletions
diff --git a/src/image.c b/src/image.c
index 9ba1a7972f0..aa45b001d30 100644
--- a/src/image.c
+++ b/src/image.c
@@ -9257,8 +9257,8 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. *
9257 eassert (gdk_pixbuf_get_has_alpha (pixbuf)); 9257 eassert (gdk_pixbuf_get_has_alpha (pixbuf));
9258 eassert (gdk_pixbuf_get_bits_per_sample (pixbuf) == 8); 9258 eassert (gdk_pixbuf_get_bits_per_sample (pixbuf) == 8);
9259 9259
9260#ifdef USE_CAIRO
9261 { 9260 {
9261#ifdef USE_CAIRO
9262 unsigned char *data = (unsigned char *) xmalloc (width*height*4); 9262 unsigned char *data = (unsigned char *) xmalloc (width*height*4);
9263 uint32_t bgcolor = get_spec_bg_or_alpha_as_argb (img, f); 9263 uint32_t bgcolor = get_spec_bg_or_alpha_as_argb (img, f);
9264 9264
@@ -9284,82 +9284,77 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. *
9284 9284
9285 create_cairo_image_surface (img, data, width, height); 9285 create_cairo_image_surface (img, data, width, height);
9286 g_object_unref (pixbuf); 9286 g_object_unref (pixbuf);
9287 }
9288#else 9287#else
9289 /* Try to create a x pixmap to hold the svg pixmap. */ 9288 /* Try to create a x pixmap to hold the svg pixmap. */
9290 XImagePtr ximg; 9289 XImagePtr ximg;
9291 if (!image_create_x_image_and_pixmap (f, img, width, height, 0, &ximg, 0)) 9290 if (!image_create_x_image_and_pixmap (f, img, width, height, 0, &ximg, 0))
9292 { 9291 {
9293 g_object_unref (pixbuf); 9292 g_object_unref (pixbuf);
9294 return 0; 9293 return 0;
9295 } 9294 }
9296 9295
9297 init_color_table (); 9296 init_color_table ();
9298 9297
9299 /* Handle alpha channel by combining the image with a background 9298 /* Handle alpha channel by combining the image with a background
9300 color. */ 9299 color. */
9301 XColor background; 9300 XColor background;
9302 Lisp_Object specified_bg = image_spec_value (img->spec, QCbackground, NULL); 9301 Lisp_Object specified_bg = image_spec_value (img->spec, QCbackground, NULL);
9303 if (!STRINGP (specified_bg) 9302 if (!STRINGP (specified_bg)
9304 || !x_defined_color (f, SSDATA (specified_bg), &background, 0)) 9303 || !x_defined_color (f, SSDATA (specified_bg), &background, 0))
9305 x_query_frame_background_color (f, &background); 9304 x_query_frame_background_color (f, &background);
9306 9305
9307 /* SVG pixmaps specify transparency in the last byte, so right 9306 /* SVG pixmaps specify transparency in the last byte, so right
9308 shift 8 bits to get rid of it, since emacs doesn't support 9307 shift 8 bits to get rid of it, since emacs doesn't support
9309 transparency. */ 9308 transparency. */
9310 background.red >>= 8; 9309 background.red >>= 8;
9311 background.green >>= 8; 9310 background.green >>= 8;
9312 background.blue >>= 8; 9311 background.blue >>= 8;
9313 9312
9314 /* This loop handles opacity values, since Emacs assumes 9313 /* This loop handles opacity values, since Emacs assumes
9315 non-transparent images. Each pixel must be "flattened" by 9314 non-transparent images. Each pixel must be "flattened" by
9316 calculating the resulting color, given the transparency of the 9315 calculating the resulting color, given the transparency of the
9317 pixel, and the image background color. */ 9316 pixel, and the image background color. */
9318 for (int y = 0; y < height; ++y) 9317 for (int y = 0; y < height; ++y)
9319 { 9318 {
9320 for (int x = 0; x < width; ++x) 9319 for (int x = 0; x < width; ++x)
9321 { 9320 {
9322 int red; 9321 int red = *pixels++;
9323 int green; 9322 int green = *pixels++;
9324 int blue; 9323 int blue = *pixels++;
9325 int opacity; 9324 int opacity = *pixels++;
9326 9325
9327 red = *pixels++; 9326 red = ((red * opacity)
9328 green = *pixels++; 9327 + (background.red * ((1 << 8) - opacity)));
9329 blue = *pixels++; 9328 green = ((green * opacity)
9330 opacity = *pixels++; 9329 + (background.green * ((1 << 8) - opacity)));
9331 9330 blue = ((blue * opacity)
9332 red = ((red * opacity) 9331 + (background.blue * ((1 << 8) - opacity)));
9333 + (background.red * ((1 << 8) - opacity))); 9332
9334 green = ((green * opacity) 9333 XPutPixel (ximg, x, y, lookup_rgb_color (f, red, green, blue));
9335 + (background.green * ((1 << 8) - opacity))); 9334 }
9336 blue = ((blue * opacity)
9337 + (background.blue * ((1 << 8) - opacity)));
9338
9339 XPutPixel (ximg, x, y, lookup_rgb_color (f, red, green, blue));
9340 }
9341 9335
9342 pixels += rowstride - 4 * width; 9336 pixels += rowstride - 4 * width;
9343 } 9337 }
9344 9338
9345#ifdef COLOR_TABLE_SUPPORT 9339#ifdef COLOR_TABLE_SUPPORT
9346 /* Remember colors allocated for this image. */ 9340 /* Remember colors allocated for this image. */
9347 img->colors = colors_in_color_table (&img->ncolors); 9341 img->colors = colors_in_color_table (&img->ncolors);
9348 free_color_table (); 9342 free_color_table ();
9349#endif /* COLOR_TABLE_SUPPORT */ 9343#endif /* COLOR_TABLE_SUPPORT */
9350 9344
9351 g_object_unref (pixbuf); 9345 g_object_unref (pixbuf);
9352 9346
9353 img->width = width; 9347 img->width = width;
9354 img->height = height; 9348 img->height = height;
9355 9349
9356 /* Maybe fill in the background field while we have ximg handy. 9350 /* Maybe fill in the background field while we have ximg handy.
9357 Casting avoids a GCC warning. */ 9351 Casting avoids a GCC warning. */
9358 IMAGE_BACKGROUND (img, f, (XImagePtr_or_DC)ximg); 9352 IMAGE_BACKGROUND (img, f, (XImagePtr_or_DC)ximg);
9359 9353
9360 /* Put ximg into the image. */ 9354 /* Put ximg into the image. */
9361 image_put_x_image (f, img, ximg, 0); 9355 image_put_x_image (f, img, ximg, 0);
9362#endif /* ! USE_CAIRO */ 9356#endif /* ! USE_CAIRO */
9357 }
9363 9358
9364 return 1; 9359 return 1;
9365 9360