This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository legacy-imlib2_loaders.

View the commit online.

commit 5784c387ecbf8963ebd2d3d5a98f7cc427b2e6e3
Author: Kim Woelders <[email protected]>
AuthorDate: Fri May 13 20:42:18 2022 +0200

    Follow imlib2 loader API changes
---
 src/modules/loaders/Makefile.am             |   2 -
 src/modules/loaders/common.h                |  67 -------------
 src/modules/loaders/debug.h                 |  36 -------
 src/modules/loaders/image.h                 | 147 ----------------------------
 src/modules/loaders/loader_ani.c            |  27 ++---
 src/modules/loaders/loader_common.h         |  31 ------
 src/modules/loaders/loader_xcf.c            |  33 +++----
 src/modules/loaders/loader_xcf_pixelfuncs.c |  17 +---
 src/modules/loaders/types.h                 |  21 ----
 9 files changed, 25 insertions(+), 356 deletions(-)

diff --git a/src/modules/loaders/Makefile.am b/src/modules/loaders/Makefile.am
index 276e45a..f78c5d6 100644
--- a/src/modules/loaders/Makefile.am
+++ b/src/modules/loaders/Makefile.am
@@ -19,8 +19,6 @@ $(ANI_L) \
 $(EET_L) \
 $(XCF_L)
 
-EXTRA_DIST = common.h debug.h image.h types.h loader_common.h
-
 eet_la_SOURCES      = loader_eet.c
 eet_la_CPPFLAGS     = @EET_CFLAGS@
 eet_la_LDFLAGS      = -module -avoid-version
diff --git a/src/modules/loaders/common.h b/src/modules/loaders/common.h
deleted file mode 100644
index 6e4a236..0000000
--- a/src/modules/loaders/common.h
+++ /dev/null
@@ -1,67 +0,0 @@
-#ifndef __COMMON
-#define __COMMON 1
-
-#include "config.h"
-#include "types.h"
-
-#if __GNUC__
-#define __PRINTF_N__(no)  __attribute__((__format__(__printf__, (no), (no)+1)))
-#else
-#define __PRINTF_N__(no)
-#endif
-#define __PRINTF__   __PRINTF_N__(1)
-#define __PRINTF_2__ __PRINTF_N__(2)
-
-#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
-
-#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)
-
-#ifndef WORDS_BIGENDIAN
-#define A_VAL(p) ((uint8_t *)(p))[3]
-#define R_VAL(p) ((uint8_t *)(p))[2]
-#define G_VAL(p) ((uint8_t *)(p))[1]
-#define B_VAL(p) ((uint8_t *)(p))[0]
-#else
-#define A_VAL(p) ((uint8_t *)(p))[0]
-#define R_VAL(p) ((uint8_t *)(p))[1]
-#define G_VAL(p) ((uint8_t *)(p))[2]
-#define B_VAL(p) ((uint8_t *)(p))[3]
-#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); }
-
-#define MIN(a, b) (((a) < (b)) ? (a) : (b))
-#define MAX(a, b) (((a) > (b)) ? (a) : (b))
-
-#endif
diff --git a/src/modules/loaders/debug.h b/src/modules/loaders/debug.h
deleted file mode 100644
index 128fe61..0000000
--- a/src/modules/loaders/debug.h
+++ /dev/null
@@ -1,36 +0,0 @@
-#ifndef IMLIB2_DEDUG_H
-#define IMLIB2_DEDUG_H
-
-#if IMLIB2_DEBUG
-
-#define D(fmt...)     if (__imlib_debug)     __imlib_printf(DBG_PFX, fmt)
-#define DC(M, fmt...) if (__imlib_debug & M) __imlib_printf(DBG_PFX, fmt)
-
-#define DBG_FILE	0x0001
-#define DBG_LOAD	0x0002
-#define DBG_LDR 	0x0004
-#define DBG_LDR2	0x0008
-
-#if __LOADER_COMMON_H
-#undef D
-#define D(fmt...)  DC(DBG_LDR, fmt)
-#define DL(fmt...) DC(DBG_LDR2, fmt)
-#endif
-
-extern unsigned int __imlib_debug;
-
-__PRINTF_2__ void   __imlib_printf(const char *pfx, const char *fmt, ...);
-
-unsigned int        __imlib_time_us(void);
-
-#else
-
-#define D(fmt...)
-#define DC(fmt...)
-#if __LOADER_COMMON_H
-#define DL(fmt...)
-#endif
-
-#endif /* IMLIB2_DEBUG */
-
-#endif /* IMLIB2_DEDUG_H */
diff --git a/src/modules/loaders/image.h b/src/modules/loaders/image.h
deleted file mode 100644
index 153a680..0000000
--- a/src/modules/loaders/image.h
+++ /dev/null
@@ -1,147 +0,0 @@
-#ifndef __IMAGE
-#define __IMAGE 1
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
-
-#include "types.h"
-
-typedef struct _imlibldctx ImlibLdCtx;
-
-typedef void        (*ImlibDataDestructorFunction)(ImlibImage * im, void *data);
-typedef void       *(*ImlibImageDataMemoryFunction)(void *, size_t size);
-
-enum _iflags {
-   F_NONE = 0,
-   F_HAS_ALPHA = (1 << 0),
-   F_UNCACHEABLE = (1 << 1),
-   F_ALWAYS_CHECK_DISK = (1 << 2),
-   F_INVALID = (1 << 3),
-   F_DONT_FREE_DATA = (1 << 4),
-   F_FORMAT_IRRELEVANT = (1 << 5),
-};
-
-/* Must match the ones in Imlib2.h.in */
-#define FF_IMAGE_ANIMATED       (1 << 0)        /* Frames are an animated sequence    */
-#define FF_FRAME_BLEND          (1 << 1)        /* Blend current onto previous frame  */
-#define FF_FRAME_DISPOSE_CLEAR  (1 << 2)        /* Clear before rendering next frame  */
-#define FF_FRAME_DISPOSE_PREV   (1 << 3)        /* Revert before rendering next frame */
-
-typedef struct {
-   int                 left, right, top, bottom;
-} ImlibBorder;
-
-typedef struct _ImlibImageTag {
-   char               *key;
-   int                 val;
-   void               *data;
-   void                (*destructor)(ImlibImage * im, void *data);
-   struct _ImlibImageTag *next;
-} ImlibImageTag;
-
-struct _ImlibImage {
-   char               *file;
-   int                 w, h;
-   uint32_t           *data;
-   ImlibImageFlags     flags;
-   time_t              moddate;
-   ImlibBorder         border;
-   int                 references;
-   ImlibLoader        *loader;
-   char               *format;
-   ImlibImage         *next;
-   ImlibImageTag      *tags;
-   char               *real_file;
-   char               *key;
-   ImlibImageDataMemoryFunction data_memory_func;
-   ImlibLdCtx         *lc;
-   FILE               *fp;
-   off_t               fsize;
-   int                 canvas_w;        /* Canvas size      */
-   int                 canvas_h;
-   int                 frame_count;     /* Number of frames */
-   int                 frame_num;       /* Current frame    */
-   int                 frame_x; /* Frame origin     */
-   int                 frame_y;
-   int                 frame_flags;     /* Frame flags      */
-   int                 frame_delay;     /* Frame delay (ms) */
-};
-
-typedef struct {
-   FILE               *fp;
-   ImlibProgressFunction pfunc;
-   int                 pgran;
-   char                immed;
-   char                nocache;
-   int                 err;
-   int                 frame;
-} ImlibLoadArgs;
-
-ImlibLoader        *__imlib_FindBestLoader(const char *file, const char *format,
-                                           int for_save);
-
-void                __imlib_LoaderSetFormats(ImlibLoader * l,
-                                             const char *const *fmt,
-                                             unsigned int num);
-
-ImlibImage         *__imlib_CreateImage(int w, int h, uint32_t * data);
-ImlibImage         *__imlib_LoadImage(const char *file, ImlibLoadArgs * ila);
-int                 __imlib_LoadEmbedded(ImlibLoader * l, ImlibImage * im,
-                                         const char *file, int load_data);
-int                 __imlib_LoadImageData(ImlibImage * im);
-void                __imlib_DirtyImage(ImlibImage * im);
-void                __imlib_FreeImage(ImlibImage * im);
-void                __imlib_SaveImage(ImlibImage * im, const char *file,
-                                      ImlibLoadArgs * ila);
-
-uint32_t           *__imlib_AllocateData(ImlibImage * im);
-void                __imlib_FreeData(ImlibImage * im);
-void                __imlib_ReplaceData(ImlibImage * im, uint32_t * new_data);
-
-void                __imlib_LoadProgressSetPass(ImlibImage * im,
-                                                int pass, int n_pass);
-int                 __imlib_LoadProgress(ImlibImage * im,
-                                         int x, int y, int w, int h);
-int                 __imlib_LoadProgressRows(ImlibImage * im,
-                                             int row, int nrows);
-
-const char         *__imlib_GetKey(const ImlibImage * im);
-
-void                __imlib_AttachTag(ImlibImage * im, const char *key,
-                                      int val, void *data,
-                                      ImlibDataDestructorFunction destructor);
-ImlibImageTag      *__imlib_GetTag(const ImlibImage * im, const char *key);
-ImlibImageTag      *__imlib_RemoveTag(ImlibImage * im, const char *key);
-void                __imlib_FreeTag(ImlibImage * im, ImlibImageTag * t);
-void                __imlib_FreeAllTags(ImlibImage * im);
-
-void                __imlib_SetCacheSize(int size);
-int                 __imlib_GetCacheSize(void);
-int                 __imlib_CurrentCacheSize(void);
-
-#define IM_FLAG_SET(im, f)      ((im)->flags |= (f))
-#define IM_FLAG_CLR(im, f)      ((im)->flags &= ~(f))
-#define IM_FLAG_UPDATE(im, f, set) \
-   do { if (set) IM_FLAG_SET(im, f); else IM_FLAG_CLR(im, f); } while(0)
-#define IM_FLAG_ISSET(im, f)    (((im)->flags & (f)) != 0)
-
-#define LOAD_BREAK       2      /* Break signaled by progress callback */
-#define LOAD_SUCCESS     1      /* Image loaded successfully           */
-#define LOAD_FAIL        0      /* Image was not recognized by loader  */
-#define LOAD_OOM        -1      /* Could not allocate memory           */
-#define LOAD_BADFILE    -2      /* File could not be accessed          */
-#define LOAD_BADIMAGE   -3      /* Image is corrupt                    */
-#define LOAD_BADFRAME   -4      /* Requested frame not found           */
-
-/* 32767 is the maximum pixmap dimension and ensures that
- * (w * h * sizeof(uint32_t)) 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) )
-
-#endif
diff --git a/src/modules/loaders/loader_ani.c b/src/modules/loaders/loader_ani.c
index eb84f14..44c350b 100644
--- a/src/modules/loaders/loader_ani.c
+++ b/src/modules/loaders/loader_ani.c
@@ -22,15 +22,9 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 */
+#include "Imlib2_Loader.h"
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <string.h>
-
-#include "loader_common.h"
+static const char  *const _formats[] = { "ani" };
 
 #define ANI_DBG 0
 #if ANI_DBG
@@ -222,19 +216,22 @@ ani_save_ico(MsChunk * chunk)
    return strdup(tmp);
 }
 
-int
-load2(ImlibImage * im, int load_data)
+static int
+_load(ImlibImage * im, int load_data)
 {
    int                 rc;
    ImlibLoader        *loader;
    MsAni              *ani = NULL;
    MsChunk            *chunk;
 
+   if (!im->fi->fp)
+      return LOAD_FAIL;
+
    loader = __imlib_FindBestLoader(NULL, "ico", 0);
    if (!loader)
       return LOAD_FAIL;
 
-   ani = ani_init(im->fp);
+   ani = ani_init(im->fi->fp);
    if (!ani)
       return LOAD_FAIL;
 
@@ -264,10 +261,4 @@ load2(ImlibImage * im, int load_data)
    return rc;
 }
 
-void
-formats(ImlibLoader * l)
-{
-   static const char  *const list_formats[] = { "ani" };
-   __imlib_LoaderSetFormats(l, list_formats,
-                            sizeof(list_formats) / sizeof(char *));
-}
+IMLIB_LOADER(_formats, _load, NULL);
diff --git a/src/modules/loaders/loader_common.h b/src/modules/loaders/loader_common.h
deleted file mode 100644
index 5afbac1..0000000
--- a/src/modules/loaders/loader_common.h
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef __LOADER_COMMON_H
-#define __LOADER_COMMON_H 1
-
-#include "common.h"
-
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/mman.h>
-
-#include "debug.h"
-#include "image.h"
-
-__EXPORT__ char     load(ImlibImage * im, ImlibProgressFunction progress,
-                         char progress_granularity, char load_data);
-__EXPORT__ int      load2(ImlibImage * im, int load_data);
-__EXPORT__ char     save(ImlibImage * im, ImlibProgressFunction progress,
-                         char progress_granularity);
-__EXPORT__ void     formats(ImlibLoader * l);
-
-typedef int         (imlib_decompress_load_f) (const void *fdata,
-                                               unsigned int fsize, int dest);
-
-int                 decompress_load(ImlibImage * im, int load_data,
-                                    const char *const *pext, int next,
-                                    imlib_decompress_load_f * fdec);
-
-#define QUIT_WITH_RC(_err) { rc = _err; goto quit; }
-#define QUITx_WITH_RC(_err, _lbl) { rc = _err; goto _lbl; }
-
-#endif /* __LOADER_COMMON_H */
diff --git a/src/modules/loaders/loader_xcf.c b/src/modules/loaders/loader_xcf.c
index 5548727..07efa17 100644
--- a/src/modules/loaders/loader_xcf.c
+++ b/src/modules/loaders/loader_xcf.c
@@ -1,5 +1,4 @@
 /*
-  
   -----------------------------[ XCF Loader ]-----------------------------
 
   This program is free software; you can redistribute it and/or modify
@@ -43,19 +42,10 @@
   concept of a channel with a layer, since it doesn't really matter.
 
   Ok, hope this helps with understanding XCF.                 -- cK.
-
 */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
 #include <netinet/in.h>
 
-#include "loader_common.h"
+#include "Imlib2_Loader.h"
 #include "loader_xcf.h"
 
 #define XCF_DBG 0
@@ -65,6 +55,8 @@
 #define D(fmt...)
 #endif
 
+static const char  *const _formats[] = { "xcf" };
+
 #define TILE_WIDTH   64
 #define TILE_HEIGHT  64
 
@@ -1572,18 +1564,21 @@ xcf_to_imlib(ImlibImage * im)
 {
    im->w = image->width;
    im->h = image->height;
-   IM_FLAG_SET(im, F_HAS_ALPHA);
+   im->has_alpha = 1;
 
    im->data = ""
 }
 
-int
-load2(ImlibImage * im, int load_data)
+static int
+_load(ImlibImage * im, int load_data)
 {
    int                 rc = LOAD_FAIL;
 
+   if (!im->fi->fp)
+      return LOAD_FAIL;
+
    /* initialize */
-   if (!xcf_file_init(im->fp))
+   if (!xcf_file_init(im->fi->fp))
       return LOAD_FAIL;
 
    /* do it! */
@@ -1606,10 +1601,4 @@ load2(ImlibImage * im, int load_data)
    return rc;
 }
 
-void
-formats(ImlibLoader * l)
-{
-   static const char  *const list_formats[] = { "xcf" };
-   __imlib_LoaderSetFormats(l, list_formats,
-                            sizeof(list_formats) / sizeof(char *));
-}
+IMLIB_LOADER(_formats, _load, NULL);
diff --git a/src/modules/loaders/loader_xcf_pixelfuncs.c b/src/modules/loaders/loader_xcf_pixelfuncs.c
index 17e139e..385bf51 100644
--- a/src/modules/loaders/loader_xcf_pixelfuncs.c
+++ b/src/modules/loaders/loader_xcf_pixelfuncs.c
@@ -1,5 +1,4 @@
 /*
-  
   -----------------------------[ XCF Loader ]-----------------------------
 
   This program is free software; you can redistribute it and/or modify
@@ -15,21 +14,15 @@
   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software Foundation,
   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
 */
+#include <stdint.h>
+#include <stdlib.h>
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <math.h>
-#include <netinet/in.h>
-
-#include "common.h"
-#include "image.h"
 #include "loader_xcf.h"
 
+#define MIN(a, b) (((a) < (b)) ? (a) : (b))
+#define MAX(a, b) (((a) > (b)) ? (a) : (b))
+
 #ifndef WORDS_BIGENDIAN
 
 #define A_VAL(p) ((uint8_t *)(p))[3]
diff --git a/src/modules/loaders/types.h b/src/modules/loaders/types.h
deleted file mode 100644
index e0b9aad..0000000
--- a/src/modules/loaders/types.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef TYPES_H
-#define TYPES_H 1
-
-#include <stdint.h>
-
-typedef struct _ImlibLoader ImlibLoader;
-
-typedef struct _ImlibImage ImlibImage;
-typedef unsigned int ImlibImageFlags;
-
-typedef int         (*ImlibProgressFunction)(ImlibImage * im, char percent,
-                                             int update_x, int update_y,
-                                             int update_w, int update_h);
-
-typedef int         ImlibOp;
-
-typedef struct _ImlibColorModifier ImlibColorModifier;
-
-typedef struct _ImlibUpdate ImlibUpdate;
-
-#endif /* TYPES_H */

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to