Merge x11_draw.c/h into x11_pixmap.c/h

Closely related, might as well combine.
This commit is contained in:
Kim Woelders 2022-03-04 15:11:17 +01:00
parent ac1d4b0520
commit f0acaee282
7 changed files with 92 additions and 122 deletions

View File

@ -62,7 +62,6 @@ if BUILD_X11
libImlib2_la_SOURCES += \
x11_color.c x11_color.h \
x11_context.c x11_context.h \
x11_draw.c x11_draw.h \
x11_grab.c x11_grab.h \
x11_pixmap.c x11_pixmap.h \
x11_rend.c x11_rend.h \

View File

@ -23,7 +23,6 @@
#include "updates.h"
#ifdef BUILD_X11
#include "x11_color.h"
#include "x11_draw.h"
#include "x11_grab.h"
#include "x11_pixmap.h"
#include "x11_rend.h"

View File

@ -1,69 +0,0 @@
#include "common.h"
#include <X11/Xlib.h>
#include <X11/extensions/XShm.h>
#include "blend.h"
#include "colormod.h"
#include "image.h"
#include "x11_draw.h"
#include "x11_pixmap.h"
#include "x11_rend.h"
char
__imlib_CreatePixmapsForImage(Display * d, Drawable w, Visual * v, int depth,
Colormap cm, ImlibImage * im, Pixmap * p,
Mask * m, int sx, int sy, int sw, int sh, int dw,
int dh, char antialias, char hiq,
char dither_mask, int mat,
ImlibColorModifier * cmod)
{
ImlibImagePixmap *ip = NULL;
Pixmap pmap = 0;
Pixmap mask = 0;
long long mod_count = 0;
if (cmod)
mod_count = cmod->modification_count;
ip = __imlib_FindCachedImagePixmap(im, dw, dh, d, v, depth, sx, sy,
sw, sh, cm, antialias, hiq, dither_mask,
mod_count);
if (ip)
{
if (p)
*p = ip->pixmap;
if (m)
*m = ip->mask;
ip->references++;
#ifdef DEBUG_CACHE
fprintf(stderr,
"[Imlib2] Match found in cache. Reference count is %d, pixmap 0x%08lx, mask 0x%08lx\n",
ip->references, ip->pixmap, ip->mask);
#endif
return 2;
}
if (p)
{
pmap = XCreatePixmap(d, w, dw, dh, depth);
*p = pmap;
}
if (m)
{
if (IM_FLAG_ISSET(im, F_HAS_ALPHA))
mask = XCreatePixmap(d, w, dw, dh, 1);
*m = mask;
}
__imlib_RenderImage(d, im, pmap, mask, v, cm, depth, sx, sy, sw, sh, 0, 0,
dw, dh, antialias, hiq, 0, dither_mask, mat, cmod,
OP_COPY);
ip = __imlib_AddImagePixmapToCache(im, pmap, mask,
dw, dh, d, v, depth, sx, sy,
sw, sh, cm, antialias, hiq, dither_mask,
mod_count);
#ifdef DEBUG_CACHE
fprintf(stderr,
"[Imlib2] Created pixmap. Reference count is %d, pixmap 0x%08lx, mask 0x%08lx\n",
ip->references, ip->pixmap, ip->mask);
#endif
return 1;
}

View File

@ -1,17 +0,0 @@
#ifndef X11_DRAW_H
#define X11_DRAW_H 1
#include "colormod.h"
#include "common.h"
char __imlib_CreatePixmapsForImage(Display * d, Drawable w,
Visual * v, int depth,
Colormap cm, ImlibImage * im,
Pixmap * p, Mask * m, int sx,
int sy, int sw, int sh,
int dw, int dh,
char anitalias, char hiq,
char dither_mask, int mat,
ImlibColorModifier * cmod);
#endif /* X11_DRAW_H */

View File

@ -3,6 +3,25 @@
#include <X11/Xlib.h>
#include "x11_pixmap.h"
#include "x11_rend.h"
typedef struct _ImlibImagePixmap {
int w, h;
Pixmap pixmap, mask;
Display *display;
Visual *visual;
int depth;
int source_x, source_y, source_w, source_h;
Colormap colormap;
char antialias, hi_quality, dither_mask;
ImlibBorder border;
ImlibImage *image;
char *file;
char dirty;
int references;
DATABIG modification_count;
struct _ImlibImagePixmap *next;
} ImlibImagePixmap;
static ImlibImagePixmap *pixmaps = NULL;
@ -34,7 +53,7 @@ __imlib_ConsumeImagePixmap(ImlibImagePixmap * ip)
free(ip);
}
ImlibImagePixmap *
static ImlibImagePixmap *
__imlib_FindCachedImagePixmap(ImlibImage * im, int w, int h, Display * d,
Visual * v, int depth, int sx, int sy, int sw,
int sh, Colormap cm, char aa, char hiq,
@ -73,7 +92,7 @@ __imlib_FindCachedImagePixmap(ImlibImage * im, int w, int h, Display * d,
}
/* add a pixmap cahce struct to the pixmap cache (at the start of course */
ImlibImagePixmap *
static ImlibImagePixmap *
__imlib_AddImagePixmapToCache(ImlibImage * im, Pixmap pmap, Pixmap mask,
int w, int h,
Display * d, Visual * v, int depth,
@ -301,3 +320,61 @@ __imlib_PixmapCacheSize(void)
return current_cache;
}
char
__imlib_CreatePixmapsForImage(Display * d, Drawable w, Visual * v, int depth,
Colormap cm, ImlibImage * im, Pixmap * p,
Mask * m, int sx, int sy, int sw, int sh, int dw,
int dh, char antialias, char hiq,
char dither_mask, int mat,
ImlibColorModifier * cmod)
{
ImlibImagePixmap *ip = NULL;
Pixmap pmap = 0;
Pixmap mask = 0;
long long mod_count = 0;
if (cmod)
mod_count = cmod->modification_count;
ip = __imlib_FindCachedImagePixmap(im, dw, dh, d, v, depth, sx, sy,
sw, sh, cm, antialias, hiq, dither_mask,
mod_count);
if (ip)
{
if (p)
*p = ip->pixmap;
if (m)
*m = ip->mask;
ip->references++;
#ifdef DEBUG_CACHE
fprintf(stderr,
"[Imlib2] Match found in cache. Reference count is %d, pixmap 0x%08lx, mask 0x%08lx\n",
ip->references, ip->pixmap, ip->mask);
#endif
return 2;
}
if (p)
{
pmap = XCreatePixmap(d, w, dw, dh, depth);
*p = pmap;
}
if (m)
{
if (IM_FLAG_ISSET(im, F_HAS_ALPHA))
mask = XCreatePixmap(d, w, dw, dh, 1);
*m = mask;
}
__imlib_RenderImage(d, im, pmap, mask, v, cm, depth, sx, sy, sw, sh, 0, 0,
dw, dh, antialias, hiq, 0, dither_mask, mat, cmod,
OP_COPY);
ip = __imlib_AddImagePixmapToCache(im, pmap, mask,
dw, dh, d, v, depth, sx, sy,
sw, sh, cm, antialias, hiq, dither_mask,
mod_count);
#ifdef DEBUG_CACHE
fprintf(stderr,
"[Imlib2] Created pixmap. Reference count is %d, pixmap 0x%08lx, mask 0x%08lx\n",
ip->references, ip->pixmap, ip->mask);
#endif
return 1;
}

View File

@ -5,38 +5,6 @@
#include "image.h"
typedef struct _ImlibImagePixmap {
int w, h;
Pixmap pixmap, mask;
Display *display;
Visual *visual;
int depth;
int source_x, source_y, source_w, source_h;
Colormap colormap;
char antialias, hi_quality, dither_mask;
ImlibBorder border;
ImlibImage *image;
char *file;
char dirty;
int references;
DATABIG modification_count;
struct _ImlibImagePixmap *next;
} ImlibImagePixmap;
ImlibImagePixmap *__imlib_FindCachedImagePixmap(ImlibImage * im, int w, int h,
Display * d, Visual * v,
int depth, int sx, int sy,
int sw, int sh, Colormap cm,
char aa, char hiq, char dmask,
DATABIG modification_count);
ImlibImagePixmap *__imlib_AddImagePixmapToCache(ImlibImage * im,
Pixmap p, Pixmap m,
int w, int h,
Display * d, Visual * v,
int depth, int sx, int sy,
int sw, int sh, Colormap cm,
char aa, char hiq, char dmask,
DATABIG modification_count);
void __imlib_CleanupImagePixmapCache(void);
int __imlib_PixmapCacheSize(void);
@ -44,4 +12,16 @@ void __imlib_FreePixmap(Display * d, Pixmap p);
void __imlib_DirtyPixmapsForImage(const ImlibImage * im);
void __imlib_PixmapUnrefImage(const ImlibImage * im);
#include "colormod.h"
char __imlib_CreatePixmapsForImage(Display * d, Drawable w,
Visual * v, int depth,
Colormap cm, ImlibImage * im,
Pixmap * p, Mask * m, int sx,
int sy, int sw, int sh,
int dw, int dh,
char anitalias, char hiq,
char dither_mask, int mat,
ImlibColorModifier * cmod);
#endif /* X11_PIXMAP_H */

View File

@ -2,6 +2,7 @@
#define X11_REND_H 1
#include "common.h"
#include "blend.h"
DATA32 __imlib_RenderGetPixel(Display * d, Drawable w, Visual * v,
Colormap cm, int depth, DATA8 r,