summaryrefslogtreecommitdiff
path: root/src/image.c
Commit message (Collapse)AuthorAgeFilesLines
* Improvements for `:base-uri' svg image propertyZajcev Evgeny2020-12-261-3/+5
| | | | | | | * src/image.c (svg_load): Use ENCODE_FILE for `:base-uri' * doc/lispref/display.texi (SVG Images): Add more documentation for `:base-uri'
* Fix image cache lookupAlan Third2020-12-201-1/+1
| | | | | * src/image.c (lookup_image): ignore_colors should be false as we want to search for images with matching colors.
* image-cache-size improvementsMattias Engdegård2020-12-201-17/+41
| | | | | | | | | | | | | Implement for non-Cairo X11 and NS. Count masks as well, and XImage objects on X11. * src/image.c (image_size_in_bytes): New. (image_frame_cache_size): Use image_size_in_bytes. * src/nsterm.h: * src/nsimage.m (ns_image_size_in_bytes, [EmacsImage sizeInBytes]): New function and method. * src/w32gui.h: * src/w32term.c (w32_image_size): Update signature.
* Merge from origin/emacs-27Glenn Morris2020-12-151-0/+9
|\ | | | | | | | | 62a6934af9 Fix crash when using XRender and restoring image from X (b... de032d41c6 Bind k to image-kill-buffer in doc-view-mode-map.
| * Fix crash when using XRender and restoring image from X (bug#44930)Alan Third2020-12-121-0/+9
| | | | | | | | | | | | | | * src/dispextern.h (struct image): Add original dimension elements. * src/image.c (image_set_transform): Store the original dimensions. (image_get_x_image): If we're using transforms use the original dimensions with XGetImage.
* | Fix assertion on SVG load failureAlan Third2020-12-121-5/+6
| | | | | | | | | | * src/image.c (svg_load_image): Move setting DPI to after rsvg_handle error checking.
* | Explicitly specify svg base_uri using `:base-uri' image propertyZajcev Evgeny2020-12-121-7/+14
| | | | | | | | | | | | | | | | | | * src/image.c (svg_load): Check `:base-uri' image property to explicitly set base_uri for images embedded into SVG (enum svg_keyword_index): (svg_format): Add :base-uri. * lisp/svg.el (svg-embed-base-uri-image): New function to embed images located relative to images `:base-uri'
* | Revert "Explicitly specify svg base_uri using `:base-uri' image property"Alan Third2020-12-121-12/+7
| | | | | | | | | | | | This reverts commit a8e2143a5c03785742464406306fda7fce6caf04. I applied the incorrect version of the patch.
* | Unbreak the MS-Windows build broken by recent changesEli Zaretskii2020-12-121-0/+6
| | | | | | | | | | | | * src/image.c (rsvg_handle_set_dpi_x_y) [WINDOWSNT]: DEF_DLL_FN it. (init_svg_functions): LOAD_DLL_FN rsvg_handle_set_dpi_x_y. <rsvg_handle_set_dpi_x_y>: Define as a macro
* | Improve support for 'memory-report' on MS-WindowsEli Zaretskii2020-12-121-4/+17
| | | | | | | | | | | | | | | | * src/w32term.c (w32_image_size): New function. * src/image.c (image_frame_cache_size) [HAVE_NTGUI]: Support reporting the size of frame image cache. (image_frame_cache_size, Fimage_cache_size): The total size is now of the type 'size_t', not 'int'.
* | Use real DPI when rendering SVGs (bug#45124)Alan Third2020-12-121-10/+21
| | | | | | | | | | | | | | * src/image.c (svg_css_length_to_pixels): Pass in a DPI value instead of using a hard coded value. (svg_load_image): Set the DPI on the rsvg_handle, and pass it to svg_css_length_to_pixels.
* | Explicitly specify svg base_uri using `:base-uri' image propertyZajcev Evgeny2020-12-121-7/+12
| | | | | | | | | | * src/image.c (svg_load): Check `:base-uri' image property to explicitly set base_uri for images embedded into SVG
* | Fix image-cache-size crashLars Ingebrigtsen2020-12-111-4/+4
| | | | | | | | | | * src/image.c (image_frame_cache_size): Ensure that img->pixmap is in use before trying to access it.
* | Fix compilation of image.c on non-Cairo systemsLars Ingebrigtsen2020-12-111-0/+2
| | | | | | | | | | * src/image.c (image_frame_cache_size): pixmap->width etc is only defined on Cairo. Return 0 for now on other systems.
* | Add new function 'image-cache-size'Lars Ingebrigtsen2020-12-111-0/+35
| | | | | | | | | | * src/image.c (Fimage_cache_size): New defun. (image_frame_cache_size): New function.
* | Make uncache_image slightly more efficientLars Ingebrigtsen2020-12-091-1/+2
| | | | | | | | | | * src/image.c (uncache_image): Extremely minor speed-up: Only compute the hash once.
* | Restore Emacs 27 image cache semanticsLars Ingebrigtsen2020-12-091-12/+1
| | | | | | | | | | | | | | | | * src/image.c (equal_lists): Remove. (search_image_cache): Use Fequal instead of equal_lists. Benchmarking shows no measurable time difference, and this restores the cache semantics from Emacs 27 (where file names didn't have to be EQ for the cache to be used).
* | Fix compilation on MS-Windows with librsvg > 2.46.0Eli Zaretskii2020-11-201-8/+4
| | | | | | | | | | | | * src/image.c (rsvg_handle_get_dimensions, init_svg_functions): Make 'rsvg_handle_get_dimensions' available and defined for all versions of librsvg. (Bug#44655)
* | Fix SVG display again (bug#44655)Alan Third2020-11-181-21/+12
| | | | | | | | | | | | * src/image.c (svg_load_image): Fall back to rsvg_handle_get_dimensions if we can't calculate the size of the image.
* | Fix a recent change in image.c for MS-WindowsEli Zaretskii2020-11-101-1/+1
| | | | | | | | | | | | * src/image.c: Fix DEF_DLL_FN of rsvg_handle_get_intrinsic_dimensions. Reported by Andy Moreton <andrewjmoreton@gmail.com>.
* | Fix css length calculationsAlan Third2020-11-091-0/+3
| | | | | | | | | | * src/image.c (svg_css_length_to_pixels): Put in missing breaks where necessary.
* | Fix compilation of image.c on MS-WindowsEli Zaretskii2020-11-091-5/+11
| | | | | | | | | | | | | | | | This is a followup to last change in image.c. * src/image.c (rsvg_handle_get_intrinsic_dimensions): Define to call fn_rsvg_handle_get_intrinsic_dimensions. (svg_css_length_to_pixels): Compile only for librsvg >= 2.46.0, as RsvgLength type was not defined before.
* | Calculate SVG image sizes more accurately (bug#44206)Alan Third2020-11-091-5/+97
| | | | | | | | | | * src/image.c (svg_css_length_to_pixels): New function. (svg_load_image): Try more methods to work out the image size.
* | Fix a segfault in the new svg codeLars Ingebrigtsen2020-11-011-2/+2
| | | | | | | | | | * src/image.c (svg_load_image): Don't pass in a NULL for the logical rect, because that will sometimes segfault.
* | Fix last change in image.c for MS-WindowsEli Zaretskii2020-10-241-3/+21
| | | | | | | | | | | | | | | | | | | | * src/image.c [LIBRSVG_CHECK_VERSION (2, 46, 0)]: Define prototype for rsvg_handle_get_geometry_for_layer. (init_svg_functions) [LIBRSVG_CHECK_VERSION (2, 46, 0)]: Load rsvg_handle_get_geometry_for_layer from the DLL, instead of rsvg_handle_get_dimensions. (rsvg_handle_get_geometry_for_layer) [LIBRSVG_CHECK_VERSION (2, 46, 0)]: Define macro. (Bug#44065)
* | Fix SVG image dimension calculations (bug#44065)Alan Third2020-10-221-14/+32
| | | | | | | | | | | | * src/image.c (svg_load_image): Calculate the image size by using the viewBox size and applying it to the image. * etc/PROBLEMS: Describe the problem with librsvg 2.45 and below.
* | Avoid segfaults in lookup_image when faces were freedEli Zaretskii2020-10-031-2/+8
| | | | | | | | | | | | | | * src/image.c (lookup_image): Make sure the frame's face cache exists and has at least the basic faces. If FACE_ID is not a basic face, and is no longer cached, fall back on the 'default' face. (Bug#43700)
* | Merge from origin/emacs-27Glenn Morris2020-09-091-10/+14
|\ \ | |/ | | | | | | | | 366a97c980 (origin/emacs-27) Avoid crashes when trying to load bad GI... 7938713105 C++ Mode: handle comma separated brace initializers. 2b95300cf8 * lisp/display-fill-column-indicator.el: Fix bug#41145
| * Avoid crashes when trying to load bad GIF filesEli Zaretskii2020-09-081-10/+14
| | | | | | | | | | * src/image.c (gif_load): Handle the case when GifErrorString returns NULL. (Bug#43281)
* | * src/image.c (svg_load_image): Use xmalloc and xfree. (bug#43135)Alan Third2020-09-031-3/+3
| |
* | Fix image display on w32 as followup to recent changesEli Zaretskii2020-08-231-11/+6
| | | | | | | | | | | | | | The new code calls 'malloc' and 'free', so we can no longer * src/image.c (struct image_type): Rename 'load' to 'load_img' and 'free' to 'free_img'. All callers changed. (free_image) [WINDOWSNT]: Don't #undef 'free'.
* | Silence compiler warning (bug#40845)Alan Third2020-08-231-1/+1
| | | | | | | | * src/image.c (lookup_image): Don't allow face to be NULL.
* | Set basic SVG attributes (bug#40845)Alan Third2020-08-231-49/+154
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * test/manual/image-transforms-tests.el: Replace hard-coded colors with defaults. * src/dispextern.h (struct image): * src/image.c (search_image_cache): (xbm_load_image): (xbm_load): (pbm_load): Rename from frame to face where relevant. (svg_load_image): Parse the image to find out the size, then wrap it in another SVG to set a new size and colors, etc. (lookup_image): Use the face colors instead of the frame colors. (search_image_cache): Add ability to ignore the face colors. (uncache_image): Uncache all copies of the image that share the spec, even if the face colors don't match. * etc/NEWS: Describe the changes.
* | Make image cache lookups work again after previous patchLars Ingebrigtsen2020-08-211-1/+1
| | | | | | | | | | * src/image.c (search_image_cache): Fix reversed logic in previous patch.
* | Fix minor bugs in image.cPip Cet2020-08-181-24/+47
| | | | | | | | | | | | | | | | | | | | * test/src/image-tests.el (image-test-circular-specs): New file. * src/image.c (parse_image_spec): Return failure for circular lists. (valid_image_p): Don't look at odd-numbered list elements expecting to find a property name. (image_spec_value): Handle circular lists. (equal_lists): Introduce. (search_image_cache): Use `equal_lists' (bug#36403).
* | Don't smooth images when scaling up (bug#38394)Alan Third2020-08-041-3/+17
| | | | | | | | | | | | | | | | | | * src/image.c (image_set_transform [HAVE_XRENDER]): Use different filter when scaling up vs scaling down. * src/nsimage.m (ns_image_set_smoothing): ([EmacsImage setSmoothing:]): New functions. * src/nsterm.h: Add definitions. * src/nsterm.m (ns_dumpglyphs_image): Disable smoothing if requested.
* | Don't message complete GIF data upon errorsLars Ingebrigtsen2020-07-171-1/+4
| | | | | | | | | | | | * src/image.c (gif_load): When unable to parse a GIF specified via a data attribute, don't message the complete binary, because that's not useful (bug#40850).
* | Fix GDI+ image loading by file nameEli Zaretskii2020-04-251-4/+6
| | | | | | | | | | | | | | | | | | | | Without a call to image_find_image, we can get a file name that is relative to data-directory/images/, or a file name that starts with "~/", in which case w32_load_image would fail. * src/image.c (native_image_load): Call image_find_image_file to resolve and encode the image file name. * src/w32image.c (w32_load_image): No need to encode the file name, as it's already encoded by native_image_load.
* | Use native image API for NSAlan Third2020-04-161-63/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * configure.ac (NATIVE_IMAGE_API): Move above NS definitions. (HAVE_NATIVE_IMAGE_API): Set for NS. (HAVE_PNG, HAVE_JPEG, HAVE_GIF, HAVE_TIFF): Enable on NS builds. * src/image.c (HAVE_NS): Fix a number of #if's so they no longer rely on HAVE_NS. (PIX_MASK_DRAW): Add for HAVE_NS so libpng support will compile. (image_can_use_native_api): (native_image_load): Add NS support. (png_load): (jpeg_load): (tiff_load): (gif_load): Remove NS specific definitions. * src/nsimage.m (ns_can_use_native_image_api): New function. * src/nsterm.h: (ns_can_use_native_image_api): New function.
* | Avoid compiler warning in image.cEli Zaretskii2020-04-141-6/+3
| | | | | | | | | | | | | | | | * src/image.c (image_can_use_native_api): Avoid compiler warnings by making this function conditioned on HAVE_NATIVE_IMAGE_API. (initialize_image_type): Call image_can_use_native_api only if HAVE_NATIVE_IMAGE_API is non-zero. Reported by Basil L. Contovounesios <contovob@tcd.ie>.
* | ; * src/image.c: Cleanup of #ifdef's related to HAVE_NATIVE_IMAGE_API.Eli Zaretskii2020-04-141-4/+2
| |
* | Make use of MS-Windows native image API be selectable at run timeEli Zaretskii2020-04-141-59/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* | Initial version of native image API support for MS-WindowsJuan José García-Ripoll2020-04-141-32/+131
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/w32image.c: New file. * src/w32term.h: Add prototypes of 'w32_load_image', 'w32_gdiplus_startup', 'w32_gdiplus_shutdown', and 'w32_query_frame_background_color'. * src/w32term.c (w32_query_frame_background_color): No longer static. * src/w32.c (term_ntproc) [HAVE_GDIPLUS]: Call 'w32_gdiplus_shutdown'. * src/image.c (struct image_type) <valid_p>: Accept an additional argument, the image type. All implementations changed. (init_native_image_functions, native_image_p, native_image_load) [HAVE_NATIVE_IMAGE_API]: New methods for "native image type". (initialize_image_type) [HAVE_NATIVE_IMAGE_API]: Call 'init_native_image_functions'. (image_types) [HAVE_NATIVE_IMAGE_API]: Add settings for native image API. (lookup_image_type) [HAVE_NATIVE_IMAGE_API]: Initialize native functions if needed. * lisp/term/w32-win.el (dynamic-library-alist): Add gdiplus and shlwapi. * etc/NEWS: Announce the new feature. * configure.ac (native-image-api): New option, OFF by default. (HAVE_NATIVE_IMAGE_API): If native-image-api is selected, add w32image.o to W32_OBJ.
* | Pacify gcc in xpm_scanPaul Eggert2020-04-061-2/+3
| | | | | | | | | | * src/image.c (xpm_scan): Redo a loop for clarity. This also pacifies --enable-gcc-warnings (GCC 9.3.1 x86-64 with -Og).
* | Merge from origin/emacs-27Glenn Morris2020-01-151-4/+4
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 0e936f18f8 (origin/emacs-27) Fix build failure with --with-cairo --wi... c34f7e884b Add new node "Package Statuses" to manual fdee034ac8 * lisp/isearch.el: Fix corner cases of isearch-lazy-count. 7b14329d86 ; * lisp/simple.el (messages-buffer): Doc fix. (Bug#39124) 7ec66a59e3 Document spacing issues with Xft for some fonts 08cd247fbd ; * etc/NEWS: Fix typo. d645628e3c Always use lexical-binding in lisp-interaction-mode (bug#3... c42198f78c ; *etc/NEWS: Fix typo. 0ed9cfa7dc vc-dir: ensure we don't use a pager with git 37e0d00c14 Improve ERC's matching of nicks and URLs (bug#38257) d47b157969 Handle tab-bar clicks on a GPM-capable console. e4791f3f8e ;* etc/TODO: Update. # Conflicts: # etc/NEWS
| * Fix build failure with --with-cairo --without-pngYAMAMOTO Mitsuharu2020-01-151-4/+4
| | | | | | | | * src/image.c: Don't enable PNG section only by USE_CAIRO.
* | Merge from origin/emacs-27Glenn Morris2020-01-081-0/+4
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 6cd9ccb0a2 (origin/emacs-27) Fix compression of directories in Dired 42329e6d3b ; * etc/NEWS: Review of the whole text. af5709f16b Further enhancement on `tramp-file-local-name' fb432446f5 Objective C Mode imenu: cease recognizing "functions" with... a18373a999 ; * etc/NEWS: Update the text about the XDG_CONFIG_HOME/em... 73fd8a4b53 Fix BSD and macOS builds w.r.t. pthread_setname_np (bug#38... f54b24304d Scale top-left coordinates in display-monitor-attributes-list b46c75b16c xref-matches-in-files: Big Tramp speed-up 883b3490d8 * lisp/net/tramp.el (tramp-file-local-name): Remove `save-... c01f55f126 Fix rendering bug due to unsynchronized cairo surface size... 075f21c0e3 Avoid crash by access to cleared img->pixmap->data/img->ma... 16c6dfb4f1 Avoid assertion violations in very small-height windows 9063124b91 Use pthread_setname_np to set thread name # Conflicts: # etc/NEWS # lisp/net/tramp.el
| * Avoid crash by access to cleared img->pixmap->data/img->mask->data (Bug#38774)YAMAMOTO Mitsuharu2020-01-071-0/+4
| | | | | | | | | | * src/image.c (prepare_image_for_display) [USE_CAIRO]: Call IMAGE_BACKGROUND and IMAGE_BACKGROUND_TRANSPARENT.
* | Help the compiler inline sxhashPaul Eggert2020-01-071-2/+2
|/ | | | | | | * src/fns.c (sxhash_obj): Rename from sxhash and make it static, so that the compiler can inline it better. (sxhash): New function that does not take a depth arg. All callers changed.
* Update copyright year to 2020Paul Eggert2020-01-011-1/+1
| | | | Run "TZ=UTC0 admin/update-copyright $(git ls-files)".