diff options
| author | Eli Zaretskii | 2020-04-14 18:10:41 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2020-04-14 18:10:41 +0300 |
| commit | e94206aaf608a899c81bb07fe91d26439f51b3f8 (patch) | |
| tree | a4a24407f1ba3d70ae192a1aad954a2bed3e91e1 /src/image.c | |
| parent | df254a7445a86dc25d133f2d79be8096190a8b96 (diff) | |
| download | emacs-e94206aaf608a899c81bb07fe91d26439f51b3f8.tar.gz emacs-e94206aaf608a899c81bb07fe91d26439f51b3f8.zip | |
Make use of MS-Windows native image API be selectable at run time
* configure.ac: Minor cleanup in how w32image.o is added to the
build when native image APIs are requested.
* src/w32gui.h (w32_load_image, w32_can_use_native_image_api)
(w32_gdiplus_shutdown): Move prototypes from w32term.h here, since
w32.c doesn't include w32term.h.
* src/image.c (struct image_type): No need to pass TYPE to the
'valid_p' method. All callers changed.
(initialize_image_type) [HAVE_NATIVE_IMAGE_API]: Call
'image_can_use_native_api' before trying image-specific methods.
(image_can_use_native_api): New function.
(image_types): Remove the native_image_type parts.
(syms_of_image): New symbol 'native-image'.
(parse_image_spec): Accept native-image "type" for any image type.
* src/w32term.c (syms_of_w32term): New variable
'w32-use-native-image-API'.
* src/w32image.c: (w32_can_use_native_image_api): New function.
(gdiplus_init): Rename from w32_gdiplus_startup. Simplify code.
Move the call to GdiplusStartup to a separate function. Use
ordinal number for SHCreateMemStream if cannot load it by name.
(w32_load_image): Ignore Win32Error status from
w32_select_active_frame.
Move DEFSYMs from here...
* src/image.c (syms_of_image) [HAVE_NATIVE_IMAGE_API]: ...to here.
* etc/NEWS: Update the entry about native image API use.
Diffstat (limited to 'src/image.c')
| -rw-r--r-- | src/image.c | 134 |
1 files changed, 75 insertions, 59 deletions
diff --git a/src/image.c b/src/image.c index ff2d12fa1a1..4ef3e9d3e4c 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -751,7 +751,7 @@ struct image_type | |||
| 751 | 751 | ||
| 752 | /* Check that SPEC is a valid image specification for the given | 752 | /* Check that SPEC is a valid image specification for the given |
| 753 | image type. Value is true if SPEC is valid. */ | 753 | image type. Value is true if SPEC is valid. */ |
| 754 | bool (*valid_p) (Lisp_Object spec, Lisp_Object type); | 754 | bool (*valid_p) (Lisp_Object spec); |
| 755 | 755 | ||
| 756 | /* Load IMG which is used on frame F from information contained in | 756 | /* Load IMG which is used on frame F from information contained in |
| 757 | IMG->spec. Value is true if successful. */ | 757 | IMG->spec. Value is true if successful. */ |
| @@ -807,7 +807,7 @@ valid_image_p (Lisp_Object object) | |||
| 807 | { | 807 | { |
| 808 | struct image_type const *type = lookup_image_type (XCAR (tail)); | 808 | struct image_type const *type = lookup_image_type (XCAR (tail)); |
| 809 | if (type) | 809 | if (type) |
| 810 | return type->valid_p (object, builtin_lisp_symbol (type->type)); | 810 | return type->valid_p (object); |
| 811 | } | 811 | } |
| 812 | break; | 812 | break; |
| 813 | } | 813 | } |
| @@ -816,7 +816,6 @@ valid_image_p (Lisp_Object object) | |||
| 816 | return false; | 816 | return false; |
| 817 | } | 817 | } |
| 818 | 818 | ||
| 819 | |||
| 820 | /* Log error message with format string FORMAT and trailing arguments. | 819 | /* Log error message with format string FORMAT and trailing arguments. |
| 821 | Signaling an error, e.g. when an image cannot be loaded, is not a | 820 | Signaling an error, e.g. when an image cannot be loaded, is not a |
| 822 | good idea because this would interrupt redisplay, and the error | 821 | good idea because this would interrupt redisplay, and the error |
| @@ -1004,7 +1003,8 @@ parse_image_spec (Lisp_Object spec, struct image_keyword *keywords, | |||
| 1004 | break; | 1003 | break; |
| 1005 | } | 1004 | } |
| 1006 | 1005 | ||
| 1007 | if (EQ (key, QCtype) && !EQ (type, value)) | 1006 | if (EQ (key, QCtype) |
| 1007 | && !(EQ (type, value) || EQ (type, Qnative_image))) | ||
| 1008 | return false; | 1008 | return false; |
| 1009 | } | 1009 | } |
| 1010 | 1010 | ||
| @@ -3144,12 +3144,12 @@ enum xbm_token | |||
| 3144 | displayed is used. */ | 3144 | displayed is used. */ |
| 3145 | 3145 | ||
| 3146 | static bool | 3146 | static bool |
| 3147 | xbm_image_p (Lisp_Object object, Lisp_Object type) | 3147 | xbm_image_p (Lisp_Object object) |
| 3148 | { | 3148 | { |
| 3149 | struct image_keyword kw[XBM_LAST]; | 3149 | struct image_keyword kw[XBM_LAST]; |
| 3150 | 3150 | ||
| 3151 | memcpy (kw, xbm_format, sizeof kw); | 3151 | memcpy (kw, xbm_format, sizeof kw); |
| 3152 | if (!parse_image_spec (object, kw, XBM_LAST, type)) | 3152 | if (!parse_image_spec (object, kw, XBM_LAST, Qxbm)) |
| 3153 | return 0; | 3153 | return 0; |
| 3154 | 3154 | ||
| 3155 | eassert (EQ (kw[XBM_TYPE].value, Qxbm)); | 3155 | eassert (EQ (kw[XBM_TYPE].value, Qxbm)); |
| @@ -3697,7 +3697,7 @@ xbm_load (struct frame *f, struct image *img) | |||
| 3697 | bool success_p = 0; | 3697 | bool success_p = 0; |
| 3698 | Lisp_Object file_name; | 3698 | Lisp_Object file_name; |
| 3699 | 3699 | ||
| 3700 | eassert (xbm_image_p (img->spec, Qxbm)); | 3700 | eassert (xbm_image_p (img->spec)); |
| 3701 | 3701 | ||
| 3702 | /* If IMG->spec specifies a file name, create a non-file spec from it. */ | 3702 | /* If IMG->spec specifies a file name, create a non-file spec from it. */ |
| 3703 | file_name = image_spec_value (img->spec, QCfile, NULL); | 3703 | file_name = image_spec_value (img->spec, QCfile, NULL); |
| @@ -4155,11 +4155,11 @@ xpm_valid_color_symbols_p (Lisp_Object color_symbols) | |||
| 4155 | /* Value is true if OBJECT is a valid XPM image specification. */ | 4155 | /* Value is true if OBJECT is a valid XPM image specification. */ |
| 4156 | 4156 | ||
| 4157 | static bool | 4157 | static bool |
| 4158 | xpm_image_p (Lisp_Object object, Lisp_Object type) | 4158 | xpm_image_p (Lisp_Object object) |
| 4159 | { | 4159 | { |
| 4160 | struct image_keyword fmt[XPM_LAST]; | 4160 | struct image_keyword fmt[XPM_LAST]; |
| 4161 | memcpy (fmt, xpm_format, sizeof fmt); | 4161 | memcpy (fmt, xpm_format, sizeof fmt); |
| 4162 | return (parse_image_spec (object, fmt, XPM_LAST, type) | 4162 | return (parse_image_spec (object, fmt, XPM_LAST, Qxpm) |
| 4163 | /* Either `:file' or `:data' must be present. */ | 4163 | /* Either `:file' or `:data' must be present. */ |
| 4164 | && fmt[XPM_FILE].count + fmt[XPM_DATA].count == 1 | 4164 | && fmt[XPM_FILE].count + fmt[XPM_DATA].count == 1 |
| 4165 | /* Either no `:color-symbols' or it's a list of conses | 4165 | /* Either no `:color-symbols' or it's a list of conses |
| @@ -5883,13 +5883,13 @@ static const struct image_keyword pbm_format[PBM_LAST] = | |||
| 5883 | /* Return true if OBJECT is a valid PBM image specification. */ | 5883 | /* Return true if OBJECT is a valid PBM image specification. */ |
| 5884 | 5884 | ||
| 5885 | static bool | 5885 | static bool |
| 5886 | pbm_image_p (Lisp_Object object, Lisp_Object type) | 5886 | pbm_image_p (Lisp_Object object) |
| 5887 | { | 5887 | { |
| 5888 | struct image_keyword fmt[PBM_LAST]; | 5888 | struct image_keyword fmt[PBM_LAST]; |
| 5889 | 5889 | ||
| 5890 | memcpy (fmt, pbm_format, sizeof fmt); | 5890 | memcpy (fmt, pbm_format, sizeof fmt); |
| 5891 | 5891 | ||
| 5892 | if (!parse_image_spec (object, fmt, PBM_LAST, type)) | 5892 | if (!parse_image_spec (object, fmt, PBM_LAST, Qpbm)) |
| 5893 | return 0; | 5893 | return 0; |
| 5894 | 5894 | ||
| 5895 | /* Must specify either :data or :file. */ | 5895 | /* Must specify either :data or :file. */ |
| @@ -6235,21 +6235,30 @@ pbm_load (struct frame *f, struct image *img) | |||
| 6235 | /*********************************************************************** | 6235 | /*********************************************************************** |
| 6236 | NATIVE IMAGE HANDLING | 6236 | NATIVE IMAGE HANDLING |
| 6237 | ***********************************************************************/ | 6237 | ***********************************************************************/ |
| 6238 | #if defined(HAVE_NATIVE_IMAGE_API) && defined(HAVE_NTGUI) | 6238 | |
| 6239 | static bool | ||
| 6240 | image_can_use_native_api (Lisp_Object type) | ||
| 6241 | { | ||
| 6242 | #if HAVE_NATIVE_IMAGE_API | ||
| 6243 | # ifdef HAVE_NTGUI | ||
| 6244 | return w32_can_use_native_image_api (type); | ||
| 6245 | # else | ||
| 6246 | return false; | ||
| 6247 | # endif | ||
| 6248 | #else | ||
| 6249 | return false; | ||
| 6250 | #endif | ||
| 6251 | } | ||
| 6252 | |||
| 6253 | #if HAVE_NATIVE_IMAGE_API | ||
| 6254 | |||
| 6239 | /* | 6255 | /* |
| 6240 | * These functions are actually defined in the OS-native implementation | 6256 | * These functions are actually defined in the OS-native implementation |
| 6241 | * file. Currently, for Windows GDI+ interface, w32image.c, but other | 6257 | * file. Currently, for Windows GDI+ interface, w32image.c, but other |
| 6242 | * operating systems can follow suit. | 6258 | * operating systems can follow suit. |
| 6243 | */ | 6259 | */ |
| 6244 | 6260 | ||
| 6245 | static bool | ||
| 6246 | init_native_image_functions (void) | ||
| 6247 | { | ||
| 6248 | return w32_gdiplus_startup (); | ||
| 6249 | } | ||
| 6250 | |||
| 6251 | /* Indices of image specification fields in native format, below. */ | 6261 | /* Indices of image specification fields in native format, below. */ |
| 6252 | |||
| 6253 | enum native_image_keyword_index | 6262 | enum native_image_keyword_index |
| 6254 | { | 6263 | { |
| 6255 | NATIVE_IMAGE_TYPE, | 6264 | NATIVE_IMAGE_TYPE, |
| @@ -6268,7 +6277,6 @@ enum native_image_keyword_index | |||
| 6268 | 6277 | ||
| 6269 | /* Vector of image_keyword structures describing the format | 6278 | /* Vector of image_keyword structures describing the format |
| 6270 | of valid user-defined image specifications. */ | 6279 | of valid user-defined image specifications. */ |
| 6271 | |||
| 6272 | static const struct image_keyword native_image_format[] = | 6280 | static const struct image_keyword native_image_format[] = |
| 6273 | { | 6281 | { |
| 6274 | {":type", IMAGE_SYMBOL_VALUE, 1}, | 6282 | {":type", IMAGE_SYMBOL_VALUE, 1}, |
| @@ -6287,12 +6295,12 @@ static const struct image_keyword native_image_format[] = | |||
| 6287 | /* Return true if OBJECT is a valid native API image specification. */ | 6295 | /* Return true if OBJECT is a valid native API image specification. */ |
| 6288 | 6296 | ||
| 6289 | static bool | 6297 | static bool |
| 6290 | native_image_p (Lisp_Object object, Lisp_Object type) | 6298 | native_image_p (Lisp_Object object) |
| 6291 | { | 6299 | { |
| 6292 | struct image_keyword fmt[NATIVE_IMAGE_LAST]; | 6300 | struct image_keyword fmt[NATIVE_IMAGE_LAST]; |
| 6293 | memcpy (fmt, native_image_format, sizeof fmt); | 6301 | memcpy (fmt, native_image_format, sizeof fmt); |
| 6294 | 6302 | ||
| 6295 | if (!parse_image_spec (object, fmt, 10, type)) | 6303 | if (!parse_image_spec (object, fmt, 10, Qnative_image)) |
| 6296 | return 0; | 6304 | return 0; |
| 6297 | 6305 | ||
| 6298 | /* Must specify either the :data or :file keyword. */ | 6306 | /* Must specify either the :data or :file keyword. */ |
| @@ -6302,11 +6310,17 @@ native_image_p (Lisp_Object object, Lisp_Object type) | |||
| 6302 | static bool | 6310 | static bool |
| 6303 | native_image_load (struct frame *f, struct image *img) | 6311 | native_image_load (struct frame *f, struct image *img) |
| 6304 | { | 6312 | { |
| 6313 | |||
| 6314 | # ifdef HAVE_NTGUI | ||
| 6305 | return w32_load_image (f, img, | 6315 | return w32_load_image (f, img, |
| 6306 | image_spec_value (img->spec, QCfile, NULL), | 6316 | image_spec_value (img->spec, QCfile, NULL), |
| 6307 | image_spec_value (img->spec, QCdata, NULL)); | 6317 | image_spec_value (img->spec, QCdata, NULL)); |
| 6318 | # else | ||
| 6319 | return 0; | ||
| 6320 | # endif | ||
| 6308 | } | 6321 | } |
| 6309 | #endif | 6322 | |
| 6323 | #endif /* HAVE_NATIVE_IMAGE_API */ | ||
| 6310 | 6324 | ||
| 6311 | 6325 | ||
| 6312 | /*********************************************************************** | 6326 | /*********************************************************************** |
| @@ -6352,12 +6366,12 @@ static const struct image_keyword png_format[PNG_LAST] = | |||
| 6352 | /* Return true if OBJECT is a valid PNG image specification. */ | 6366 | /* Return true if OBJECT is a valid PNG image specification. */ |
| 6353 | 6367 | ||
| 6354 | static bool | 6368 | static bool |
| 6355 | png_image_p (Lisp_Object object, Lisp_Object type) | 6369 | png_image_p (Lisp_Object object) |
| 6356 | { | 6370 | { |
| 6357 | struct image_keyword fmt[PNG_LAST]; | 6371 | struct image_keyword fmt[PNG_LAST]; |
| 6358 | memcpy (fmt, png_format, sizeof fmt); | 6372 | memcpy (fmt, png_format, sizeof fmt); |
| 6359 | 6373 | ||
| 6360 | if (!parse_image_spec (object, fmt, PNG_LAST, type)) | 6374 | if (!parse_image_spec (object, fmt, PNG_LAST, Qpng)) |
| 6361 | return 0; | 6375 | return 0; |
| 6362 | 6376 | ||
| 6363 | /* Must specify either the :data or :file keyword. */ | 6377 | /* Must specify either the :data or :file keyword. */ |
| @@ -7014,13 +7028,13 @@ static const struct image_keyword jpeg_format[JPEG_LAST] = | |||
| 7014 | /* Return true if OBJECT is a valid JPEG image specification. */ | 7028 | /* Return true if OBJECT is a valid JPEG image specification. */ |
| 7015 | 7029 | ||
| 7016 | static bool | 7030 | static bool |
| 7017 | jpeg_image_p (Lisp_Object object, Lisp_Object type) | 7031 | jpeg_image_p (Lisp_Object object) |
| 7018 | { | 7032 | { |
| 7019 | struct image_keyword fmt[JPEG_LAST]; | 7033 | struct image_keyword fmt[JPEG_LAST]; |
| 7020 | 7034 | ||
| 7021 | memcpy (fmt, jpeg_format, sizeof fmt); | 7035 | memcpy (fmt, jpeg_format, sizeof fmt); |
| 7022 | 7036 | ||
| 7023 | if (!parse_image_spec (object, fmt, JPEG_LAST, type)) | 7037 | if (!parse_image_spec (object, fmt, JPEG_LAST, Qjpeg)) |
| 7024 | return 0; | 7038 | return 0; |
| 7025 | 7039 | ||
| 7026 | /* Must specify either the :data or :file keyword. */ | 7040 | /* Must specify either the :data or :file keyword. */ |
| @@ -7590,12 +7604,12 @@ static const struct image_keyword tiff_format[TIFF_LAST] = | |||
| 7590 | /* Return true if OBJECT is a valid TIFF image specification. */ | 7604 | /* Return true if OBJECT is a valid TIFF image specification. */ |
| 7591 | 7605 | ||
| 7592 | static bool | 7606 | static bool |
| 7593 | tiff_image_p (Lisp_Object object, Lisp_Object type) | 7607 | tiff_image_p (Lisp_Object object) |
| 7594 | { | 7608 | { |
| 7595 | struct image_keyword fmt[TIFF_LAST]; | 7609 | struct image_keyword fmt[TIFF_LAST]; |
| 7596 | memcpy (fmt, tiff_format, sizeof fmt); | 7610 | memcpy (fmt, tiff_format, sizeof fmt); |
| 7597 | 7611 | ||
| 7598 | if (!parse_image_spec (object, fmt, TIFF_LAST, type)) | 7612 | if (!parse_image_spec (object, fmt, TIFF_LAST, Qtiff)) |
| 7599 | return 0; | 7613 | return 0; |
| 7600 | 7614 | ||
| 7601 | /* Must specify either the :data or :file keyword. */ | 7615 | /* Must specify either the :data or :file keyword. */ |
| @@ -8038,12 +8052,12 @@ gif_clear_image (struct frame *f, struct image *img) | |||
| 8038 | /* Return true if OBJECT is a valid GIF image specification. */ | 8052 | /* Return true if OBJECT is a valid GIF image specification. */ |
| 8039 | 8053 | ||
| 8040 | static bool | 8054 | static bool |
| 8041 | gif_image_p (Lisp_Object object, Lisp_Object type) | 8055 | gif_image_p (Lisp_Object object) |
| 8042 | { | 8056 | { |
| 8043 | struct image_keyword fmt[GIF_LAST]; | 8057 | struct image_keyword fmt[GIF_LAST]; |
| 8044 | memcpy (fmt, gif_format, sizeof fmt); | 8058 | memcpy (fmt, gif_format, sizeof fmt); |
| 8045 | 8059 | ||
| 8046 | if (!parse_image_spec (object, fmt, GIF_LAST, type)) | 8060 | if (!parse_image_spec (object, fmt, GIF_LAST, Qgif)) |
| 8047 | return 0; | 8061 | return 0; |
| 8048 | 8062 | ||
| 8049 | /* Must specify either the :data or :file keyword. */ | 8063 | /* Must specify either the :data or :file keyword. */ |
| @@ -8650,12 +8664,12 @@ imagemagick_clear_image (struct frame *f, | |||
| 8650 | identify the IMAGEMAGICK format. */ | 8664 | identify the IMAGEMAGICK format. */ |
| 8651 | 8665 | ||
| 8652 | static bool | 8666 | static bool |
| 8653 | imagemagick_image_p (Lisp_Object object, Lisp_Object type) | 8667 | imagemagick_image_p (Lisp_Object object) |
| 8654 | { | 8668 | { |
| 8655 | struct image_keyword fmt[IMAGEMAGICK_LAST]; | 8669 | struct image_keyword fmt[IMAGEMAGICK_LAST]; |
| 8656 | memcpy (fmt, imagemagick_format, sizeof fmt); | 8670 | memcpy (fmt, imagemagick_format, sizeof fmt); |
| 8657 | 8671 | ||
| 8658 | if (!parse_image_spec (object, fmt, IMAGEMAGICK_LAST, type)) | 8672 | if (!parse_image_spec (object, fmt, IMAGEMAGICK_LAST, Qimagemagick)) |
| 8659 | return 0; | 8673 | return 0; |
| 8660 | 8674 | ||
| 8661 | /* Must specify either the :data or :file keyword. */ | 8675 | /* Must specify either the :data or :file keyword. */ |
| @@ -9445,12 +9459,12 @@ static const struct image_keyword svg_format[SVG_LAST] = | |||
| 9445 | identify the SVG format. */ | 9459 | identify the SVG format. */ |
| 9446 | 9460 | ||
| 9447 | static bool | 9461 | static bool |
| 9448 | svg_image_p (Lisp_Object object, Lisp_Object type) | 9462 | svg_image_p (Lisp_Object object) |
| 9449 | { | 9463 | { |
| 9450 | struct image_keyword fmt[SVG_LAST]; | 9464 | struct image_keyword fmt[SVG_LAST]; |
| 9451 | memcpy (fmt, svg_format, sizeof fmt); | 9465 | memcpy (fmt, svg_format, sizeof fmt); |
| 9452 | 9466 | ||
| 9453 | if (!parse_image_spec (object, fmt, SVG_LAST, type)) | 9467 | if (!parse_image_spec (object, fmt, SVG_LAST, Qsvg)) |
| 9454 | return 0; | 9468 | return 0; |
| 9455 | 9469 | ||
| 9456 | /* Must specify either the :data or :file keyword. */ | 9470 | /* Must specify either the :data or :file keyword. */ |
| @@ -9913,7 +9927,7 @@ static const struct image_keyword gs_format[GS_LAST] = | |||
| 9913 | specification. */ | 9927 | specification. */ |
| 9914 | 9928 | ||
| 9915 | static bool | 9929 | static bool |
| 9916 | gs_image_p (Lisp_Object object, Lisp_Object type) | 9930 | gs_image_p (Lisp_Object object) |
| 9917 | { | 9931 | { |
| 9918 | struct image_keyword fmt[GS_LAST]; | 9932 | struct image_keyword fmt[GS_LAST]; |
| 9919 | Lisp_Object tem; | 9933 | Lisp_Object tem; |
| @@ -9921,7 +9935,7 @@ gs_image_p (Lisp_Object object, Lisp_Object type) | |||
| 9921 | 9935 | ||
| 9922 | memcpy (fmt, gs_format, sizeof fmt); | 9936 | memcpy (fmt, gs_format, sizeof fmt); |
| 9923 | 9937 | ||
| 9924 | if (!parse_image_spec (object, fmt, GS_LAST, type)) | 9938 | if (!parse_image_spec (object, fmt, GS_LAST, Qpostscript)) |
| 9925 | return 0; | 9939 | return 0; |
| 9926 | 9940 | ||
| 9927 | /* Bounding box must be a list or vector containing 4 integers. */ | 9941 | /* Bounding box must be a list or vector containing 4 integers. */ |
| @@ -10208,20 +10222,19 @@ static bool | |||
| 10208 | initialize_image_type (struct image_type const *type) | 10222 | initialize_image_type (struct image_type const *type) |
| 10209 | { | 10223 | { |
| 10210 | #ifdef WINDOWSNT | 10224 | #ifdef WINDOWSNT |
| 10211 | Lisp_Object typesym, tested; | 10225 | Lisp_Object typesym = builtin_lisp_symbol (type->type); |
| 10212 | bool (*init) (void) = type->init; | ||
| 10213 | 10226 | ||
| 10214 | #ifdef HAVE_NATIVE_IMAGE_API | 10227 | #ifdef HAVE_NATIVE_IMAGE_API |
| 10215 | if (init == init_native_image_functions) | 10228 | if (image_can_use_native_api (typesym)) |
| 10216 | return init(); | 10229 | return true; |
| 10217 | #endif | 10230 | #endif |
| 10218 | 10231 | ||
| 10219 | typesym = builtin_lisp_symbol (type->type); | 10232 | Lisp_Object tested = Fassq (typesym, Vlibrary_cache); |
| 10220 | tested = Fassq (typesym, Vlibrary_cache); | ||
| 10221 | /* If we failed to load the library before, don't try again. */ | 10233 | /* If we failed to load the library before, don't try again. */ |
| 10222 | if (CONSP (tested)) | 10234 | if (CONSP (tested)) |
| 10223 | return !NILP (XCDR (tested)) ? true : false; | 10235 | return !NILP (XCDR (tested)) ? true : false; |
| 10224 | 10236 | ||
| 10237 | bool (*init) (void) = type->init; | ||
| 10225 | if (init) | 10238 | if (init) |
| 10226 | { | 10239 | { |
| 10227 | bool type_valid = init (); | 10240 | bool type_valid = init (); |
| @@ -10248,16 +10261,6 @@ static struct image_type const image_types[] = | |||
| 10248 | { SYMBOL_INDEX (Qsvg), svg_image_p, svg_load, image_clear_image, | 10261 | { SYMBOL_INDEX (Qsvg), svg_image_p, svg_load, image_clear_image, |
| 10249 | IMAGE_TYPE_INIT (init_svg_functions) }, | 10262 | IMAGE_TYPE_INIT (init_svg_functions) }, |
| 10250 | #endif | 10263 | #endif |
| 10251 | #if defined HAVE_NATIVE_IMAGE_API | ||
| 10252 | { SYMBOL_INDEX (Qjpeg), native_image_p, native_image_load, image_clear_image, | ||
| 10253 | IMAGE_TYPE_INIT (init_native_image_functions) }, | ||
| 10254 | { SYMBOL_INDEX (Qpng), native_image_p, native_image_load, image_clear_image, | ||
| 10255 | IMAGE_TYPE_INIT (init_native_image_functions) }, | ||
| 10256 | { SYMBOL_INDEX (Qgif), native_image_p, native_image_load, image_clear_image, | ||
| 10257 | IMAGE_TYPE_INIT (init_native_image_functions) }, | ||
| 10258 | { SYMBOL_INDEX (Qtiff), native_image_p, native_image_load, image_clear_image, | ||
| 10259 | IMAGE_TYPE_INIT (init_native_image_functions) }, | ||
| 10260 | #endif | ||
| 10261 | #if defined HAVE_PNG || defined HAVE_NS | 10264 | #if defined HAVE_PNG || defined HAVE_NS |
| 10262 | { SYMBOL_INDEX (Qpng), png_image_p, png_load, image_clear_image, | 10265 | { SYMBOL_INDEX (Qpng), png_image_p, png_load, image_clear_image, |
| 10263 | IMAGE_TYPE_INIT (init_png_functions) }, | 10266 | IMAGE_TYPE_INIT (init_png_functions) }, |
| @@ -10282,23 +10285,28 @@ static struct image_type const image_types[] = | |||
| 10282 | { SYMBOL_INDEX (Qpbm), pbm_image_p, pbm_load, image_clear_image }, | 10285 | { SYMBOL_INDEX (Qpbm), pbm_image_p, pbm_load, image_clear_image }, |
| 10283 | }; | 10286 | }; |
| 10284 | 10287 | ||
| 10288 | #ifdef HAVE_NATIVE_IMAGE_API | ||
| 10289 | struct image_type native_image_type = | ||
| 10290 | { SYMBOL_INDEX (Qnative_image), native_image_p, native_image_load, | ||
| 10291 | image_clear_image }; | ||
| 10292 | #endif | ||
| 10293 | |||
| 10285 | /* Look up image type TYPE, and return a pointer to its image_type | 10294 | /* Look up image type TYPE, and return a pointer to its image_type |
| 10286 | structure. Return 0 if TYPE is not a known image type. */ | 10295 | structure. Return 0 if TYPE is not a known image type. */ |
| 10287 | 10296 | ||
| 10288 | static struct image_type const * | 10297 | static struct image_type const * |
| 10289 | lookup_image_type (Lisp_Object type) | 10298 | lookup_image_type (Lisp_Object type) |
| 10290 | { | 10299 | { |
| 10300 | #ifdef HAVE_NATIVE_IMAGE_API | ||
| 10301 | if (image_can_use_native_api (type)) | ||
| 10302 | return &native_image_type; | ||
| 10303 | #endif | ||
| 10304 | |||
| 10291 | for (int i = 0; i < ARRAYELTS (image_types); i++) | 10305 | for (int i = 0; i < ARRAYELTS (image_types); i++) |
| 10292 | { | 10306 | { |
| 10293 | struct image_type const *r = &image_types[i]; | 10307 | struct image_type const *r = &image_types[i]; |
| 10294 | if (EQ (type, builtin_lisp_symbol (r->type))) | 10308 | if (EQ (type, builtin_lisp_symbol (r->type))) |
| 10295 | #ifdef HAVE_NATIVE_IMAGE_API | ||
| 10296 | /* We can have more than one backend for one image type. */ | ||
| 10297 | if (initialize_image_type (r)) | ||
| 10298 | return r; | ||
| 10299 | #else | ||
| 10300 | return initialize_image_type (r) ? r : NULL; | 10309 | return initialize_image_type (r) ? r : NULL; |
| 10301 | #endif | ||
| 10302 | } | 10310 | } |
| 10303 | return NULL; | 10311 | return NULL; |
| 10304 | } | 10312 | } |
| @@ -10454,6 +10462,14 @@ non-numeric, there is no explicit limit on the size of images. */); | |||
| 10454 | #endif /* HAVE_NTGUI */ | 10462 | #endif /* HAVE_NTGUI */ |
| 10455 | #endif /* HAVE_RSVG */ | 10463 | #endif /* HAVE_RSVG */ |
| 10456 | 10464 | ||
| 10465 | #if HAVE_NATIVE_IMAGE_API | ||
| 10466 | DEFSYM (Qnative_image, "native-image"); | ||
| 10467 | # ifdef HAVE_NTGUI | ||
| 10468 | DEFSYM (Qgdiplus, "gdiplus"); | ||
| 10469 | DEFSYM (Qshlwapi, "shlwapi"); | ||
| 10470 | # endif | ||
| 10471 | #endif | ||
| 10472 | |||
| 10457 | defsubr (&Sinit_image_library); | 10473 | defsubr (&Sinit_image_library); |
| 10458 | #ifdef HAVE_IMAGEMAGICK | 10474 | #ifdef HAVE_IMAGEMAGICK |
| 10459 | defsubr (&Simagemagick_types); | 10475 | defsubr (&Simagemagick_types); |