1 #include "common.h"
2 #ifdef BUILD_X11
3 #include <X11/Xlib.h>
4 #include <X11/extensions/XShm.h>
5
6 #include "blend.h"
7 #include "colormod.h"
8 #include "draw.h"
9 #include "image.h"
10 #include "rend.h"
11
12 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)13 __imlib_CreatePixmapsForImage(Display * d, Drawable w, Visual * v, int depth,
14 Colormap cm, ImlibImage * im, Pixmap * p,
15 Mask * m, int sx, int sy, int sw, int sh, int dw,
16 int dh, char antialias, char hiq,
17 char dither_mask, int mat,
18 ImlibColorModifier * cmod)
19 {
20 ImlibImagePixmap *ip = NULL;
21 Pixmap pmap = 0;
22 Pixmap mask = 0;
23 long long mod_count = 0;
24
25 if (cmod)
26 mod_count = cmod->modification_count;
27 ip = __imlib_FindCachedImagePixmap(im, dw, dh, d, v, depth, sx, sy,
28 sw, sh, cm, antialias, hiq, dither_mask,
29 mod_count);
30 if (ip)
31 {
32 if (p)
33 *p = ip->pixmap;
34 if (m)
35 *m = ip->mask;
36 ip->references++;
37 #ifdef DEBUG_CACHE
38 fprintf(stderr,
39 "[Imlib2] Match found in cache. Reference count is %d, pixmap 0x%08x, mask 0x%08x\n",
40 ip->references, ip->pixmap, ip->mask);
41 #endif
42 return 2;
43 }
44 if (p)
45 {
46 pmap = XCreatePixmap(d, w, dw, dh, depth);
47 *p = pmap;
48 }
49 if (m)
50 {
51 if (IMAGE_HAS_ALPHA(im))
52 mask = XCreatePixmap(d, w, dw, dh, 1);
53 *m = mask;
54 }
55 __imlib_RenderImage(d, im, pmap, mask, v, cm, depth, sx, sy, sw, sh, 0, 0,
56 dw, dh, antialias, hiq, 0, dither_mask, mat, cmod,
57 OP_COPY);
58 ip = __imlib_ProduceImagePixmap();
59 ip->visual = v;
60 ip->depth = depth;
61 ip->image = im;
62 if (im->file)
63 ip->file = strdup(im->file);
64 ip->border.left = im->border.left;
65 ip->border.right = im->border.right;
66 ip->border.top = im->border.top;
67 ip->border.bottom = im->border.bottom;
68 ip->colormap = cm;
69 ip->display = d;
70 ip->w = dw;
71 ip->h = dh;
72 ip->source_x = sx;
73 ip->source_y = sy;
74 ip->source_w = sw;
75 ip->source_h = sh;
76 ip->antialias = antialias;
77 ip->modification_count = mod_count;
78 ip->dither_mask = dither_mask;
79 ip->hi_quality = hiq;
80 ip->references = 1;
81 ip->pixmap = pmap;
82 ip->mask = mask;
83 __imlib_AddImagePixmapToCache(ip);
84 #ifdef DEBUG_CACHE
85 fprintf(stderr,
86 "[Imlib2] Created pixmap. Reference count is %d, pixmap 0x%08x, mask 0x%08x\n",
87 ip->references, ip->pixmap, ip->mask);
88 #endif
89 return 1;
90 }
91
92 #endif /* BUILD_X11 */
93