aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGerd Moellmann2000-09-18 13:17:55 +0000
committerGerd Moellmann2000-09-18 13:17:55 +0000
commitdd00328a08085779c84bfeb0e0f1d58c73f50f66 (patch)
treed91e211a8d00e7f7c9ab5e1fbff8b4fa5be01b7f /src
parent05b1f851b32cfcd0bc5bad64dfba6b4f90f92fb7 (diff)
downloademacs-dd00328a08085779c84bfeb0e0f1d58c73f50f66.tar.gz
emacs-dd00328a08085779c84bfeb0e0f1d58c73f50f66.zip
(x_clear_image_1): New function.
(x_clear_image): Use it. (x_from_xcolors): Use x_clear_image_1; don't free the image's mask.
Diffstat (limited to 'src')
-rw-r--r--src/xfns.c58
1 files changed, 36 insertions, 22 deletions
diff --git a/src/xfns.c b/src/xfns.c
index e34d36a8c06..ede3ce8ffff 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -5478,7 +5478,7 @@ prepare_image_for_display (f, img)
5478 5478
5479 /* If IMG doesn't have a pixmap yet, load it now, using the image 5479 /* If IMG doesn't have a pixmap yet, load it now, using the image
5480 type dependent loader function. */ 5480 type dependent loader function. */
5481 if (img->pixmap == 0 && !img->load_failed_p) 5481 if (img->pixmap == None && !img->load_failed_p)
5482 img->load_failed_p = img->type->load (f, img) == 0; 5482 img->load_failed_p = img->type->load (f, img) == 0;
5483} 5483}
5484 5484
@@ -5513,41 +5513,56 @@ image_ascent (img, face)
5513 Helper functions for X image types 5513 Helper functions for X image types
5514 ***********************************************************************/ 5514 ***********************************************************************/
5515 5515
5516static void x_clear_image_1 P_ ((struct frame *, struct image *, int,
5517 int, int));
5516static void x_clear_image P_ ((struct frame *f, struct image *img)); 5518static void x_clear_image P_ ((struct frame *f, struct image *img));
5517static unsigned long x_alloc_image_color P_ ((struct frame *f, 5519static unsigned long x_alloc_image_color P_ ((struct frame *f,
5518 struct image *img, 5520 struct image *img,
5519 Lisp_Object color_name, 5521 Lisp_Object color_name,
5520 unsigned long dflt)); 5522 unsigned long dflt));
5521 5523
5522/* Free X resources of image IMG which is used on frame F. */ 5524
5525/* Clear X resources of image IMG on frame F. PIXMAP_P non-zero means
5526 free the pixmap if any. MASK_P non-zero means clear the mask
5527 pixmap if any. COLORS_P non-zero means free colors allocated for
5528 the image, if any. */
5523 5529
5524static void 5530static void
5525x_clear_image (f, img) 5531x_clear_image_1 (f, img, pixmap_p, mask_p, colors_p)
5526 struct frame *f; 5532 struct frame *f;
5527 struct image *img; 5533 struct image *img;
5534 int pixmap_p, mask_p, colors_p;
5528{ 5535{
5529 BLOCK_INPUT; 5536 if (pixmap_p && img->pixmap)
5530
5531 if (img->pixmap)
5532 { 5537 {
5533 XFreePixmap (FRAME_X_DISPLAY (f), img->pixmap); 5538 XFreePixmap (FRAME_X_DISPLAY (f), img->pixmap);
5534 img->pixmap = 0; 5539 img->pixmap = None;
5535 } 5540 }
5536 5541
5537 if (img->mask) 5542 if (mask_p && img->mask)
5538 { 5543 {
5539 XFreePixmap (FRAME_X_DISPLAY (f), img->mask); 5544 XFreePixmap (FRAME_X_DISPLAY (f), img->mask);
5540 img->mask = 0; 5545 img->mask = None;
5541 } 5546 }
5542 5547
5543 if (img->ncolors) 5548 if (colors_p && img->ncolors)
5544 { 5549 {
5545 x_free_colors (f, img->colors, img->ncolors); 5550 x_free_colors (f, img->colors, img->ncolors);
5546 xfree (img->colors); 5551 xfree (img->colors);
5547 img->colors = NULL; 5552 img->colors = NULL;
5548 img->ncolors = 0; 5553 img->ncolors = 0;
5549 } 5554 }
5550 5555}
5556
5557/* Free X resources of image IMG which is used on frame F. */
5558
5559static void
5560x_clear_image (f, img)
5561 struct frame *f;
5562 struct image *img;
5563{
5564 BLOCK_INPUT;
5565 x_clear_image_1 (f, img, 1, 1, 1);
5551 UNBLOCK_INPUT; 5566 UNBLOCK_INPUT;
5552} 5567}
5553 5568
@@ -5837,7 +5852,7 @@ lookup_image (f, spec)
5837 else if (NILP (mask) && found_p && img->mask) 5852 else if (NILP (mask) && found_p && img->mask)
5838 { 5853 {
5839 XFreePixmap (FRAME_X_DISPLAY (f), img->mask); 5854 XFreePixmap (FRAME_X_DISPLAY (f), img->mask);
5840 img->mask = 0; 5855 img->mask = None;
5841 } 5856 }
5842 } 5857 }
5843 } 5858 }
@@ -5865,9 +5880,8 @@ lookup_image (f, spec)
5865 Fplist_get (tem, QCcolor_adjustment)); 5880 Fplist_get (tem, QCcolor_adjustment));
5866 } 5881 }
5867 } 5882 }
5868
5869 } 5883 }
5870 5884
5871 UNBLOCK_INPUT; 5885 UNBLOCK_INPUT;
5872 xassert (!interrupt_input_blocked); 5886 xassert (!interrupt_input_blocked);
5873 } 5887 }
@@ -5990,7 +6004,7 @@ x_create_x_image_and_pixmap (f, width, height, depth, ximg, pixmap)
5990 6004
5991 /* Allocate a pixmap of the same size. */ 6005 /* Allocate a pixmap of the same size. */
5992 *pixmap = XCreatePixmap (display, window, width, height, depth); 6006 *pixmap = XCreatePixmap (display, window, width, height, depth);
5993 if (*pixmap == 0) 6007 if (*pixmap == None)
5994 { 6008 {
5995 x_destroy_x_image (*ximg); 6009 x_destroy_x_image (*ximg);
5996 *ximg = NULL; 6010 *ximg = NULL;
@@ -6575,7 +6589,7 @@ xbm_load_image (f, img, contents, end)
6575 depth); 6589 depth);
6576 xfree (data); 6590 xfree (data);
6577 6591
6578 if (img->pixmap == 0) 6592 if (img->pixmap == None)
6579 { 6593 {
6580 x_clear_image (f, img); 6594 x_clear_image (f, img);
6581 image_error ("Unable to create X pixmap for `%s'", img->spec, Qnil); 6595 image_error ("Unable to create X pixmap for `%s'", img->spec, Qnil);
@@ -7454,7 +7468,7 @@ x_from_xcolors (f, img, colors)
7454 } 7468 }
7455 7469
7456 xfree (colors); 7470 xfree (colors);
7457 x_clear_image (f, img); 7471 x_clear_image_1 (f, img, 1, 0, 1);
7458 7472
7459 x_put_x_image (f, oimg, pixmap, img->width, img->height); 7473 x_put_x_image (f, oimg, pixmap, img->width, img->height);
7460 x_destroy_x_image (oimg); 7474 x_destroy_x_image (oimg);
@@ -7611,7 +7625,7 @@ x_disable_image (f, img)
7611 struct image *img; 7625 struct image *img;
7612{ 7626{
7613 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 7627 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
7614 7628
7615 if (dpyinfo->n_planes >= 2) 7629 if (dpyinfo->n_planes >= 2)
7616 { 7630 {
7617 /* Color (or grayscale). Convert to gray, and equalize. Just 7631 /* Color (or grayscale). Convert to gray, and equalize. Just
@@ -7684,9 +7698,9 @@ x_build_heuristic_mask (f, img, how)
7684 if (img->mask) 7698 if (img->mask)
7685 { 7699 {
7686 XFreePixmap (FRAME_X_DISPLAY (f), img->mask); 7700 XFreePixmap (FRAME_X_DISPLAY (f), img->mask);
7687 img->mask = 0; 7701 img->mask = None;
7688 } 7702 }
7689 7703
7690 /* Create an image and pixmap serving as mask. */ 7704 /* Create an image and pixmap serving as mask. */
7691 rc = x_create_x_image_and_pixmap (f, img->width, img->height, 1, 7705 rc = x_create_x_image_and_pixmap (f, img->width, img->height, 1,
7692 &mask_img, &img->mask); 7706 &mask_img, &img->mask);
@@ -8471,7 +8485,7 @@ png_load (f, img)
8471 { 8485 {
8472 x_destroy_x_image (ximg); 8486 x_destroy_x_image (ximg);
8473 XFreePixmap (FRAME_X_DISPLAY (f), img->pixmap); 8487 XFreePixmap (FRAME_X_DISPLAY (f), img->pixmap);
8474 img->pixmap = 0; 8488 img->pixmap = None;
8475 goto error; 8489 goto error;
8476 } 8490 }
8477 8491
@@ -9691,7 +9705,7 @@ gs_load (f, img)
9691 img->height = in_height * FRAME_X_DISPLAY_INFO (f)->resy; 9705 img->height = in_height * FRAME_X_DISPLAY_INFO (f)->resy;
9692 9706
9693 /* Create the pixmap. */ 9707 /* Create the pixmap. */
9694 xassert (img->pixmap == 0); 9708 xassert (img->pixmap == None);
9695 img->pixmap = XCreatePixmap (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 9709 img->pixmap = XCreatePixmap (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
9696 img->width, img->height, 9710 img->width, img->height,
9697 DefaultDepthOfScreen (FRAME_X_SCREEN (f))); 9711 DefaultDepthOfScreen (FRAME_X_SCREEN (f)));