kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2_loaders.git/commit/?id=65da6124f831152bcec87510dd5c809c300d2029

commit 65da6124f831152bcec87510dd5c809c300d2029
Author: Kim Woelders <k...@woelders.dk>
Date:   Sun Nov 17 06:40:23 2019 +0100

    Copy updated headers from imlib2
---
 src/modules/loaders/common.h | 43 +++++++++++++++++++++++++++++++++++--------
 src/modules/loaders/image.h  | 21 ++++++++++++++-------
 2 files changed, 49 insertions(+), 15 deletions(-)

diff --git a/src/modules/loaders/common.h b/src/modules/loaders/common.h
index 08916a1..0df2338 100644
--- a/src/modules/loaders/common.h
+++ b/src/modules/loaders/common.h
@@ -9,9 +9,6 @@
 #include <string.h>
 #include <math.h>
 #include <time.h>
-#ifdef WITH_DMALLOC
-#include <dmalloc.h>
-#endif
 
 #define DATABIG unsigned long long
 #define DATA64  unsigned long long
@@ -19,6 +16,35 @@
 #define DATA16  unsigned short
 #define DATA8   unsigned char
 
+#define SWAP32(x) \
+    ((((x) & 0x000000ff ) << 24) | \
+     (((x) & 0x0000ff00 ) <<  8) | \
+     (((x) & 0x00ff0000 ) >>  8) | \
+     (((x) & 0xff000000 ) >> 24))
+
+#define SWAP16(x) \
+    ((((x) & 0x00ff ) << 8) | \
+     (((x) & 0xff00 ) >> 8))
+
+#ifdef WORDS_BIGENDIAN
+#define SWAP_LE_16(x) SWAP16(x)
+#define SWAP_LE_32(x) SWAP32(x)
+#define SWAP_LE_16_INPLACE(x) x = SWAP16(x)
+#define SWAP_LE_32_INPLACE(x) x = SWAP32(x)
+#else
+#define SWAP_LE_16(x) (x)
+#define SWAP_LE_32(x) (x)
+#define SWAP_LE_16_INPLACE(x)
+#define SWAP_LE_32_INPLACE(x)
+#endif
+
+#define PIXEL_ARGB(a, r, g, b)  ((a) << 24) | ((r) << 16) | ((g) << 8) | (b)
+
+#define PIXEL_A(argb)  (((argb) >> 24) & 0xff)
+#define PIXEL_R(argb)  (((argb) >> 16) & 0xff)
+#define PIXEL_G(argb)  (((argb) >>  8) & 0xff)
+#define PIXEL_B(argb)  (((argb)      ) & 0xff)
+
 #ifdef DO_MMX_ASM
 int                 __imlib_get_cpuid(void);
 
@@ -27,13 +53,14 @@ int                 __imlib_get_cpuid(void);
 #endif
 
 #define CLIP(x, y, w, h, xx, yy, ww, hh) \
-if (x < (xx)) {w += (x - (xx)); x = (xx);} \
-if (y < (yy)) {h += (y - (yy)); y = (yy);} \
-if ((x + w) > ((xx) + (ww))) {w = (ww) - (x - xx);} \
-if ((y + h) > ((yy) + (hh))) {h = (hh) - (y - yy);}
+    if (x < (xx)) { w += (x - (xx)); x = (xx); } \
+    if (y < (yy)) { h += (y - (yy)); y = (yy); } \
+    if ((x + w) > ((xx) + (ww))) { w = (ww) - (x - xx); } \
+    if ((y + h) > ((yy) + (hh))) { h = (hh) - (y - yy); }
+
 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
 
-#define round(x) ((x)>=0?(int)((x)+0.5):(int)((x)-0.5))
+#define round(x) ((x) >=0 ? (int)((x) + 0.5) : (int)((x) - 0.5))
 
 #endif
diff --git a/src/modules/loaders/image.h b/src/modules/loaders/image.h
index ac35f6b..991f428 100644
--- a/src/modules/loaders/image.h
+++ b/src/modules/loaders/image.h
@@ -24,6 +24,7 @@ typedef int         (*ImlibProgressFunction)(ImlibImage * im, 
char percent,
                                              int update_x, int update_y,
                                              int update_w, int update_h);
 typedef void        (*ImlibDataDestructorFunction)(ImlibImage * im, void 
*data);
+typedef void       *(*ImlibImageDataMemoryFunction)(void *, size_t size);
 
 enum _iflags {
    F_NONE = 0,
@@ -66,6 +67,7 @@ struct _imlibimage {
    ImlibImageTag      *tags;
    char               *real_file;
    char               *key;
+   ImlibImageDataMemoryFunction data_memory_func;
 };
 
 #ifdef BUILD_X11
@@ -102,6 +104,10 @@ struct _imlibloader {
    ImlibLoader        *next;
 };
 
+DATA32             *__imlib_AllocateData(ImlibImage * im);
+void                __imlib_FreeData(ImlibImage * im);
+void                __imlib_ReplaceData(ImlibImage * im, DATA32 * new_data);
+
 void                __imlib_AttachTag(ImlibImage * im, const char *key,
                                       int val, void *data,
                                       ImlibDataDestructorFunction destructor);
@@ -137,9 +143,8 @@ void                __imlib_CleanupImagePixmapCache(void);
 void                __imlib_RemoveAllLoaders(void);
 ImlibLoader        *__imlib_FindBestLoaderForFile(const char *file,
                                                   int for_save);
-ImlibLoader        *__imlib_FindBestLoaderForFileFormat(const char *file,
-                                                        char *format,
-                                                        int for_save);
+ImlibLoader        *__imlib_FindBestLoaderForFormat(const char *format,
+                                                    int for_save);
 void                __imlib_SetImageAlphaFlag(ImlibImage * im, char alpha);
 ImlibImage         *__imlib_CreateImage(int w, int h, DATA32 * data);
 ImlibImage         *__imlib_LoadImage(const char *file,
@@ -180,12 +185,14 @@ void                __imlib_SaveImage(ImlibImage * im, 
const char *file,
 #define SET_FLAG(flags, f) ((flags) |= (f))
 #define UNSET_FLAG(flags, f) ((flags) &= (~f))
 
-/* The maximum pixmap dimension is 65535. */
-/* However, for now, use 46340 (46340^2 < 2^31) to avoid buffer overflow 
issues. */
-/* Reduced further to 32767, so that (w * h * sizeof(DATA32)) won't exceed 
ULONG_MAX */
+/* 32767 is the maximum pixmap dimension and ensures that
+ * (w * h * sizeof(DATA32)) won't exceed ULONG_MAX */
 #define X_MAX_DIM 32767
+/* NB! The image dimensions are sometimes used in (dim << 16) like expressions
+ * so great care must be taken if ever it is attempted to change this
+ * condition */
 
 #define IMAGE_DIMENSIONS_OK(w, h) \
-   ( ((w) > 0) && ((h) > 0) && ((w) < X_MAX_DIM) && ((h) < X_MAX_DIM) )
+   ( ((w) > 0) && ((h) > 0) && ((w) <= X_MAX_DIM) && ((h) <= X_MAX_DIM) )
 
 #endif

-- 


Reply via email to