diff options
| author | Paul Eggert | 2016-01-23 01:02:00 -0800 |
|---|---|---|
| committer | Paul Eggert | 2016-01-23 01:04:09 -0800 |
| commit | c07bddd69dab6252ce1e8a283a023d693b7d7ad6 (patch) | |
| tree | b5d75d39e8e1433189fe06d129d7285e94e263af /src/image.c | |
| parent | 035bd8159fe5bcea15eacc8a23ab54f4bc3b6f17 (diff) | |
| download | emacs-c07bddd69dab6252ce1e8a283a023d693b7d7ad6.tar.gz emacs-c07bddd69dab6252ce1e8a283a023d693b7d7ad6.zip | |
Pacify --enable-gcc-warnings --with-cairo
Problem reported by Alexander Kuleshov in:
http://lists.gnu.org/archive/html/emacs-devel/2016-01/msg01289.html
* src/gtkutil.c (xg_get_page_setup):
Use switch rather than if-then-else.
* src/image.c (COLOR_TABLE_SUPPORT):
Define directly rather than via #define and optional later #undef.
(lookup_rgb_color) [USE_CAIRO && ENABLE_CHECKING]:
Crash when the pixel is undefined, as there is a genuine bug
here (Bug#22442).
* src/image.c (tiff_load, gif_load, svg_load_image)
(x_kill_gs_process) [USE_CAIRO]:
* src/xterm.c (x_draw_fringe_bitmap) [USE_CAIRO]:
Omit unused locals, or move them to where they’re needed.
(x_clear_area1): Now ATTRIBUTE_UNUSED.
Diffstat (limited to 'src/image.c')
| -rw-r--r-- | src/image.c | 66 |
1 files changed, 27 insertions, 39 deletions
diff --git a/src/image.c b/src/image.c index 8bb5ff77b22..4681cba1f87 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -57,8 +57,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 57 | #endif /* HAVE_WINDOW_SYSTEM */ | 57 | #endif /* HAVE_WINDOW_SYSTEM */ |
| 58 | 58 | ||
| 59 | #ifdef HAVE_X_WINDOWS | 59 | #ifdef HAVE_X_WINDOWS |
| 60 | #define COLOR_TABLE_SUPPORT 1 | ||
| 61 | |||
| 62 | typedef struct x_bitmap_record Bitmap_Record; | 60 | typedef struct x_bitmap_record Bitmap_Record; |
| 63 | #define GET_PIXEL(ximg, x, y) XGetPixel (ximg, x, y) | 61 | #define GET_PIXEL(ximg, x, y) XGetPixel (ximg, x, y) |
| 64 | #define NO_PIXMAP None | 62 | #define NO_PIXMAP None |
| @@ -74,9 +72,6 @@ typedef struct x_bitmap_record Bitmap_Record; | |||
| 74 | # include "w32.h" | 72 | # include "w32.h" |
| 75 | #endif | 73 | #endif |
| 76 | 74 | ||
| 77 | /* W32_TODO : Color tables on W32. */ | ||
| 78 | #undef COLOR_TABLE_SUPPORT | ||
| 79 | |||
| 80 | typedef struct w32_bitmap_record Bitmap_Record; | 75 | typedef struct w32_bitmap_record Bitmap_Record; |
| 81 | #define GET_PIXEL(ximg, x, y) GetPixel (ximg, x, y) | 76 | #define GET_PIXEL(ximg, x, y) GetPixel (ximg, x, y) |
| 82 | #define NO_PIXMAP 0 | 77 | #define NO_PIXMAP 0 |
| @@ -89,13 +84,7 @@ typedef struct w32_bitmap_record Bitmap_Record; | |||
| 89 | 84 | ||
| 90 | #endif /* HAVE_NTGUI */ | 85 | #endif /* HAVE_NTGUI */ |
| 91 | 86 | ||
| 92 | #ifdef USE_CAIRO | ||
| 93 | #undef COLOR_TABLE_SUPPORT | ||
| 94 | #endif | ||
| 95 | |||
| 96 | #ifdef HAVE_NS | 87 | #ifdef HAVE_NS |
| 97 | #undef COLOR_TABLE_SUPPORT | ||
| 98 | |||
| 99 | typedef struct ns_bitmap_record Bitmap_Record; | 88 | typedef struct ns_bitmap_record Bitmap_Record; |
| 100 | 89 | ||
| 101 | #define GET_PIXEL(ximg, x, y) XGetPixel (ximg, x, y) | 90 | #define GET_PIXEL(ximg, x, y) XGetPixel (ximg, x, y) |
| @@ -109,6 +98,12 @@ typedef struct ns_bitmap_record Bitmap_Record; | |||
| 109 | #define DefaultDepthOfScreen(screen) x_display_list->n_planes | 98 | #define DefaultDepthOfScreen(screen) x_display_list->n_planes |
| 110 | #endif /* HAVE_NS */ | 99 | #endif /* HAVE_NS */ |
| 111 | 100 | ||
| 101 | #if (defined HAVE_X_WINDOWS \ | ||
| 102 | && ! (defined HAVE_NTGUI || defined USE_CAIRO || defined HAVE_NS)) | ||
| 103 | /* W32_TODO : Color tables on W32. */ | ||
| 104 | # define COLOR_TABLE_SUPPORT 1 | ||
| 105 | #endif | ||
| 106 | |||
| 112 | static void x_disable_image (struct frame *, struct image *); | 107 | static void x_disable_image (struct frame *, struct image *); |
| 113 | static void x_edge_detection (struct frame *, struct image *, Lisp_Object, | 108 | static void x_edge_detection (struct frame *, struct image *, Lisp_Object, |
| 114 | Lisp_Object); | 109 | Lisp_Object); |
| @@ -4615,16 +4610,13 @@ colors_in_color_table (int *n) | |||
| 4615 | static unsigned long | 4610 | static unsigned long |
| 4616 | lookup_rgb_color (struct frame *f, int r, int g, int b) | 4611 | lookup_rgb_color (struct frame *f, int r, int g, int b) |
| 4617 | { | 4612 | { |
| 4618 | unsigned long pixel; | ||
| 4619 | |||
| 4620 | #ifdef HAVE_NTGUI | 4613 | #ifdef HAVE_NTGUI |
| 4621 | pixel = PALETTERGB (r >> 8, g >> 8, b >> 8); | 4614 | return PALETTERGB (r >> 8, g >> 8, b >> 8); |
| 4622 | #endif /* HAVE_NTGUI */ | 4615 | #elif defined HAVE_NS |
| 4623 | 4616 | return RGB_TO_ULONG (r >> 8, g >> 8, b >> 8); | |
| 4624 | #ifdef HAVE_NS | 4617 | #else |
| 4625 | pixel = RGB_TO_ULONG (r >> 8, g >> 8, b >> 8); | 4618 | eassume (false); |
| 4626 | #endif /* HAVE_NS */ | 4619 | #endif |
| 4627 | return pixel; | ||
| 4628 | } | 4620 | } |
| 4629 | 4621 | ||
| 4630 | static void | 4622 | static void |
| @@ -7320,7 +7312,6 @@ tiff_load (struct frame *f, struct image *img) | |||
| 7320 | { | 7312 | { |
| 7321 | unsigned char *data = (unsigned char *) xmalloc (width*height*4); | 7313 | unsigned char *data = (unsigned char *) xmalloc (width*height*4); |
| 7322 | uint32_t *dataptr = (uint32_t *) data; | 7314 | uint32_t *dataptr = (uint32_t *) data; |
| 7323 | int r, g, b, a; | ||
| 7324 | 7315 | ||
| 7325 | for (y = 0; y < height; ++y) | 7316 | for (y = 0; y < height; ++y) |
| 7326 | { | 7317 | { |
| @@ -7634,19 +7625,19 @@ gif_load (struct frame *f, struct image *img) | |||
| 7634 | { | 7625 | { |
| 7635 | int rc, width, height, x, y, i, j; | 7626 | int rc, width, height, x, y, i, j; |
| 7636 | ColorMapObject *gif_color_map; | 7627 | ColorMapObject *gif_color_map; |
| 7637 | unsigned long pixel_colors[256]; | ||
| 7638 | GifFileType *gif; | 7628 | GifFileType *gif; |
| 7639 | gif_memory_source memsrc; | 7629 | gif_memory_source memsrc; |
| 7640 | Lisp_Object specified_bg = image_spec_value (img->spec, QCbackground, NULL); | 7630 | Lisp_Object specified_bg = image_spec_value (img->spec, QCbackground, NULL); |
| 7641 | Lisp_Object specified_file = image_spec_value (img->spec, QCfile, NULL); | 7631 | Lisp_Object specified_file = image_spec_value (img->spec, QCfile, NULL); |
| 7642 | Lisp_Object specified_data = image_spec_value (img->spec, QCdata, NULL); | 7632 | Lisp_Object specified_data = image_spec_value (img->spec, QCdata, NULL); |
| 7643 | unsigned long bgcolor = 0; | ||
| 7644 | EMACS_INT idx; | 7633 | EMACS_INT idx; |
| 7645 | int gif_err; | 7634 | int gif_err; |
| 7646 | 7635 | ||
| 7647 | #ifdef USE_CAIRO | 7636 | #ifdef USE_CAIRO |
| 7648 | unsigned char *data = 0; | 7637 | unsigned char *data = 0; |
| 7649 | #else | 7638 | #else |
| 7639 | unsigned long pixel_colors[256]; | ||
| 7640 | unsigned long bgcolor = 0; | ||
| 7650 | XImagePtr ximg; | 7641 | XImagePtr ximg; |
| 7651 | #endif | 7642 | #endif |
| 7652 | 7643 | ||
| @@ -7833,9 +7824,13 @@ gif_load (struct frame *f, struct image *img) | |||
| 7833 | gif_load call to construct and save all animation frames. */ | 7824 | gif_load call to construct and save all animation frames. */ |
| 7834 | 7825 | ||
| 7835 | init_color_table (); | 7826 | init_color_table (); |
| 7827 | |||
| 7828 | #ifndef USE_CAIRO | ||
| 7836 | if (STRINGP (specified_bg)) | 7829 | if (STRINGP (specified_bg)) |
| 7837 | bgcolor = x_alloc_image_color (f, img, specified_bg, | 7830 | bgcolor = x_alloc_image_color (f, img, specified_bg, |
| 7838 | FRAME_BACKGROUND_PIXEL (f)); | 7831 | FRAME_BACKGROUND_PIXEL (f)); |
| 7832 | #endif | ||
| 7833 | |||
| 7839 | for (j = 0; j <= idx; ++j) | 7834 | for (j = 0; j <= idx; ++j) |
| 7840 | { | 7835 | { |
| 7841 | /* We use a local variable `raster' here because RasterBits is a | 7836 | /* We use a local variable `raster' here because RasterBits is a |
| @@ -9182,11 +9177,6 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. * | |||
| 9182 | int height; | 9177 | int height; |
| 9183 | const guint8 *pixels; | 9178 | const guint8 *pixels; |
| 9184 | int rowstride; | 9179 | int rowstride; |
| 9185 | XImagePtr ximg; | ||
| 9186 | Lisp_Object specified_bg; | ||
| 9187 | XColor background; | ||
| 9188 | int x; | ||
| 9189 | int y; | ||
| 9190 | 9180 | ||
| 9191 | #if ! GLIB_CHECK_VERSION (2, 36, 0) | 9181 | #if ! GLIB_CHECK_VERSION (2, 36, 0) |
| 9192 | /* g_type_init is a glib function that must be called prior to | 9182 | /* g_type_init is a glib function that must be called prior to |
| @@ -9240,16 +9230,14 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. * | |||
| 9240 | #ifdef USE_CAIRO | 9230 | #ifdef USE_CAIRO |
| 9241 | { | 9231 | { |
| 9242 | unsigned char *data = (unsigned char *) xmalloc (width*height*4); | 9232 | unsigned char *data = (unsigned char *) xmalloc (width*height*4); |
| 9243 | int y; | ||
| 9244 | uint32_t bgcolor = get_spec_bg_or_alpha_as_argb (img, f); | 9233 | uint32_t bgcolor = get_spec_bg_or_alpha_as_argb (img, f); |
| 9245 | 9234 | ||
| 9246 | for (y = 0; y < height; ++y) | 9235 | for (int y = 0; y < height; ++y) |
| 9247 | { | 9236 | { |
| 9248 | const guchar *iconptr = pixels + y * rowstride; | 9237 | const guchar *iconptr = pixels + y * rowstride; |
| 9249 | uint32_t *dataptr = (uint32_t *) (data + y * rowstride); | 9238 | uint32_t *dataptr = (uint32_t *) (data + y * rowstride); |
| 9250 | int x; | ||
| 9251 | 9239 | ||
| 9252 | for (x = 0; x < width; ++x) | 9240 | for (int x = 0; x < width; ++x) |
| 9253 | { | 9241 | { |
| 9254 | if (iconptr[3] == 0) | 9242 | if (iconptr[3] == 0) |
| 9255 | *dataptr = bgcolor; | 9243 | *dataptr = bgcolor; |
| @@ -9269,6 +9257,7 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. * | |||
| 9269 | } | 9257 | } |
| 9270 | #else | 9258 | #else |
| 9271 | /* Try to create a x pixmap to hold the svg pixmap. */ | 9259 | /* Try to create a x pixmap to hold the svg pixmap. */ |
| 9260 | XImagePtr ximg; | ||
| 9272 | if (!image_create_x_image_and_pixmap (f, img, width, height, 0, &ximg, 0)) | 9261 | if (!image_create_x_image_and_pixmap (f, img, width, height, 0, &ximg, 0)) |
| 9273 | { | 9262 | { |
| 9274 | g_object_unref (pixbuf); | 9263 | g_object_unref (pixbuf); |
| @@ -9279,7 +9268,8 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. * | |||
| 9279 | 9268 | ||
| 9280 | /* Handle alpha channel by combining the image with a background | 9269 | /* Handle alpha channel by combining the image with a background |
| 9281 | color. */ | 9270 | color. */ |
| 9282 | specified_bg = image_spec_value (img->spec, QCbackground, NULL); | 9271 | XColor background; |
| 9272 | Lisp_Object specified_bg = image_spec_value (img->spec, QCbackground, NULL); | ||
| 9283 | if (!STRINGP (specified_bg) | 9273 | if (!STRINGP (specified_bg) |
| 9284 | || !x_defined_color (f, SSDATA (specified_bg), &background, 0)) | 9274 | || !x_defined_color (f, SSDATA (specified_bg), &background, 0)) |
| 9285 | x_query_frame_background_color (f, &background); | 9275 | x_query_frame_background_color (f, &background); |
| @@ -9295,9 +9285,9 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. * | |||
| 9295 | non-transparent images. Each pixel must be "flattened" by | 9285 | non-transparent images. Each pixel must be "flattened" by |
| 9296 | calculating the resulting color, given the transparency of the | 9286 | calculating the resulting color, given the transparency of the |
| 9297 | pixel, and the image background color. */ | 9287 | pixel, and the image background color. */ |
| 9298 | for (y = 0; y < height; ++y) | 9288 | for (int y = 0; y < height; ++y) |
| 9299 | { | 9289 | { |
| 9300 | for (x = 0; x < width; ++x) | 9290 | for (int x = 0; x < width; ++x) |
| 9301 | { | 9291 | { |
| 9302 | int red; | 9292 | int red; |
| 9303 | int green; | 9293 | int green; |
| @@ -9597,8 +9587,6 @@ x_kill_gs_process (Pixmap pixmap, struct frame *f) | |||
| 9597 | 0, 0, img->width, img->height, ~0, ZPixmap); | 9587 | 0, 0, img->width, img->height, ~0, ZPixmap); |
| 9598 | if (ximg) | 9588 | if (ximg) |
| 9599 | { | 9589 | { |
| 9600 | int x, y; | ||
| 9601 | |||
| 9602 | /* Initialize the color table. */ | 9590 | /* Initialize the color table. */ |
| 9603 | init_color_table (); | 9591 | init_color_table (); |
| 9604 | 9592 | ||
| @@ -9606,8 +9594,8 @@ x_kill_gs_process (Pixmap pixmap, struct frame *f) | |||
| 9606 | color table. After having done so, the color table will | 9594 | color table. After having done so, the color table will |
| 9607 | contain an entry for each color used by the image. */ | 9595 | contain an entry for each color used by the image. */ |
| 9608 | #ifdef COLOR_TABLE_SUPPORT | 9596 | #ifdef COLOR_TABLE_SUPPORT |
| 9609 | for (y = 0; y < img->height; ++y) | 9597 | for (int y = 0; y < img->height; ++y) |
| 9610 | for (x = 0; x < img->width; ++x) | 9598 | for (int x = 0; x < img->width; ++x) |
| 9611 | { | 9599 | { |
| 9612 | unsigned long pixel = XGetPixel (ximg, x, y); | 9600 | unsigned long pixel = XGetPixel (ximg, x, y); |
| 9613 | 9601 | ||