aboutsummaryrefslogtreecommitdiffstats
path: root/src/image.c
diff options
context:
space:
mode:
authorAlexander Gramiak2019-05-09 13:07:35 -0600
committerAlexander Gramiak2019-05-19 19:50:32 -0600
commitc0e146e4ec266edf348473c3db7ca8d16745f4f7 (patch)
tree3f2070ccbf941ba14f43836f7cfa1b4c78979043 /src/image.c
parent05b79539f4d22bfe5160777aa5a963aeb74b000c (diff)
downloademacs-c0e146e4ec266edf348473c3db7ca8d16745f4f7.tar.gz
emacs-c0e146e4ec266edf348473c3db7ca8d16745f4f7.zip
Introduce Emacs_Color struct and typedef
This avoids clashing with the XColor struct from X. * src/dispextern [HAVE_X_WINDOWS]: Define Emacs_Color alias. [!HAVE_X_WINDOWS]: Rename XColor compatibility struct to Emacs_Color. Remove unused fields. * src/gtkutil.c: * src/gtkutil.h: * src/image.c: * src/nsterm.h: * src/nsterm.m: * src/termhooks.h: * src/w32fns.c: * src/w32term.c: * src/w32term.h: * src/xfaces.c: * src/xfns.c: * src/xterm.h: Use Emacs_Color over XColor outside of X-specific sections.
Diffstat (limited to 'src/image.c')
-rw-r--r--src/image.c66
1 files changed, 33 insertions, 33 deletions
diff --git a/src/image.c b/src/image.c
index 071b92a741e..c768ece9786 100644
--- a/src/image.c
+++ b/src/image.c
@@ -1076,10 +1076,10 @@ image_ascent (struct image *img, struct face *face, struct glyph_slice *slice)
1076 1076
1077#ifdef USE_CAIRO 1077#ifdef USE_CAIRO
1078static uint32_t 1078static uint32_t
1079xcolor_to_argb32 (XColor xc) 1079emacs_color_to_argb32 (Emacs_Color *ec)
1080{ 1080{
1081 return ((0xffu << 24) | ((xc.red / 256) << 16) 1081 return ((0xffu << 24) | ((ec->red / 256) << 16)
1082 | ((xc.green / 256) << 8) | (xc.blue / 256)); 1082 | ((ec->green / 256) << 8) | (ec->blue / 256));
1083} 1083}
1084 1084
1085static uint32_t 1085static uint32_t
@@ -1087,11 +1087,11 @@ get_spec_bg_or_alpha_as_argb (struct image *img,
1087 struct frame *f) 1087 struct frame *f)
1088{ 1088{
1089 uint32_t bgcolor = 0; 1089 uint32_t bgcolor = 0;
1090 XColor xbgcolor; 1090 Emacs_Color xbgcolor;
1091 Lisp_Object bg = image_spec_value (img->spec, QCbackground, NULL); 1091 Lisp_Object bg = image_spec_value (img->spec, QCbackground, NULL);
1092 1092
1093 if (STRINGP (bg) && x_parse_color (f, SSDATA (bg), &xbgcolor)) 1093 if (STRINGP (bg) && x_parse_color (f, SSDATA (bg), &xbgcolor))
1094 bgcolor = xcolor_to_argb32 (xbgcolor); 1094 bgcolor = emacs_color_to_argb32 (&xbgcolor);
1095 1095
1096 return bgcolor; 1096 return bgcolor;
1097} 1097}
@@ -1321,7 +1321,7 @@ static unsigned long
1321image_alloc_image_color (struct frame *f, struct image *img, 1321image_alloc_image_color (struct frame *f, struct image *img,
1322 Lisp_Object color_name, unsigned long dflt) 1322 Lisp_Object color_name, unsigned long dflt)
1323{ 1323{
1324 XColor color; 1324 Emacs_Color color;
1325 unsigned long result; 1325 unsigned long result;
1326 1326
1327 eassert (STRINGP (color_name)); 1327 eassert (STRINGP (color_name));
@@ -4286,7 +4286,7 @@ xpm_load_image (struct frame *f,
4286 char *color, *max_color; 4286 char *color, *max_color;
4287 int key, next_key, max_key = 0; 4287 int key, next_key, max_key = 0;
4288 Lisp_Object symbol_color = Qnil, color_val; 4288 Lisp_Object symbol_color = Qnil, color_val;
4289 XColor cdef; 4289 Emacs_Color cdef;
4290 4290
4291 expect (XPM_TK_STRING); 4291 expect (XPM_TK_STRING);
4292 if (len <= chars_per_pixel || len >= BUFSIZ + chars_per_pixel) 4292 if (len <= chars_per_pixel || len >= BUFSIZ + chars_per_pixel)
@@ -4772,17 +4772,17 @@ static int laplace_matrix[9] = {
4772#define COLOR_INTENSITY(R, G, B) ((2 * (R) + 3 * (G) + (B)) / 6) 4772#define COLOR_INTENSITY(R, G, B) ((2 * (R) + 3 * (G) + (B)) / 6)
4773 4773
4774 4774
4775/* On frame F, return an array of XColor structures describing image 4775/* On frame F, return an array of Emacs_Color structures describing image
4776 IMG->pixmap. Each XColor structure has its pixel color set. RGB_P 4776 IMG->pixmap. Each Emacs_Color structure has its pixel color set. RGB_P
4777 means also fill the red/green/blue members of the XColor 4777 means also fill the red/green/blue members of the Emacs_Color
4778 structures. Value is a pointer to the array of XColors structures, 4778 structures. Value is a pointer to the array of Emacs_Color structures,
4779 allocated with xmalloc; it must be freed by the caller. */ 4779 allocated with xmalloc; it must be freed by the caller. */
4780 4780
4781static XColor * 4781static Emacs_Color *
4782image_to_xcolors (struct frame *f, struct image *img, bool rgb_p) 4782image_to_emacs_colors (struct frame *f, struct image *img, bool rgb_p)
4783{ 4783{
4784 int x, y; 4784 int x, y;
4785 XColor *colors, *p; 4785 Emacs_Color *colors, *p;
4786 XImagePtr_or_DC ximg; 4786 XImagePtr_or_DC ximg;
4787 ptrdiff_t nbytes; 4787 ptrdiff_t nbytes;
4788#ifdef HAVE_NTGUI 4788#ifdef HAVE_NTGUI
@@ -4798,13 +4798,13 @@ image_to_xcolors (struct frame *f, struct image *img, bool rgb_p)
4798 /* Get the X image or create a memory device context for IMG. */ 4798 /* Get the X image or create a memory device context for IMG. */
4799 ximg = image_get_x_image_or_dc (f, img, 0, &prev); 4799 ximg = image_get_x_image_or_dc (f, img, 0, &prev);
4800 4800
4801 /* Fill the `pixel' members of the XColor array. I wished there 4801 /* Fill the `pixel' members of the Emacs_Color array. I wished there
4802 were an easy and portable way to circumvent XGetPixel. */ 4802 were an easy and portable way to circumvent XGetPixel. */
4803 p = colors; 4803 p = colors;
4804 for (y = 0; y < img->height; ++y) 4804 for (y = 0; y < img->height; ++y)
4805 { 4805 {
4806#if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) 4806#if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI)
4807 XColor *row = p; 4807 Emacs_Color *row = p;
4808 for (x = 0; x < img->width; ++x, ++p) 4808 for (x = 0; x < img->width; ++x, ++p)
4809 p->pixel = GET_PIXEL (ximg, x, y); 4809 p->pixel = GET_PIXEL (ximg, x, y);
4810 if (rgb_p) 4810 if (rgb_p)
@@ -4878,16 +4878,16 @@ XPutPixel (XImagePtr ximg, int x, int y, COLORREF color)
4878 4878
4879#endif /* HAVE_NTGUI */ 4879#endif /* HAVE_NTGUI */
4880 4880
4881/* Create IMG->pixmap from an array COLORS of XColor structures, whose 4881/* Create IMG->pixmap from an array COLORS of Emacs_Color structures, whose
4882 RGB members are set. F is the frame on which this all happens. 4882 RGB members are set. F is the frame on which this all happens.
4883 COLORS will be freed; an existing IMG->pixmap will be freed, too. */ 4883 COLORS will be freed; an existing IMG->pixmap will be freed, too. */
4884 4884
4885static void 4885static void
4886image_from_xcolors (struct frame *f, struct image *img, XColor *colors) 4886image_from_emacs_colors (struct frame *f, struct image *img, Emacs_Color *colors)
4887{ 4887{
4888 int x, y; 4888 int x, y;
4889 XImagePtr oimg = NULL; 4889 XImagePtr oimg = NULL;
4890 XColor *p; 4890 Emacs_Color *p;
4891 4891
4892 init_color_table (); 4892 init_color_table ();
4893 4893
@@ -4925,8 +4925,8 @@ static void
4925image_detect_edges (struct frame *f, struct image *img, 4925image_detect_edges (struct frame *f, struct image *img,
4926 int *matrix, int color_adjust) 4926 int *matrix, int color_adjust)
4927{ 4927{
4928 XColor *colors = image_to_xcolors (f, img, 1); 4928 Emacs_Color *colors = image_to_emacs_colors (f, img, 1);
4929 XColor *new, *p; 4929 Emacs_Color *new, *p;
4930 int x, y, i, sum; 4930 int x, y, i, sum;
4931 ptrdiff_t nbytes; 4931 ptrdiff_t nbytes;
4932 4932
@@ -4969,7 +4969,7 @@ image_detect_edges (struct frame *f, struct image *img,
4969 for (xx = x - 1; xx < x + 2; ++xx, ++i) 4969 for (xx = x - 1; xx < x + 2; ++xx, ++i)
4970 if (matrix[i]) 4970 if (matrix[i])
4971 { 4971 {
4972 XColor *t = COLOR (colors, xx, yy); 4972 Emacs_Color *t = COLOR (colors, xx, yy);
4973 r += matrix[i] * t->red; 4973 r += matrix[i] * t->red;
4974 g += matrix[i] * t->green; 4974 g += matrix[i] * t->green;
4975 b += matrix[i] * t->blue; 4975 b += matrix[i] * t->blue;
@@ -4983,7 +4983,7 @@ image_detect_edges (struct frame *f, struct image *img,
4983 } 4983 }
4984 4984
4985 xfree (colors); 4985 xfree (colors);
4986 image_from_xcolors (f, img, new); 4986 image_from_emacs_colors (f, img, new);
4987 4987
4988#undef COLOR 4988#undef COLOR
4989} 4989}
@@ -5066,8 +5066,8 @@ image_disable_image (struct frame *f, struct image *img)
5066 /* Color (or grayscale). Convert to gray, and equalize. Just 5066 /* Color (or grayscale). Convert to gray, and equalize. Just
5067 drawing such images with a stipple can look very odd, so 5067 drawing such images with a stipple can look very odd, so
5068 we're using this method instead. */ 5068 we're using this method instead. */
5069 XColor *colors = image_to_xcolors (f, img, 1); 5069 Emacs_Color *colors = image_to_emacs_colors (f, img, 1);
5070 XColor *p, *end; 5070 Emacs_Color *p, *end;
5071 const int h = 15000; 5071 const int h = 15000;
5072 const int l = 30000; 5072 const int l = 30000;
5073 5073
@@ -5080,7 +5080,7 @@ image_disable_image (struct frame *f, struct image *img)
5080 p->red = p->green = p->blue = i2; 5080 p->red = p->green = p->blue = i2;
5081 } 5081 }
5082 5082
5083 image_from_xcolors (f, img, colors); 5083 image_from_emacs_colors (f, img, colors);
5084 } 5084 }
5085 5085
5086 /* Draw a cross over the disabled image, if we must or if we 5086 /* Draw a cross over the disabled image, if we must or if we
@@ -5522,7 +5522,7 @@ pbm_load (struct frame *f, struct image *img)
5522 unsigned long fg = FRAME_FOREGROUND_PIXEL (f); 5522 unsigned long fg = FRAME_FOREGROUND_PIXEL (f);
5523 unsigned long bg = FRAME_BACKGROUND_PIXEL (f); 5523 unsigned long bg = FRAME_BACKGROUND_PIXEL (f);
5524#ifdef USE_CAIRO 5524#ifdef USE_CAIRO
5525 XColor xfg, xbg; 5525 Emacs_Color xfg, xbg;
5526 int fga32, bga32; 5526 int fga32, bga32;
5527#endif 5527#endif
5528 /* Parse the image specification. */ 5528 /* Parse the image specification. */
@@ -5542,7 +5542,7 @@ pbm_load (struct frame *f, struct image *img)
5542 xfg.pixel = fg; 5542 xfg.pixel = fg;
5543 x_query_colors (f, &xfg, 1); 5543 x_query_colors (f, &xfg, 1);
5544 } 5544 }
5545 fga32 = xcolor_to_argb32 (xfg); 5545 fga32 = emacs_color_to_argb32 (&xfg);
5546 5546
5547 if (! fmt[PBM_BACKGROUND].count 5547 if (! fmt[PBM_BACKGROUND].count
5548 || ! STRINGP (fmt[PBM_BACKGROUND].value) 5548 || ! STRINGP (fmt[PBM_BACKGROUND].value)
@@ -5555,7 +5555,7 @@ pbm_load (struct frame *f, struct image *img)
5555 xbg.pixel = bg; 5555 xbg.pixel = bg;
5556 x_query_colors (f, &xbg, 1); 5556 x_query_colors (f, &xbg, 1);
5557 } 5557 }
5558 bga32 = xcolor_to_argb32 (xbg); 5558 bga32 = emacs_color_to_argb32 (&xbg);
5559#else 5559#else
5560 if (fmt[PBM_FOREGROUND].count 5560 if (fmt[PBM_FOREGROUND].count
5561 && STRINGP (fmt[PBM_FOREGROUND].value)) 5561 && STRINGP (fmt[PBM_FOREGROUND].value))
@@ -6180,7 +6180,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
6180 /* png_color_16 *image_bg; */ 6180 /* png_color_16 *image_bg; */
6181 Lisp_Object specified_bg 6181 Lisp_Object specified_bg
6182 = image_spec_value (img->spec, QCbackground, NULL); 6182 = image_spec_value (img->spec, QCbackground, NULL);
6183 XColor color; 6183 Emacs_Color color;
6184 6184
6185 /* If the user specified a color, try to use it; if not, use the 6185 /* If the user specified a color, try to use it; if not, use the
6186 current frame background, ignoring any default background 6186 current frame background, ignoring any default background
@@ -7813,7 +7813,7 @@ gif_load (struct frame *f, struct image *img)
7813 uint32_t *data32 = (uint32_t *) cairo_image_surface_get_data (surface); 7813 uint32_t *data32 = (uint32_t *) cairo_image_surface_get_data (surface);
7814 if (STRINGP (specified_bg)) 7814 if (STRINGP (specified_bg))
7815 { 7815 {
7816 XColor color; 7816 Emacs_Color color;
7817 if (FRAME_TERMINAL (f)->defined_color_hook 7817 if (FRAME_TERMINAL (f)->defined_color_hook
7818 (f, SSDATA (specified_bg), &color, false, false)) 7818 (f, SSDATA (specified_bg), &color, false, false))
7819 { 7819 {
@@ -8548,7 +8548,7 @@ imagemagick_load_image (struct frame *f, struct image *img,
8548 8548
8549 /* Retrieve the frame's background color, for use later. */ 8549 /* Retrieve the frame's background color, for use later. */
8550 { 8550 {
8551 XColor bgcolor; 8551 Emacs_Color bgcolor;
8552 Lisp_Object specified_bg; 8552 Lisp_Object specified_bg;
8553 8553
8554 specified_bg = image_spec_value (img->spec, QCbackground, NULL); 8554 specified_bg = image_spec_value (img->spec, QCbackground, NULL);
@@ -9285,7 +9285,7 @@ svg_load_image (struct frame *f, struct image *img, char *contents,
9285 9285
9286 /* Handle alpha channel by combining the image with a background 9286 /* Handle alpha channel by combining the image with a background
9287 color. */ 9287 color. */
9288 XColor background; 9288 Emacs_Color background;
9289 Lisp_Object specified_bg = image_spec_value (img->spec, QCbackground, NULL); 9289 Lisp_Object specified_bg = image_spec_value (img->spec, QCbackground, NULL);
9290 if (!STRINGP (specified_bg) 9290 if (!STRINGP (specified_bg)
9291 || !FRAME_TERMINAL (f)->defined_color_hook (f, 9291 || !FRAME_TERMINAL (f)->defined_color_hook (f,