Commit graph

20 commits

Author SHA1 Message Date
Adam Jackson ad0fe6b6f9 image-loader: Fix undefined left shift in premultiply_data
../shared/image-loader.c:184:14: runtime error: left shift of 255 by 24 places cannot be represented in type 'int'

Store each channel in a uint32_t instead of a byte so we compute the shift over
an unsigned type.
2019-10-16 16:06:06 -04:00
Marius Vlad 7a8a3a3547 Fix compiler warnings: clobber variables
This patchs fixes warnings generated by older toolchains:

shared/image-loader.c: In function 'load_png':
shared/image-loader.c:211:12: warning: variable 'data' might be clobbered by 'longjmp' or 'vfork' [-Wclobbered]
  png_byte *data = NULL;

See https://linux.die.net/man/3/longjmp why is this needed.

Signed-off-by: Marius Vlad <marius.vlad0@gmail.com>
2018-12-15 18:37:57 +02:00
Quentin Glidic 9ba1546172
shared/image: Silence maybe-uninitialized warning
shared/image-loader.c: In function 'load_image':
shared/image-loader.c:434:12: warning: 'image' may be used uninitialized
in this function [-Wmaybe-uninitialized]
  } else if (!image) {
              ^

Warning produced by GCC 5.3 and 6.1, with -Og.

Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com>
2016-08-15 16:31:00 +02:00
Jussi Kukkonen 649bbce607 include stdint.h for int32_t/uint32_t
Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
2016-07-26 16:26:08 -07:00
Emmanuel Gil Peyrot 66e1614122 configure: Make jpeglib an optional dependency.
It doesn’t make sense to fail the entire build when jpeglib isn’t
present, so this commit makes it optional just like libwebp in the
previous one, disabled with --without-jpeg and forced with --with-jpeg.

Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2016-03-07 12:05:52 -08:00
Emmanuel Gil Peyrot 58b7a156c5 configure: Make WebP support togglable, and improve its error message.
The current way was enabling WebP support whenever libwebp was found,
giving no way to the user to disable it if they had the library
installed but didn’t want to link against it.  This adds a
--without-webp configure option to never link against it, and a
--with-webp one to fail the build if it isn’t found, the default being
to use it if it is present.

Additionally, we now tell the user when WebP support has been disabled
and they try to load a WebP file.

Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2016-02-19 18:33:00 -08:00
Jon Cruz 35b2eaa989 Moved helper macro to a discrete include file.
To help reduce code duplication and also 'kitchen-sink' includes
the ARRAY_LENGTH macro was moved to a stand-alone file and
referenced from the sources consuming it. Other macros will be
added in subsequent passes.

Signed-off-by: Jon A. Cruz <jonc@osg.samsung.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2015-06-15 17:11:45 -07:00
Bryce Harrington 6c6164c5ba shared: Update boilerplate from MIT X11 license to MIT Expat license 2015-06-15 13:04:18 -07:00
Bill Spitzak 28371f7d55 load_image: always print a message on failure if filename is not empty
It was rather inconsistent before. This may help users figure out why
backgrounds and icons don't show up. A better api where the error can
be queried might be nice, but this seems sufficient for current Weston use.

[Pekka Paalanen: removed one stray space.]

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-09-11 13:01:47 +03:00
Daniel Stone c228e23b05 configure.ac: Enable AC_USE_SYSTEM_EXTENSIONS
AC_USE_SYSTEM_EXTENSIONS enables _XOPEN_SOURCE, _GNU_SOURCE and similar
macros to expose the largest extent of functionality supported by the
underlying system.  This is required since these macros are often
limiting rather than merely additive, e.g. _XOPEN_SOURCE will actually
on some systems hide declarations which are not part of the X/Open spec.

Since this goes into config.h rather than the command line, ensure all
source is consistently including config.h before anything else,
including system libraries.  This doesn't need to be guarded by a
HAVE_CONFIG_H ifdef, which was only ever a hangover from the X.Org
modular transition.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>

[pq: rebased and converted more files]
2013-06-05 01:16:34 -04:00
Armin K eb3c73f288 Fix compiler warnings
This prevents compiler warnings when using libpng 1.6 and GCC 4.8
2013-04-03 20:40:44 -04:00
Kristian Høgsberg 3c2360ff9d Add new shared/image-loader.h to separate include dependencies
Before, cairo-util.h would combine pixman and cairo includes.  X11 and
Wayland compositors uses this to load an image as a pixman_image_t but are
forced to include cairo headers.  Clients use load_cairo_surface to
load images as cairo_surface_t's, but are forced to include pixman.h.

We move the load_image pixman prototype to its own header, so compositors
can get at the pixman prototype without including cairo.h and clients
can include the cairo based function without including pixman.h.
2013-01-28 16:02:04 -05:00
Pekka Paalanen 4fbb65372e Fix build warnings from image_loader
Fix the following build warnings, and the build failures due to the
warning fixes:

  CC     libshared_cairo_la-image-loader.lo
image-loader.c:369:1: warning: no previous prototype for 'load_image'

  CC     x11_backend_la-compositor-x11.lo
compositor-x11.c: In function 'x11_output_set_icon':
compositor-x11.c:396:2: warning: implicit declaration of function 'load_image'
compositor-x11.c:396:8: warning: assignment makes pointer from integer without a cast

  CC     wayland_backend_la-compositor-wayland.lo
compositor-wayland.c: In function 'create_border':
compositor-wayland.c:97:2: warning: implicit declaration of function 'load_image'
compositor-wayland.c:97:8: warning: assignment makes pointer from integer without a cast

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-11-30 14:24:00 -05:00
Kristian Høgsberg c234fb819f image-loader: Use pixman_image_t, not struct pixman_image_t 2012-07-11 15:45:59 -04:00
Rafal Mielniczuk 9d4ddefcce image-loader: don't leak pixman_image bits data
Set the pixman_image destroy function to free bits data
2012-07-11 15:42:51 -04:00
Martin Olsson 712f5f405e shared: Don't leak file descriptor in shared/image-loader.c 2012-07-09 17:50:44 -04:00
Kristian Høgsberg b71302e1db Fix a few -pedantic warnings
We're not enabling -pedantic by default, but a quick test brought up a few
issues that we should fix.
2012-05-10 14:11:44 -04:00
Kristian Høgsberg ee4b4cb933 shared: Use $(GCC_CFLAGS), fix warnings 2012-04-11 09:46:51 -04:00
Jonas Ådahl 3685c3abf6 Fix `unused-result' warnings.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2012-04-03 14:50:15 -04:00
Kristian Høgsberg f02a649a3c Consolidate image loading code and move to shared/ 2012-03-12 01:40:59 -04:00