summaryrefslogtreecommitdiff
path: root/pixman/src/icimage.h
blob: f1d5ca13e4f1846b317a7d1477b56ec05ba31a03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
/*
 * Copyright © 2000 Keith Packard
 *
 * Permission to use, copy, modify, distribute, and sell this software and its
 * documentation for any purpose is hereby granted without fee, provided that
 * the above copyright notice appear in all copies and that both that
 * copyright notice and this permission notice appear in supporting
 * documentation, and that the name of Keith Packard not be used in
 * advertising or publicity pertaining to distribution of the software without
 * specific, written prior permission.  Keith Packard makes no
 * representations about the suitability of this software for any purpose.  It
 * is provided "as is" without express or implied warranty.
 *
 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
 * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 * PERFORMANCE OF THIS SOFTWARE.
 */

/* XXX: This whole file should be moved up into incint.h (and cleaned
   up considerably as well) */

#ifndef _ICIMAGE_H_
#define _ICIMAGE_H_

/* #include "glyphstr.h" */
/* #include "scrnintstr.h" */

/* XXX: Hmmm... what's needed from here?
#include "resource.h"
*/


#define IcIntMult(a,b,t) ( (t) = (a) * (b) + 0x80, ( ( ( (t)>>8 ) + (t) )>>8 ) )
#define IcIntDiv(a,b)	 (((uint16_t) (a) * 255) / (b))

#define IcGet8(v,i)   ((uint16_t) (uint8_t) ((v) >> i))

/*
 * There are two ways of handling alpha -- either as a single unified value or
 * a separate value for each component, hence each macro must have two
 * versions.  The unified alpha version has a 'U' at the end of the name,
 * the component version has a 'C'.  Similarly, functions which deal with
 * this difference will have two versions using the same convention.
 */

#define IcOverU(x,y,i,a,t) ((t) = IcIntMult(IcGet8(y,i),(a),(t)) + IcGet8(x,i),\
			   (uint32_t) ((uint8_t) ((t) | (0 - ((t) >> 8)))) << (i))

#define IcOverC(x,y,i,a,t) ((t) = IcIntMult(IcGet8(y,i),IcGet8(a,i),(t)) + IcGet8(x,i),\
			    (uint32_t) ((uint8_t) ((t) | (0 - ((t) >> 8)))) << (i))

#define IcInU(x,i,a,t) ((uint32_t) IcIntMult(IcGet8(x,i),(a),(t)) << (i))

#define IcInC(x,i,a,t) ((uint32_t) IcIntMult(IcGet8(x,i),IcGet8(a,i),(t)) << (i))

#define IcGen(x,y,i,ax,ay,t,u,v) ((t) = (IcIntMult(IcGet8(y,i),ay,(u)) + \
					 IcIntMult(IcGet8(x,i),ax,(v))),\
				  (uint32_t) ((uint8_t) ((t) | \
						     (0 - ((t) >> 8)))) << (i))

#define IcAdd(x,y,i,t)	((t) = IcGet8(x,i) + IcGet8(y,i), \
			 (uint32_t) ((uint8_t) ((t) | (0 - ((t) >> 8)))) << (i))

/*
typedef struct _IndexFormat {
    VisualPtr	    pVisual; 
    ColormapPtr	    pColormap;
    int		    nvalues;
    xIndexValue	    *pValues;
    void	    *devPrivate;
} IndexFormatRec;
*/

/*
typedef struct _IcFormat {
    uint32_t	    id;
    uint32_t	    format;
    unsigned char   type;
    unsigned char   depth;
    DirectFormatRec direct;
    IndexFormatRec  index;
} IcFormatRec;
*/

struct _IcImage {
    IcPixels	    *pixels;
    IcFormat	    image_format;
    int		    format_code;
    int		    refcnt;
    
    unsigned int    repeat : 1;
    unsigned int    graphicsExposures : 1;
    unsigned int    subWindowMode : 1;
    unsigned int    polyEdge : 1;
    unsigned int    polyMode : 1;
    /* XXX: Do we need this field */
    unsigned int    freeCompClip : 1;
    unsigned int    clientClipType : 2;
    unsigned int    componentAlpha : 1;
    unsigned int    unused : 23;

    struct _IcImage *alphaMap;
    IcPoint	    alphaOrigin;

    IcPoint 	    clipOrigin;
    void	   *clientClip;

    unsigned long   dither;

    unsigned long   stateChanges;
    unsigned long   serialNumber;

    PixRegion	    *pCompositeClip;
    
    IcTransform     *transform;

    IcFilter	    filter;
    IcFixed16_16    *filter_params;
    int		    filter_nparams;

    int		    owns_pixels;
};

#endif /* _ICIMAGE_H_ */

#ifndef _IC_MIPICT_H_
#define _IC_MIPICT_H_

#define IC_MAX_INDEXED	256 /* XXX depth must be <= 8 */

#if IC_MAX_INDEXED <= 256
typedef uint8_t IcIndexType;
#endif

/* XXX: We're not supporting indexed operations, right?
typedef struct _IcIndexed {
    int	color;
    uint32_t	rgba[IC_MAX_INDEXED];
    IcIndexType	ent[32768];
} IcIndexedRec, *IcIndexedPtr;
*/

#define IcCvtR8G8B8to15(s) ((((s) >> 3) & 0x001f) | \
			     (((s) >> 6) & 0x03e0) | \
			     (((s) >> 9) & 0x7c00))
#define IcIndexToEnt15(icf,rgb15) ((icf)->ent[rgb15])
#define IcIndexToEnt24(icf,rgb24) IcIndexToEnt15(icf,IcCvtR8G8B8to15(rgb24))

#define IcIndexToEntY24(icf,rgb24) ((icf)->ent[CvtR8G8B8toY15(rgb24)])

/*
extern int __internal_linkage
IcCreatePicture (PicturePtr pPicture);
*/

extern void __internal_linkage
IcImageInit (IcImage *image);

extern void __internal_linkage
IcImageDestroyClip (IcImage *image);

/*
extern void __internal_linkage
IcValidatePicture (PicturePtr pPicture,
		   Mask       mask);
*/


/* XXX: What should this be?
extern int __internal_linkage
IcClipPicture (PixRegion    *region,
	       IcImage	    *image,
	       int16_t	    xReg,
	       int16_t	    yReg,
	       int16_t	    xPict,
	       int16_t	    yPict);
*/

extern int __internal_linkage
IcComputeCompositeRegion (PixRegion	*region,
			  IcImage	*iSrc,
			  IcImage	*iMask,
			  IcImage	*iDst,
			  int16_t		xSrc,
			  int16_t		ySrc,
			  int16_t		xMask,
			  int16_t		yMask,
			  int16_t		xDst,
			  int16_t		yDst,
			  uint16_t	width,
			  uint16_t	height);

/*
extern int __internal_linkage
IcPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats);
*/

/*
extern void __internal_linkage
IcGlyphs (IcOperator	op,
	  PicturePtr	pSrc,
	  PicturePtr	pDst,
	  PictFormatPtr	maskFormat,
	  int16_t		xSrc,
	  int16_t		ySrc,
	  int		nlist,
	  GlyphListPtr	list,
	  GlyphPtr	*glyphs);
*/

/*
extern void __internal_linkage
IcCompositeRects (IcOperator	op,
		  PicturePtr	pDst,
		  xRenderColor  *color,
		  int		nRect,
		  xRectangle    *rects);
*/

extern IcImage * __internal_linkage
IcCreateAlphaPicture (IcImage	*dst,
		      IcFormat	*format,
		      uint16_t	width,
		      uint16_t	height);

typedef void	(*CompositeFunc) (IcOperator   op,
				  IcImage    *iSrc,
				  IcImage    *iMask,
				  IcImage    *iDst,
				  int16_t      xSrc,
				  int16_t      ySrc,
				  int16_t      xMask,
				  int16_t      yMask,
				  int16_t      xDst,
				  int16_t      yDst,
				  uint16_t     width,
				  uint16_t     height);

typedef struct _IcCompositeOperand IcCompositeOperand;

typedef uint32_t (*IcCompositeFetch)(IcCompositeOperand *op);
typedef void (*IcCompositeStore) (IcCompositeOperand *op, uint32_t value);

typedef void (*IcCompositeStep) (IcCompositeOperand *op);
typedef void (*IcCompositeSet) (IcCompositeOperand *op, int x, int y);

struct _IcCompositeOperand {
    union {
	struct {
	    IcBits		*top_line;
	    int			left_offset;
	    
	    int			start_offset;
	    IcBits		*line;
	    uint32_t		offset;
	    IcStride		stride;
	    int			bpp;
	} drawable;
	struct {
	    int			alpha_dx;
	    int			alpha_dy;
	} external;
	struct {
	    int			top_y;
	    int			left_x;
	    int			start_x;
	    int			x;
	    int			y;
	    IcTransform		*transform;
	    IcFilter		filter;
	} transform;
    } u;
    IcCompositeFetch	fetch;
    IcCompositeFetch	fetcha;
    IcCompositeStore	store;
    IcCompositeStep	over;
    IcCompositeStep	down;
    IcCompositeSet	set;
/* XXX: We're not supporting indexed operations, right?
    IcIndexedPtr	indexed;
*/
    PixRegion		*clip;
};

typedef void (*IcCombineFunc) (IcCompositeOperand	*src,
			       IcCompositeOperand	*msk,
			       IcCompositeOperand	*dst);

typedef struct _IcAccessMap {
    uint32_t		format_code;
    IcCompositeFetch	fetch;
    IcCompositeFetch	fetcha;
    IcCompositeStore	store;
} IcAccessMap;

/* iccompose.c */

typedef struct _IcCompSrc {
    uint32_t	value;
    uint32_t	alpha;
} IcCompSrc;

extern int __internal_linkage
IcBuildCompositeOperand (IcImage	    *image,
			 IcCompositeOperand op[4],
			 int16_t		    x,
			 int16_t		    y,
			 int		    transform,
			 int		    alpha);

extern void __internal_linkage
IcCompositeGeneral (IcOperator	op,
		    IcImage	*iSrc,
		    IcImage	*iMask,
		    IcImage	*iDst,
		    int16_t	xSrc,
		    int16_t	ySrc,
		    int16_t	xMask,
		    int16_t	yMask,
		    int16_t	xDst,
		    int16_t	yDst,
		    uint16_t	width,
		    uint16_t	height);

#endif /* _IC_MIPICT_H_ */