Subversion Repositories Kolibri OS

Rev

Rev 1891 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1891 Rev 3931
Line 29... Line 29...
29
#endif
29
#endif
Line 30... Line 30...
30
 
30
 
31
#include 
31
#include 
32
#include 
32
#include 
-
 
33
#include 
Line 33... Line -...
33
#include 
-
 
34
 
34
#include 
-
 
35
 
Line 35... Line 36...
35
#include "pixman-private.h"
36
#include "pixman-accessor.h"
36
#include "pixman-accessor.h"
37
#include "pixman-private.h"
37
 
38
 
38
#define CONVERT_RGB24_TO_Y15(s)						\
39
#define CONVERT_RGB24_TO_Y15(s)						\
Line 43... Line 44...
43
#define CONVERT_RGB24_TO_RGB15(s)                                       \
44
#define CONVERT_RGB24_TO_RGB15(s)                                       \
44
    ((((s) >> 3) & 0x001f) |                                            \
45
    ((((s) >> 3) & 0x001f) |                                            \
45
     (((s) >> 6) & 0x03e0) |                                            \
46
     (((s) >> 6) & 0x03e0) |                                            \
46
     (((s) >> 9) & 0x7c00))
47
     (((s) >> 9) & 0x7c00))
Line 47... Line -...
47
 
-
 
48
#define RGB15_TO_ENTRY(mif,rgb15)					\
48
 
Line -... Line 49...
-
 
49
/* Fetch macros */
-
 
50
 
-
 
51
#ifdef WORDS_BIGENDIAN
-
 
52
#define FETCH_1(img,l,o)						\
-
 
53
    (((READ ((img), ((uint32_t *)(l)) + ((o) >> 5))) >> (0x1f - ((o) & 0x1f))) & 0x1)
-
 
54
#else
-
 
55
#define FETCH_1(img,l,o)						\
-
 
56
    ((((READ ((img), ((uint32_t *)(l)) + ((o) >> 5))) >> ((o) & 0x1f))) & 0x1)
-
 
57
#endif
-
 
58
 
-
 
59
#define FETCH_8(img,l,o)    (READ (img, (((uint8_t *)(l)) + ((o) >> 3))))
-
 
60
 
-
 
61
#ifdef WORDS_BIGENDIAN
-
 
62
#define FETCH_4(img,l,o)						\
-
 
63
    (((4 * (o)) & 4) ? (FETCH_8 (img,l, 4 * (o)) & 0xf) : (FETCH_8 (img,l,(4 * (o))) >> 4))
-
 
64
#else
-
 
65
#define FETCH_4(img,l,o)						\
-
 
66
    (((4 * (o)) & 4) ? (FETCH_8 (img, l, 4 * (o)) >> 4) : (FETCH_8 (img, l, (4 * (o))) & 0xf))
-
 
67
#endif
-
 
68
 
-
 
69
#ifdef WORDS_BIGENDIAN
-
 
70
#define FETCH_24(img,l,o)                                              \
-
 
71
    ((READ (img, (((uint8_t *)(l)) + ((o) * 3) + 0)) << 16)    |       \
-
 
72
     (READ (img, (((uint8_t *)(l)) + ((o) * 3) + 1)) << 8)     |       \
-
 
73
     (READ (img, (((uint8_t *)(l)) + ((o) * 3) + 2)) << 0))
-
 
74
#else
-
 
75
#define FETCH_24(img,l,o)						\
-
 
76
    ((READ (img, (((uint8_t *)(l)) + ((o) * 3) + 0)) << 0)	|	\
-
 
77
     (READ (img, (((uint8_t *)(l)) + ((o) * 3) + 1)) << 8)	|	\
-
 
78
     (READ (img, (((uint8_t *)(l)) + ((o) * 3) + 2)) << 16))
-
 
79
#endif
-
 
80
 
-
 
81
/* Store macros */
-
 
82
 
-
 
83
#ifdef WORDS_BIGENDIAN
-
 
84
#define STORE_1(img,l,o,v)						\
-
 
85
    do									\
-
 
86
    {									\
-
 
87
	uint32_t  *__d = ((uint32_t *)(l)) + ((o) >> 5);		\
-
 
88
	uint32_t __m, __v;						\
-
 
89
									\
-
 
90
	__m = 1 << (0x1f - ((o) & 0x1f));				\
-
 
91
	__v = (v)? __m : 0;						\
-
 
92
									\
-
 
93
	WRITE((img), __d, (READ((img), __d) & ~__m) | __v);		\
-
 
94
    }									\
-
 
95
    while (0)
-
 
96
#else
-
 
97
#define STORE_1(img,l,o,v)						\
-
 
98
    do									\
-
 
99
    {									\
-
 
100
	uint32_t  *__d = ((uint32_t *)(l)) + ((o) >> 5);		\
-
 
101
	uint32_t __m, __v;						\
-
 
102
									\
-
 
103
	__m = 1 << ((o) & 0x1f);					\
-
 
104
	__v = (v)? __m : 0;						\
-
 
105
									\
-
 
106
	WRITE((img), __d, (READ((img), __d) & ~__m) | __v);		\
-
 
107
    }									\
-
 
108
    while (0)
-
 
109
#endif
-
 
110
 
-
 
111
#define STORE_8(img,l,o,v)  (WRITE (img, (uint8_t *)(l) + ((o) >> 3), (v)))
49
    ((mif)->ent[rgb15])
112
 
-
 
113
#ifdef WORDS_BIGENDIAN
-
 
114
#define STORE_4(img,l,o,v)						\
-
 
115
    do									\
-
 
116
    {									\
-
 
117
	int bo = 4 * (o);						\
-
 
118
	int v4 = (v) & 0x0f;						\
-
 
119
									\
-
 
120
	STORE_8 (img, l, bo, (						\
50
 
121
		     bo & 4 ?						\
-
 
122
		     (FETCH_8 (img, l, bo) & 0xf0) | (v4) :		\
-
 
123
		     (FETCH_8 (img, l, bo) & 0x0f) | (v4 << 4)));	\
-
 
124
    } while (0)
-
 
125
#else
-
 
126
#define STORE_4(img,l,o,v)						\
-
 
127
    do									\
-
 
128
    {									\
-
 
129
	int bo = 4 * (o);						\
-
 
130
	int v4 = (v) & 0x0f;						\
-
 
131
									\
-
 
132
	STORE_8 (img, l, bo, (						\
-
 
133
		     bo & 4 ?						\
-
 
134
		     (FETCH_8 (img, l, bo) & 0x0f) | (v4 << 4) :	\
-
 
135
		     (FETCH_8 (img, l, bo) & 0xf0) | (v4)));		\
Line -... Line 136...
-
 
136
    } while (0)
-
 
137
#endif
-
 
138
 
-
 
139
#ifdef WORDS_BIGENDIAN
51
#define RGB24_TO_ENTRY(mif,rgb24)					\
140
#define STORE_24(img,l,o,v)                                            \
-
 
141
    do                                                                 \
-
 
142
    {                                                                  \
-
 
143
	uint8_t *__tmp = (l) + 3 * (o);				       \
-
 
144
        							       \
-
 
145
	WRITE ((img), __tmp++, ((v) & 0x00ff0000) >> 16);	       \
-
 
146
	WRITE ((img), __tmp++, ((v) & 0x0000ff00) >>  8);	       \
-
 
147
	WRITE ((img), __tmp++, ((v) & 0x000000ff) >>  0);	       \
-
 
148
    }                                                                  \
-
 
149
    while (0)
-
 
150
#else
52
    RGB15_TO_ENTRY (mif,CONVERT_RGB24_TO_RGB15 (rgb24))
151
#define STORE_24(img,l,o,v)                                            \
-
 
152
    do                                                                 \
-
 
153
    {                                                                  \
-
 
154
	uint8_t *__tmp = (l) + 3 * (o);				       \
-
 
155
        							       \
-
 
156
	WRITE ((img), __tmp++, ((v) & 0x000000ff) >>  0);	       \
-
 
157
	WRITE ((img), __tmp++, ((v) & 0x0000ff00) >>  8);	       \
-
 
158
	WRITE ((img), __tmp++, ((v) & 0x00ff0000) >> 16);	       \
Line 53... Line 159...
53
 
159
    }								       \
54
#define RGB24_TO_ENTRY_Y(mif,rgb24)					\
160
    while (0)
55
    ((mif)->ent[CONVERT_RGB24_TO_Y15 (rgb24)])
161
#endif
Line 84... Line 190...
84
 
190
 
85
#define YV12_V(line)                                                    \
191
#define YV12_V(line)                                                    \
86
    ((uint8_t *) ((bits) + offset0 +                                    \
192
    ((uint8_t *) ((bits) + offset0 +                                    \
Line 87... Line 193...
87
                  ((stride) >> 1) * ((line) >> 1)))
193
                  ((stride) >> 1) * ((line) >> 1)))
Line 88... Line 194...
88
 
194
 
89
/********************************** Fetch ************************************/
195
/* Misc. helpers */
-
 
196
 
90
 
197
static force_inline void
91
static void
198
get_shifts (pixman_format_code_t  format,
92
fetch_scanline_a8r8g8b8 (pixman_image_t *image,
199
	    int			 *a,
-
 
200
	    int			 *r,
93
                         int             x,
201
	    int                  *g,
-
 
202
	    int                  *b)
94
                         int             y,
203
{
-
 
204
    switch (PIXMAN_FORMAT_TYPE (format))
-
 
205
    {
-
 
206
    case PIXMAN_TYPE_A:
-
 
207
	*b = 0;
-
 
208
	*g = 0;
95
                         int             width,
209
	*r = 0;
-
 
210
	*a = 0;
-
 
211
	break;
-
 
212
 
96
                         uint32_t *      buffer,
213
    case PIXMAN_TYPE_ARGB:
-
 
214
    case PIXMAN_TYPE_ARGB_SRGB:
-
 
215
	*b = 0;
-
 
216
	*g = *b + PIXMAN_FORMAT_B (format);
97
                         const uint32_t *mask)
217
	*r = *g + PIXMAN_FORMAT_G (format);
98
{
218
	*a = *r + PIXMAN_FORMAT_R (format);
-
 
219
	break;
-
 
220
 
99
    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
221
    case PIXMAN_TYPE_ABGR:
100
    
222
	*r = 0;
-
 
223
	*g = *r + PIXMAN_FORMAT_R (format);
101
    MEMCPY_WRAPPED (image,
224
	*b = *g + PIXMAN_FORMAT_G (format);
-
 
225
	*a = *b + PIXMAN_FORMAT_B (format);
-
 
226
	break;
-
 
227
 
-
 
228
    case PIXMAN_TYPE_BGRA:
-
 
229
	/* With BGRA formats we start counting at the high end of the pixel */
-
 
230
	*b = PIXMAN_FORMAT_BPP (format) - PIXMAN_FORMAT_B (format);
-
 
231
	*g = *b - PIXMAN_FORMAT_B (format);
102
                    buffer, (const uint32_t *)bits + x,
232
	*r = *g - PIXMAN_FORMAT_G (format);
103
                    width * sizeof(uint32_t));
233
	*a = *r - PIXMAN_FORMAT_R (format);
-
 
234
	break;
104
}
235
 
105
 
236
    case PIXMAN_TYPE_RGBA:
106
static void
237
	/* With BGRA formats we start counting at the high end of the pixel */
107
fetch_scanline_x8r8g8b8 (pixman_image_t *image,
238
	*r = PIXMAN_FORMAT_BPP (format) - PIXMAN_FORMAT_R (format);
-
 
239
	*g = *r - PIXMAN_FORMAT_R (format);
-
 
240
	*b = *g - PIXMAN_FORMAT_G (format);
-
 
241
	*a = *b - PIXMAN_FORMAT_B (format);
-
 
242
	break;
-
 
243
 
-
 
244
    default:
-
 
245
	assert (0);
-
 
246
	break;
-
 
247
    }
108
                         int             x,
248
}
-
 
249
 
109
                         int             y,
250
static force_inline uint32_t
110
                         int             width,
251
convert_channel (uint32_t pixel, uint32_t def_value,
-
 
252
		 int n_from_bits, int from_shift,
-
 
253
		 int n_to_bits, int to_shift)
111
                         uint32_t *      buffer,
254
{
112
                         const uint32_t *mask)
255
    uint32_t v;
113
{
256
 
-
 
257
    if (n_from_bits && n_to_bits)
-
 
258
	v  = unorm_to_unorm (pixel >> from_shift, n_from_bits, n_to_bits);
-
 
259
    else if (n_to_bits)
Line 114... Line -...
114
    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
-
 
115
    const uint32_t *pixel = (const uint32_t *)bits + x;
260
	v = def_value;
116
    const uint32_t *end = pixel + width;
261
    else
Line 117... Line 262...
117
    
262
	v = 0;
118
    while (pixel < end)
263
 
119
	*buffer++ = READ (image, pixel++) | 0xff000000;
-
 
120
}
-
 
121
 
-
 
122
static void
-
 
123
fetch_scanline_a8b8g8r8 (pixman_image_t *image,
-
 
124
                         int             x,
264
    return (v & ((1 << n_to_bits) - 1)) << to_shift;
125
                         int             y,
-
 
126
                         int             width,
-
 
127
                         uint32_t *      buffer,
-
 
128
                         const uint32_t *mask)
-
 
129
{
-
 
130
    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
-
 
131
    const uint32_t *pixel = (uint32_t *)bits + x;
-
 
132
    const uint32_t *end = pixel + width;
-
 
133
    
-
 
134
    while (pixel < end)
-
 
135
    {
-
 
136
	uint32_t p = READ (image, pixel++);
-
 
137
	
-
 
138
	*buffer++ = (p & 0xff00ff00)	|
-
 
139
	    ((p >> 16) & 0xff)		|
-
 
140
	    ((p & 0xff) << 16);
-
 
141
    }
-
 
142
}
-
 
143
 
-
 
144
static void
-
 
145
fetch_scanline_x8b8g8r8 (pixman_image_t *image,
-
 
146
                         int             x,
-
 
147
                         int             y,
-
 
148
                         int             width,
-
 
149
                         uint32_t *      buffer,
-
 
150
                         const uint32_t *mask)
-
 
151
{
-
 
152
    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
-
 
153
    const uint32_t *pixel = (uint32_t *)bits + x;
-
 
154
    const uint32_t *end = pixel + width;
-
 
155
    
-
 
156
    while (pixel < end)
-
 
157
    {
-
 
158
	uint32_t p = READ (image, pixel++);
-
 
159
	
-
 
160
	*buffer++ = 0xff000000		|
-
 
161
	    (p & 0x0000ff00)		|
-
 
162
	    ((p >> 16) & 0xff)		|
-
 
163
	    ((p & 0xff) << 16);
-
 
164
    }
-
 
165
}
-
 
166
 
-
 
167
static void
-
 
168
fetch_scanline_b8g8r8a8 (pixman_image_t *image,
-
 
169
                         int             x,
-
 
170
                         int             y,
-
 
171
                         int             width,
-
 
172
                         uint32_t *      buffer,
-
 
173
                         const uint32_t *mask)
-
 
174
{
-
 
175
    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
-
 
176
    const uint32_t *pixel = (uint32_t *)bits + x;
-
 
177
    const uint32_t *end = pixel + width;
-
 
178
 
-
 
179
    while (pixel < end)
-
 
180
    {
-
 
181
	uint32_t p = READ (image, pixel++);
-
 
182
 
-
 
183
	*buffer++ = (((p & 0xff000000) >> 24)	|
-
 
184
	             ((p & 0x00ff0000) >> 8)	|
-
 
185
	             ((p & 0x0000ff00) << 8)	|
-
 
186
	             ((p & 0x000000ff) << 24));
-
 
187
    }
-
 
188
}
-
 
189
 
-
 
190
static void
-
 
191
fetch_scanline_b8g8r8x8 (pixman_image_t *image,
-
 
192
                         int             x,
-
 
193
                         int             y,
-
 
194
                         int             width,
-
 
195
                         uint32_t *      buffer,
-
 
196
                         const uint32_t *mask)
-
 
197
{
-
 
198
    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
-
 
199
    const uint32_t *pixel = (uint32_t *)bits + x;
-
 
200
    const uint32_t *end = pixel + width;
-
 
201
    
-
 
202
    while (pixel < end)
-
 
203
    {
-
 
204
	uint32_t p = READ (image, pixel++);
-
 
205
	
-
 
206
	*buffer++ = (0xff000000 |
-
 
207
	             ((p & 0xff000000) >> 24)	|
-
 
208
	             ((p & 0x00ff0000) >> 8)	|
-
 
209
	             ((p & 0x0000ff00) << 8));
-
 
210
    }
-
 
211
}
-
 
212
 
-
 
213
static void
-
 
214
fetch_scanline_x14r6g6b6 (pixman_image_t *image,
-
 
215
                          int             x,
-
 
216
                          int             y,
265
}
217
                          int             width,
266
 
218
                          uint32_t *      buffer,
-
 
219
                          const uint32_t *mask)
-
 
220
{
-
 
221
    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
-
 
222
    const uint32_t *pixel = (const uint32_t *)bits + x;
-
 
223
    const uint32_t *end = pixel + width;
267
static force_inline uint32_t
224
 
-
 
225
    while (pixel < end)
-
 
226
    {
-
 
227
	uint32_t p = READ (image, pixel++);
-
 
228
	uint32_t r, g, b;
-
 
229
 
-
 
230
	r = ((p & 0x3f000) << 6) | ((p & 0x30000));
-
 
231
	g = ((p & 0x00fc0) << 4) | ((p & 0x00c00) >> 2);
-
 
232
	b = ((p & 0x0003f) << 2) | ((p & 0x00030) >> 4);
-
 
233
 
-
 
234
	*buffer++ = 0xff000000 | r | g | b;
-
 
235
    }
-
 
236
}
-
 
237
 
-
 
238
/* Expects a uint64_t buffer */
-
 
239
static void
-
 
240
fetch_scanline_a2r10g10b10 (pixman_image_t *image,
-
 
241
                            int             x,
-
 
242
                            int             y,
-
 
243
                            int             width,
-
 
244
                            uint32_t *      b,
-
 
245
                            const uint32_t *mask)
-
 
246
{
-
 
247
    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
-
 
248
    const uint32_t *pixel = bits + x;
-
 
249
    const uint32_t *end = pixel + width;
-
 
250
    uint64_t *buffer = (uint64_t *)b;
-
 
251
 
-
 
252
    while (pixel < end)
-
 
253
    {
-
 
Line 254... Line 268...
254
	uint32_t p = READ (image, pixel++);
268
convert_pixel (pixman_format_code_t from, pixman_format_code_t to, uint32_t pixel)
255
	uint64_t a = p >> 30;
269
{
256
	uint64_t r = (p >> 20) & 0x3ff;
-
 
Line 257... Line 270...
257
	uint64_t g = (p >> 10) & 0x3ff;
270
    int a_from_shift, r_from_shift, g_from_shift, b_from_shift;
-
 
271
    int a_to_shift, r_to_shift, g_to_shift, b_to_shift;
-
 
272
    uint32_t a, r, g, b;
-
 
273
 
258
	uint64_t b = p & 0x3ff;
274
    get_shifts (from, &a_from_shift, &r_from_shift, &g_from_shift, &b_from_shift);
-
 
275
    get_shifts (to, &a_to_shift, &r_to_shift, &g_to_shift, &b_to_shift);
-
 
276
 
-
 
277
    a = convert_channel (pixel, ~0,
259
 
278
			 PIXMAN_FORMAT_A (from), a_from_shift,
-
 
279
			 PIXMAN_FORMAT_A (to), a_to_shift);
-
 
280
 
-
 
281
    r = convert_channel (pixel, 0,
260
	r = r << 6 | r >> 4;
282
			 PIXMAN_FORMAT_R (from), r_from_shift,
-
 
283
			 PIXMAN_FORMAT_R (to), r_to_shift);
-
 
284
 
Line 261... Line 285...
261
	g = g << 6 | g >> 4;
285
    g = convert_channel (pixel, 0,
262
	b = b << 6 | b >> 4;
-
 
263
 
286
			 PIXMAN_FORMAT_G (from), g_from_shift,
Line 264... Line 287...
264
	a <<= 14;
287
			 PIXMAN_FORMAT_G (to), g_to_shift);
265
	a |= a >> 2;
-
 
266
	a |= a >> 4;
288
 
267
	a |= a >> 8;
-
 
268
 
-
 
269
	*buffer++ = a << 48 | r << 32 | g << 16 | b;
-
 
270
    }
289
    b = convert_channel (pixel, 0,
271
}
290
			 PIXMAN_FORMAT_B (from), b_from_shift,
272
 
291
			 PIXMAN_FORMAT_B (to), b_to_shift);
273
/* Expects a uint64_t buffer */
-
 
274
static void
292
 
275
fetch_scanline_x2r10g10b10 (pixman_image_t *image,
-
 
276
                            int             x,
293
    return a | r | g | b;
277
                            int             y,
-
 
278
                            int             width,
-
 
279
                            uint32_t *      b,
294
}
280
                            const uint32_t *mask)
295
 
281
{
-
 
282
    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
-
 
283
    const uint32_t *pixel = (uint32_t *)bits + x;
-
 
284
    const uint32_t *end = pixel + width;
-
 
285
    uint64_t *buffer = (uint64_t *)b;
-
 
286
    
-
 
287
    while (pixel < end)
-
 
288
    {
-
 
289
	uint32_t p = READ (image, pixel++);
-
 
290
	uint64_t r = (p >> 20) & 0x3ff;
-
 
291
	uint64_t g = (p >> 10) & 0x3ff;
296
static force_inline uint32_t
292
	uint64_t b = p & 0x3ff;
-
 
293
	
-
 
294
	r = r << 6 | r >> 4;
297
convert_pixel_to_a8r8g8b8 (pixman_image_t *image,
295
	g = g << 6 | g >> 4;
-
 
296
	b = b << 6 | b >> 4;
-
 
297
	
-
 
298
	*buffer++ = 0xffffULL << 48 | r << 32 | g << 16 | b;
-
 
299
    }
-
 
300
}
-
 
301
 
-
 
302
/* Expects a uint64_t buffer */
-
 
303
static void
-
 
304
fetch_scanline_a2b10g10r10 (pixman_image_t *image,
-
 
305
                            int             x,
-
 
306
                            int             y,
-
 
307
                            int             width,
-
 
308
                            uint32_t *      b,
298
			   pixman_format_code_t format,
309
                            const uint32_t *mask)
299
			   uint32_t pixel)
310
{
-
 
311
    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
-
 
312
    const uint32_t *pixel = bits + x;
-
 
313
    const uint32_t *end = pixel + width;
-
 
314
    uint64_t *buffer = (uint64_t *)b;
-
 
315
    
-
 
316
    while (pixel < end)
-
 
317
    {
-
 
318
	uint32_t p = READ (image, pixel++);
-
 
319
	uint64_t a = p >> 30;
-
 
320
	uint64_t b = (p >> 20) & 0x3ff;
-
 
321
	uint64_t g = (p >> 10) & 0x3ff;
-
 
322
	uint64_t r = p & 0x3ff;
-
 
323
	
-
 
324
	r = r << 6 | r >> 4;
-
 
325
	g = g << 6 | g >> 4;
300
{
326
	b = b << 6 | b >> 4;
301
    if (PIXMAN_FORMAT_TYPE (format) == PIXMAN_TYPE_GRAY		||
Line 327... Line 302...
327
	
302
	PIXMAN_FORMAT_TYPE (format) == PIXMAN_TYPE_COLOR)
328
	a <<= 14;
-
 
329
	a |= a >> 2;
303
    {
330
	a |= a >> 4;
-
 
331
	a |= a >> 8;
-
 
332
 
-
 
333
	*buffer++ = a << 48 | r << 32 | g << 16 | b;
-
 
334
    }
304
	return image->bits.indexed->rgba[pixel];
335
}
305
    }
336
 
-
 
337
/* Expects a uint64_t buffer */
306
    else
338
static void
-
 
339
fetch_scanline_x2b10g10r10 (pixman_image_t *image,
-
 
340
                            int             x,
-
 
341
                            int             y,
-
 
342
                            int             width,
307
    {
343
                            uint32_t *      b,
308
	return convert_pixel (format, PIXMAN_a8r8g8b8, pixel);
344
                            const uint32_t *mask)
-
 
345
{
-
 
346
    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
-
 
Line 347... Line -...
347
    const uint32_t *pixel = (uint32_t *)bits + x;
-
 
348
    const uint32_t *end = pixel + width;
-
 
349
    uint64_t *buffer = (uint64_t *)b;
-
 
350
    
-
 
351
    while (pixel < end)
309
    }
352
    {
-
 
353
	uint32_t p = READ (image, pixel++);
310
}
354
	uint64_t b = (p >> 20) & 0x3ff;
-
 
355
	uint64_t g = (p >> 10) & 0x3ff;
-
 
356
	uint64_t r = p & 0x3ff;
-
 
357
	
-
 
358
	r = r << 6 | r >> 4;
-
 
359
	g = g << 6 | g >> 4;
-
 
360
	b = b << 6 | b >> 4;
-
 
361
	
-
 
362
	*buffer++ = 0xffffULL << 48 | r << 32 | g << 16 | b;
-
 
363
    }
-
 
364
}
311
 
365
 
-
 
366
static void
-
 
367
fetch_scanline_r8g8b8 (pixman_image_t *image,
-
 
368
                       int             x,
312
static force_inline uint32_t
369
                       int             y,
-
 
370
                       int             width,
-
 
371
                       uint32_t *      buffer,
-
 
372
                       const uint32_t *mask)
313
convert_pixel_from_a8r8g8b8 (pixman_image_t *image,
373
{
-
 
374
    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
-
 
375
    const uint8_t *pixel = (const uint8_t *)bits + 3 * x;
-
 
376
    const uint8_t *end = pixel + 3 * width;
-
 
377
    
-
 
378
    while (pixel < end)
-
 
379
    {
-
 
Line 380... Line 314...
380
	uint32_t b = 0xff000000;
314
			     pixman_format_code_t format, uint32_t pixel)
381
	
-
 
382
#ifdef WORDS_BIGENDIAN
315
{
383
	b |= (READ (image, pixel++) << 16);
-
 
384
	b |= (READ (image, pixel++) << 8);
316
    if (PIXMAN_FORMAT_TYPE (format) == PIXMAN_TYPE_GRAY)
385
	b |= (READ (image, pixel++));
-
 
386
#else
-
 
387
	b |= (READ (image, pixel++));
-
 
388
	b |= (READ (image, pixel++) << 8);
-
 
389
	b |= (READ (image, pixel++) << 16);
-
 
390
#endif
-
 
391
	
-
 
392
	*buffer++ = b;
-
 
393
    }
-
 
394
}
-
 
395
 
-
 
396
static void
-
 
397
fetch_scanline_b8g8r8 (pixman_image_t *image,
317
    {
398
                       int             x,
-
 
399
                       int             y,
-
 
400
                       int             width,
318
	pixel = CONVERT_RGB24_TO_Y15 (pixel);
401
                       uint32_t *      buffer,
-
 
402
                       const uint32_t *mask)
-
 
403
{
-
 
404
    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
-
 
405
    const uint8_t *pixel = (const uint8_t *)bits + 3 * x;
-
 
406
    const uint8_t *end = pixel + 3 * width;
-
 
407
    
-
 
408
    while (pixel < end)
-
 
409
    {
319
 
410
	uint32_t b = 0xff000000;
320
	return image->bits.indexed->ent[pixel & 0x7fff];
Line 411... Line 321...
411
#ifdef WORDS_BIGENDIAN
321
    }
412
	b |= (READ (image, pixel++));
322
    else if (PIXMAN_FORMAT_TYPE (format) == PIXMAN_TYPE_COLOR)
413
	b |= (READ (image, pixel++) << 8);
323
    {
414
	b |= (READ (image, pixel++) << 16);
324
	pixel = convert_pixel (PIXMAN_a8r8g8b8, PIXMAN_x1r5g5b5, pixel);
415
#else
-
 
416
	b |= (READ (image, pixel++) << 16);
-
 
417
	b |= (READ (image, pixel++) << 8);
325
 
418
	b |= (READ (image, pixel++));
326
	return image->bits.indexed->ent[pixel & 0x7fff];
419
#endif
-
 
420
	*buffer++ = b;
-
 
421
    }
327
    }
Line 422... Line 328...
422
}
328
    else
423
 
329
    {
424
static void
330
	return convert_pixel (PIXMAN_a8r8g8b8, format, pixel);
425
fetch_scanline_r5g6b5 (pixman_image_t *image,
331
    }
426
                       int             x,
-
 
427
                       int             y,
332
}
Line 428... Line 333...
428
                       int             width,
333
 
429
                       uint32_t *      buffer,
334
static force_inline uint32_t
-
 
335
fetch_and_convert_pixel (pixman_image_t	*	image,
Line -... Line 336...
-
 
336
			 const uint8_t *	bits,
430
                       const uint32_t *mask)
337
			 int			offset,
431
{
338
			 pixman_format_code_t	format)
432
    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
-
 
Line 433... Line 339...
433
    const uint16_t *pixel = (const uint16_t *)bits + x;
339
{
434
    const uint16_t *end = pixel + width;
-
 
435
    
-
 
436
    while (pixel < end)
-
 
437
    {
-
 
438
	uint32_t p = READ (image, pixel++);
340
    uint32_t pixel;
439
	uint32_t r = (((p) << 3) & 0xf8) |
-
 
440
	    (((p) << 5) & 0xfc00) |
341
 
441
	    (((p) << 8) & 0xf80000);
-
 
442
	
-
 
443
	r |= (r >> 5) & 0x70007;
-
 
Line 444... Line -...
444
	r |= (r >> 6) & 0x300;
-
 
445
	
342
    switch (PIXMAN_FORMAT_BPP (format))
446
	*buffer++ = 0xff000000 | r;
343
    {
447
    }
344
    case 1:
Line 448... Line 345...
448
}
345
	pixel = FETCH_1 (image, bits, offset);
449
 
346
	break;
450
static void
347
 
Line -... Line 348...
-
 
348
    case 4:
451
fetch_scanline_b5g6r5 (pixman_image_t *image,
349
	pixel = FETCH_4 (image, bits, offset);
452
                       int             x,
350
	break;
453
                       int             y,
351
 
Line 454... Line -...
454
                       int             width,
-
 
455
                       uint32_t *      buffer,
-
 
456
                       const uint32_t *mask)
-
 
457
{
-
 
458
    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
-
 
459
    const uint16_t *pixel = (const uint16_t *)bits + x;
-
 
460
    const uint16_t *end = pixel + width;
-
 
461
    
-
 
462
    while (pixel < end)
-
 
463
    {
352
    case 8:
464
	uint32_t p = READ (image, pixel++);
-
 
465
	uint32_t r, g, b;
-
 
466
	
-
 
467
	b = ((p & 0xf800) | ((p & 0xe000) >> 5)) >> 8;
-
 
468
	g = ((p & 0x07e0) | ((p & 0x0600) >> 6)) << 5;
-
 
469
	r = ((p & 0x001c) | ((p & 0x001f) << 5)) << 14;
-
 
470
	
-
 
471
	*buffer++ = 0xff000000 | r | g | b;
-
 
472
    }
-
 
473
}
-
 
474
 
-
 
475
static void
-
 
476
fetch_scanline_a1r5g5b5 (pixman_image_t *image,
-
 
477
                         int             x,
-
 
478
                         int             y,
353
	pixel = READ (image, bits + offset);
Line 479... Line 354...
479
                         int             width,
354
	break;
480
                         uint32_t *      buffer,
355
 
481
                         const uint32_t *mask)
356
    case 16:
482
{
357
	pixel = READ (image, ((uint16_t *)bits + offset));
483
    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
358
	break;
484
    const uint16_t *pixel = (const uint16_t *)bits + x;
359
 
485
    const uint16_t *end = pixel + width;
-
 
486
    
360
    case 24:
487
    while (pixel < end)
-
 
488
    {
361
	pixel = FETCH_24 (image, bits, offset);
489
	uint32_t p = READ (image, pixel++);
362
	break;
Line 490... Line 363...
490
	uint32_t r, g, b, a;
363
 
491
	
364
    case 32:
-
 
365
	pixel = READ (image, ((uint32_t *)bits + offset));
492
	a = (uint32_t) ((uint8_t) (0 - ((p & 0x8000) >> 15))) << 24;
366
	break;
493
	r = ((p & 0x7c00) | ((p & 0x7000) >> 5)) << 9;
367
 
Line 494... Line 368...
494
	g = ((p & 0x03e0) | ((p & 0x0380) >> 5)) << 6;
368
    default:
495
	b = ((p & 0x001c) | ((p & 0x001f) << 5)) >> 2;
369
	pixel = 0xffff00ff; /* As ugly as possible to detect the bug */
496
	
370
	break;
Line -... Line 371...
-
 
371
    }
497
	*buffer++ = a | r | g | b;
372
 
498
    }
373
    return convert_pixel_to_a8r8g8b8 (image, format, pixel);
499
}
-
 
Line 500... Line 374...
500
 
374
}
501
static void
-
 
502
fetch_scanline_x1r5g5b5 (pixman_image_t *image,
-
 
503
                         int             x,
-
 
504
                         int             y,
-
 
505
                         int             width,
-
 
506
                         uint32_t *      buffer,
-
 
507
                         const uint32_t *mask)
-
 
508
{
-
 
509
    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
375
 
510
    const uint16_t *pixel = (const uint16_t *)bits + x;
-
 
511
    const uint16_t *end = pixel + width;
376
static force_inline void
Line 512... Line -...
512
    
-
 
513
    while (pixel < end)
377
convert_and_store_pixel (bits_image_t *		image,
514
    {
378
			 uint8_t *		dest,
-
 
379
			 int                    offset,
Line 515... Line -...
515
	uint32_t p = READ (image, pixel++);
-
 
516
	uint32_t r, g, b;
380
			 pixman_format_code_t	format,
517
	
381
			 uint32_t		pixel)
518
	r = ((p & 0x7c00) | ((p & 0x7000) >> 5)) << 9;
382
{
Line -... Line 383...
-
 
383
    uint32_t converted = convert_pixel_from_a8r8g8b8 (
519
	g = ((p & 0x03e0) | ((p & 0x0380) >> 5)) << 6;
384
	(pixman_image_t *)image, format, pixel);
-
 
385
 
520
	b = ((p & 0x001c) | ((p & 0x001f) << 5)) >> 2;
386
    switch (PIXMAN_FORMAT_BPP (format))
521
	
387
    {
Line -... Line 388...
-
 
388
    case 1:
522
	*buffer++ = 0xff000000 | r | g | b;
389
	STORE_1 (image, dest, offset, converted & 0x01);
523
    }
390
	break;
524
}
391
 
525
 
392
    case 4:
526
static void
393
	STORE_4 (image, dest, offset, converted & 0xf);
527
fetch_scanline_a1b5g5r5 (pixman_image_t *image,
394
	break;
528
                         int             x,
395
 
529
                         int             y,
396
    case 8:
-
 
397
	WRITE (image, (dest + offset), converted & 0xff);
530
                         int             width,
398
	break;
-
 
399
 
-
 
400
    case 16:
-
 
401
	WRITE (image, ((uint16_t *)dest + offset), converted & 0xffff);
-
 
402
	break;
-
 
403
 
-
 
404
    case 24:
-
 
405
	STORE_24 (image, dest, offset, converted);
-
 
406
	break;
-
 
407
 
-
 
408
    case 32:
531
                         uint32_t *      buffer,
409
	WRITE (image, ((uint32_t *)dest + offset), converted);
532
                         const uint32_t *mask)
410
	break;
533
{
-
 
534
    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
411
 
-
 
412
    default:
-
 
413
	*dest = 0x0;
535
    const uint16_t *pixel = (const uint16_t *)bits + x;
414
	break;
536
    const uint16_t *end = pixel + width;
415
    }
-
 
416
}
537
    uint32_t r, g, b, a;
417
 
538
    
418
#define MAKE_ACCESSORS(format)						\
539
    while (pixel < end)
419
    static void								\
-
 
420
    fetch_scanline_ ## format (pixman_image_t *image,			\
-
 
421
			       int	       x,			\
540
    {
422
			       int             y,			\
-
 
423
			       int             width,			\
-
 
424
			       uint32_t *      buffer,			\
-
 
425
			       const uint32_t *mask)			\
-
 
426
    {									\
-
 
427
	uint8_t *bits =							\
-
 
428
	    (uint8_t *)(image->bits.bits + y * image->bits.rowstride);	\
-
 
429
	int i;								\
-
 
430
									\
-
 
431
	for (i = 0; i < width; ++i)					\
541
	uint32_t p = READ (image, pixel++);
432
	{								\
542
	
433
	    *buffer++ =							\
-
 
434
		fetch_and_convert_pixel (image, bits, x + i, PIXMAN_ ## format); \
543
	a = (uint32_t) ((uint8_t) (0 - ((p & 0x8000) >> 15))) << 24;
435
	}								\
544
	b = ((p & 0x7c00) | ((p & 0x7000) >> 5)) >> 7;
436
    }									\
545
	g = ((p & 0x03e0) | ((p & 0x0380) >> 5)) << 6;
437
									\
-
 
438
    static void								\
Line -... Line 439...
-
 
439
    store_scanline_ ## format (bits_image_t *  image,			\
-
 
440
			       int             x,			\
546
	r = ((p & 0x001c) | ((p & 0x001f) << 5)) << 14;
441
			       int             y,			\
-
 
442
			       int             width,			\
-
 
443
			       const uint32_t *values)			\
-
 
444
    {									\
-
 
445
	uint8_t *dest =							\
-
 
446
	    (uint8_t *)(image->bits + y * image->rowstride);		\
-
 
447
	int i;								\
-
 
448
									\
-
 
449
	for (i = 0; i < width; ++i)					\
-
 
450
	{								\
-
 
451
	    convert_and_store_pixel (					\
-
 
452
		image, dest, i + x, PIXMAN_ ## format, values[i]);	\
-
 
453
	}								\
-
 
454
    }									\
-
 
455
									\
547
	
456
    static uint32_t							\
548
	*buffer++ = a | r | g | b;
457
    fetch_pixel_ ## format (bits_image_t *image,			\
549
    }
458
			    int		offset,				\
550
}
459
			    int		line)				\
-
 
460
    {									\
-
 
461
	uint8_t *bits =							\
-
 
462
	    (uint8_t *)(image->bits + line * image->rowstride);		\
-
 
463
									\
-
 
464
	return fetch_and_convert_pixel ((pixman_image_t *)image,	\
551
 
465
					bits, offset, PIXMAN_ ## format); \
552
static void
466
    }									\
-
 
467
									\
-
 
468
    static const void *const __dummy__ ## format
-
 
469
 
553
fetch_scanline_x1b5g5r5 (pixman_image_t *image,
470
MAKE_ACCESSORS(a8r8g8b8);
-
 
471
MAKE_ACCESSORS(x8r8g8b8);
554
                         int             x,
472
MAKE_ACCESSORS(a8b8g8r8);
555
                         int             y,
473
MAKE_ACCESSORS(x8b8g8r8);
556
                         int             width,
474
MAKE_ACCESSORS(x14r6g6b6);
-
 
475
MAKE_ACCESSORS(b8g8r8a8);
-
 
476
MAKE_ACCESSORS(b8g8r8x8);
Line -... Line 477...
-
 
477
MAKE_ACCESSORS(r8g8b8x8);
-
 
478
MAKE_ACCESSORS(r8g8b8a8);
-
 
479
MAKE_ACCESSORS(r8g8b8);
557
                         uint32_t *      buffer,
480
MAKE_ACCESSORS(b8g8r8);
-
 
481
MAKE_ACCESSORS(r5g6b5);
-
 
482
MAKE_ACCESSORS(b5g6r5);
558
                         const uint32_t *mask)
483
MAKE_ACCESSORS(a1r5g5b5);
-
 
484
MAKE_ACCESSORS(x1r5g5b5);
-
 
485
MAKE_ACCESSORS(a1b5g5r5);
-
 
486
MAKE_ACCESSORS(x1b5g5r5);
-
 
487
MAKE_ACCESSORS(a4r4g4b4);
-
 
488
MAKE_ACCESSORS(x4r4g4b4);
-
 
489
MAKE_ACCESSORS(a4b4g4r4);
-
 
490
MAKE_ACCESSORS(x4b4g4r4);
-
 
491
MAKE_ACCESSORS(a8);
-
 
492
MAKE_ACCESSORS(c8);
-
 
493
MAKE_ACCESSORS(g8);
-
 
494
MAKE_ACCESSORS(r3g3b2);
-
 
495
MAKE_ACCESSORS(b2g3r3);
-
 
496
MAKE_ACCESSORS(a2r2g2b2);
-
 
497
MAKE_ACCESSORS(a2b2g2r2);
-
 
498
MAKE_ACCESSORS(x4a4);
-
 
499
MAKE_ACCESSORS(a4);
-
 
500
MAKE_ACCESSORS(g4);
-
 
501
MAKE_ACCESSORS(c4);
-
 
502
MAKE_ACCESSORS(r1g2b1);
-
 
503
MAKE_ACCESSORS(b1g2r1);
-
 
504
MAKE_ACCESSORS(a1r1g1b1);
-
 
505
MAKE_ACCESSORS(a1b1g1r1);
-
 
506
MAKE_ACCESSORS(a1);
559
{
507
MAKE_ACCESSORS(g1);
-
 
508
 
-
 
509
/********************************** Fetch ************************************/
-
 
510
/* Table mapping sRGB-encoded 8 bit numbers to linearly encoded
-
 
511
 * floating point numbers. We assume that single precision
-
 
512
 * floating point follows the IEEE 754 format.
-
 
513
 */
-
 
514
static const uint32_t to_linear_u[256] =
-
 
515
{
-
 
516
    0x00000000, 0x399f22b4, 0x3a1f22b4, 0x3a6eb40e, 0x3a9f22b4, 0x3ac6eb61,
-
 
517
    0x3aeeb40e, 0x3b0b3e5d, 0x3b1f22b4, 0x3b33070b, 0x3b46eb61, 0x3b5b518a,
-
 
518
    0x3b70f18a, 0x3b83e1c5, 0x3b8fe614, 0x3b9c87fb, 0x3ba9c9b5, 0x3bb7ad6d,
-
 
519
    0x3bc63547, 0x3bd5635f, 0x3be539bd, 0x3bf5ba70, 0x3c0373b5, 0x3c0c6152,
-
 
520
    0x3c15a703, 0x3c1f45bc, 0x3c293e68, 0x3c3391f4, 0x3c3e4149, 0x3c494d43,
-
 
521
    0x3c54b6c7, 0x3c607eb1, 0x3c6ca5df, 0x3c792d22, 0x3c830aa8, 0x3c89af9e,
-
 
522
    0x3c9085db, 0x3c978dc5, 0x3c9ec7c0, 0x3ca63432, 0x3cadd37d, 0x3cb5a601,
-
 
523
    0x3cbdac20, 0x3cc5e639, 0x3cce54ab, 0x3cd6f7d2, 0x3cdfd00e, 0x3ce8ddb9,
-
 
524
    0x3cf2212c, 0x3cfb9ac1, 0x3d02a569, 0x3d0798dc, 0x3d0ca7e4, 0x3d11d2ae,
-
 
525
    0x3d171963, 0x3d1c7c2e, 0x3d21fb3a, 0x3d2796af, 0x3d2d4ebb, 0x3d332380,
560
    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
526
    0x3d39152b, 0x3d3f23e3, 0x3d454fd0, 0x3d4b991c, 0x3d51ffeb, 0x3d588466,
-
 
527
    0x3d5f26b7, 0x3d65e6fe, 0x3d6cc564, 0x3d73c210, 0x3d7add25, 0x3d810b65,
Line 561... Line 528...
561
    const uint16_t *pixel = (const uint16_t *)bits + x;
528
    0x3d84b793, 0x3d88732e, 0x3d8c3e48, 0x3d9018f4, 0x3d940343, 0x3d97fd48,
562
    const uint16_t *end = pixel + width;
-
 
563
    
-
 
564
    while (pixel < end)
-
 
Line 565... Line -...
565
    {
-
 
566
	uint32_t p = READ (image, pixel++);
-
 
567
	uint32_t r, g, b;
-
 
568
	
-
 
569
	b = ((p & 0x7c00) | ((p & 0x7000) >> 5)) >> 7;
529
    0x3d9c0714, 0x3da020b9, 0x3da44a48, 0x3da883d6, 0x3daccd70, 0x3db12728,
570
	g = ((p & 0x03e0) | ((p & 0x0380) >> 5)) << 6;
530
    0x3db59110, 0x3dba0b38, 0x3dbe95b2, 0x3dc3308f, 0x3dc7dbe0, 0x3dcc97b4,
571
	r = ((p & 0x001c) | ((p & 0x001f) << 5)) << 14;
-
 
572
	
-
 
573
	*buffer++ = 0xff000000 | r | g | b;
-
 
574
    }
-
 
575
}
-
 
576
 
531
    0x3dd1641c, 0x3dd6412a, 0x3ddb2eec, 0x3de02d75, 0x3de53cd3, 0x3dea5d16,
577
static void
-
 
578
fetch_scanline_a4r4g4b4 (pixman_image_t *image,
532
    0x3def8e52, 0x3df4d091, 0x3dfa23e5, 0x3dff885e, 0x3e027f06, 0x3e05427f,
579
                         int             x,
533
    0x3e080ea2, 0x3e0ae376, 0x3e0dc104, 0x3e10a752, 0x3e139669, 0x3e168e50,
Line 580... Line 534...
580
                         int             y,
534
    0x3e198f0e, 0x3e1c98ab, 0x3e1fab2e, 0x3e22c6a0, 0x3e25eb08, 0x3e29186a,
581
                         int             width,
535
    0x3e2c4ed0, 0x3e2f8e42, 0x3e32d6c4, 0x3e362861, 0x3e39831e, 0x3e3ce702,
582
                         uint32_t *      buffer,
536
    0x3e405416, 0x3e43ca5e, 0x3e4749e4, 0x3e4ad2ae, 0x3e4e64c2, 0x3e520027,
583
                         const uint32_t *mask)
-
 
584
{
-
 
585
    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
-
 
586
    const uint16_t *pixel = (const uint16_t *)bits + x;
-
 
587
    const uint16_t *end = pixel + width;
-
 
Line 588... Line 537...
588
    
537
    0x3e55a4e6, 0x3e595303, 0x3e5d0a8a, 0x3e60cb7c, 0x3e6495e0, 0x3e6869bf,
-
 
538
    0x3e6c4720, 0x3e702e08, 0x3e741e7f, 0x3e78188c, 0x3e7c1c34, 0x3e8014c0,
589
    while (pixel < end)
539
    0x3e822039, 0x3e84308b, 0x3e8645b8, 0x3e885fc3, 0x3e8a7eb0, 0x3e8ca281,
-
 
540
    0x3e8ecb3a, 0x3e90f8df, 0x3e932b72, 0x3e9562f6, 0x3e979f6f, 0x3e99e0e0,
590
    {
541
    0x3e9c274e, 0x3e9e72b8, 0x3ea0c322, 0x3ea31892, 0x3ea57308, 0x3ea7d28a,
Line 591... Line -...
591
	uint32_t p = READ (image, pixel++);
-
 
592
	uint32_t r, g, b, a;
-
 
593
	
-
 
594
	a = ((p & 0xf000) | ((p & 0xf000) >> 4)) << 16;
-
 
595
	r = ((p & 0x0f00) | ((p & 0x0f00) >> 4)) << 12;
542
    0x3eaa3718, 0x3eaca0b7, 0x3eaf0f69, 0x3eb18332, 0x3eb3fc16, 0x3eb67a15,
596
	g = ((p & 0x00f0) | ((p & 0x00f0) >> 4)) << 8;
-
 
597
	b = ((p & 0x000f) | ((p & 0x000f) << 4));
-
 
598
	
-
 
599
	*buffer++ = a | r | g | b;
-
 
600
    }
-
 
601
}
-
 
602
 
-
 
603
static void
543
    0x3eb8fd34, 0x3ebb8576, 0x3ebe12de, 0x3ec0a56e, 0x3ec33d2a, 0x3ec5da14,
604
fetch_scanline_x4r4g4b4 (pixman_image_t *image,
544
    0x3ec87c30, 0x3ecb2380, 0x3ecdd008, 0x3ed081ca, 0x3ed338c9, 0x3ed5f508,
605
                         int             x,
-
 
606
                         int             y,
545
    0x3ed8b68a, 0x3edb7d52, 0x3ede4962, 0x3ee11abe, 0x3ee3f168, 0x3ee6cd64,
607
                         int             width,
-
 
608
                         uint32_t *      buffer,
-
 
609
                         const uint32_t *mask)
-
 
610
{
-
 
611
    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
-
 
612
    const uint16_t *pixel = (const uint16_t *)bits + x;
-
 
613
    const uint16_t *end = pixel + width;
-
 
614
    
-
 
615
    while (pixel < end)
546
    0x3ee9aeb6, 0x3eec955d, 0x3eef815d, 0x3ef272ba, 0x3ef56976, 0x3ef86594,
Line 616... Line 547...
616
    {
547
    0x3efb6717, 0x3efe6e02, 0x3f00bd2b, 0x3f02460c, 0x3f03d1a5, 0x3f055ff8,
617
	uint32_t p = READ (image, pixel++);
548
    0x3f06f105, 0x3f0884ce, 0x3f0a1b54, 0x3f0bb499, 0x3f0d509f, 0x3f0eef65,
618
	uint32_t r, g, b;
549
    0x3f1090ef, 0x3f12353c, 0x3f13dc50, 0x3f15862a, 0x3f1732cc, 0x3f18e237,
619
	
550
    0x3f1a946d, 0x3f1c4970, 0x3f1e013f, 0x3f1fbbde, 0x3f21794c, 0x3f23398c,
620
	r = ((p & 0x0f00) | ((p & 0x0f00) >> 4)) << 12;
551
    0x3f24fca0, 0x3f26c286, 0x3f288b42, 0x3f2a56d3, 0x3f2c253d, 0x3f2df680,
621
	g = ((p & 0x00f0) | ((p & 0x00f0) >> 4)) << 8;
552
    0x3f2fca9d, 0x3f31a195, 0x3f337b6a, 0x3f35581e, 0x3f3737b1, 0x3f391a24,
622
	b = ((p & 0x000f) | ((p & 0x000f) << 4));
553
    0x3f3aff7a, 0x3f3ce7b2, 0x3f3ed2d0, 0x3f40c0d2, 0x3f42b1bc, 0x3f44a58e,
623
	
554
    0x3f469c49, 0x3f4895ee, 0x3f4a9280, 0x3f4c91ff, 0x3f4e946c, 0x3f5099c8,
624
	*buffer++ = 0xff000000 | r | g | b;
555
    0x3f52a216, 0x3f54ad55, 0x3f56bb88, 0x3f58ccae, 0x3f5ae0cb, 0x3f5cf7de,
625
    }
556
    0x3f5f11ec, 0x3f612ef0, 0x3f634eef, 0x3f6571ea, 0x3f6797e1, 0x3f69c0d6,
626
}
557
    0x3f6beccb, 0x3f6e1bc0, 0x3f704db6, 0x3f7282af, 0x3f74baac, 0x3f76f5ae,
-
 
558
    0x3f7933b6, 0x3f7b74c6, 0x3f7db8de, 0x3f800000
Line 627... Line 559...
627
 
559
};
628
static void
560
 
629
fetch_scanline_a4b4g4r4 (pixman_image_t *image,
561
static const float * const to_linear = (const float *)to_linear_u;
630
                         int             x,
562
 
631
                         int             y,
-
 
632
                         int             width,
-
 
633
                         uint32_t *      buffer,
-
 
634
                         const uint32_t *mask)
-
 
635
{
-
 
636
    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
-
 
637
    const uint16_t *pixel = (const uint16_t *)bits + x;
-
 
638
    const uint16_t *end = pixel + width;
-
 
639
    
-
 
640
    while (pixel < end)
-
 
641
    {
-
 
642
	uint32_t p = READ (image, pixel++);
-
 
643
	uint32_t r, g, b, a;
-
 
644
	
-
 
645
	a = ((p & 0xf000) | ((p & 0xf000) >> 4)) << 16;
-
 
646
	b = ((p & 0x0f00) | ((p & 0x0f00) >> 4)) >> 4;
-
 
647
	g = ((p & 0x00f0) | ((p & 0x00f0) >> 4)) << 8;
-
 
648
	r = ((p & 0x000f) | ((p & 0x000f) << 4)) << 16;
-
 
649
	
-
 
650
	*buffer++ = a | r | g | b;
-
 
651
    }
-
 
652
}
-
 
653
 
-
 
654
static void
-
 
Line 655... Line -...
655
fetch_scanline_x4b4g4r4 (pixman_image_t *image,
-
 
656
                         int             x,
-
 
657
                         int             y,
-
 
658
                         int             width,
-
 
659
                         uint32_t *      buffer,
-
 
660
                         const uint32_t *mask)
563
static uint8_t
661
{
-
 
662
    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
-
 
663
    const uint16_t *pixel = (const uint16_t *)bits + x;
-
 
664
    const uint16_t *end = pixel + width;
-
 
665
    
-
 
Line 666... Line 564...
666
    while (pixel < end)
564
to_srgb (float f)
667
    {
-
 
668
	uint32_t p = READ (image, pixel++);
565
{
669
	uint32_t r, g, b;
566
    uint8_t low = 0;
Line 670... Line -...
670
	
-
 
671
	b = ((p & 0x0f00) | ((p & 0x0f00) >> 4)) >> 4;
-
 
672
	g = ((p & 0x00f0) | ((p & 0x00f0) >> 4)) << 8;
-
 
673
	r = ((p & 0x000f) | ((p & 0x000f) << 4)) << 16;
-
 
674
	
-
 
675
	*buffer++ = 0xff000000 | r | g | b;
-
 
676
    }
-
 
677
}
567
    uint8_t high = 255;
678
 
568
 
679
static void
569
    while (high - low > 1)
Line -... Line 570...
-
 
570
    {
680
fetch_scanline_a8 (pixman_image_t *image,
571
	uint8_t mid = (low + high) / 2;
681
                   int             x,
572
 
682
                   int             y,
573
	if (to_linear[mid] > f)
683
                   int             width,
574
	    high = mid;
684
                   uint32_t *      buffer,
575
	else
685
                   const uint32_t *mask)
576
	    low = mid;
686
{
577
    }
687
    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
578
 
688
    const uint8_t *pixel = (const uint8_t *)bits + x;
579
    if (to_linear[high] - f < f - to_linear[low])
689
    const uint8_t *end = pixel + width;
580
	return high;
690
    
581
    else
-
 
582
	return low;
Line 691... Line 583...
691
    while (pixel < end)
583
}
692
	*buffer++ = READ (image, pixel++) << 24;
584
 
693
}
585
static void
694
 
586
fetch_scanline_a8r8g8b8_sRGB_float (pixman_image_t *image,
-
 
587
				    int             x,
-
 
588
				    int             y,
-
 
589
				    int             width,
Line 695... Line 590...
695
static void
590
				    uint32_t *      b,
696
fetch_scanline_r3g3b2 (pixman_image_t *image,
-
 
697
                       int             x,
-
 
698
                       int             y,
-
 
699
                       int             width,
-
 
700
                       uint32_t *      buffer,
591
				    const uint32_t *mask)
701
                       const uint32_t *mask)
-
 
702
{
-
 
703
    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
-
 
704
    const uint8_t *pixel = (const uint8_t *)bits + x;
-
 
705
    const uint8_t *end = pixel + width;
592
{
706
    
-
 
707
    while (pixel < end)
-
 
708
    {
593
    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
Line 709... Line 594...
709
	uint32_t p = READ (image, pixel++);
594
    const uint32_t *pixel = bits + x;
710
	uint32_t r, g, b;
595
    const uint32_t *end = pixel + width;
711
	
596
    argb_t *buffer = (argb_t *)b;
Line -... Line 597...
-
 
597
 
712
	r = ((p & 0xe0) | ((p & 0xe0) >> 3) | ((p & 0xc0) >> 6)) << 16;
598
    while (pixel < end)
713
	g = ((p & 0x1c) | ((p & 0x18) >> 3) | ((p & 0x1c) << 3)) << 8;
599
    {
714
	b = (((p & 0x03)     ) |
600
	uint32_t p = READ (image, pixel++);
715
	     ((p & 0x03) << 2) |
601
	argb_t *argb = buffer;
716
	     ((p & 0x03) << 4) |
602
 
717
	     ((p & 0x03) << 6));
603
	argb->a = pixman_unorm_to_float ((p >> 24) & 0xff, 8);
718
	
604
 
719
	*buffer++ = 0xff000000 | r | g | b;
605
	argb->r = to_linear [(p >> 16) & 0xff];
720
    }
606
	argb->g = to_linear [(p >>  8) & 0xff];
721
}
607
	argb->b = to_linear [(p >>  0) & 0xff];
722
 
608
 
-
 
609
	buffer++;
Line 723... Line 610...
723
static void
610
    }
724
fetch_scanline_b2g3r3 (pixman_image_t *image,
611
}
725
                       int             x,
612
 
-
 
613
/* Expects a float buffer */
-
 
614
static void
726
                       int             y,
615
fetch_scanline_a2r10g10b10_float (pixman_image_t *image,
Line 727... Line 616...
727
                       int             width,
616
				  int             x,
728
                       uint32_t *      buffer,
617
				  int             y,
729
                       const uint32_t *mask)
618
				  int             width,
730
{
619
				  uint32_t *      b,
Line 731... Line 620...
731
    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
620
				  const uint32_t *mask)
732
    const uint8_t *pixel = (const uint8_t *)bits + x;
621
{
733
    const uint8_t *end = pixel + width;
622
    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
Line -... Line 623...
-
 
623
    const uint32_t *pixel = bits + x;
734
 
624
    const uint32_t *end = pixel + width;
735
    while (pixel < end)
625
    argb_t *buffer = (argb_t *)b;
736
    {
626
 
737
	uint32_t p = READ (image, pixel++);
627
    while (pixel < end)
738
	uint32_t r, g, b;
628
    {
739
 
629
	uint32_t p = READ (image, pixel++);
740
	b  = p & 0xc0;
630
	uint64_t a = p >> 30;
741
	b |= b >> 2;
631
	uint64_t r = (p >> 20) & 0x3ff;
742
	b |= b >> 4;
632
	uint64_t g = (p >> 10) & 0x3ff;
743
	b &= 0xff;
633
	uint64_t b = p & 0x3ff;
744
 
634
 
-
 
635
	buffer->a = pixman_unorm_to_float (a, 2);
Line 745... Line 636...
745
	g  = (p & 0x38) << 10;
636
	buffer->r = pixman_unorm_to_float (r, 10);
746
	g |= g >> 3;
637
	buffer->g = pixman_unorm_to_float (g, 10);
747
	g |= g >> 6;
638
	buffer->b = pixman_unorm_to_float (b, 10);
748
	g &= 0xff00;
639
 
-
 
640
	buffer++;
-
 
641
    }
-
 
642
}
Line 749... Line 643...
749
 
643
 
750
	r  = (p & 0x7) << 21;
644
/* Expects a float buffer */
751
	r |= r >> 3;
645
static void
752
	r |= r >> 6;
646
fetch_scanline_x2r10g10b10_float (pixman_image_t *image,
Line 753... Line 647...
753
	r &= 0xff0000;
647
				  int             x,
754
 
648
				  int             y,
755
	*buffer++ = 0xff000000 | r | g | b;
649
				  int             width,
Line -... Line 650...
-
 
650
				  uint32_t *      b,
756
    }
651
				  const uint32_t *mask)
757
}
652
{
758
 
653
    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
759
static void
654
    const uint32_t *pixel = (uint32_t *)bits + x;
760
fetch_scanline_a2r2g2b2 (pixman_image_t *image,
655
    const uint32_t *end = pixel + width;
761
                         int             x,
656
    argb_t *buffer = (argb_t *)b;
762
                         int             y,
657
 
763
                         int             width,
658
    while (pixel < end)
764
                         uint32_t *      buffer,
659
    {
765
                         const uint32_t *mask)
-
 
766
{
660
	uint32_t p = READ (image, pixel++);
767
    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
661
	uint64_t r = (p >> 20) & 0x3ff;
-
 
662
	uint64_t g = (p >> 10) & 0x3ff;
Line 768... Line 663...
768
    const uint8_t *pixel = (const uint8_t *)bits + x;
663
	uint64_t b = p & 0x3ff;
769
    const uint8_t *end = pixel + width;
664
 
770
    
665
	buffer->a = 1.0;
-
 
666
	buffer->r = pixman_unorm_to_float (r, 10);
-
 
667
	buffer->g = pixman_unorm_to_float (g, 10);
-
 
668
	buffer->b = pixman_unorm_to_float (b, 10);
Line 771... Line -...
771
    while (pixel < end)
-
 
772
    {
-
 
773
	uint32_t p = READ (image, pixel++);
-
 
774
	uint32_t a, r, g, b;
-
 
775
	
-
 
776
	a = ((p & 0xc0) * 0x55) << 18;
-
 
777
	r = ((p & 0x30) * 0x55) << 12;
-
 
778
	g = ((p & 0x0c) * 0x55) << 6;
-
 
779
	b = ((p & 0x03) * 0x55);
-
 
780
	
-
 
781
	*buffer++ = a | r | g | b;
-
 
782
    }
-
 
783
}
-
 
784
 
-
 
785
static void
-
 
786
fetch_scanline_a2b2g2r2 (pixman_image_t *image,
-
 
787
                         int             x,
-
 
788
                         int             y,
-
 
789
                         int             width,
-
 
790
                         uint32_t *      buffer,
-
 
791
                         const uint32_t *mask)
-
 
792
{
-
 
793
    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
-
 
794
    const uint8_t *pixel = (const uint8_t *)bits + x;
-
 
795
    const uint8_t *end = pixel + width;
-
 
796
    
-
 
797
    while (pixel < end)
-
 
798
    {
-
 
799
	uint32_t p = READ (image, pixel++);
-
 
800
	uint32_t a, r, g, b;
-
 
801
	
-
 
802
	a = ((p & 0xc0) * 0x55) << 18;
-
 
803
	b = ((p & 0x30) * 0x55) >> 4;
-
 
804
	g = ((p & 0x0c) * 0x55) << 6;
-
 
805
	r = ((p & 0x03) * 0x55) << 16;
-
 
806
	
-
 
807
	*buffer++ = a | r | g | b;
-
 
808
    }
-
 
809
}
-
 
810
 
-
 
811
static void
-
 
812
fetch_scanline_c8 (pixman_image_t *image,
-
 
813
                   int             x,
-
 
814
                   int             y,
-
 
815
                   int             width,
-
 
816
                   uint32_t *      buffer,
-
 
817
                   const uint32_t *mask)
-
 
818
{
-
 
819
    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
-
 
820
    const pixman_indexed_t * indexed = image->bits.indexed;
-
 
821
    const uint8_t *pixel = (const uint8_t *)bits + x;
669
 
822
    const uint8_t *end = pixel + width;
-
 
823
    
-
 
824
    while (pixel < end)
-
 
825
    {
-
 
826
	uint32_t p = READ (image, pixel++);
-
 
827
	
-
 
828
	*buffer++ = indexed->rgba[p];
-
 
829
    }
-
 
830
}
-
 
831
 
-
 
832
static void
-
 
833
fetch_scanline_x4a4 (pixman_image_t *image,
-
 
834
                     int             x,
-
 
835
                     int             y,
-
 
836
                     int             width,
-
 
837
                     uint32_t *      buffer,
-
 
838
                     const uint32_t *mask)
670
	buffer++;
839
{
-
 
840
    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
-
 
841
    const uint8_t *pixel = (const uint8_t *)bits + x;
-
 
842
    const uint8_t *end = pixel + width;
-
 
843
   
-
 
844
    while (pixel < end)
-
 
845
    {
671
    }
846
	uint8_t p = READ (image, pixel++) & 0xf;
-
 
847
 
-
 
848
	*buffer++ = (p | (p << 4)) << 24;
-
 
849
    }
-
 
850
}
-
 
851
 
-
 
852
#define FETCH_8(img,l,o)    (READ (img, (((uint8_t *)(l)) + ((o) >> 3))))
-
 
853
#ifdef WORDS_BIGENDIAN
-
 
854
#define FETCH_4(img,l,o)						\
-
 
855
    (((4 * (o)) & 4) ? (FETCH_8 (img,l, 4 * (o)) & 0xf) : (FETCH_8 (img,l,(4 * (o))) >> 4))
-
 
856
#else
-
 
857
#define FETCH_4(img,l,o)						\
-
 
858
    (((4 * (o)) & 4) ? (FETCH_8 (img, l, 4 * (o)) >> 4) : (FETCH_8 (img, l, (4 * (o))) & 0xf))
-
 
859
#endif
-
 
860
 
-
 
861
static void
-
 
862
fetch_scanline_a4 (pixman_image_t *image,
-
 
863
                   int             x,
-
 
864
                   int             y,
-
 
865
                   int             width,
-
 
866
                   uint32_t *      buffer,
-
 
867
                   const uint32_t *mask)
-
 
868
{
-
 
869
    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
672
}
870
    int i;
-
 
871
 
-
 
872
    for (i = 0; i < width; ++i)
-
 
873
    {
-
 
874
	uint32_t p = FETCH_4 (image, bits, i + x);
-
 
875
 
-
 
876
	p |= p << 4;
-
 
877
 
-
 
878
	*buffer++ = p << 24;
-
 
879
    }
-
 
880
}
-
 
881
 
-
 
882
static void
-
 
883
fetch_scanline_r1g2b1 (pixman_image_t *image,
-
 
884
                       int             x,
-
 
885
                       int             y,
-
 
886
                       int             width,
-
 
887
                       uint32_t *      buffer,
-
 
888
                       const uint32_t *mask)
-
 
889
{
-
 
890
    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
-
 
891
    int i;
-
 
892
    
-
 
893
    for (i = 0; i < width; ++i)
-
 
894
    {
-
 
895
	uint32_t p = FETCH_4 (image, bits, i + x);
-
 
896
	uint32_t r, g, b;
-
 
897
	
-
 
898
	r = ((p & 0x8) * 0xff) << 13;
-
 
899
	g = ((p & 0x6) * 0x55) << 7;
-
 
900
	b = ((p & 0x1) * 0xff);
-
 
901
	
-
 
902
	*buffer++ = 0xff000000 | r | g | b;
-
 
903
    }
-
 
904
}
-
 
905
 
-
 
906
static void
-
 
907
fetch_scanline_b1g2r1 (pixman_image_t *image,
-
 
908
                       int             x,
-
 
909
                       int             y,
-
 
910
                       int             width,
-
 
911
                       uint32_t *      buffer,
-
 
912
                       const uint32_t *mask)
-
 
913
{
-
 
914
    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
-
 
915
    int i;
-
 
916
    
-
 
917
    for (i = 0; i < width; ++i)
-
 
918
    {
-
 
919
	uint32_t p = FETCH_4 (image, bits, i + x);
-
 
920
	uint32_t r, g, b;
-
 
921
	
-
 
922
	b = ((p & 0x8) * 0xff) >> 3;
-
 
923
	g = ((p & 0x6) * 0x55) << 7;
-
 
924
	r = ((p & 0x1) * 0xff) << 16;
-
 
925
 
-
 
926
	*buffer++ = 0xff000000 | r | g | b;
-
 
927
    }
-
 
928
}
-
 
929
 
-
 
930
static void
-
 
931
fetch_scanline_a1r1g1b1 (pixman_image_t *image,
-
 
932
                         int             x,
-
 
933
                         int             y,
-
 
934
                         int             width,
-
 
935
                         uint32_t *      buffer,
-
 
936
                         const uint32_t *mask)
-
 
937
{
-
 
938
    uint32_t a, r, g, b;
-
 
939
    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
-
 
940
    int i;
-
 
941
 
-
 
942
    for (i = 0; i < width; ++i)
-
 
943
    {
-
 
944
	uint32_t p = FETCH_4 (image, bits, i + x);
-
 
945
 
-
 
946
	a = ((p & 0x8) * 0xff) << 21;
-
 
947
	r = ((p & 0x4) * 0xff) << 14;
-
 
948
	g = ((p & 0x2) * 0xff) << 7;
-
 
949
	b = ((p & 0x1) * 0xff);
-
 
950
 
-
 
951
	*buffer++ = a | r | g | b;
-
 
952
    }
-
 
953
}
-
 
954
 
-
 
955
static void
-
 
956
fetch_scanline_a1b1g1r1 (pixman_image_t *image,
-
 
957
                         int             x,
-
 
958
                         int             y,
-
 
959
                         int             width,
-
 
960
                         uint32_t *      buffer,
-
 
961
                         const uint32_t *mask)
-
 
962
{
-
 
963
    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
-
 
964
    int i;
-
 
965
 
-
 
966
    for (i = 0; i < width; ++i)
-
 
967
    {
-
 
968
	uint32_t p = FETCH_4 (image, bits, i + x);
-
 
969
	uint32_t a, r, g, b;
-
 
970
 
-
 
971
	a = ((p & 0x8) * 0xff) << 21;
-
 
972
	b = ((p & 0x4) * 0xff) >> 2;
-
 
973
	g = ((p & 0x2) * 0xff) << 7;
-
 
974
	r = ((p & 0x1) * 0xff) << 16;
-
 
975
 
-
 
976
	*buffer++ = a | r | g | b;
-
 
977
    }
-
 
978
}
-
 
979
 
-
 
980
static void
-
 
981
fetch_scanline_c4 (pixman_image_t *image,
-
 
982
                   int             x,
-
 
983
                   int             y,
-
 
984
                   int             width,
-
 
985
                   uint32_t *      buffer,
-
 
986
                   const uint32_t *mask)
-
 
987
{
-
 
988
    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
-
 
989
    const pixman_indexed_t * indexed = image->bits.indexed;
-
 
990
    int i;
-
 
991
    
-
 
992
    for (i = 0; i < width; ++i)
-
 
993
    {
-
 
994
	uint32_t p = FETCH_4 (image, bits, i + x);
-
 
995
	
-
 
Line 996... Line 673...
996
	*buffer++ = indexed->rgba[p];
673
 
997
    }
674
/* Expects a float buffer */
998
}
675
static void
Line 999... Line 676...
999
 
676
fetch_scanline_a2b10g10r10_float (pixman_image_t *image,
1000
static void
677
				  int             x,
Line 1126... Line 803...
1126
    }
803
    }
1127
}
804
}
Line 1128... Line 805...
1128
 
805
 
Line 1129... Line -...
1129
/**************************** Pixel wise fetching *****************************/
-
 
1130
 
806
/**************************** Pixel wise fetching *****************************/
1131
/* Despite the type, expects a uint64_t buffer */
807
 
1132
static uint64_t
808
static argb_t
1133
fetch_pixel_a2r10g10b10 (bits_image_t *image,
809
fetch_pixel_x2r10g10b10_float (bits_image_t *image,
1134
			 int		  offset,
810
			       int	   offset,
1135
			 int           line)
811
			       int           line)
1136
{
812
{
1137
    uint32_t *bits = image->bits + line * image->rowstride;
-
 
1138
    uint32_t p = READ (image, bits + offset);
813
    uint32_t *bits = image->bits + line * image->rowstride;
1139
    uint64_t a = p >> 30;
814
    uint32_t p = READ (image, bits + offset);
1140
    uint64_t r = (p >> 20) & 0x3ff;
815
    uint64_t r = (p >> 20) & 0x3ff;
-
 
816
    uint64_t g = (p >> 10) & 0x3ff;
Line 1141... Line 817...
1141
    uint64_t g = (p >> 10) & 0x3ff;
817
    uint64_t b = p & 0x3ff;
1142
    uint64_t b = p & 0x3ff;
818
    argb_t argb;
-
 
819
 
1143
 
820
    argb.a = 1.0;
Line 1144... Line -...
1144
    r = r << 6 | r >> 4;
-
 
1145
    g = g << 6 | g >> 4;
-
 
1146
    b = b << 6 | b >> 4;
821
    argb.r = pixman_unorm_to_float (r, 10);
1147
 
-
 
1148
    a <<= 14;
-
 
1149
    a |= a >> 2;
-
 
1150
    a |= a >> 4;
822
    argb.g = pixman_unorm_to_float (g, 10);
Line 1151... Line -...
1151
    a |= a >> 8;
-
 
1152
 
823
    argb.b = pixman_unorm_to_float (b, 10);
1153
    return a << 48 | r << 32 | g << 16 | b;
824
 
1154
}
825
    return argb;
1155
 
826
}
1156
/* Despite the type, this function expects a uint64_t buffer */
827
 
1157
static uint64_t
828
static argb_t
1158
fetch_pixel_x2r10g10b10 (bits_image_t *image,
829
fetch_pixel_a2r10g10b10_float (bits_image_t *image,
-
 
830
			       int	     offset,
1159
			 int	   offset,
831
			       int           line)
1160
			 int           line)
832
{
1161
{
833
    uint32_t *bits = image->bits + line * image->rowstride;
-
 
834
    uint32_t p = READ (image, bits + offset);
Line 1162... Line 835...
1162
    uint32_t *bits = image->bits + line * image->rowstride;
835
    uint64_t a = p >> 30;
-
 
836
    uint64_t r = (p >> 20) & 0x3ff;
1163
    uint32_t p = READ (image, bits + offset);
837
    uint64_t g = (p >> 10) & 0x3ff;
1164
    uint64_t r = (p >> 20) & 0x3ff;
838
    uint64_t b = p & 0x3ff;
Line 1165... Line 839...
1165
    uint64_t g = (p >> 10) & 0x3ff;
839
    argb_t argb;
1166
    uint64_t b = p & 0x3ff;
840
 
Line 1167... Line -...
1167
    
-
 
1168
    r = r << 6 | r >> 4;
841
    argb.a = pixman_unorm_to_float (a, 2);
1169
    g = g << 6 | g >> 4;
842
    argb.r = pixman_unorm_to_float (r, 10);
1170
    b = b << 6 | b >> 4;
843
    argb.g = pixman_unorm_to_float (g, 10);
1171
    
844
    argb.b = pixman_unorm_to_float (b, 10);
1172
    return 0xffffULL << 48 | r << 32 | g << 16 | b;
845
 
1173
}
846
    return argb;
1174
 
847
}
1175
/* Despite the type, expects a uint64_t buffer */
848
 
1176
static uint64_t
849
static argb_t
1177
fetch_pixel_a2b10g10r10 (bits_image_t *image,
850
fetch_pixel_a2b10g10r10_float (bits_image_t *image,
1178
			 int           offset,
851
			       int           offset,
-
 
852
			       int           line)
Line 1179... Line 853...
1179
			 int           line)
853
{
1180
{
854
    uint32_t *bits = image->bits + line * image->rowstride;
1181
    uint32_t *bits = image->bits + line * image->rowstride;
855
    uint32_t p = READ (image, bits + offset);
1182
    uint32_t p = READ (image, bits + offset);
-
 
1183
    uint64_t a = p >> 30;
-
 
1184
    uint64_t b = (p >> 20) & 0x3ff;
856
    uint64_t a = p >> 30;
1185
    uint64_t g = (p >> 10) & 0x3ff;
-
 
1186
    uint64_t r = p & 0x3ff;
-
 
Line 1187... Line 857...
1187
    
857
    uint64_t b = (p >> 20) & 0x3ff;
1188
    r = r << 6 | r >> 4;
858
    uint64_t g = (p >> 10) & 0x3ff;
Line 1189... Line -...
1189
    g = g << 6 | g >> 4;
-
 
1190
    b = b << 6 | b >> 4;
859
    uint64_t r = p & 0x3ff;
1191
    
860
    argb_t argb;
1192
    a <<= 14;
861
 
1193
    a |= a >> 2;
862
    argb.a = pixman_unorm_to_float (a, 2);
1194
    a |= a >> 4;
863
    argb.r = pixman_unorm_to_float (r, 10);
1195
    a |= a >> 8;
864
    argb.g = pixman_unorm_to_float (g, 10);
1196
    
865
    argb.b = pixman_unorm_to_float (b, 10);
1197
    return a << 48 | r << 32 | g << 16 | b;
866
 
1198
}
867
    return argb;
1199
 
868
}
-
 
869
 
Line 1200... Line -...
1200
/* Despite the type, this function expects a uint64_t buffer */
-
 
1201
static uint64_t
-
 
1202
fetch_pixel_x2b10g10r10 (bits_image_t *image,
870
static argb_t
1203
			 int           offset,
-
 
1204
			 int           line)
-
 
1205
{
-
 
1206
    uint32_t *bits = image->bits + line * image->rowstride;
-
 
1207
    uint32_t p = READ (image, bits + offset);
-
 
1208
    uint64_t b = (p >> 20) & 0x3ff;
-
 
1209
    uint64_t g = (p >> 10) & 0x3ff;
-
 
1210
    uint64_t r = p & 0x3ff;
-
 
1211
    
-
 
1212
    r = r << 6 | r >> 4;
-
 
1213
    g = g << 6 | g >> 4;
871
fetch_pixel_x2b10g10r10_float (bits_image_t *image,
1214
    b = b << 6 | b >> 4;
-
 
1215
    
-
 
1216
    return 0xffffULL << 48 | r << 32 | g << 16 | b;
-
 
1217
}
-
 
1218
 
-
 
1219
static uint32_t
-
 
1220
fetch_pixel_a8r8g8b8 (bits_image_t *image,
-
 
1221
		      int           offset,
-
 
1222
		      int           line)
-
 
1223
{
-
 
1224
    uint32_t *bits = image->bits + line * image->rowstride;
-
 
1225
    return READ (image, (uint32_t *)bits + offset);
-
 
1226
}
-
 
1227
 
-
 
1228
static uint32_t
-
 
1229
fetch_pixel_x8r8g8b8 (bits_image_t *image,
-
 
1230
		      int           offset,
-
 
1231
		      int           line)
-
 
1232
{
-
 
1233
    uint32_t *bits = image->bits + line * image->rowstride;
-
 
1234
 
872
			       int           offset,
1235
    return READ (image, (uint32_t *)bits + offset) | 0xff000000;
-
 
1236
}
-
 
1237
 
-
 
1238
static uint32_t
-
 
1239
fetch_pixel_a8b8g8r8 (bits_image_t *image,
-
 
1240
		      int           offset,
-
 
1241
		      int           line)
-
 
1242
{
-
 
1243
    uint32_t *bits = image->bits + line * image->rowstride;
-
 
1244
    uint32_t pixel = READ (image, (uint32_t *)bits + offset);
-
 
1245
    
-
 
1246
    return ((pixel & 0xff000000) |
873
			       int           line)
1247
	    ((pixel >> 16) & 0xff) |
-
 
1248
	    (pixel & 0x0000ff00) |
-
 
1249
	    ((pixel & 0xff) << 16));
-
 
1250
}
-
 
1251
 
-
 
1252
static uint32_t
-
 
Line 1253... Line 874...
1253
fetch_pixel_x8b8g8r8 (bits_image_t *image,
874
{
1254
		      int           offset,
-
 
1255
		      int           line)
-
 
1256
{
-
 
1257
    uint32_t *bits = image->bits + line * image->rowstride;
-
 
1258
    uint32_t pixel = READ (image, (uint32_t *)bits + offset);
-
 
1259
    
-
 
1260
    return ((0xff000000) |
-
 
1261
	    ((pixel >> 16) & 0xff) |
-
 
1262
	    (pixel & 0x0000ff00) |
-
 
1263
	    ((pixel & 0xff) << 16));
-
 
1264
}
-
 
1265
 
875
    uint32_t *bits = image->bits + line * image->rowstride;
Line 1266... Line 876...
1266
static uint32_t
876
    uint32_t p = READ (image, bits + offset);
1267
fetch_pixel_b8g8r8a8 (bits_image_t *image,
877
    uint64_t b = (p >> 20) & 0x3ff;
1268
		      int           offset,
878
    uint64_t g = (p >> 10) & 0x3ff;
1269
		      int           line)
879
    uint64_t r = p & 0x3ff;
1270
{
880
    argb_t argb;
1271
    uint32_t *bits = image->bits + line * image->rowstride;
881
 
1272
    uint32_t pixel = READ (image, (uint32_t *)bits + offset);
-
 
1273
    
-
 
1274
    return ((pixel & 0xff000000) >> 24 |
-
 
1275
	    (pixel & 0x00ff0000) >> 8 |
-
 
1276
	    (pixel & 0x0000ff00) << 8 |
-
 
1277
	    (pixel & 0x000000ff) << 24);
-
 
1278
}
-
 
1279
 
-
 
1280
static uint32_t
-
 
1281
fetch_pixel_b8g8r8x8 (bits_image_t *image,
-
 
1282
		      int           offset,
-
 
1283
		      int           line)
-
 
1284
{
-
 
1285
    uint32_t *bits = image->bits + line * image->rowstride;
-
 
1286
    uint32_t pixel = READ (image, (uint32_t *)bits + offset);
-
 
1287
    
-
 
1288
    return ((0xff000000) |
-
 
1289
	    (pixel & 0xff000000) >> 24 |
-
 
1290
	    (pixel & 0x00ff0000) >> 8 |
-
 
1291
	    (pixel & 0x0000ff00) << 8);
-
 
1292
}
-
 
1293
 
-
 
1294
static uint32_t
-
 
1295
fetch_pixel_x14r6g6b6 (bits_image_t *image,
-
 
1296
                       int           offset,
-
 
1297
                       int           line)
-
 
1298
{
-
 
1299
    uint32_t *bits = image->bits + line * image->rowstride;
-
 
1300
    uint32_t pixel = READ (image, (uint32_t *) bits + offset);
-
 
1301
    uint32_t r, g, b;
-
 
1302
 
-
 
1303
    r = ((pixel & 0x3f000) << 6) | ((pixel & 0x30000));
-
 
1304
    g = ((pixel & 0x00fc0) << 4) | ((pixel & 0x00c00) >> 2);
-
 
1305
    b = ((pixel & 0x0003f) << 2) | ((pixel & 0x00030) >> 4);
-
 
1306
 
-
 
1307
    return 0xff000000 | r | g | b;
-
 
1308
}
-
 
1309
 
-
 
1310
static uint32_t
-
 
1311
fetch_pixel_r8g8b8 (bits_image_t *image,
-
 
1312
		    int           offset,
-
 
1313
		    int           line)
-
 
1314
{
-
 
1315
    uint32_t *bits = image->bits + line * image->rowstride;
-
 
1316
    uint8_t   *pixel = ((uint8_t *) bits) + (offset * 3);
-
 
1317
    
-
 
1318
#ifdef WORDS_BIGENDIAN
-
 
1319
    return (0xff000000 |
-
 
1320
	    (READ (image, pixel + 0) << 16) |
-
 
1321
	    (READ (image, pixel + 1) << 8) |
-
 
1322
	    (READ (image, pixel + 2)));
-
 
1323
#else
-
 
1324
    return (0xff000000 |
-
 
1325
	    (READ (image, pixel + 2) << 16) |
-
 
1326
	    (READ (image, pixel + 1) << 8) |
-
 
1327
	    (READ (image, pixel + 0)));
-
 
1328
#endif
-
 
1329
}
-
 
1330
 
-
 
1331
static uint32_t
-
 
1332
fetch_pixel_b8g8r8 (bits_image_t *image,
-
 
1333
		    int           offset,
-
 
1334
		    int           line)
-
 
1335
{
-
 
1336
    uint32_t *bits = image->bits + line * image->rowstride;
-
 
1337
    uint8_t   *pixel = ((uint8_t *) bits) + (offset * 3);
-
 
1338
#ifdef WORDS_BIGENDIAN
-
 
1339
    return (0xff000000 |
-
 
1340
	    (READ (image, pixel + 2) << 16) |
-
 
1341
	    (READ (image, pixel + 1) << 8) |
-
 
1342
	    (READ (image, pixel + 0)));
-
 
1343
#else
-
 
1344
    return (0xff000000 |
-
 
1345
	    (READ (image, pixel + 0) << 16) |
-
 
1346
	    (READ (image, pixel + 1) << 8) |
-
 
1347
	    (READ (image, pixel + 2)));
-
 
1348
#endif
-
 
1349
}
-
 
1350
 
-
 
1351
static uint32_t
-
 
1352
fetch_pixel_r5g6b5 (bits_image_t *image,
-
 
1353
		    int           offset,
-
 
1354
		    int           line)
-
 
1355
{
-
 
1356
    uint32_t *bits = image->bits + line * image->rowstride;
-
 
1357
    uint32_t pixel = READ (image, (uint16_t *) bits + offset);
-
 
1358
    uint32_t r, g, b;
-
 
1359
    
-
 
1360
    r = ((pixel & 0xf800) | ((pixel & 0xe000) >> 5)) << 8;
-
 
1361
    g = ((pixel & 0x07e0) | ((pixel & 0x0600) >> 6)) << 5;
-
 
1362
    b = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) >> 2;
-
 
1363
    
-
 
1364
    return (0xff000000 | r | g | b);
-
 
1365
}
-
 
1366
 
-
 
1367
static uint32_t
-
 
1368
fetch_pixel_b5g6r5 (bits_image_t *image,
-
 
1369
		    int           offset,
-
 
1370
		    int           line)
-
 
1371
{
-
 
1372
    uint32_t r, g, b;
-
 
1373
    uint32_t *bits = image->bits + line * image->rowstride;
-
 
1374
    uint32_t pixel = READ (image, (uint16_t *) bits + offset);
-
 
1375
    
-
 
1376
    b = ((pixel & 0xf800) | ((pixel & 0xe000) >> 5)) >> 8;
-
 
1377
    g = ((pixel & 0x07e0) | ((pixel & 0x0600) >> 6)) << 5;
-
 
1378
    r = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) << 14;
-
 
1379
    
-
 
1380
    return (0xff000000 | r | g | b);
-
 
1381
}
-
 
1382
 
-
 
1383
static uint32_t
-
 
1384
fetch_pixel_a1r5g5b5 (bits_image_t *image,
-
 
1385
		      int           offset,
-
 
1386
		      int           line)
-
 
1387
{
-
 
1388
    uint32_t *bits = image->bits + line * image->rowstride;
-
 
1389
    uint32_t pixel = READ (image, (uint16_t *) bits + offset);
-
 
1390
    uint32_t a, r, g, b;
-
 
1391
    
-
 
1392
    a = (uint32_t) ((uint8_t) (0 - ((pixel & 0x8000) >> 15))) << 24;
-
 
1393
    r = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) << 9;
-
 
1394
    g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6;
-
 
1395
    b = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) >> 2;
-
 
1396
    
-
 
1397
    return (a | r | g | b);
-
 
1398
}
-
 
1399
 
-
 
1400
static uint32_t
-
 
1401
fetch_pixel_x1r5g5b5 (bits_image_t *image,
-
 
1402
		      int           offset,
-
 
1403
		      int           line)
-
 
1404
{
-
 
1405
    uint32_t *bits = image->bits + line * image->rowstride;
-
 
1406
    uint32_t pixel = READ (image, (uint16_t *) bits + offset);
-
 
1407
    uint32_t r, g, b;
-
 
1408
    
-
 
1409
    r = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) << 9;
-
 
1410
    g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6;
-
 
1411
    b = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) >> 2;
-
 
1412
    
-
 
1413
    return (0xff000000 | r | g | b);
-
 
1414
}
-
 
1415
 
-
 
1416
static uint32_t
-
 
1417
fetch_pixel_a1b5g5r5 (bits_image_t *image,
-
 
1418
		      int           offset,
-
 
1419
		      int           line)
-
 
1420
{
-
 
1421
    uint32_t *bits = image->bits + line * image->rowstride;
-
 
1422
    uint32_t pixel = READ (image, (uint16_t *) bits + offset);
-
 
1423
    uint32_t a, r, g, b;
-
 
1424
    
-
 
1425
    a = (uint32_t) ((uint8_t) (0 - ((pixel & 0x8000) >> 15))) << 24;
-
 
1426
    b = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) >> 7;
-
 
1427
    g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6;
-
 
1428
    r = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) << 14;
-
 
1429
    
-
 
1430
    return (a | r | g | b);
-
 
1431
}
-
 
1432
 
-
 
1433
static uint32_t
-
 
1434
fetch_pixel_x1b5g5r5 (bits_image_t *image,
-
 
1435
		      int           offset,
-
 
1436
		      int           line)
-
 
1437
{
-
 
1438
    uint32_t *bits = image->bits + line * image->rowstride;
-
 
1439
    uint32_t pixel = READ (image, (uint16_t *) bits + offset);
-
 
1440
    uint32_t r, g, b;
-
 
1441
    
-
 
1442
    b = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) >> 7;
-
 
1443
    g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6;
-
 
1444
    r = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) << 14;
-
 
1445
    
-
 
1446
    return (0xff000000 | r | g | b);
-
 
1447
}
-
 
1448
 
-
 
1449
static uint32_t
-
 
1450
fetch_pixel_a4r4g4b4 (bits_image_t *image,
-
 
1451
		      int           offset,
-
 
1452
		      int           line)
-
 
1453
{
-
 
1454
    uint32_t *bits = image->bits + line * image->rowstride;
-
 
1455
    uint32_t pixel = READ (image, (uint16_t *) bits + offset);
-
 
1456
    uint32_t a, r, g, b;
-
 
1457
    
-
 
1458
    a = ((pixel & 0xf000) | ((pixel & 0xf000) >> 4)) << 16;
-
 
1459
    r = ((pixel & 0x0f00) | ((pixel & 0x0f00) >> 4)) << 12;
-
 
1460
    g = ((pixel & 0x00f0) | ((pixel & 0x00f0) >> 4)) << 8;
-
 
1461
    b = ((pixel & 0x000f) | ((pixel & 0x000f) << 4));
-
 
1462
    
-
 
1463
    return (a | r | g | b);
-
 
1464
}
-
 
1465
 
-
 
1466
static uint32_t
-
 
1467
fetch_pixel_x4r4g4b4 (bits_image_t *image,
-
 
1468
		      int           offset,
-
 
1469
		      int           line)
-
 
1470
{
-
 
1471
    uint32_t *bits = image->bits + line * image->rowstride;
-
 
1472
    uint32_t pixel = READ (image, (uint16_t *) bits + offset);
-
 
1473
    uint32_t r, g, b;
-
 
1474
    
-
 
1475
    r = ((pixel & 0x0f00) | ((pixel & 0x0f00) >> 4)) << 12;
-
 
1476
    g = ((pixel & 0x00f0) | ((pixel & 0x00f0) >> 4)) << 8;
-
 
1477
    b = ((pixel & 0x000f) | ((pixel & 0x000f) << 4));
-
 
1478
    
-
 
1479
    return (0xff000000 | r | g | b);
-
 
1480
}
-
 
1481
 
-
 
1482
static uint32_t
-
 
1483
fetch_pixel_a4b4g4r4 (bits_image_t *image,
-
 
1484
		      int           offset,
-
 
1485
		      int           line)
-
 
1486
{
-
 
1487
    uint32_t *bits = image->bits + line * image->rowstride;
-
 
1488
    uint32_t pixel = READ (image, (uint16_t *) bits + offset);
-
 
1489
    uint32_t a, r, g, b;
-
 
1490
    
-
 
1491
    a = ((pixel & 0xf000) | ((pixel & 0xf000) >> 4)) << 16;
-
 
1492
    b = ((pixel & 0x0f00) | ((pixel & 0x0f00) >> 4)) >> 4;
-
 
1493
    g = ((pixel & 0x00f0) | ((pixel & 0x00f0) >> 4)) << 8;
-
 
1494
    r = ((pixel & 0x000f) | ((pixel & 0x000f) << 4)) << 16;
-
 
1495
    
-
 
1496
    return (a | r | g | b);
-
 
1497
}
-
 
1498
 
-
 
1499
static uint32_t
-
 
1500
fetch_pixel_x4b4g4r4 (bits_image_t *image,
-
 
1501
		      int           offset,
-
 
1502
		      int           line)
-
 
1503
{
-
 
1504
    uint32_t *bits = image->bits + line * image->rowstride;
-
 
1505
    uint32_t pixel = READ (image, (uint16_t *) bits + offset);
-
 
1506
    uint32_t r, g, b;
-
 
1507
    
-
 
1508
    b = ((pixel & 0x0f00) | ((pixel & 0x0f00) >> 4)) >> 4;
-
 
1509
    g = ((pixel & 0x00f0) | ((pixel & 0x00f0) >> 4)) << 8;
-
 
1510
    r = ((pixel & 0x000f) | ((pixel & 0x000f) << 4)) << 16;
-
 
1511
    
-
 
1512
    return (0xff000000 | r | g | b);
-
 
1513
}
-
 
1514
 
-
 
1515
static uint32_t
-
 
1516
fetch_pixel_a8 (bits_image_t *image,
-
 
1517
		int           offset,
-
 
1518
		int           line)
-
 
1519
{
-
 
1520
    uint32_t *bits = image->bits + line * image->rowstride;
-
 
1521
    uint32_t pixel = READ (image, (uint8_t *) bits + offset);
-
 
1522
    
-
 
1523
    return pixel << 24;
-
 
1524
}
-
 
1525
 
-
 
1526
static uint32_t
-
 
1527
fetch_pixel_r3g3b2 (bits_image_t *image,
-
 
1528
		    int           offset,
-
 
1529
		    int           line)
-
 
1530
{
-
 
1531
    uint32_t *bits = image->bits + line * image->rowstride;
-
 
1532
    uint32_t pixel = READ (image, (uint8_t *) bits + offset);
-
 
1533
    uint32_t r, g, b;
-
 
1534
    
-
 
1535
    r = ((pixel & 0xe0) |
-
 
1536
	 ((pixel & 0xe0) >> 3) |
-
 
1537
	 ((pixel & 0xc0) >> 6)) << 16;
-
 
1538
    
-
 
1539
    g = ((pixel & 0x1c) |
-
 
1540
	 ((pixel & 0x18) >> 3) |
-
 
1541
	 ((pixel & 0x1c) << 3)) << 8;
-
 
1542
    
-
 
1543
    b = (((pixel & 0x03)     ) |
-
 
1544
	 ((pixel & 0x03) << 2) |
-
 
1545
	 ((pixel & 0x03) << 4) |
-
 
1546
	 ((pixel & 0x03) << 6));
-
 
1547
    
-
 
1548
    return (0xff000000 | r | g | b);
-
 
1549
}
-
 
1550
 
-
 
1551
static uint32_t
-
 
1552
fetch_pixel_b2g3r3 (bits_image_t *image,
-
 
1553
		    int           offset,
-
 
1554
		    int           line)
-
 
1555
{
-
 
1556
    uint32_t *bits = image->bits + line * image->rowstride;
-
 
1557
    uint32_t p = READ (image, (uint8_t *) bits + offset);
-
 
1558
    uint32_t r, g, b;
-
 
1559
 
-
 
1560
    b  = p & 0xc0;
-
 
1561
    b |= b >> 2;
-
 
1562
    b |= b >> 4;
-
 
1563
    b &= 0xff;
-
 
1564
 
-
 
1565
    g  = (p & 0x38) << 10;
-
 
1566
    g |= g >> 3;
-
 
1567
    g |= g >> 6;
-
 
1568
    g &= 0xff00;
-
 
1569
 
-
 
1570
    r  = (p & 0x7) << 21;
-
 
1571
    r |= r >> 3;
-
 
1572
    r |= r >> 6;
-
 
1573
    r &= 0xff0000;
-
 
1574
 
-
 
1575
    return 0xff000000 | r | g | b;
-
 
1576
}
-
 
1577
 
-
 
1578
static uint32_t
-
 
1579
fetch_pixel_a2r2g2b2 (bits_image_t *image,
-
 
1580
		      int           offset,
-
 
1581
		      int           line)
-
 
1582
{
-
 
1583
    uint32_t *bits = image->bits + line * image->rowstride;
-
 
1584
    uint32_t pixel = READ (image, (uint8_t *) bits + offset);
-
 
1585
    uint32_t a, r, g, b;
-
 
1586
    
-
 
1587
    a = ((pixel & 0xc0) * 0x55) << 18;
-
 
1588
    r = ((pixel & 0x30) * 0x55) << 12;
-
 
1589
    g = ((pixel & 0x0c) * 0x55) << 6;
-
 
1590
    b = ((pixel & 0x03) * 0x55);
-
 
1591
    
-
 
1592
    return a | r | g | b;
-
 
1593
}
-
 
1594
 
-
 
1595
static uint32_t
-
 
1596
fetch_pixel_a2b2g2r2 (bits_image_t *image,
-
 
1597
		      int           offset,
-
 
1598
		      int           line)
-
 
1599
{
-
 
1600
    uint32_t *bits = image->bits + line * image->rowstride;
-
 
1601
    uint32_t pixel = READ (image, (uint8_t *) bits + offset);
-
 
1602
    uint32_t a, r, g, b;
-
 
1603
    
-
 
1604
    a = ((pixel & 0xc0) * 0x55) << 18;
-
 
1605
    b = ((pixel & 0x30) * 0x55) >> 4;
-
 
1606
    g = ((pixel & 0x0c) * 0x55) << 6;
-
 
1607
    r = ((pixel & 0x03) * 0x55) << 16;
-
 
1608
    
-
 
1609
    return a | r | g | b;
-
 
1610
}
-
 
1611
 
-
 
1612
static uint32_t
-
 
1613
fetch_pixel_c8 (bits_image_t *image,
-
 
1614
		int           offset,
-
 
1615
		int           line)
-
 
1616
{
-
 
1617
    uint32_t *bits = image->bits + line * image->rowstride;
-
 
1618
    uint32_t pixel = READ (image, (uint8_t *) bits + offset);
-
 
1619
    const pixman_indexed_t * indexed = image->indexed;
-
 
1620
    
-
 
1621
    return indexed->rgba[pixel];
-
 
1622
}
-
 
1623
 
-
 
1624
static uint32_t
-
 
1625
fetch_pixel_x4a4 (bits_image_t *image,
-
 
1626
		  int           offset,
-
 
1627
		  int           line)
-
 
1628
{
-
 
1629
    uint32_t *bits = image->bits + line * image->rowstride;
-
 
1630
    uint32_t pixel = READ (image, (uint8_t *) bits + offset);
-
 
1631
    
-
 
1632
    return ((pixel & 0xf) | ((pixel & 0xf) << 4)) << 24;
-
 
1633
}
-
 
1634
 
-
 
1635
static uint32_t
-
 
1636
fetch_pixel_a4 (bits_image_t *image,
-
 
1637
		int           offset,
-
 
1638
		int           line)
-
 
1639
{
-
 
1640
    uint32_t *bits = image->bits + line * image->rowstride;
-
 
1641
    uint32_t pixel = FETCH_4 (image, bits, offset);
-
 
1642
    
-
 
1643
    pixel |= pixel << 4;
-
 
1644
    return pixel << 24;
-
 
1645
}
-
 
1646
 
-
 
1647
static uint32_t
-
 
1648
fetch_pixel_r1g2b1 (bits_image_t *image,
-
 
1649
		    int           offset,
-
 
1650
		    int           line)
-
 
1651
{
-
 
1652
    uint32_t *bits = image->bits + line * image->rowstride;
-
 
1653
    uint32_t pixel = FETCH_4 (image, bits, offset);
-
 
1654
    uint32_t r, g, b;
-
 
1655
    
-
 
1656
    r = ((pixel & 0x8) * 0xff) << 13;
-
 
1657
    g = ((pixel & 0x6) * 0x55) << 7;
-
 
1658
    b = ((pixel & 0x1) * 0xff);
-
 
1659
    
-
 
1660
    return 0xff000000 | r | g | b;
-
 
1661
}
-
 
1662
 
-
 
1663
static uint32_t
-
 
1664
fetch_pixel_b1g2r1 (bits_image_t *image,
-
 
1665
		    int           offset,
-
 
1666
		    int           line)
-
 
1667
{
-
 
1668
    uint32_t *bits = image->bits + line * image->rowstride;
-
 
1669
    uint32_t pixel = FETCH_4 (image, bits, offset);
-
 
1670
    uint32_t r, g, b;
-
 
1671
    
-
 
1672
    b = ((pixel & 0x8) * 0xff) >> 3;
-
 
1673
    g = ((pixel & 0x6) * 0x55) << 7;
-
 
1674
    r = ((pixel & 0x1) * 0xff) << 16;
-
 
1675
    
-
 
1676
    return 0xff000000 | r | g | b;
-
 
1677
}
-
 
1678
 
-
 
1679
static uint32_t
-
 
1680
fetch_pixel_a1r1g1b1 (bits_image_t *image,
-
 
1681
		      int           offset,
-
 
1682
		      int           line)
-
 
1683
{
-
 
1684
    uint32_t *bits = image->bits + line * image->rowstride;
-
 
1685
    uint32_t pixel = FETCH_4 (image, bits, offset);
-
 
1686
    uint32_t a, r, g, b;
-
 
1687
 
-
 
1688
    a = ((pixel & 0x8) * 0xff) << 21;
-
 
1689
    r = ((pixel & 0x4) * 0xff) << 14;
-
 
1690
    g = ((pixel & 0x2) * 0xff) << 7;
-
 
1691
    b = ((pixel & 0x1) * 0xff);
-
 
1692
 
-
 
1693
    return a | r | g | b;
-
 
1694
}
-
 
1695
 
-
 
1696
static uint32_t
-
 
1697
fetch_pixel_a1b1g1r1 (bits_image_t *image,
-
 
1698
		      int           offset,
-
 
1699
		      int           line)
-
 
1700
{
-
 
1701
    uint32_t *bits = image->bits + line * image->rowstride;
-
 
1702
    uint32_t pixel = FETCH_4 (image, bits, offset);
-
 
1703
    uint32_t a, r, g, b;
-
 
1704
 
-
 
1705
    a = ((pixel & 0x8) * 0xff) << 21;
-
 
1706
    b = ((pixel & 0x4) * 0xff) >> 2;
-
 
1707
    g = ((pixel & 0x2) * 0xff) << 7;
-
 
1708
    r = ((pixel & 0x1) * 0xff) << 16;
-
 
1709
 
-
 
1710
    return a | r | g | b;
-
 
1711
}
-
 
1712
 
-
 
1713
static uint32_t
-
 
1714
fetch_pixel_c4 (bits_image_t *image,
-
 
1715
		int           offset,
-
 
1716
		int           line)
-
 
1717
{
882
    argb.a = 1.0;
1718
    uint32_t *bits = image->bits + line * image->rowstride;
-
 
1719
    uint32_t pixel = FETCH_4 (image, bits, offset);
-
 
1720
    const pixman_indexed_t * indexed = image->indexed;
-
 
1721
 
-
 
1722
    return indexed->rgba[pixel];
-
 
1723
}
-
 
1724
 
-
 
1725
static uint32_t
-
 
1726
fetch_pixel_a1 (bits_image_t *image,
-
 
1727
		int           offset,
-
 
1728
		int           line)
883
    argb.r = pixman_unorm_to_float (r, 10);
1729
{
-
 
1730
    uint32_t *bits = image->bits + line * image->rowstride;
-
 
1731
    uint32_t pixel = READ (image, bits + (offset >> 5));
-
 
Line 1732... Line -...
1732
    uint32_t a;
-
 
1733
    
-
 
1734
#ifdef WORDS_BIGENDIAN
-
 
1735
    a = pixel >> (0x1f - (offset & 0x1f));
-
 
1736
#else
-
 
1737
    a = pixel >> (offset & 0x1f);
-
 
1738
#endif
-
 
1739
    a = a & 1;
884
    argb.g = pixman_unorm_to_float (g, 10);
1740
    a |= a << 1;
-
 
Line 1741... Line -...
1741
    a |= a << 2;
-
 
1742
    a |= a << 4;
885
    argb.b = pixman_unorm_to_float (b, 10);
1743
    
-
 
1744
    return a << 24;
886
 
1745
}
-
 
1746
 
887
    return argb;
Line 1747... Line 888...
1747
static uint32_t
888
}
1748
fetch_pixel_g1 (bits_image_t *image,
889
 
Line 1749... Line 890...
1749
		int           offset,
890
static argb_t
1750
		int           line)
891
fetch_pixel_a8r8g8b8_sRGB_float (bits_image_t *image,
1751
{
892
				 int	       offset,
Line 1819... Line 960...
1819
	(b >= 0 ? b < 0x1000000 ? (b >> 16) & 0x0000ff : 0x0000ff : 0);
960
	(b >= 0 ? b < 0x1000000 ? (b >> 16) & 0x0000ff : 0x0000ff : 0);
1820
}
961
}
Line 1821... Line 962...
1821
 
962
 
Line 1822... Line -...
1822
/*********************************** Store ************************************/
-
 
1823
 
-
 
1824
#define SPLIT_A(v)              \
-
 
1825
    uint32_t a = ((v) >> 24),   \
-
 
1826
	r = ((v) >> 16) & 0xff, \
-
 
1827
	g = ((v) >> 8) & 0xff,  \
-
 
1828
	b = (v) & 0xff
-
 
1829
 
-
 
1830
#define SPLIT(v)                     \
-
 
1831
    uint32_t r = ((v) >> 16) & 0xff, \
-
 
1832
	g = ((v) >> 8) & 0xff,       \
-
 
1833
	b = (v) & 0xff
963
/*********************************** Store ************************************/
1834
 
964
 
1835
static void
965
static void
1836
store_scanline_a2r10g10b10 (bits_image_t *  image,
966
store_scanline_a2r10g10b10_float (bits_image_t *  image,
1837
                            int             x,
967
				  int             x,
1838
                            int             y,
968
				  int             y,
1839
                            int             width,
969
				  int             width,
1840
                            const uint32_t *v)
970
				  const uint32_t *v)
1841
{
971
{
1842
    uint32_t *bits = image->bits + image->rowstride * y;
972
    uint32_t *bits = image->bits + image->rowstride * y;
1843
    uint32_t *pixel = bits + x;
973
    uint32_t *pixel = bits + x;
Line 1844... Line 974...
1844
    uint64_t *values = (uint64_t *)v;
974
    argb_t *values = (argb_t *)v;
1845
    int i;
975
    int i;
1846
    
976
 
1847
    for (i = 0; i < width; ++i)
-
 
1848
    {
-
 
1849
	WRITE (image, pixel++,
-
 
1850
	       ((values[i] >> 32) & 0xc0000000) |
-
 
1851
	       ((values[i] >> 18) & 0x3ff00000) |
-
 
1852
	       ((values[i] >> 12) & 0xffc00) | 
-
 
Line 1853... Line -...
1853
	       ((values[i] >> 6) & 0x3ff));    
-
 
1854
    }
-
 
1855
}
-
 
1856
 
977
    for (i = 0; i < width; ++i)
1857
static void
-
 
1858
store_scanline_x2r10g10b10 (bits_image_t *  image,
978
    {
1859
                            int             x,
-
 
1860
                            int             y,
-
 
1861
                            int             width,
979
	uint16_t a, r, g, b;
1862
                            const uint32_t *v)
980
 
1863
{
-
 
Line 1864... Line -...
1864
    uint32_t *bits = image->bits + image->rowstride * y;
-
 
1865
    uint64_t *values = (uint64_t *)v;
-
 
1866
    uint32_t *pixel = bits + x;
981
	a = pixman_float_to_unorm (values[i].a, 2);
1867
    int i;
-
 
1868
    
982
	r = pixman_float_to_unorm (values[i].r, 10);
1869
    for (i = 0; i < width; ++i)
-
 
1870
    {
983
	g = pixman_float_to_unorm (values[i].g, 10);
1871
	WRITE (image, pixel++,
984
	b = pixman_float_to_unorm (values[i].b, 10);
Line 1872... Line 985...
1872
	       ((values[i] >> 18) & 0x3ff00000) | 
985
 
1873
	       ((values[i] >> 12) & 0xffc00) |
986
	WRITE (image, pixel++,
1874
	       ((values[i] >> 6) & 0x3ff));
987
	       (a << 30) | (r << 20) | (g << 10) | b);
1875
    }
988
    }
1876
}
989
}
1877
 
990
 
1878
static void
991
static void
1879
store_scanline_a2b10g10r10 (bits_image_t *  image,
992
store_scanline_x2r10g10b10_float (bits_image_t *  image,
1880
                            int             x,
993
				  int             x,
1881
                            int             y,
994
				  int             y,
1882
                            int             width,
-
 
1883
                            const uint32_t *v)
-
 
1884
{
-
 
1885
    uint32_t *bits = image->bits + image->rowstride * y;
-
 
1886
    uint32_t *pixel = bits + x;
-
 
1887
    uint64_t *values = (uint64_t *)v;
-
 
1888
    int i;
-
 
1889
    
-
 
1890
    for (i = 0; i < width; ++i)
-
 
1891
    {
-
 
1892
	WRITE (image, pixel++,
-
 
1893
	       ((values[i] >> 32) & 0xc0000000) |
-
 
1894
	       ((values[i] >> 38) & 0x3ff) |
-
 
1895
	       ((values[i] >> 12) & 0xffc00) |
-
 
1896
	       ((values[i] << 14) & 0x3ff00000));
-
 
1897
    }
-
 
1898
}
-
 
1899
 
-
 
1900
static void
-
 
1901
store_scanline_x2b10g10r10 (bits_image_t *  image,
-
 
1902
                            int             x,
-
 
1903
                            int             y,
-
 
1904
                            int             width,
-
 
1905
                            const uint32_t *v)
-
 
1906
{
-
 
1907
    uint32_t *bits = image->bits + image->rowstride * y;
-
 
1908
    uint64_t *values = (uint64_t *)v;
-
 
1909
    uint32_t *pixel = bits + x;
-
 
1910
    int i;
-
 
1911
    
-
 
1912
    for (i = 0; i < width; ++i)
-
 
1913
    {
-
 
1914
	WRITE (image, pixel++,
-
 
1915
	       ((values[i] >> 38) & 0x3ff) |
-
 
1916
	       ((values[i] >> 12) & 0xffc00) |
-
 
1917
	       ((values[i] << 14) & 0x3ff00000));
-
 
1918
    }
-
 
1919
}
-
 
1920
 
-
 
1921
static void
-
 
1922
store_scanline_a8r8g8b8 (bits_image_t *  image,
-
 
1923
                         int             x,
-
 
1924
                         int             y,
-
 
1925
                         int             width,
-
 
1926
                         const uint32_t *values)
-
 
1927
{
-
 
1928
    uint32_t *bits = image->bits + image->rowstride * y;
-
 
1929
    
-
 
1930
    MEMCPY_WRAPPED (image, ((uint32_t *)bits) + x, values,
-
 
1931
                    width * sizeof(uint32_t));
-
 
1932
}
-
 
1933
 
-
 
1934
static void
-
 
1935
store_scanline_x8r8g8b8 (bits_image_t *  image,
-
 
1936
                         int             x,
-
 
1937
                         int             y,
-
 
1938
                         int             width,
-
 
1939
                         const uint32_t *values)
-
 
1940
{
-
 
1941
    uint32_t *bits = image->bits + image->rowstride * y;
-
 
1942
    uint32_t *pixel = (uint32_t *)bits + x;
-
 
1943
    int i;
-
 
1944
    
-
 
1945
    for (i = 0; i < width; ++i)
-
 
1946
	WRITE (image, pixel++, values[i] & 0xffffff);
-
 
1947
}
-
 
1948
 
-
 
1949
static void
-
 
1950
store_scanline_a8b8g8r8 (bits_image_t *  image,
-
 
1951
                         int             x,
-
 
1952
                         int             y,
-
 
1953
                         int             width,
-
 
1954
                         const uint32_t *values)
-
 
1955
{
-
 
1956
    uint32_t *bits = image->bits + image->rowstride * y;
-
 
1957
    uint32_t *pixel = (uint32_t *)bits + x;
-
 
1958
    int i;
-
 
1959
    
-
 
1960
    for (i = 0; i < width; ++i)
-
 
1961
    {
-
 
1962
	WRITE (image, pixel++,
-
 
1963
	       (values[i] & 0xff00ff00)         |
-
 
1964
	       ((values[i] >> 16) & 0xff)       |
-
 
1965
	       ((values[i] & 0xff) << 16));
-
 
1966
    }
-
 
1967
}
-
 
1968
 
-
 
1969
static void
-
 
1970
store_scanline_x8b8g8r8 (bits_image_t *  image,
-
 
1971
                         int             x,
-
 
1972
                         int             y,
-
 
1973
                         int             width,
-
 
1974
                         const uint32_t *values)
-
 
1975
{
-
 
1976
    uint32_t *bits = image->bits + image->rowstride * y;
-
 
1977
    uint32_t *pixel = (uint32_t *)bits + x;
-
 
1978
    int i;
-
 
1979
    
-
 
1980
    for (i = 0; i < width; ++i)
-
 
1981
    {
-
 
1982
	WRITE (image, pixel++,
-
 
1983
	       (values[i] & 0x0000ff00)         |
-
 
1984
	       ((values[i] >> 16) & 0xff)       |
-
 
1985
	       ((values[i] & 0xff) << 16));
-
 
1986
    }
-
 
1987
}
-
 
1988
 
-
 
1989
static void
-
 
1990
store_scanline_b8g8r8a8 (bits_image_t *  image,
-
 
1991
                         int             x,
-
 
1992
                         int             y,
-
 
1993
                         int             width,
-
 
1994
                         const uint32_t *values)
-
 
1995
{
-
 
1996
    uint32_t *bits = image->bits + image->rowstride * y;
-
 
1997
    uint32_t *pixel = (uint32_t *)bits + x;
-
 
1998
    int i;
-
 
1999
    
-
 
2000
    for (i = 0; i < width; ++i)
-
 
2001
    {
-
 
2002
	WRITE (image, pixel++,
-
 
2003
	       ((values[i] >> 24) & 0x000000ff) |
-
 
2004
	       ((values[i] >>  8) & 0x0000ff00) |
-
 
2005
	       ((values[i] <<  8) & 0x00ff0000) |
-
 
2006
	       ((values[i] << 24) & 0xff000000));
-
 
2007
    }
-
 
2008
}
-
 
2009
 
-
 
2010
static void
-
 
2011
store_scanline_b8g8r8x8 (bits_image_t *  image,
-
 
2012
                         int             x,
-
 
2013
                         int             y,
995
				  int             width,
Line 2014... Line 996...
2014
                         int             width,
996
				  const uint32_t *v)
2015
                         const uint32_t *values)
997
{
2016
{
998
    uint32_t *bits = image->bits + image->rowstride * y;
2017
    uint32_t *bits = image->bits + image->rowstride * y;
-
 
2018
    uint32_t *pixel = (uint32_t *)bits + x;
-
 
2019
    int i;
-
 
2020
    
-
 
2021
    for (i = 0; i < width; ++i)
-
 
Line 2022... Line -...
2022
    {
-
 
2023
	WRITE (image, pixel++,
-
 
2024
	       ((values[i] >>  8) & 0x0000ff00) |
-
 
2025
	       ((values[i] <<  8) & 0x00ff0000) |
-
 
2026
	       ((values[i] << 24) & 0xff000000));
-
 
2027
    }
-
 
2028
}
-
 
2029
 
-
 
2030
static void
-
 
2031
store_scanline_x14r6g6b6 (bits_image_t *  image,
-
 
2032
                          int             x,
-
 
2033
                          int             y,
-
 
2034
                          int             width,
-
 
2035
                          const uint32_t *values)
-
 
2036
{
-
 
2037
    uint32_t *bits = image->bits + image->rowstride * y;
-
 
2038
    uint32_t *pixel = ((uint32_t *) bits) + x;
-
 
2039
    int i;
-
 
2040
 
-
 
2041
    for (i = 0; i < width; ++i)
-
 
2042
    {
-
 
2043
	uint32_t s = values[i];
-
 
2044
	uint32_t r, g, b;
-
 
2045
 
-
 
2046
	r = (s & 0xfc0000) >> 6;
-
 
2047
	g = (s & 0x00fc00) >> 4;
-
 
2048
	b = (s & 0x0000fc) >> 2;
-
 
2049
 
-
 
2050
	WRITE (image, pixel++, r | g | b);
-
 
2051
    }
-
 
2052
}
-
 
2053
 
-
 
2054
static void
-
 
2055
store_scanline_r8g8b8 (bits_image_t *  image,
-
 
2056
                       int             x,
-
 
2057
                       int             y,
-
 
2058
                       int             width,
-
 
2059
                       const uint32_t *values)
999
    uint32_t *pixel = bits + x;
2060
{
-
 
2061
    uint32_t *bits = image->bits + image->rowstride * y;
-
 
2062
    uint8_t *pixel = ((uint8_t *) bits) + 3 * x;
-
 
2063
    int i;
-
 
2064
    
-
 
2065
    for (i = 0; i < width; ++i)
-
 
2066
    {
-
 
2067
	uint32_t val = values[i];
-
 
2068
	
-
 
2069
#ifdef WORDS_BIGENDIAN
-
 
2070
	WRITE (image, pixel++, (val & 0x00ff0000) >> 16);
-
 
2071
	WRITE (image, pixel++, (val & 0x0000ff00) >>  8);
-
 
2072
	WRITE (image, pixel++, (val & 0x000000ff) >>  0);
-
 
2073
#else
-
 
2074
	WRITE (image, pixel++, (val & 0x000000ff) >>  0);
-
 
2075
	WRITE (image, pixel++, (val & 0x0000ff00) >>  8);
-
 
2076
	WRITE (image, pixel++, (val & 0x00ff0000) >> 16);
-
 
2077
#endif
-
 
2078
    }
-
 
2079
}
-
 
2080
 
-
 
2081
static void
-
 
2082
store_scanline_b8g8r8 (bits_image_t *  image,
-
 
2083
                       int             x,
-
 
2084
                       int             y,
-
 
2085
                       int             width,
-
 
2086
                       const uint32_t *values)
1000
    argb_t *values = (argb_t *)v;
2087
{
-
 
2088
    uint32_t *bits = image->bits + image->rowstride * y;
-
 
2089
    uint8_t *pixel = ((uint8_t *) bits) + 3 * x;
-
 
2090
    int i;
-
 
2091
    
-
 
2092
    for (i = 0; i < width; ++i)
-
 
2093
    {
-
 
2094
	uint32_t val = values[i];
-
 
2095
	
-
 
2096
#ifdef WORDS_BIGENDIAN
-
 
2097
	WRITE (image, pixel++, (val & 0x000000ff) >>  0);
-
 
2098
	WRITE (image, pixel++, (val & 0x0000ff00) >>  8);
-
 
2099
	WRITE (image, pixel++, (val & 0x00ff0000) >> 16);
-
 
2100
#else
-
 
2101
	WRITE (image, pixel++, (val & 0x00ff0000) >> 16);
-
 
2102
	WRITE (image, pixel++, (val & 0x0000ff00) >>  8);
-
 
2103
	WRITE (image, pixel++, (val & 0x000000ff) >>  0);
-
 
2104
#endif
-
 
2105
    }
-
 
2106
}
-
 
2107
 
-
 
2108
static void
-
 
2109
store_scanline_r5g6b5 (bits_image_t *  image,
-
 
2110
                       int             x,
-
 
2111
                       int             y,
-
 
2112
                       int             width,
-
 
2113
                       const uint32_t *values)
1001
    int i;
2114
{
-
 
2115
    uint32_t *bits = image->bits + image->rowstride * y;
-
 
2116
    uint16_t *pixel = ((uint16_t *) bits) + x;
-
 
2117
    int i;
-
 
2118
    
-
 
2119
    for (i = 0; i < width; ++i)
-
 
2120
    {
-
 
2121
	uint32_t s = values[i];
-
 
2122
	
-
 
2123
	WRITE (image, pixel++,
-
 
2124
	       ((s >> 3) & 0x001f) |
-
 
2125
	       ((s >> 5) & 0x07e0) |
-
 
2126
	       ((s >> 8) & 0xf800));
-
 
2127
    }
-
 
2128
}
-
 
2129
 
-
 
2130
static void
-
 
2131
store_scanline_b5g6r5 (bits_image_t *  image,
-
 
2132
                       int             x,
-
 
2133
                       int             y,
-
 
2134
                       int             width,
-
 
2135
                       const uint32_t *values)
-
 
Line 2136... Line 1002...
2136
{
1002
 
2137
    uint32_t *bits = image->bits + image->rowstride * y;
-
 
2138
    uint16_t  *pixel = ((uint16_t *) bits) + x;
-
 
2139
    int i;
1003
    for (i = 0; i < width; ++i)
2140
    
1004
    {
2141
    for (i = 0; i < width; ++i)
1005
	uint16_t r, g, b;
Line 2142... Line 1006...
2142
    {
1006
 
2143
	SPLIT (values[i]);
1007
	r = pixman_float_to_unorm (values[i].r, 10);
2144
	
1008
	g = pixman_float_to_unorm (values[i].g, 10);
2145
	WRITE (image, pixel++,
1009
	b = pixman_float_to_unorm (values[i].b, 10);
2146
	       ((b << 8) & 0xf800) |
1010
 
2147
	       ((g << 3) & 0x07e0) |
-
 
2148
	       ((r >> 3)         ));
-
 
2149
    }
-
 
2150
}
-
 
2151
 
-
 
2152
static void
-
 
2153
store_scanline_a1r5g5b5 (bits_image_t *  image,
-
 
2154
                         int             x,
-
 
2155
                         int             y,
-
 
2156
                         int             width,
-
 
2157
                         const uint32_t *values)
-
 
2158
{
-
 
2159
    uint32_t *bits = image->bits + image->rowstride * y;
-
 
2160
    uint16_t  *pixel = ((uint16_t *) bits) + x;
-
 
2161
    int i;
-
 
2162
    
-
 
2163
    for (i = 0; i < width; ++i)
-
 
2164
    {
-
 
2165
	SPLIT_A (values[i]);
-
 
2166
	
-
 
2167
	WRITE (image, pixel++,
-
 
2168
	       ((a << 8) & 0x8000) |
-
 
2169
	       ((r << 7) & 0x7c00) |
-
 
2170
	       ((g << 2) & 0x03e0) |
-
 
2171
	       ((b >> 3)         ));
-
 
2172
    }
-
 
2173
}
-
 
2174
 
-
 
2175
static void
-
 
2176
store_scanline_x1r5g5b5 (bits_image_t *  image,
-
 
2177
                         int             x,
-
 
2178
                         int             y,
-
 
2179
                         int             width,
-
 
2180
                         const uint32_t *values)
-
 
2181
{
-
 
2182
    uint32_t *bits = image->bits + image->rowstride * y;
-
 
2183
    uint16_t  *pixel = ((uint16_t *) bits) + x;
-
 
2184
    int i;
-
 
2185
    
-
 
2186
    for (i = 0; i < width; ++i)
-
 
2187
    {
-
 
2188
	SPLIT (values[i]);
-
 
2189
	
-
 
2190
	WRITE (image, pixel++,
-
 
2191
	       ((r << 7) & 0x7c00) |
-
 
2192
	       ((g << 2) & 0x03e0) |
-
 
2193
	       ((b >> 3)         ));
-
 
2194
    }
-
 
2195
}
-
 
2196
 
-
 
2197
static void
-
 
2198
store_scanline_a1b5g5r5 (bits_image_t *  image,
-
 
2199
                         int             x,
-
 
2200
                         int             y,
-
 
2201
                         int             width,
-
 
2202
                         const uint32_t *values)
-
 
2203
{
-
 
2204
    uint32_t *bits = image->bits + image->rowstride * y;
-
 
2205
    uint16_t  *pixel = ((uint16_t *) bits) + x;
-
 
2206
    int i;
-
 
2207
    
-
 
2208
    for (i = 0; i < width; ++i)
-
 
2209
    {
-
 
2210
	SPLIT_A (values[i]);
-
 
2211
	
-
 
2212
	WRITE (image, pixel++,
-
 
2213
	       ((a << 8) & 0x8000) |
-
 
2214
	       ((b << 7) & 0x7c00) |
-
 
2215
	       ((g << 2) & 0x03e0) |
-
 
2216
	       ((r >> 3)         ));
-
 
2217
    }
-
 
2218
}
-
 
2219
 
-
 
2220
static void
-
 
2221
store_scanline_x1b5g5r5 (bits_image_t *  image,
-
 
2222
                         int             x,
-
 
2223
                         int             y,
-
 
2224
                         int             width,
-
 
2225
                         const uint32_t *values)
-
 
2226
{
-
 
2227
    uint32_t *bits = image->bits + image->rowstride * y;
-
 
2228
    uint16_t  *pixel = ((uint16_t *) bits) + x;
-
 
2229
    int i;
-
 
2230
    
-
 
2231
    for (i = 0; i < width; ++i)
-
 
2232
    {
-
 
2233
	SPLIT (values[i]);
-
 
2234
	
-
 
2235
	WRITE (image, pixel++, ((b << 7) & 0x7c00) |
-
 
2236
	       ((g << 2) & 0x03e0) |
-
 
2237
	       ((r >> 3)         ));
-
 
2238
    }
-
 
2239
}
-
 
2240
 
-
 
2241
static void
-
 
2242
store_scanline_a4r4g4b4 (bits_image_t *  image,
-
 
2243
                         int             x,
-
 
2244
                         int             y,
-
 
2245
                         int             width,
-
 
2246
                         const uint32_t *values)
-
 
2247
{
-
 
2248
    uint32_t *bits = image->bits + image->rowstride * y;
-
 
2249
    uint16_t  *pixel = ((uint16_t *) bits) + x;
-
 
2250
    int i;
-
 
2251
    
-
 
2252
    for (i = 0; i < width; ++i)
-
 
2253
    {
-
 
2254
	SPLIT_A (values[i]);
-
 
2255
	
-
 
2256
	WRITE (image, pixel++,
-
 
2257
	       ((a << 8) & 0xf000) |
-
 
2258
	       ((r << 4) & 0x0f00) |
-
 
2259
	       ((g     ) & 0x00f0) |
-
 
2260
	       ((b >> 4)         ));
-
 
2261
    }
-
 
2262
}
-
 
2263
 
-
 
2264
static void
-
 
2265
store_scanline_x4r4g4b4 (bits_image_t *  image,
-
 
2266
                         int             x,
-
 
2267
                         int             y,
-
 
2268
                         int             width,
-
 
2269
                         const uint32_t *values)
-
 
2270
{
-
 
2271
    uint32_t *bits = image->bits + image->rowstride * y;
-
 
2272
    uint16_t  *pixel = ((uint16_t *) bits) + x;
-
 
2273
    int i;
-
 
2274
    
-
 
2275
    for (i = 0; i < width; ++i)
-
 
2276
    {
-
 
2277
	SPLIT (values[i]);
-
 
2278
	
-
 
2279
	WRITE (image, pixel++,
-
 
2280
	       ((r << 4) & 0x0f00) |
-
 
2281
	       ((g     ) & 0x00f0) |
1011
	WRITE (image, pixel++,
2282
	       ((b >> 4)         ));
1012
	       (r << 20) | (g << 10) | b);
2283
    }
1013
    }
2284
}
1014
}
-
 
1015
 
2285
 
1016
static void
Line 2286... Line 1017...
2286
static void
1017
store_scanline_a2b10g10r10_float (bits_image_t *  image,
2287
store_scanline_a4b4g4r4 (bits_image_t *  image,
1018
				  int             x,
2288
                         int             x,
1019
				  int             y,
2289
                         int             y,
-
 
2290
                         int             width,
-
 
2291
                         const uint32_t *values)
-
 
2292
{
-
 
2293
    uint32_t *bits = image->bits + image->rowstride * y;
-
 
2294
    uint16_t  *pixel = ((uint16_t *) bits) + x;
-
 
2295
    int i;
-
 
2296
    
-
 
2297
    for (i = 0; i < width; ++i)
-
 
2298
    {
-
 
2299
	SPLIT_A (values[i]);
-
 
2300
	WRITE (image, pixel++, ((a << 8) & 0xf000) |
-
 
2301
	       ((b << 4) & 0x0f00) |
-
 
2302
	       ((g     ) & 0x00f0) |
-
 
2303
	       ((r >> 4)         ));
-
 
2304
    }
-
 
2305
}
-
 
Line -... Line 1020...
-
 
1020
				  int             width,
2306
 
1021
				  const uint32_t *v)
2307
static void
1022
{
2308
store_scanline_x4b4g4r4 (bits_image_t *  image,
1023
    uint32_t *bits = image->bits + image->rowstride * y;
Line 2309... Line 1024...
2309
                         int             x,
1024
    uint32_t *pixel = bits + x;
2310
                         int             y,
-
 
2311
                         int             width,
-
 
2312
                         const uint32_t *values)
1025
    argb_t *values = (argb_t *)v;
2313
{
1026
    int i;
2314
    uint32_t *bits = image->bits + image->rowstride * y;
1027
 
Line 2315... Line 1028...
2315
    uint16_t  *pixel = ((uint16_t *) bits) + x;
1028
    for (i = 0; i < width; ++i)
2316
    int i;
1029
    {
2317
    
1030
	uint16_t a, r, g, b;
2318
    for (i = 0; i < width; ++i)
1031
 
2319
    {
1032
	a = pixman_float_to_unorm (values[i].a, 2);
2320
	SPLIT (values[i]);
1033
	r = pixman_float_to_unorm (values[i].r, 10);
2321
	
1034
	g = pixman_float_to_unorm (values[i].g, 10);
2322
	WRITE (image, pixel++,
1035
	b = pixman_float_to_unorm (values[i].b, 10);
2323
	       ((b << 4) & 0x0f00) |
1036
 
-
 
1037
	WRITE (image, pixel++,
2324
	       ((g     ) & 0x00f0) |
1038
	       (a << 30) | (b << 20) | (g << 10) | r);
Line 2325... Line 1039...
2325
	       ((r >> 4)         ));
1039
    }
2326
    }
1040
}
2327
}
-
 
2328
 
1041
 
2329
static void
-
 
Line 2330... Line -...
2330
store_scanline_a8 (bits_image_t *  image,
-
 
2331
                   int             x,
-
 
2332
                   int             y,
-
 
2333
                   int             width,
-
 
2334
                   const uint32_t *values)
1042
static void
2335
{
1043
store_scanline_x2b10g10r10_float (bits_image_t *  image,
2336
    uint32_t *bits = image->bits + image->rowstride * y;
-
 
2337
    uint8_t   *pixel = ((uint8_t *) bits) + x;
-
 
2338
    int i;
1044
				  int             x,
2339
    
-
 
2340
    for (i = 0; i < width; ++i)
-
 
2341
    {
-
 
2342
	WRITE (image, pixel++, values[i] >> 24);
-
 
2343
    }
-
 
Line 2344... Line 1045...
2344
}
1045
				  int             y,
2345
 
-
 
2346
static void
-
 
2347
store_scanline_r3g3b2 (bits_image_t *  image,
1046
				  int             width,
2348
                       int             x,
1047
				  const uint32_t *v)
2349
                       int             y,
1048
{
Line 2350... Line 1049...
2350
                       int             width,
1049
    uint32_t *bits = image->bits + image->rowstride * y;
2351
                       const uint32_t *values)
1050
    uint32_t *pixel = bits + x;
2352
{
1051
    argb_t *values = (argb_t *)v;
2353
    uint32_t *bits = image->bits + image->rowstride * y;
1052
    int i;
2354
    uint8_t   *pixel = ((uint8_t *) bits) + x;
1053
 
2355
    int i;
1054
    for (i = 0; i < width; ++i)
2356
    
1055
    {
2357
    for (i = 0; i < width; ++i)
1056
	uint16_t r, g, b;
2358
    {
1057
 
-
 
1058
	r = pixman_float_to_unorm (values[i].r, 10);
2359
	SPLIT (values[i]);
1059
	g = pixman_float_to_unorm (values[i].g, 10);
Line 2360... Line 1060...
2360
	
1060
	b = pixman_float_to_unorm (values[i].b, 10);
2361
	WRITE (image, pixel++,
1061
 
2362
	       ((r     ) & 0xe0) |
1062
	WRITE (image, pixel++,
2363
	       ((g >> 3) & 0x1c) |
-
 
2364
	       ((b >> 6)       ));
-
 
2365
    }
-
 
2366
}
-
 
2367
 
-
 
2368
static void
-
 
2369
store_scanline_b2g3r3 (bits_image_t *  image,
-
 
2370
                       int             x,
-
 
2371
                       int             y,
-
 
2372
                       int             width,
-
 
2373
                       const uint32_t *values)
-
 
2374
{
-
 
2375
    uint32_t *bits = image->bits + image->rowstride * y;
-
 
2376
    uint8_t   *pixel = ((uint8_t *) bits) + x;
-
 
2377
    int i;
-
 
2378
    
-
 
2379
    for (i = 0; i < width; ++i)
-
 
2380
    {
-
 
Line -... Line 1063...
-
 
1063
	       (b << 20) | (g << 10) | r);
2381
	SPLIT (values[i]);
1064
    }
2382
	
1065
}
2383
	WRITE (image, pixel++,
1066
 
Line 2384... Line 1067...
2384
	       ((b     ) & 0xc0) |
1067
static void
2385
	       ((g >> 2) & 0x38) |
-
 
2386
	       ((r >> 5)       ));
-
 
2387
    }
-
 
2388
}
-
 
2389
 
-
 
2390
static void
-
 
2391
store_scanline_a2r2g2b2 (bits_image_t *  image,
-
 
2392
                         int             x,
-
 
2393
                         int             y,
-
 
2394
                         int             width,
1068
store_scanline_a8r8g8b8_sRGB_float (bits_image_t *  image,
2395
                         const uint32_t *values)
-
 
2396
{
-
 
2397
    uint32_t *bits = image->bits + image->rowstride * y;
-
 
2398
    uint8_t   *pixel = ((uint8_t *) bits) + x;
-
 
2399
    int i;
-
 
2400
    
-
 
2401
    for (i = 0; i < width; ++i)
-
 
2402
    {
-
 
2403
	SPLIT_A (values[i]);
-
 
2404
	
-
 
2405
	WRITE (image, pixel++,
-
 
2406
	       ((a     ) & 0xc0) |
-
 
2407
	       ((r >> 2) & 0x30) |
-
 
2408
	       ((g >> 4) & 0x0c) |
-
 
2409
	       ((b >> 6)       ));
-
 
2410
    }
-
 
2411
}
-
 
2412
 
-
 
2413
static void
-
 
2414
store_scanline_a2b2g2r2 (bits_image_t *  image,
-
 
2415
                         int             x,
-
 
2416
                         int             y,
-
 
2417
                         int             width,
-
 
2418
                         const uint32_t *values)
-
 
2419
{
-
 
2420
    uint32_t *bits = image->bits + image->rowstride * y;
-
 
2421
    uint8_t   *pixel = ((uint8_t *) bits) + x;
-
 
2422
    int i;
-
 
2423
    
-
 
2424
    for (i = 0; i < width; ++i)
-
 
2425
    {
-
 
2426
	SPLIT_A (values[i]);
-
 
2427
	
-
 
2428
	WRITE (image, pixel++,
-
 
2429
	       ((a     ) & 0xc0) |
-
 
2430
	       ((b >> 2) & 0x30) |
-
 
2431
	       ((g >> 4) & 0x0c) |
-
 
2432
	       ((r >> 6)       ));
-
 
2433
    }
-
 
2434
}
-
 
2435
 
-
 
2436
static void
-
 
2437
store_scanline_c8 (bits_image_t *  image,
-
 
2438
                   int             x,
-
 
2439
                   int             y,
-
 
2440
                   int             width,
-
 
2441
                   const uint32_t *values)
-
 
2442
{
-
 
2443
    uint32_t *bits = image->bits + image->rowstride * y;
-
 
2444
    uint8_t *pixel = ((uint8_t *) bits) + x;
-
 
2445
    const pixman_indexed_t *indexed = image->indexed;
-
 
2446
    int i;
-
 
2447
    
-
 
2448
    for (i = 0; i < width; ++i)
-
 
2449
	WRITE (image, pixel++, RGB24_TO_ENTRY (indexed,values[i]));
-
 
2450
}
-
 
2451
 
-
 
2452
static void
-
 
2453
store_scanline_g8 (bits_image_t *  image,
-
 
2454
                   int             x,
-
 
2455
                   int             y,
-
 
2456
                   int             width,
-
 
2457
                   const uint32_t *values)
-
 
2458
{
-
 
2459
    uint32_t *bits = image->bits + image->rowstride * y;
-
 
2460
    uint8_t *pixel = ((uint8_t *) bits) + x;
-
 
2461
    const pixman_indexed_t *indexed = image->indexed;
-
 
2462
    int i;
-
 
2463
 
-
 
2464
    for (i = 0; i < width; ++i)
-
 
2465
	WRITE (image, pixel++, RGB24_TO_ENTRY_Y (indexed,values[i]));
-
 
2466
}
-
 
2467
 
-
 
2468
static void
-
 
2469
store_scanline_x4a4 (bits_image_t *  image,
-
 
2470
                     int             x,
-
 
2471
                     int             y,
-
 
2472
                     int             width,
-
 
2473
                     const uint32_t *values)
-
 
2474
{
-
 
2475
    uint32_t *bits = image->bits + image->rowstride * y;
-
 
2476
    uint8_t   *pixel = ((uint8_t *) bits) + x;
-
 
2477
    int i;
-
 
2478
 
-
 
2479
    for (i = 0; i < width; ++i)
-
 
2480
	WRITE (image, pixel++, values[i] >> 28);
-
 
2481
}
-
 
2482
 
-
 
2483
#define STORE_8(img,l,o,v)  (WRITE (img, (uint8_t *)(l) + ((o) >> 3), (v)))
-
 
2484
#ifdef WORDS_BIGENDIAN
-
 
2485
 
-
 
2486
#define STORE_4(img,l,o,v)						\
-
 
2487
    do									\
-
 
2488
    {									\
-
 
2489
	int bo = 4 * (o);						\
-
 
2490
	int v4 = (v) & 0x0f;						\
-
 
2491
									\
-
 
2492
	STORE_8 (img, l, bo, (						\
-
 
2493
		     bo & 4 ?						\
-
 
2494
		     (FETCH_8 (img, l, bo) & 0xf0) | (v4) :		\
-
 
2495
		     (FETCH_8 (img, l, bo) & 0x0f) | (v4 << 4)));	\
-
 
2496
    } while (0)
-
 
2497
#else
-
 
2498
 
-
 
2499
#define STORE_4(img,l,o,v)						\
-
 
2500
    do									\
-
 
2501
    {									\
-
 
2502
	int bo = 4 * (o);						\
-
 
2503
	int v4 = (v) & 0x0f;						\
-
 
2504
									\
-
 
2505
	STORE_8 (img, l, bo, (						\
-
 
2506
		     bo & 4 ?						\
-
 
2507
		     (FETCH_8 (img, l, bo) & 0x0f) | (v4 << 4) :	\
-
 
2508
		     (FETCH_8 (img, l, bo) & 0xf0) | (v4)));		\
-
 
2509
    } while (0)
-
 
2510
#endif
-
 
2511
 
-
 
2512
static void
-
 
2513
store_scanline_a4 (bits_image_t *  image,
-
 
2514
                   int             x,
-
 
2515
                   int             y,
-
 
2516
                   int             width,
-
 
2517
                   const uint32_t *values)
-
 
2518
{
-
 
2519
    uint32_t *bits = image->bits + image->rowstride * y;
-
 
2520
    int i;
-
 
2521
 
-
 
2522
    for (i = 0; i < width; ++i)
-
 
2523
	STORE_4 (image, bits, i + x, values[i] >> 28);
-
 
2524
}
1069
				    int             x,
2525
 
1070
				    int             y,
Line -... Line 1071...
-
 
1071
				    int             width,
-
 
1072
				    const uint32_t *v)
-
 
1073
{
-
 
1074
    uint32_t *bits = image->bits + image->rowstride * y;
-
 
1075
    uint32_t *pixel = bits + x;
2526
static void
1076
    argb_t *values = (argb_t *)v;
2527
store_scanline_r1g2b1 (bits_image_t *  image,
1077
    int i;
2528
                       int             x,
1078
 
2529
                       int             y,
1079
    for (i = 0; i < width; ++i)
2530
                       int             width,
1080
    {
2531
                       const uint32_t *values)
1081
	uint8_t a, r, g, b;
2532
{
1082
 
2533
    uint32_t *bits = image->bits + image->rowstride * y;
-
 
2534
    int i;
-
 
2535
 
-
 
2536
    for (i = 0; i < width; ++i)
-
 
2537
    {
-
 
2538
	uint32_t pixel;
1083
	a = pixman_float_to_unorm (values[i].a, 8);
Line 2539... Line -...
2539
 
-
 
2540
	SPLIT (values[i]);
-
 
2541
	pixel = (((r >> 4) & 0x8) |
-
 
2542
	         ((g >> 5) & 0x6) |
-
 
2543
	         ((b >> 7)      ));
1084
	r = to_srgb (values[i].r);
2544
	STORE_4 (image, bits, i + x, pixel);
-
 
2545
    }
-
 
Line 2546... Line -...
2546
}
-
 
2547
 
-
 
2548
static void
-
 
2549
store_scanline_b1g2r1 (bits_image_t *  image,
-
 
2550
                       int             x,
1085
	g = to_srgb (values[i].g);
2551
                       int             y,
1086
	b = to_srgb (values[i].b);
2552
                       int             width,
-
 
2553
                       const uint32_t *values)
-
 
2554
{
1087
 
Line -... Line 1088...
-
 
1088
	WRITE (image, pixel++,
2555
    uint32_t *bits = image->bits + image->rowstride * y;
1089
	       (a << 24) | (r << 16) | (g << 8) | b);
2556
    int i;
1090
    }
2557
 
1091
}
Line 2558... Line -...
2558
    for (i = 0; i < width; ++i)
-
 
2559
    {
-
 
2560
	uint32_t pixel;
-
 
2561
 
-
 
2562
	SPLIT (values[i]);
1092
 
Line 2563... Line 1093...
2563
	pixel = (((b >> 4) & 0x8) |
1093
/*
2564
	         ((g >> 5) & 0x6) |
-
 
2565
	         ((r >> 7)      ));
1094
 * Contracts a floating point image to 32bpp and then stores it using a
Line 2566... Line 1095...
2566
	STORE_4 (image, bits, i + x, pixel);
1095
 * regular 32-bit store proc. Despite the type, this function expects an
2567
    }
1096
 * argb_t buffer.
2568
}
1097
 */
2569
 
1098
static void
2570
static void
1099
store_scanline_generic_float (bits_image_t *  image,
2571
store_scanline_a1r1g1b1 (bits_image_t *  image,
1100
			      int             x,
2572
                         int             x,
-
 
2573
                         int             y,
-
 
2574
                         int             width,
-
 
2575
                         const uint32_t *values)
-
 
2576
{
1101
			      int             y,
2577
    uint32_t *bits = image->bits + image->rowstride * y;
1102
			      int             width,
2578
    int i;
-
 
2579
 
-
 
2580
    for (i = 0; i < width; ++i)
-
 
2581
    {
-
 
2582
	uint32_t pixel;
-
 
2583
 
-
 
2584
	SPLIT_A (values[i]);
1103
			      const uint32_t *values)
Line 2585... Line 1104...
2585
	pixel = (((a >> 4) & 0x8) |
1104
{
2586
	         ((r >> 5) & 0x4) |
-
 
2587
	         ((g >> 6) & 0x2) |
1105
    uint32_t *argb8_pixels;
Line -... Line 1106...
-
 
1106
 
-
 
1107
    assert (image->common.type == BITS);
-
 
1108
 
2588
	         ((b >> 7)      ));
1109
    argb8_pixels = pixman_malloc_ab (width, sizeof(uint32_t));
2589
 
1110
    if (!argb8_pixels)
2590
	STORE_4 (image, bits, i + x, pixel);
1111
	return;
2591
    }
1112
 
2592
}
1113
    /* Contract the scanline.  We could do this in place if values weren't
-
 
1114
     * const.
2593
 
1115
     */
2594
static void
1116
    pixman_contract_from_float (argb8_pixels, (argb_t *)values, width);
2595
store_scanline_a1b1g1r1 (bits_image_t *  image,
1117
 
-
 
1118
    image->store_scanline_32 (image, x, y, width, argb8_pixels);
2596
                         int             x,
1119
 
2597
                         int             y,
1120
    free (argb8_pixels);
Line 2598... Line 1121...
2598
                         int             width,
1121
}
2599
                         const uint32_t *values)
1122
 
2600
{
1123
static void
Line 2601... Line -...
2601
    uint32_t *bits = image->bits + image->rowstride * y;
-
 
2602
    int i;
1124
fetch_scanline_generic_float (pixman_image_t *image,
2603
 
-
 
2604
    for (i = 0; i < width; ++i)
-
 
Line 2605... Line -...
2605
    {
-
 
2606
	uint32_t pixel;
-
 
2607
 
1125
			      int	      x,
2608
	SPLIT_A (values[i]);
1126
			      int	      y,
2609
	pixel = (((a >> 4) & 0x8) |
1127
			      int	      width,
2610
	         ((b >> 5) & 0x4) |
-
 
2611
	         ((g >> 6) & 0x2) |
-
 
2612
	         ((r >> 7)      ));
-
 
2613
 
-
 
2614
	STORE_4 (image, bits, i + x, pixel);
1128
			      uint32_t *      buffer,
Line 2615... Line 1129...
2615
    }
1129
			      const uint32_t *mask)
2616
}
1130
{
2617
 
1131
    image->bits.fetch_scanline_32 (image, x, y, width, buffer, NULL);
Line 2618... Line 1132...
2618
static void
1132
 
2619
store_scanline_c4 (bits_image_t *  image,
-
 
2620
                   int             x,
1133
    pixman_expand_to_float ((argb_t *)buffer, buffer, image->bits.format, width);
2621
                   int             y,
1134
}
Line 2622... Line 1135...
2622
                   int             width,
1135
 
2623
                   const uint32_t *values)
1136
/* The 32_sRGB paths should be deleted after narrow processing
2624
{
1137
 * is no longer invoked for formats that are considered wide.
2625
    uint32_t *bits = image->bits + image->rowstride * y;
1138
 * (Also see fetch_pixel_generic_lossy_32) */
2626
    const pixman_indexed_t *indexed = image->indexed;
-
 
2627
    int i;
-
 
2628
    
1139
static void
2629
    for (i = 0; i < width; ++i)
1140
fetch_scanline_a8r8g8b8_32_sRGB (pixman_image_t *image,
-
 
1141
                                 int             x,
2630
    {
1142
                                 int             y,
Line 2631... Line 1143...
2631
	uint32_t pixel;
1143
                                 int             width,
2632
	
1144
                                 uint32_t       *buffer,
2633
	pixel = RGB24_TO_ENTRY (indexed, values[i]);
1145
                                 const uint32_t *mask)
2634
	STORE_4 (image, bits, i + x, pixel);
1146
{
Line 2635... Line -...
2635
    }
-
 
2636
}
1147
    const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
2637
 
-
 
2638
static void
1148
    const uint32_t *pixel = (uint32_t *)bits + x;
2639
store_scanline_g4 (bits_image_t *  image,
-
 
2640
                   int             x,
1149
    const uint32_t *end = pixel + width;
Line 2641... Line 1150...
2641
                   int             y,
1150
    uint32_t tmp;
2642
                   int             width,
-
 
2643
                   const uint32_t *values)
1151
    
Line 2644... Line 1152...
2644
{
1152
    while (pixel < end)
2645
    uint32_t *bits = image->bits + image->rowstride * y;
1153
    {
2646
    const pixman_indexed_t *indexed = image->indexed;
1154
	uint8_t a, r, g, b;
2647
    int i;
1155
 
2648
    
1156
	tmp = READ (image, pixel++);
2649
    for (i = 0; i < width; ++i)
1157
 
2650
    {
1158
	a = (tmp >> 24) & 0xff;
2651
	uint32_t pixel;
1159
	r = (tmp >> 16) & 0xff;
2652
	
1160
	g = (tmp >> 8) & 0xff;
-
 
1161
	b = (tmp >> 0) & 0xff;
-
 
1162
 
2653
	pixel = RGB24_TO_ENTRY_Y (indexed, values[i]);
1163
	r = to_linear[r] * 255.0f + 0.5f;
Line 2654... Line 1164...
2654
	STORE_4 (image, bits, i + x, pixel);
1164
	g = to_linear[g] * 255.0f + 0.5f;
2655
    }
1165
	b = to_linear[b] * 255.0f + 0.5f;
2656
}
-
 
2657
 
1166
 
Line 2658... Line -...
2658
static void
-
 
2659
store_scanline_a1 (bits_image_t *  image,
-
 
2660
                   int             x,
-
 
2661
                   int             y,
1167
	*buffer++ = (a << 24) | (r << 16) | (g << 8) | (b << 0);
2662
                   int             width,
-
 
2663
                   const uint32_t *values)
-
 
Line 2664... Line -...
2664
{
-
 
2665
    uint32_t *bits = image->bits + image->rowstride * y;
-
 
2666
    int i;
-
 
2667
    
-
 
2668
    for (i = 0; i < width; ++i)
-
 
2669
    {
-
 
2670
	uint32_t  *pixel = ((uint32_t *) bits) + ((i + x) >> 5);
-
 
2671
	uint32_t mask, v;
-
 
2672
	
-
 
2673
#ifdef WORDS_BIGENDIAN
-
 
2674
	mask = 1 << (0x1f - ((i + x) & 0x1f));
-
 
2675
#else
-
 
2676
	mask = 1 << ((i + x) & 0x1f);
-
 
2677
#endif
-
 
2678
	v = values[i] & 0x80000000 ? mask : 0;
-
 
2679
	
1168
    }
2680
	WRITE (image, pixel, (READ (image, pixel) & ~mask) | v);
-
 
2681
    }
-
 
2682
}
-
 
2683
 
-
 
2684
static void
1169
}
2685
store_scanline_g1 (bits_image_t *  image,
-
 
2686
                   int             x,
-
 
2687
                   int             y,
-
 
2688
                   int             width,
-
 
2689
                   const uint32_t *values)
-
 
2690
{
-
 
2691
    uint32_t *bits = image->bits + image->rowstride * y;
-
 
2692
    const pixman_indexed_t *indexed = image->indexed;
-
 
2693
    int i;
-
 
2694
    
1170
 
2695
    for (i = 0; i < width; ++i)
-
 
2696
    {
-
 
2697
	uint32_t  *pixel = ((uint32_t *) bits) + ((i + x) >> 5);
-
 
2698
	uint32_t mask, v;
1171
static uint32_t
2699
	
-
 
2700
#ifdef WORDS_BIGENDIAN
-
 
2701
	mask = 1 << (0x1f - ((i + x) & 0x1f));
-
 
2702
#else
-
 
2703
	mask = 1 << ((i + x) & 0x1f);
-
 
2704
#endif
-
 
2705
	v = RGB24_TO_ENTRY_Y (indexed, values[i]) & 0x1 ? mask : 0;
-
 
2706
	
-
 
2707
	WRITE (image, pixel, (READ (image, pixel) & ~mask) | v);
-
 
2708
    }
-
 
Line 2709... Line -...
2709
}
-
 
2710
 
1172
fetch_pixel_a8r8g8b8_32_sRGB (bits_image_t *image,
2711
/*
-
 
2712
 * Contracts a 64bpp image to 32bpp and then stores it using a regular 32-bit
-
 
2713
 * store proc. Despite the type, this function expects a uint64_t buffer.
-
 
2714
 */
1173
			      int           offset,
2715
static void
-
 
2716
store_scanline_generic_64 (bits_image_t *  image,
-
 
2717
                           int             x,
-
 
2718
                           int             y,
-
 
2719
                           int             width,
-
 
2720
                           const uint32_t *values)
1174
			      int           line)
2721
{
-
 
Line 2722... Line 1175...
2722
    uint32_t *argb8_pixels;
1175
{
2723
    
1176
    uint32_t *bits = image->bits + line * image->rowstride;
2724
    assert (image->common.type == BITS);
-
 
2725
    
-
 
2726
    argb8_pixels = pixman_malloc_ab (width, sizeof(uint32_t));
1177
    uint32_t tmp = READ (image, bits + offset);
Line 2727... Line -...
2727
    if (!argb8_pixels)
-
 
2728
	return;
1178
    uint8_t a, r, g, b;
2729
    
1179
 
2730
    /* Contract the scanline.  We could do this in place if values weren't
1180
    a = (tmp >> 24) & 0xff;
2731
     * const.
1181
    r = (tmp >> 16) & 0xff;
2732
     */
1182
    g = (tmp >> 8) & 0xff;
2733
    pixman_contract (argb8_pixels, (uint64_t *)values, width);
1183
    b = (tmp >> 0) & 0xff;
2734
    
1184
 
2735
    image->store_scanline_32 (image, x, y, width, argb8_pixels);
-
 
Line 2736... Line 1185...
2736
    
1185
    r = to_linear[r] * 255.0f + 0.5f;
2737
    free (argb8_pixels);
-
 
2738
}
-
 
2739
 
-
 
2740
/* Despite the type, this function expects both buffer
-
 
2741
 * and mask to be uint64_t
-
 
2742
 */
-
 
2743
static void
-
 
2744
fetch_scanline_generic_64 (pixman_image_t *image,
-
 
2745
                           int             x,
-
 
2746
                           int             y,
-
 
Line 2747... Line -...
2747
                           int             width,
-
 
2748
                           uint32_t *      buffer,
-
 
2749
                           const uint32_t *mask)
1186
    g = to_linear[g] * 255.0f + 0.5f;
2750
{
1187
    b = to_linear[b] * 255.0f + 0.5f;
Line 2751... Line 1188...
2751
    pixman_format_code_t format;
1188
 
2752
    
1189
    return (a << 24) | (r << 16) | (g << 8) | (b << 0);
2753
    /* Fetch the pixels into the first half of buffer and then expand them in
1190
}
Line 2806... Line 1243...
2806
static uint32_t
1243
static uint32_t
2807
fetch_pixel_generic_lossy_32 (bits_image_t *image,
1244
fetch_pixel_generic_lossy_32 (bits_image_t *image,
2808
			      int           offset,
1245
			      int           offset,
2809
			      int           line)
1246
			      int           line)
2810
{
1247
{
2811
    uint64_t pixel64 = image->fetch_pixel_64 (image, offset, line);
1248
    argb_t pixel64 = image->fetch_pixel_float (image, offset, line);
2812
    uint32_t result;
1249
    uint32_t result;
Line 2813... Line 1250...
2813
    
1250
 
Line 2814... Line 1251...
2814
    pixman_contract (&result, &pixel64, 1);
1251
    pixman_contract_from_float (&result, &pixel64, 1);
2815
 
1252
 
Line 2816... Line 1253...
2816
    return result;
1253
    return result;
2817
}
1254
}
2818
 
1255
 
2819
typedef struct
1256
typedef struct
2820
{
1257
{
2821
    pixman_format_code_t	format;
1258
    pixman_format_code_t	format;
2822
    fetch_scanline_t		fetch_scanline_32;
1259
    fetch_scanline_t		fetch_scanline_32;
2823
    fetch_scanline_t		fetch_scanline_64;
1260
    fetch_scanline_t		fetch_scanline_float;
2824
    fetch_pixel_32_t		fetch_pixel_32;
1261
    fetch_pixel_32_t		fetch_pixel_32;
2825
    fetch_pixel_64_t		fetch_pixel_64;
1262
    fetch_pixel_float_t		fetch_pixel_float;
Line 2826... Line 1263...
2826
    store_scanline_t		store_scanline_32;
1263
    store_scanline_t		store_scanline_32;
2827
    store_scanline_t		store_scanline_64;
1264
    store_scanline_t		store_scanline_float;
2828
} format_info_t;
1265
} format_info_t;
2829
 
1266
 
2830
#define FORMAT_INFO(format) 						\
1267
#define FORMAT_INFO(format) 						\
2831
    {									\
1268
    {									\
-
 
1269
	PIXMAN_ ## format,						\
2832
	PIXMAN_ ## format,						\
1270
	    fetch_scanline_ ## format,					\
-
 
1271
	    fetch_scanline_generic_float,				\
2833
	    fetch_scanline_ ## format,					\
1272
	    fetch_pixel_ ## format,					\
Line 2834... Line 1273...
2834
	    fetch_scanline_generic_64,					\
1273
	    fetch_pixel_generic_float,					\
2835
	    fetch_pixel_ ## format, fetch_pixel_generic_64,		\
1274
	    store_scanline_ ## format,					\
2836
	    store_scanline_ ## format, store_scanline_generic_64	\
1275
	    store_scanline_generic_float				\
Line 2843... Line 1282...
2843
    FORMAT_INFO (x8r8g8b8),
1282
    FORMAT_INFO (x8r8g8b8),
2844
    FORMAT_INFO (a8b8g8r8),
1283
    FORMAT_INFO (a8b8g8r8),
2845
    FORMAT_INFO (x8b8g8r8),
1284
    FORMAT_INFO (x8b8g8r8),
2846
    FORMAT_INFO (b8g8r8a8),
1285
    FORMAT_INFO (b8g8r8a8),
2847
    FORMAT_INFO (b8g8r8x8),
1286
    FORMAT_INFO (b8g8r8x8),
-
 
1287
    FORMAT_INFO (r8g8b8a8),
-
 
1288
    FORMAT_INFO (r8g8b8x8),
2848
    FORMAT_INFO (x14r6g6b6),
1289
    FORMAT_INFO (x14r6g6b6),
Line -... Line 1290...
-
 
1290
 
-
 
1291
/* sRGB formats */
-
 
1292
  { PIXMAN_a8r8g8b8_sRGB,
-
 
1293
    fetch_scanline_a8r8g8b8_32_sRGB, fetch_scanline_a8r8g8b8_sRGB_float,
-
 
1294
    fetch_pixel_a8r8g8b8_32_sRGB, fetch_pixel_a8r8g8b8_sRGB_float,
-
 
1295
    store_scanline_a8r8g8b8_32_sRGB, store_scanline_a8r8g8b8_sRGB_float,
-
 
1296
  },
2849
 
1297
 
2850
/* 24bpp formats */
1298
/* 24bpp formats */
2851
    FORMAT_INFO (r8g8b8),
1299
    FORMAT_INFO (r8g8b8),
Line 2852... Line 1300...
2852
    FORMAT_INFO (b8g8r8),
1300
    FORMAT_INFO (b8g8r8),
Line 2871... Line 1319...
2871
    FORMAT_INFO (a2r2g2b2),
1319
    FORMAT_INFO (a2r2g2b2),
2872
    FORMAT_INFO (a2b2g2r2),
1320
    FORMAT_INFO (a2b2g2r2),
Line 2873... Line 1321...
2873
    
1321
    
Line 2874... Line -...
2874
    FORMAT_INFO (c8),
-
 
2875
    
-
 
2876
#define fetch_scanline_g8 fetch_scanline_c8
1322
    FORMAT_INFO (c8),
Line 2877... Line 1323...
2877
#define fetch_pixel_g8 fetch_pixel_c8
1323
    
2878
    FORMAT_INFO (g8),
1324
    FORMAT_INFO (g8),
2879
    
1325
    
2880
#define fetch_scanline_x4c4 fetch_scanline_c8
1326
#define fetch_scanline_x4c4 fetch_scanline_c8
Line 2881... Line 1327...
2881
#define fetch_pixel_x4c4 fetch_pixel_c8
1327
#define fetch_pixel_x4c4 fetch_pixel_c8
2882
#define store_scanline_x4c4 store_scanline_c8
1328
#define store_scanline_x4c4 store_scanline_c8
2883
    FORMAT_INFO (x4c4),
1329
    FORMAT_INFO (x4c4),
2884
    
1330
    
Line 2885... Line 1331...
2885
#define fetch_scanline_x4g4 fetch_scanline_c8
1331
#define fetch_scanline_x4g4 fetch_scanline_g8
Line 2896... Line 1342...
2896
    FORMAT_INFO (a1r1g1b1),
1342
    FORMAT_INFO (a1r1g1b1),
2897
    FORMAT_INFO (a1b1g1r1),
1343
    FORMAT_INFO (a1b1g1r1),
Line 2898... Line 1344...
2898
    
1344
    
Line 2899... Line -...
2899
    FORMAT_INFO (c4),
-
 
2900
    
-
 
2901
#define fetch_scanline_g4 fetch_scanline_c4
1345
    FORMAT_INFO (c4),
Line 2902... Line 1346...
2902
#define fetch_pixel_g4 fetch_pixel_c4
1346
    
2903
    FORMAT_INFO (g4),
1347
    FORMAT_INFO (g4),
2904
    
1348
    
Line 2905... Line 1349...
2905
/* 1bpp formats */
1349
/* 1bpp formats */
Line 2906... Line 1350...
2906
    FORMAT_INFO (a1),
1350
    FORMAT_INFO (a1),
2907
    FORMAT_INFO (g1),
1351
    FORMAT_INFO (g1),
2908
    
1352
    
2909
/* Wide formats */
1353
/* Wide formats */
Line 2910... Line 1354...
2910
    
1354
    
2911
    { PIXMAN_a2r10g10b10,
1355
    { PIXMAN_a2r10g10b10,
2912
      NULL, fetch_scanline_a2r10g10b10,
1356
      NULL, fetch_scanline_a2r10g10b10_float,
2913
      fetch_pixel_generic_lossy_32, fetch_pixel_a2r10g10b10,
1357
      fetch_pixel_generic_lossy_32, fetch_pixel_a2r10g10b10_float,
Line 2914... Line 1358...
2914
      NULL, store_scanline_a2r10g10b10 },
1358
      NULL, store_scanline_a2r10g10b10_float },
2915
    
1359
 
2916
    { PIXMAN_x2r10g10b10,
1360
    { PIXMAN_x2r10g10b10,
2917
      NULL, fetch_scanline_x2r10g10b10,
1361
      NULL, fetch_scanline_x2r10g10b10_float,
Line 2918... Line 1362...
2918
      fetch_pixel_generic_lossy_32, fetch_pixel_x2r10g10b10,
1362
      fetch_pixel_generic_lossy_32, fetch_pixel_x2r10g10b10_float,
2919
      NULL, store_scanline_x2r10g10b10 },
1363
      NULL, store_scanline_x2r10g10b10_float },
2920
    
1364
 
2921
    { PIXMAN_a2b10g10r10,
1365
    { PIXMAN_a2b10g10r10,
Line 2922... Line 1366...
2922
      NULL, fetch_scanline_a2b10g10r10,
1366
      NULL, fetch_scanline_a2b10g10r10_float,
2923
      fetch_pixel_generic_lossy_32, fetch_pixel_a2b10g10r10,
1367
      fetch_pixel_generic_lossy_32, fetch_pixel_a2b10g10r10_float,
2924
      NULL, store_scanline_a2b10g10r10 },
1368
      NULL, store_scanline_a2b10g10r10_float },
2925
    
1369
 
2926
    { PIXMAN_x2b10g10r10,
1370
    { PIXMAN_x2b10g10r10,
Line 2927... Line 1371...
2927
      NULL, fetch_scanline_x2b10g10r10,
1371
      NULL, fetch_scanline_x2b10g10r10_float,
2928
      fetch_pixel_generic_lossy_32, fetch_pixel_x2b10g10r10,
1372
      fetch_pixel_generic_lossy_32, fetch_pixel_x2b10g10r10_float,
2929
      NULL, store_scanline_x2b10g10r10 },
1373
      NULL, store_scanline_x2b10g10r10_float },
2930
    
1374
 
Line 2931... Line 1375...
2931
/* YUV formats */
1375
/* YUV formats */
2932
    { PIXMAN_yuy2,
1376
    { PIXMAN_yuy2,
Line 2950... Line 1394...
2950
    while (info->format != PIXMAN_null)
1394
    while (info->format != PIXMAN_null)
2951
    {
1395
    {
2952
	if (info->format == image->format)
1396
	if (info->format == image->format)
2953
	{
1397
	{
2954
	    image->fetch_scanline_32 = info->fetch_scanline_32;
1398
	    image->fetch_scanline_32 = info->fetch_scanline_32;
2955
	    image->fetch_scanline_64 = info->fetch_scanline_64;
1399
	    image->fetch_scanline_float = info->fetch_scanline_float;
2956
	    image->fetch_pixel_32 = info->fetch_pixel_32;
1400
	    image->fetch_pixel_32 = info->fetch_pixel_32;
2957
	    image->fetch_pixel_64 = info->fetch_pixel_64;
1401
	    image->fetch_pixel_float = info->fetch_pixel_float;
2958
	    image->store_scanline_32 = info->store_scanline_32;
1402
	    image->store_scanline_32 = info->store_scanline_32;
2959
	    image->store_scanline_64 = info->store_scanline_64;
1403
	    image->store_scanline_float = info->store_scanline_float;
Line 2960... Line 1404...
2960
	    
1404
	    
2961
	    return;
1405
	    return;
Line 2962... Line 1406...
2962
	}
1406
	}