From: Guenter B. <gu...@us...> - 2001-08-19 10:23:24
|
Update of /cvsroot/xine/xine-ui/src/Imlib-light In directory usw-pr-cvs1:/tmp/cvs-serv4959/src/Imlib-light Modified Files: Imlib.h Imlib_types.h Makefile.am misc.c rend.c Log Message: 8 bit depth fixes Index: Imlib.h =================================================================== RCS file: /cvsroot/xine/xine-ui/src/Imlib-light/Imlib.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Imlib.h 2001/05/25 10:29:40 1.3 +++ Imlib.h 2001/08/19 10:23:20 1.4 @@ -19,6 +19,7 @@ void Imlib_destroy_image(ImlibData * id, ImlibImage * im); void Imlib_kill_image(ImlibData * id, ImlibImage * im); void Imlib_free_pixmap(ImlibData * id, Pixmap pmap); + int Imlib_load_colors(ImlibData * id, char *file); #ifdef __cplusplus } Index: Imlib_types.h =================================================================== RCS file: /cvsroot/xine/xine-ui/src/Imlib-light/Imlib_types.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Imlib_types.h 2001/05/19 22:47:10 1.2 +++ Imlib_types.h 2001/08/19 10:23:20 1.3 @@ -2,6 +2,9 @@ #include <X11/Xutil.h> #include <X11/Xatom.h> #include <X11/Xos.h> +#ifdef HAVE_XSHM_H +#include <X11/extensions/XShm.h> +#endif #include <X11/extensions/shape.h> #include <stdio.h> #include <unistd.h> @@ -10,6 +13,12 @@ #include <ctype.h> #include <time.h> #include <netinet/in.h> +#ifdef HAVE_IPC_H +#include <sys/ipc.h> +#endif +#ifdef HAVE_SHM_H +#include <sys/shm.h> +#endif #include <sys/time.h> #include <sys/types.h> @@ -19,12 +28,18 @@ #include <strings.h> #endif +#ifndef SYSTEM_IMRC +#define SYSTEM_IMRC "/etc/imrc" +#endif /* endef SYSTEM_IMRC */ + typedef struct _ImlibBorder ImlibBorder; typedef struct _ImlibColor ImlibColor; typedef struct _ImlibColorModifier ImlibColorModifier; typedef struct _ImlibImage ImlibImage; typedef struct _xdata Xdata; typedef struct _ImlibData ImlibData; +typedef struct _ImlibSaveInfo ImlibSaveInfo; +typedef struct _ImlibInitParams ImlibInitParams; struct _ImlibBorder { @@ -67,12 +82,19 @@ Display *disp; int screen; Window root; - Visual *visual; + Visual *visual; int depth; int render_depth; Colormap root_cmap; + char shm; + char shmp; + int shm_event; XImage *last_xim; XImage *last_sxim; +#ifdef HAVE_XSHM_H + XShmSegmentInfo last_shminfo; + XShmSegmentInfo last_sshminfo; +#endif Window base_window; int byte_order, bit_order; }; @@ -87,6 +109,7 @@ int *fast_erg; int *fast_erb; int render_type; + int max_shm; Xdata x; int byte_order; struct _cache @@ -110,6 +133,54 @@ char fallback; char ordered_dither; }; + +struct _ImlibSaveInfo + { + int quality; + int scaling; + int xjustification; + int yjustification; + int page_size; + char color; + }; + +struct _ImlibInitParams + { + int flags; + int visualid; + char *palettefile; + char sharedmem; + char sharedpixmaps; + char paletteoverride; + char remap; + char fastrender; + char hiquality; + char dither; + int imagecachesize; + int pixmapcachesize; + Colormap cmap; + }; + +#define PARAMS_VISUALID 1<<0 +#define PARAMS_PALETTEFILE 1<<1 +#define PARAMS_SHAREDMEM 1<<2 +#define PARAMS_SHAREDPIXMAPS 1<<3 +#define PARAMS_PALETTEOVERRIDE 1<<4 +#define PARAMS_REMAP 1<<5 +#define PARAMS_FASTRENDER 1<<6 +#define PARAMS_HIQUALITY 1<<7 +#define PARAMS_DITHER 1<<8 +#define PARAMS_IMAGECACHESIZE 1<<9 +#define PARAMS_PIXMAPCACHESIZE 1<<10 +#define PARAMS_COLORMAP 1<<11 + +#define PAGE_SIZE_EXECUTIVE 0 +#define PAGE_SIZE_LETTER 1 +#define PAGE_SIZE_LEGAL 2 +#define PAGE_SIZE_A4 3 +#define PAGE_SIZE_A3 4 +#define PAGE_SIZE_A5 5 +#define PAGE_SIZE_FOLIO 6 #define RT_PLAIN_PALETTE 0 #define RT_PLAIN_PALETTE_FAST 1 Index: Makefile.am =================================================================== RCS file: /cvsroot/xine/xine-ui/src/Imlib-light/Makefile.am,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- Makefile.am 2001/07/10 21:04:27 1.4 +++ Makefile.am 2001/08/19 10:23:20 1.5 @@ -3,7 +3,7 @@ noinst_LTLIBRARIES = libImlib-light.la -libImlib_light_la_SOURCES = cache.c load.c misc.c rend.c utils.c snprintf.c +libImlib_light_la_SOURCES = cache.c load.c misc.c rend.c utils.c snprintf.c colors.c noinst_HEADERS = Imlib.h Imlib_private.h Imlib_types.h Index: misc.c =================================================================== RCS file: /cvsroot/xine/xine-ui/src/Imlib-light/misc.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- misc.c 2001/05/19 22:47:10 1.2 +++ misc.c 2001/08/19 10:23:20 1.3 @@ -1,40 +1,92 @@ #define _GNU_SOURCE - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - +#include <config.h> #include "Imlib.h" #include "Imlib_private.h" +#include <locale.h> +#ifdef __EMX__ +extern const char *__XOS2RedirRoot(const char *); +#endif + #ifndef HAVE_SNPRINTF #define snprintf my_snprintf #ifdef HAVE_STDARGS int my_snprintf(char *str, size_t count, const char *fmt,...); + #else int my_snprintf(va_alist); + #endif #endif + +char x_error; -ImlibData *Imlib_init(Display * disp) { +int +Imlib_get_render_type(ImlibData * id) +{ + if (id) + return id->render_type; + else + { + fprintf(stderr, "IMLIB ERROR: Imlib not initialised\n"); + return -1; + } +} + +void +Imlib_set_render_type(ImlibData * id, int rend_type) +{ + if (id) + { + if (id->x.depth > 8) + id->render_type = rend_type; + else + { + if ((rend_type == RT_PLAIN_TRUECOL) || + (rend_type == RT_DITHER_TRUECOL)) + id->render_type = RT_DITHER_PALETTE_FAST; + else + id->render_type = rend_type; + } + return; + } + else + { + fprintf(stderr, "IMLIB ERROR: Imlib not initialised\n"); + return; + } +} + +ImlibData * +Imlib_init(Display * disp) +{ ImlibData *id; XWindowAttributes xwa; XVisualInfo xvi, *xvir; + char *homedir; + char s[4096], *s1, *s2; + FILE *f; int override = 0; int dither = 0; int remap = 1; int num; int i, max, maxn; int clas; + char *palfile; int loadpal; int vis; int newcm; + char *old_locale; - if (!disp) { - fprintf(stderr, "IMLIB ERROR: no display\n"); - return NULL; - } + /* fprintf(stderr, "Imlib Init\n"); + fflush(stderr); */ + palfile = NULL; + if (!disp) + { + fprintf(stderr, "IMLIB ERROR: no display\n"); + return NULL; + } vis = -1; loadpal = 0; id = (ImlibData *) malloc(sizeof(ImlibData)); @@ -55,6 +107,9 @@ id->x.visual = DefaultVisual(disp, id->x.screen); /* the visual type */ id->x.depth = DefaultDepth(disp, id->x.screen); /* the depth of the screen in bpp */ + id->x.shm = 0; + id->x.shmp = 0; + id->max_shm = 0; id->cache.on_image = 0; id->cache.size_image = 0; id->cache.num_image = 0; @@ -83,16 +138,195 @@ id->bmod.contrast = 256; id->ordered_dither = 1; - if (XGetWindowAttributes(disp, id->x.root, &xwa)) { - if (xwa.colormap) - id->x.root_cmap = xwa.colormap; - else - id->x.root_cmap = 0; + if (XGetWindowAttributes(disp, id->x.root, &xwa)) + { + if (xwa.colormap) + id->x.root_cmap = xwa.colormap; + else + id->x.root_cmap = 0; } else id->x.root_cmap = 0; id->num_colors = 0; + homedir = getenv("HOME"); + snprintf(s, sizeof(s), "%s/.imrc", homedir); + old_locale = strdup(setlocale(LC_NUMERIC, NULL)); + setlocale(LC_NUMERIC, "C"); +#ifndef __EMX__ + f = fopen(s, "r"); +#else + f = fopen(s, "rt"); +#endif + if (!f) +#ifndef __EMX__ + f = fopen(SYSTEM_IMRC, "r"); +#else + f = fopen(__XOS2RedirRoot(SYSTEM_IMRC), "rt"); +#endif + if (f) + { + while (fgets(s, 4096, f)) + { + if (s[0] == '#') + continue; + + s1 = strtok(s, " \t\n"); + + /* Blank line ? */ + + if (s1 == NULL) + continue; + + s2 = strtok(NULL, " \t\n"); + if (s2 == NULL) + s2 = ""; /* NULL argument */ + + if (!strcasecmp("PaletteFile", s1)) + { + palfile = strdup(s2); + } + else if (!strcasecmp("PaletteOverride", s1)) + { + if (!strcasecmp("yes", s2)) + override = 1; + else + override = 0; + } + else if (!strcasecmp("Dither", s1)) + { + if (!strcasecmp("yes", s2)) + dither = 1; + else + dither = 0; + } + else if (!strcasecmp("Remap", s1)) + { + if (!strcasecmp("fast", s2)) + remap = 1; + else + remap = 0; + } + else if (!strcasecmp("Mit-Shm", s1)) + { + { + id->x.shm = 0; + id->x.shmp = 0; + } + } + else if (!strcasecmp("SharedPixmaps", s1)) + { + id->x.shmp = 0; + } + else if (!strcasecmp("FastRender", s1)) + { + if (!strcasecmp("on", s2)) + id->fastrend = 1; + } + else if (!strcasecmp("HighQuality", s1)) + { + if (!strcasecmp("on", s2)) + id->hiq = 1; + } + else if (!strcasecmp("Shm_Max_Size", s1)) + { + num = atoi(s2); + id->max_shm = num; + } + else if (!strcasecmp("Image_Cache_Size", s1)) + { + num = atoi(s2); + id->cache.size_image = num; + } + else if (!strcasecmp("Pixmap_Cache_Size", s1)) + { + num = atoi(s2); + id->cache.size_pixmap = num; + } + else if (!strcasecmp("Image_Cache", s1)) + { + if (!strcasecmp("on", s2)) + id->cache.on_image = 1; + } + else if (!strcasecmp("Pixmap_Cache", s1)) + { + if (!strcasecmp("on", s2)) + id->cache.on_pixmap = 1; + } + else if (!strcasecmp("ForceVisualID", s1)) + { + sscanf(s, "%1024s %x", s1, &num); + vis = num; + } + else if (!strcasecmp("Fallback", s1)) + { + if (!strcasecmp("off", s2)) + id->fallback = 0; + else + id->fallback = 1; + } + else if (!strcasecmp("Gamma", s1)) + { + id->mod.gamma = (int)(256.0 * atof(s2)); + } + else if (!strcasecmp("Brightness", s1)) + { + id->mod.brightness = (int)(256.0 * atof(s2)); + } + else if (!strcasecmp("Contrast", s1)) + { + id->mod.contrast = (int)(256.0 * atof(s2)); + } + else if (!strcasecmp("Red_Gamma", s1)) + { + id->rmod.gamma = (int)(256.0 * atof(s2)); + } + else if (!strcasecmp("Red_Brightness", s1)) + { + id->rmod.brightness = (int)(256.0 * atof(s2)); + } + else if (!strcasecmp("Red_Contrast", s1)) + { + id->rmod.contrast = (int)(256.0 * atof(s2)); + } + else if (!strcasecmp("Green_Gamma", s1)) + { + id->gmod.gamma = (int)(256.0 * atof(s2)); + } + else if (!strcasecmp("Green_Brightness", s1)) + { + id->gmod.brightness = (int)(256.0 * atof(s2)); + } + else if (!strcasecmp("Green_Contrast", s1)) + { + id->gmod.contrast = (int)(256.0 * atof(s2)); + } + else if (!strcasecmp("Blue_Gamma", s1)) + { + id->bmod.gamma = (int)(256.0 * atof(s2)); + } + else if (!strcasecmp("Blue_Brightness", s1)) + { + id->bmod.brightness = (int)(256.0 * atof(s2)); + } + else if (!strcasecmp("Blue_Contrast", s1)) + { + id->bmod.contrast = (int)(256.0 * atof(s2)); + } + else if (!strcasecmp("Ordered_Dither", s1)) + { + if (!strcasecmp("off", s2)) + id->ordered_dither = 0; + else + id->ordered_dither = 1; + } + } + fclose(f); + } + setlocale(LC_NUMERIC, old_locale); + if (old_locale) + free(old_locale); + /* list all visuals for the default screen */ xvi.screen = id->x.screen; xvir = XGetVisualInfo(disp, VisualScreenMask, &xvi, &num); @@ -201,6 +435,8 @@ XFree(xvir); } } + if (id->x.depth < 8) + id->x.shmp = 0; if ((id->x.depth <= 8) || (override == 1)) loadpal = 1; if (loadpal) @@ -219,6 +455,16 @@ else id->render_type = RT_PLAIN_PALETTE; } + if (palfile != NULL) + Imlib_load_colors(id, palfile); + if (id->num_colors == 0) + { + fprintf(stderr, "IMLIB ERROR: Cannot Find Palette. A Palette is required for this mode\n"); + free(id); + if (palfile) + free(palfile); + return NULL; + } } else { @@ -239,6 +485,7 @@ mask = CWOverrideRedirect | CWBackPixel | CWBorderPixel | CWBackingStore | CWSaveUnder; newcm = 0; + /* if (id->x.visual != DefaultVisual(disp, id->x.screen)) { Colormap cm; @@ -253,6 +500,7 @@ newcm = 1; } } +*/ id->x.base_window = XCreateWindow(id->x.disp, id->x.root, -100, -100, 10, 10, 0, id->x.depth, InputOutput, @@ -274,12 +522,14 @@ if ((htonl(1) == 1) && (byt == LSBFirst)) id->fastrend = 0; } + if (palfile) + free(palfile); - /* printf ("Imlib init, d : %d visual : %d\n", id, id->x.visual); */ return id; } + Pixmap Imlib_copy_image(ImlibData * id, ImlibImage * im) { @@ -377,4 +627,103 @@ free_pixmappmap(id, pmap); clean_caches(id); } +} + +void +Imlib_set_image_border(ImlibData * id, ImlibImage * im, ImlibBorder * border) +{ + if ((im) && (border)) + { + if ((im->border.left != border->left) || + (im->border.right != border->right) || + (im->border.top != border->top) || + (im->border.bottom != border->bottom)) + { + dirty_pixmaps(id, im); + + im->border.left = border->left; + im->border.right = border->right; + im->border.top = border->top; + im->border.bottom = border->bottom; + } + } +} + +void +Imlib_get_image_border(ImlibData * id, ImlibImage * im, ImlibBorder * border) +{ + if ((im) && (border)) + { + border->left = im->border.left; + border->right = im->border.right; + border->top = im->border.top; + border->bottom = im->border.bottom; + } +} + +void +Imlib_get_image_shape(ImlibData * id, ImlibImage * im, ImlibColor * color) +{ + if ((!im) || (!color)) + return; + + color->r = im->shape_color.r; + color->g = im->shape_color.g; + color->b = im->shape_color.b; +} + +void +Imlib_set_image_shape(ImlibData * id, ImlibImage * im, ImlibColor * color) +{ + if ((!im) || (!color)) + return; + if ((im->shape_color.r != color->r) || (im->shape_color.g != color->g) || (im->shape_color.b != color->b)) + { + im->shape_color.r = color->r; + im->shape_color.g = color->g; + im->shape_color.b = color->b; + dirty_pixmaps(id, im); + } +} + +int +Imlib_get_fallback(ImlibData * id) +{ + if (!id) + return 0; + return id->fallback; +} + +void +Imlib_set_fallback(ImlibData * id, int fallback) +{ + if (!id) + return; + id->fallback = fallback; +} + +Visual * +Imlib_get_visual(ImlibData * id) +{ + if (!id) + return NULL; + return id->x.visual; +} + +Colormap +Imlib_get_colormap(ImlibData * id) +{ + if (!id) + return 0; + return id->x.root_cmap; +} + +char * +Imlib_get_sysconfig(ImlibData * id) +{ +#ifndef __EMX__ + return strdup(SYSTEM_IMRC); +#else + return strdup(__XOS2RedirRoot(SYSTEM_IMRC)); +#endif } Index: rend.c =================================================================== RCS file: /cvsroot/xine/xine-ui/src/Imlib-light/rend.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- rend.c 2001/04/18 22:45:25 1.1.1.1 +++ rend.c 2001/08/19 10:23:20 1.2 @@ -1,12 +1,11 @@ #define _GNU_SOURCE -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - +#include <config.h> #include "Imlib.h" #include "Imlib_private.h" -static int Imlib_best_color_match(ImlibData * id, int *r, int *g, int *b) { +int [...1227 lines suppressed...] @@ -6096,7 +6497,9 @@ XDestroyImage(xim); return 0; } - mask = XCreatePixmap(id->x.disp, id->x.base_window, w, h, 1); + mask = XCreatePixmap(id->x.disp, id->x.base_window, w, h, 1); + fprintf(stderr, "created ph2 mask pixmap %x (%i x %i)\n", + mask, w, h); if (!mask) { fprintf(stderr, "IMLIB ERROR: Cannot create shape pixmap\n"); @@ -6115,7 +6518,7 @@ /* copy XImage to the pixmap, if not a shared pixmap */ if ((im->shape_color.r >= 0) && (im->shape_color.g >= 0) && (im->shape_color.b >= 0)) { - if ((im->mod.gamma == 256) && (im->mod.brightness == 256) && (im->mod.contrast == 256) && + if ((im->mod.gamma == 256) && (im->mod.brightness == 256) && (im->mod.contrast == 256) && (im->rmod.gamma == 256) && (im->rmod.brightness == 256) && (im->rmod.contrast == 256) && (im->gmod.gamma == 256) && (im->gmod.brightness == 256) && (im->gmod.contrast == 256) && (im->bmod.gamma == 256) && (im->bmod.brightness == 256) && (im->bmod.contrast == 256)) |