3 * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
4 * 2005 Lars Knoll & Zack Rusin, Trolltech
5 * 2008 Aaron Plattner, NVIDIA Corporation
7 * Permission to use, copy, modify, distribute, and sell this software and its
8 * documentation for any purpose is hereby granted without fee, provided that
9 * the above copyright notice appear in all copies and that both that
10 * copyright notice and this permission notice appear in supporting
11 * documentation, and that the name of Keith Packard not be used in
12 * advertising or publicity pertaining to distribution of the software without
13 * specific, written prior permission. Keith Packard makes no
14 * representations about the suitability of this software for any purpose. It
15 * is provided "as is" without express or implied warranty.
17 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
18 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
19 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
20 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
21 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
22 * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
23 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
35 #include "pixman-private.h"
36 #include "pixman-accessor.h"
38 #define CvtR8G8B8toY15(s) (((((s) >> 16) & 0xff) * 153 + \
39 (((s) >> 8) & 0xff) * 301 + \
40 (((s) ) & 0xff) * 58) >> 2)
41 #define miCvtR8G8B8to15(s) ((((s) >> 3) & 0x001f) | \
42 (((s) >> 6) & 0x03e0) | \
43 (((s) >> 9) & 0x7c00))
44 #define miIndexToEnt15(mif,rgb15) ((mif)->ent[rgb15])
45 #define miIndexToEnt24(mif,rgb24) miIndexToEnt15(mif,miCvtR8G8B8to15(rgb24))
47 #define miIndexToEntY24(mif,rgb24) ((mif)->ent[CvtR8G8B8toY15(rgb24)])
50 * YV12 setup and access macros
53 #define YV12_SETUP(pict) \
54 uint32_t *bits = pict->bits; \
55 int stride = pict->rowstride; \
56 int offset0 = stride < 0 ? \
57 ((-stride) >> 1) * ((pict->height - 1) >> 1) - stride : \
58 stride * pict->height; \
59 int offset1 = stride < 0 ? \
60 offset0 + ((-stride) >> 1) * ((pict->height) >> 1) : \
61 offset0 + (offset0 >> 2)
62 /* Note no trailing semicolon on the above macro; if it's there, then
63 * the typical usage of YV12_SETUP(pict); will have an extra trailing ;
64 * that some compilers will interpret as a statement -- and then any further
65 * variable declarations will cause an error.
68 #define YV12_Y(line) \
69 ((uint8_t *) ((bits) + (stride) * (line)))
71 #define YV12_U(line) \
72 ((uint8_t *) ((bits) + offset1 + \
73 ((stride) >> 1) * ((line) >> 1)))
75 #define YV12_V(line) \
76 ((uint8_t *) ((bits) + offset0 + \
77 ((stride) >> 1) * ((line) >> 1)))
79 /*********************************** Fetch ************************************/
82 fbFetch_a8r8g8b8 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer)
84 const uint32_t *bits = pict->bits + y*pict->rowstride;
86 buffer, (const uint32_t *)bits + x,
87 width*sizeof(uint32_t));
91 fbFetch_x8r8g8b8 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer)
93 const uint32_t *bits = pict->bits + y*pict->rowstride;
94 const uint32_t *pixel = (const uint32_t *)bits + x;
95 const uint32_t *end = pixel + width;
97 *buffer++ = READ(pict, pixel++) | 0xff000000;
102 fbFetch_a8b8g8r8 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer)
104 const uint32_t *bits = pict->bits + y*pict->rowstride;
105 const uint32_t *pixel = (uint32_t *)bits + x;
106 const uint32_t *end = pixel + width;
107 while (pixel < end) {
108 uint32_t p = READ(pict, pixel++);
109 *buffer++ = (p & 0xff00ff00) |
116 fbFetch_x8b8g8r8 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer)
118 const uint32_t *bits = pict->bits + y*pict->rowstride;
119 const uint32_t *pixel = (uint32_t *)bits + x;
120 const uint32_t *end = pixel + width;
121 while (pixel < end) {
122 uint32_t p = READ(pict, pixel++);
123 *buffer++ = 0xff000000 |
131 fbFetch_b8g8r8a8 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer)
133 const uint32_t *bits = pict->bits + y*pict->rowstride;
134 const uint32_t *pixel = (uint32_t *)bits + x;
135 const uint32_t *end = pixel + width;
136 while (pixel < end) {
137 uint32_t p = READ(pict, pixel++);
138 *buffer++ = ((p & 0xff000000) >> 24) |
139 ((p & 0x00ff0000) >> 8) |
140 ((p & 0x0000ff00) << 8) |
141 ((p & 0x000000ff) << 24);
146 fbFetch_b8g8r8x8 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer)
148 const uint32_t *bits = pict->bits + y*pict->rowstride;
149 const uint32_t *pixel = (uint32_t *)bits + x;
150 const uint32_t *end = pixel + width;
151 while (pixel < end) {
152 uint32_t p = READ(pict, pixel++);
153 *buffer++ = 0xff000000 |
154 ((p & 0xff000000) >> 24) |
155 ((p & 0x00ff0000) >> 8) |
156 ((p & 0x0000ff00) << 8);
161 fbFetch_a2b10g10r10 (bits_image_t *pict, int x, int y, int width, uint64_t *buffer)
163 const uint32_t *bits = pict->bits + y*pict->rowstride;
164 const uint32_t *pixel = bits + x;
165 const uint32_t *end = pixel + width;
166 while (pixel < end) {
167 uint32_t p = READ(pict, pixel++);
168 uint64_t a = p >> 30;
169 uint64_t b = (p >> 20) & 0x3ff;
170 uint64_t g = (p >> 10) & 0x3ff;
171 uint64_t r = p & 0x3ff;
182 *buffer++ = a << 48 | r << 32 | g << 16 | b;
187 fbFetch_x2b10g10r10 (bits_image_t *pict, int x, int y, int width, uint64_t *buffer)
189 const uint32_t *bits = pict->bits + y*pict->rowstride;
190 const uint32_t *pixel = (uint32_t *)bits + x;
191 const uint32_t *end = pixel + width;
192 while (pixel < end) {
193 uint32_t p = READ(pict, pixel++);
194 uint64_t b = (p >> 20) & 0x3ff;
195 uint64_t g = (p >> 10) & 0x3ff;
196 uint64_t r = p & 0x3ff;
202 *buffer++ = 0xffffULL << 48 | r << 32 | g << 16 | b;
207 fbFetch_r8g8b8 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer)
209 const uint32_t *bits = pict->bits + y*pict->rowstride;
210 const uint8_t *pixel = (const uint8_t *)bits + 3*x;
211 const uint8_t *end = pixel + 3*width;
212 while (pixel < end) {
213 uint32_t b = 0xff000000;
214 #ifdef WORDS_BIGENDIAN
215 b |= (READ(pict, pixel++) << 16);
216 b |= (READ(pict, pixel++) << 8);
217 b |= (READ(pict, pixel++));
219 b |= (READ(pict, pixel++));
220 b |= (READ(pict, pixel++) << 8);
221 b |= (READ(pict, pixel++) << 16);
228 fbFetch_b8g8r8 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer)
230 const uint32_t *bits = pict->bits + y*pict->rowstride;
231 const uint8_t *pixel = (const uint8_t *)bits + 3*x;
232 const uint8_t *end = pixel + 3*width;
233 while (pixel < end) {
234 uint32_t b = 0xff000000;
235 #ifdef WORDS_BIGENDIAN
236 b |= (READ(pict, pixel++));
237 b |= (READ(pict, pixel++) << 8);
238 b |= (READ(pict, pixel++) << 16);
240 b |= (READ(pict, pixel++) << 16);
241 b |= (READ(pict, pixel++) << 8);
242 b |= (READ(pict, pixel++));
249 fbFetch_r5g6b5 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer)
251 const uint32_t *bits = pict->bits + y*pict->rowstride;
252 const uint16_t *pixel = (const uint16_t *)bits + x;
253 const uint16_t *end = pixel + width;
254 while (pixel < end) {
255 uint32_t p = READ(pict, pixel++);
256 uint32_t r = (((p) << 3) & 0xf8) |
257 (((p) << 5) & 0xfc00) |
258 (((p) << 8) & 0xf80000);
259 r |= (r >> 5) & 0x70007;
260 r |= (r >> 6) & 0x300;
261 *buffer++ = 0xff000000 | r;
266 fbFetch_b5g6r5 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer)
269 const uint32_t *bits = pict->bits + y*pict->rowstride;
270 const uint16_t *pixel = (const uint16_t *)bits + x;
271 const uint16_t *end = pixel + width;
272 while (pixel < end) {
273 uint32_t p = READ(pict, pixel++);
274 b = ((p & 0xf800) | ((p & 0xe000) >> 5)) >> 8;
275 g = ((p & 0x07e0) | ((p & 0x0600) >> 6)) << 5;
276 r = ((p & 0x001c) | ((p & 0x001f) << 5)) << 14;
277 *buffer++ = 0xff000000 | r | g | b;
282 fbFetch_a1r5g5b5 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer)
285 const uint32_t *bits = pict->bits + y*pict->rowstride;
286 const uint16_t *pixel = (const uint16_t *)bits + x;
287 const uint16_t *end = pixel + width;
288 while (pixel < end) {
289 uint32_t p = READ(pict, pixel++);
291 a = (uint32_t) ((uint8_t) (0 - ((p & 0x8000) >> 15))) << 24;
292 r = ((p & 0x7c00) | ((p & 0x7000) >> 5)) << 9;
293 g = ((p & 0x03e0) | ((p & 0x0380) >> 5)) << 6;
294 b = ((p & 0x001c) | ((p & 0x001f) << 5)) >> 2;
295 *buffer++ = a | r | g | b;
300 fbFetch_x1r5g5b5 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer)
303 const uint32_t *bits = pict->bits + y*pict->rowstride;
304 const uint16_t *pixel = (const uint16_t *)bits + x;
305 const uint16_t *end = pixel + width;
306 while (pixel < end) {
307 uint32_t p = READ(pict, pixel++);
309 r = ((p & 0x7c00) | ((p & 0x7000) >> 5)) << 9;
310 g = ((p & 0x03e0) | ((p & 0x0380) >> 5)) << 6;
311 b = ((p & 0x001c) | ((p & 0x001f) << 5)) >> 2;
312 *buffer++ = 0xff000000 | r | g | b;
317 fbFetch_a1b5g5r5 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer)
320 const uint32_t *bits = pict->bits + y*pict->rowstride;
321 const uint16_t *pixel = (const uint16_t *)bits + x;
322 const uint16_t *end = pixel + width;
323 while (pixel < end) {
324 uint32_t p = READ(pict, pixel++);
326 a = (uint32_t) ((uint8_t) (0 - ((p & 0x8000) >> 15))) << 24;
327 b = ((p & 0x7c00) | ((p & 0x7000) >> 5)) >> 7;
328 g = ((p & 0x03e0) | ((p & 0x0380) >> 5)) << 6;
329 r = ((p & 0x001c) | ((p & 0x001f) << 5)) << 14;
330 *buffer++ = a | r | g | b;
335 fbFetch_x1b5g5r5 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer)
338 const uint32_t *bits = pict->bits + y*pict->rowstride;
339 const uint16_t *pixel = (const uint16_t *)bits + x;
340 const uint16_t *end = pixel + width;
341 while (pixel < end) {
342 uint32_t p = READ(pict, pixel++);
344 b = ((p & 0x7c00) | ((p & 0x7000) >> 5)) >> 7;
345 g = ((p & 0x03e0) | ((p & 0x0380) >> 5)) << 6;
346 r = ((p & 0x001c) | ((p & 0x001f) << 5)) << 14;
347 *buffer++ = 0xff000000 | r | g | b;
352 fbFetch_a4r4g4b4 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer)
355 const uint32_t *bits = pict->bits + y*pict->rowstride;
356 const uint16_t *pixel = (const uint16_t *)bits + x;
357 const uint16_t *end = pixel + width;
358 while (pixel < end) {
359 uint32_t p = READ(pict, pixel++);
361 a = ((p & 0xf000) | ((p & 0xf000) >> 4)) << 16;
362 r = ((p & 0x0f00) | ((p & 0x0f00) >> 4)) << 12;
363 g = ((p & 0x00f0) | ((p & 0x00f0) >> 4)) << 8;
364 b = ((p & 0x000f) | ((p & 0x000f) << 4));
365 *buffer++ = a | r | g | b;
370 fbFetch_x4r4g4b4 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer)
373 const uint32_t *bits = pict->bits + y*pict->rowstride;
374 const uint16_t *pixel = (const uint16_t *)bits + x;
375 const uint16_t *end = pixel + width;
376 while (pixel < end) {
377 uint32_t p = READ(pict, pixel++);
379 r = ((p & 0x0f00) | ((p & 0x0f00) >> 4)) << 12;
380 g = ((p & 0x00f0) | ((p & 0x00f0) >> 4)) << 8;
381 b = ((p & 0x000f) | ((p & 0x000f) << 4));
382 *buffer++ = 0xff000000 | r | g | b;
387 fbFetch_a4b4g4r4 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer)
390 const uint32_t *bits = pict->bits + y*pict->rowstride;
391 const uint16_t *pixel = (const uint16_t *)bits + x;
392 const uint16_t *end = pixel + width;
393 while (pixel < end) {
394 uint32_t p = READ(pict, pixel++);
396 a = ((p & 0xf000) | ((p & 0xf000) >> 4)) << 16;
397 b = ((p & 0x0f00) | ((p & 0x0f00) >> 4)) >> 4;
398 g = ((p & 0x00f0) | ((p & 0x00f0) >> 4)) << 8;
399 r = ((p & 0x000f) | ((p & 0x000f) << 4)) << 16;
400 *buffer++ = a | r | g | b;
405 fbFetch_x4b4g4r4 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer)
408 const uint32_t *bits = pict->bits + y*pict->rowstride;
409 const uint16_t *pixel = (const uint16_t *)bits + x;
410 const uint16_t *end = pixel + width;
411 while (pixel < end) {
412 uint32_t p = READ(pict, pixel++);
414 b = ((p & 0x0f00) | ((p & 0x0f00) >> 4)) >> 4;
415 g = ((p & 0x00f0) | ((p & 0x00f0) >> 4)) << 8;
416 r = ((p & 0x000f) | ((p & 0x000f) << 4)) << 16;
417 *buffer++ = 0xff000000 | r | g | b;
422 fbFetch_a8 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer)
424 const uint32_t *bits = pict->bits + y*pict->rowstride;
425 const uint8_t *pixel = (const uint8_t *)bits + x;
426 const uint8_t *end = pixel + width;
427 while (pixel < end) {
428 *buffer++ = READ(pict, pixel++) << 24;
433 fbFetch_r3g3b2 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer)
436 const uint32_t *bits = pict->bits + y*pict->rowstride;
437 const uint8_t *pixel = (const uint8_t *)bits + x;
438 const uint8_t *end = pixel + width;
439 while (pixel < end) {
440 uint32_t p = READ(pict, pixel++);
442 r = ((p & 0xe0) | ((p & 0xe0) >> 3) | ((p & 0xc0) >> 6)) << 16;
443 g = ((p & 0x1c) | ((p & 0x18) >> 3) | ((p & 0x1c) << 3)) << 8;
448 *buffer++ = 0xff000000 | r | g | b;
453 fbFetch_b2g3r3 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer)
456 const uint32_t *bits = pict->bits + y*pict->rowstride;
457 const uint8_t *pixel = (const uint8_t *)bits + x;
458 const uint8_t *end = pixel + width;
459 while (pixel < end) {
460 uint32_t p = READ(pict, pixel++);
466 g = ((p & 0x38) | ((p & 0x38) >> 3) | ((p & 0x30) << 2)) << 8;
469 ((p & 0x06) << 6)) << 16;
470 *buffer++ = 0xff000000 | r | g | b;
475 fbFetch_a2r2g2b2 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer)
478 const uint32_t *bits = pict->bits + y*pict->rowstride;
479 const uint8_t *pixel = (const uint8_t *)bits + x;
480 const uint8_t *end = pixel + width;
481 while (pixel < end) {
482 uint32_t p = READ(pict, pixel++);
484 a = ((p & 0xc0) * 0x55) << 18;
485 r = ((p & 0x30) * 0x55) << 12;
486 g = ((p & 0x0c) * 0x55) << 6;
487 b = ((p & 0x03) * 0x55);
493 fbFetch_a2b2g2r2 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer)
496 const uint32_t *bits = pict->bits + y*pict->rowstride;
497 const uint8_t *pixel = (const uint8_t *)bits + x;
498 const uint8_t *end = pixel + width;
499 while (pixel < end) {
500 uint32_t p = READ(pict, pixel++);
502 a = ((p & 0xc0) * 0x55) << 18;
503 b = ((p & 0x30) * 0x55) >> 6;
504 g = ((p & 0x0c) * 0x55) << 6;
505 r = ((p & 0x03) * 0x55) << 16;
511 fbFetch_c8 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer)
513 const uint32_t *bits = pict->bits + y*pict->rowstride;
514 const pixman_indexed_t * indexed = pict->indexed;
515 const uint8_t *pixel = (const uint8_t *)bits + x;
516 const uint8_t *end = pixel + width;
517 while (pixel < end) {
518 uint32_t p = READ(pict, pixel++);
519 *buffer++ = indexed->rgba[p];
524 fbFetch_x4a4 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer)
526 const uint32_t *bits = pict->bits + y*pict->rowstride;
527 const uint8_t *pixel = (const uint8_t *)bits + x;
528 const uint8_t *end = pixel + width;
529 while (pixel < end) {
530 uint8_t p = READ(pict, pixel++) & 0xf;
531 *buffer++ = (p | (p << 4)) << 24;
535 #define Fetch8(img,l,o) (READ(img, (uint8_t *)(l) + ((o) >> 2)))
536 #ifdef WORDS_BIGENDIAN
537 #define Fetch4(img,l,o) ((o) & 2 ? Fetch8(img,l,o) & 0xf : Fetch8(img,l,o) >> 4)
539 #define Fetch4(img,l,o) ((o) & 2 ? Fetch8(img,l,o) >> 4 : Fetch8(img,l,o) & 0xf)
543 fbFetch_a4 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer)
545 const uint32_t *bits = pict->bits + y*pict->rowstride;
547 for (i = 0; i < width; ++i) {
548 uint32_t p = Fetch4(pict, bits, i + x);
556 fbFetch_r1g2b1 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer)
559 const uint32_t *bits = pict->bits + y*pict->rowstride;
561 for (i = 0; i < width; ++i) {
562 uint32_t p = Fetch4(pict, bits, i + x);
564 r = ((p & 0x8) * 0xff) << 13;
565 g = ((p & 0x6) * 0x55) << 7;
566 b = ((p & 0x1) * 0xff);
567 *buffer++ = 0xff000000|r|g|b;
572 fbFetch_b1g2r1 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer)
575 const uint32_t *bits = pict->bits + y*pict->rowstride;
577 for (i = 0; i < width; ++i) {
578 uint32_t p = Fetch4(pict, bits, i + x);
580 b = ((p & 0x8) * 0xff) >> 3;
581 g = ((p & 0x6) * 0x55) << 7;
582 r = ((p & 0x1) * 0xff) << 16;
583 *buffer++ = 0xff000000|r|g|b;
588 fbFetch_a1r1g1b1 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer)
591 const uint32_t *bits = pict->bits + y*pict->rowstride;
593 for (i = 0; i < width; ++i) {
594 uint32_t p = Fetch4(pict, bits, i + x);
596 a = ((p & 0x8) * 0xff) << 21;
597 r = ((p & 0x4) * 0xff) << 14;
598 g = ((p & 0x2) * 0xff) << 7;
599 b = ((p & 0x1) * 0xff);
605 fbFetch_a1b1g1r1 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer)
608 const uint32_t *bits = pict->bits + y*pict->rowstride;
610 for (i = 0; i < width; ++i) {
611 uint32_t p = Fetch4(pict, bits, i + x);
613 a = ((p & 0x8) * 0xff) << 21;
614 r = ((p & 0x4) * 0xff) >> 3;
615 g = ((p & 0x2) * 0xff) << 7;
616 b = ((p & 0x1) * 0xff) << 16;
622 fbFetch_c4 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer)
624 const uint32_t *bits = pict->bits + y*pict->rowstride;
625 const pixman_indexed_t * indexed = pict->indexed;
627 for (i = 0; i < width; ++i) {
628 uint32_t p = Fetch4(pict, bits, i + x);
630 *buffer++ = indexed->rgba[p];
636 fbFetch_a1 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer)
638 const uint32_t *bits = pict->bits + y*pict->rowstride;
640 for (i = 0; i < width; ++i) {
641 uint32_t p = READ(pict, bits + ((i + x) >> 5));
643 #ifdef WORDS_BIGENDIAN
644 a = p >> (0x1f - ((i+x) & 0x1f));
646 a = p >> ((i+x) & 0x1f);
657 fbFetch_g1 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer)
659 const uint32_t *bits = pict->bits + y*pict->rowstride;
660 const pixman_indexed_t * indexed = pict->indexed;
662 for (i = 0; i < width; ++i) {
663 uint32_t p = READ(pict, bits + ((i+x) >> 5));
665 #ifdef WORDS_BIGENDIAN
666 a = p >> (0x1f - ((i+x) & 0x1f));
668 a = p >> ((i+x) & 0x1f);
671 *buffer++ = indexed->rgba[a];
676 fbFetch_yuy2 (bits_image_t *pict, int x, int line, int width, uint32_t *buffer)
682 const uint32_t *bits = pict->bits + pict->rowstride * line;
684 for (i = 0; i < width; i++)
686 y = ((uint8_t *) bits)[(x + i) << 1] - 16;
687 u = ((uint8_t *) bits)[(((x + i) << 1) & -4) + 1] - 128;
688 v = ((uint8_t *) bits)[(((x + i) << 1) & -4) + 3] - 128;
690 /* R = 1.164(Y - 16) + 1.596(V - 128) */
691 r = 0x012b27 * y + 0x019a2e * v;
692 /* G = 1.164(Y - 16) - 0.813(V - 128) - 0.391(U - 128) */
693 g = 0x012b27 * y - 0x00d0f2 * v - 0x00647e * u;
694 /* B = 1.164(Y - 16) + 2.018(U - 128) */
695 b = 0x012b27 * y + 0x0206a2 * u;
697 WRITE(pict, buffer++, 0xff000000 |
698 (r >= 0 ? r < 0x1000000 ? r & 0xff0000 : 0xff0000 : 0) |
699 (g >= 0 ? g < 0x1000000 ? (g >> 8) & 0x00ff00 : 0x00ff00 : 0) |
700 (b >= 0 ? b < 0x1000000 ? (b >> 16) & 0x0000ff : 0x0000ff : 0));
705 fbFetch_yv12 (bits_image_t *pict, int x, int line, int width, uint32_t *buffer)
708 uint8_t *pY = YV12_Y (line);
709 uint8_t *pU = YV12_U (line);
710 uint8_t *pV = YV12_V (line);
715 for (i = 0; i < width; i++)
718 u = pU[(x + i) >> 1] - 128;
719 v = pV[(x + i) >> 1] - 128;
721 /* R = 1.164(Y - 16) + 1.596(V - 128) */
722 r = 0x012b27 * y + 0x019a2e * v;
723 /* G = 1.164(Y - 16) - 0.813(V - 128) - 0.391(U - 128) */
724 g = 0x012b27 * y - 0x00d0f2 * v - 0x00647e * u;
725 /* B = 1.164(Y - 16) + 2.018(U - 128) */
726 b = 0x012b27 * y + 0x0206a2 * u;
728 WRITE(pict, buffer++, 0xff000000 |
729 (r >= 0 ? r < 0x1000000 ? r & 0xff0000 : 0xff0000 : 0) |
730 (g >= 0 ? g < 0x1000000 ? (g >> 8) & 0x00ff00 : 0x00ff00 : 0) |
731 (b >= 0 ? b < 0x1000000 ? (b >> 16) & 0x0000ff : 0x0000ff : 0));
735 /**************************** Pixel wise fetching *****************************/
738 fbFetchPixel_a2b10g10r10 (bits_image_t *pict, uint64_t *buffer, int n_pixels)
742 for (i = 0; i < n_pixels; ++i)
744 int offset = ((uint32_t *)buffer)[2 * i];
745 int line = ((uint32_t *)buffer)[2 * i + 1];
747 if (offset == 0xffffffff || line == 0xffffffff)
753 uint32_t *bits = pict->bits + line*pict->rowstride;
754 uint32_t p = READ(pict, bits + offset);
755 uint64_t a = p >> 30;
756 uint64_t b = (p >> 20) & 0x3ff;
757 uint64_t g = (p >> 10) & 0x3ff;
758 uint64_t r = p & 0x3ff;
769 buffer[i] = a << 48 | r << 32 | g << 16 | b;
775 fbFetchPixel_x2b10g10r10 (bits_image_t *pict, uint64_t *buffer, int n_pixels)
779 for (i = 0; i < n_pixels; ++i)
781 int offset = ((uint32_t *)buffer)[2 * i];
782 int line = ((uint32_t *)buffer)[2 * i + 1];
784 if (offset == 0xffffffff || line == 0xffffffff)
790 uint32_t *bits = pict->bits + line*pict->rowstride;
791 uint32_t p = READ(pict, bits + offset);
792 uint64_t b = (p >> 20) & 0x3ff;
793 uint64_t g = (p >> 10) & 0x3ff;
794 uint64_t r = p & 0x3ff;
800 buffer[i] = 0xffffULL << 48 | r << 32 | g << 16 | b;
806 fbFetchPixel_a8r8g8b8 (bits_image_t *pict, uint32_t *buffer, int n_pixels)
810 for (i = 0; i < n_pixels; ++i)
812 int offset = buffer[2 * i];
813 int line = buffer[2 * i + 1];
815 if (offset == 0xffffffff || line == 0xffffffff)
821 uint32_t *bits = pict->bits + line*pict->rowstride;
822 buffer[i] = READ(pict, (uint32_t *)bits + offset);
828 fbFetchPixel_x8r8g8b8 (bits_image_t *pict, uint32_t *buffer, int n_pixels)
832 for (i = 0; i < n_pixels; ++i)
834 int offset = buffer[2 * i];
835 int line = buffer[2 * i + 1];
837 if (offset == 0xffffffff || line == 0xffffffff)
843 uint32_t *bits = pict->bits + line*pict->rowstride;
844 buffer[i] = READ(pict, (uint32_t *)bits + offset) | 0xff000000;
850 fbFetchPixel_a8b8g8r8 (bits_image_t *pict, uint32_t *buffer, int n_pixels)
854 for (i = 0; i < n_pixels; ++i)
856 int offset = buffer[2 * i];
857 int line = buffer[2 * i + 1];
859 if (offset == 0xffffffff || line == 0xffffffff)
865 uint32_t *bits = pict->bits + line*pict->rowstride;
866 uint32_t pixel = READ(pict, (uint32_t *)bits + offset);
868 buffer[i] = ((pixel & 0xff000000) |
869 ((pixel >> 16) & 0xff) |
870 (pixel & 0x0000ff00) |
871 ((pixel & 0xff) << 16));
877 fbFetchPixel_x8b8g8r8 (bits_image_t *pict, uint32_t *buffer, int n_pixels)
881 for (i = 0; i < n_pixels; ++i)
883 int offset = buffer[2 * i];
884 int line = buffer[2 * i + 1];
886 if (offset == 0xffffffff || line == 0xffffffff)
892 uint32_t *bits = pict->bits + line*pict->rowstride;
893 uint32_t pixel = READ(pict, (uint32_t *)bits + offset);
895 buffer[i] = ((0xff000000) |
896 ((pixel >> 16) & 0xff) |
897 (pixel & 0x0000ff00) |
898 ((pixel & 0xff) << 16));
904 fbFetchPixel_b8g8r8a8 (bits_image_t *pict, uint32_t *buffer, int n_pixels)
908 for (i = 0; i < n_pixels; ++i)
910 int offset = buffer[2 * i];
911 int line = buffer[2 * i + 1];
913 if (offset == 0xffffffff || line == 0xffffffff)
919 uint32_t *bits = pict->bits + line*pict->rowstride;
920 uint32_t pixel = READ(pict, (uint32_t *)bits + offset);
922 buffer[i] = ((pixel & 0xff000000) >> 24 |
923 (pixel & 0x00ff0000) >> 8 |
924 (pixel & 0x0000ff00) << 8 |
925 (pixel & 0x000000ff) << 24);
931 fbFetchPixel_b8g8r8x8 (bits_image_t *pict, uint32_t *buffer, int n_pixels)
935 for (i = 0; i < n_pixels; ++i)
937 int offset = buffer[2 * i];
938 int line = buffer[2 * i + 1];
940 if (offset == 0xffffffff || line == 0xffffffff)
946 uint32_t *bits = pict->bits + line*pict->rowstride;
947 uint32_t pixel = READ(pict, (uint32_t *)bits + offset);
949 buffer[i] = ((0xff000000) |
950 (pixel & 0xff000000) >> 24 |
951 (pixel & 0x00ff0000) >> 8 |
952 (pixel & 0x0000ff00) << 8);
958 fbFetchPixel_r8g8b8 (bits_image_t *pict, uint32_t *buffer, int n_pixels)
962 for (i = 0; i < n_pixels; ++i)
964 int offset = buffer[2 * i];
965 int line = buffer[2 * i + 1];
967 if (offset == 0xffffffff || line == 0xffffffff)
973 uint32_t *bits = pict->bits + line*pict->rowstride;
974 uint8_t *pixel = ((uint8_t *) bits) + (offset*3);
975 #ifdef WORDS_BIGENDIAN
976 buffer[i] = (0xff000000 |
977 (READ(pict, pixel + 0) << 16) |
978 (READ(pict, pixel + 1) << 8) |
979 (READ(pict, pixel + 2)));
981 buffer[i] = (0xff000000 |
982 (READ(pict, pixel + 2) << 16) |
983 (READ(pict, pixel + 1) << 8) |
984 (READ(pict, pixel + 0)));
991 fbFetchPixel_b8g8r8 (bits_image_t *pict, uint32_t *buffer, int n_pixels)
995 for (i = 0; i < n_pixels; ++i)
997 int offset = buffer[2 * i];
998 int line = buffer[2 * i + 1];
1000 if (offset == 0xffffffff || line == 0xffffffff)
1006 uint32_t *bits = pict->bits + line*pict->rowstride;
1007 uint8_t *pixel = ((uint8_t *) bits) + (offset*3);
1008 #ifdef WORDS_BIGENDIAN
1009 buffer[i] = (0xff000000 |
1010 (READ(pict, pixel + 2) << 16) |
1011 (READ(pict, pixel + 1) << 8) |
1012 (READ(pict, pixel + 0)));
1014 buffer[i] = (0xff000000 |
1015 (READ(pict, pixel + 0) << 16) |
1016 (READ(pict, pixel + 1) << 8) |
1017 (READ(pict, pixel + 2)));
1024 fbFetchPixel_r5g6b5 (bits_image_t *pict, uint32_t *buffer, int n_pixels)
1028 for (i = 0; i < n_pixels; ++i)
1030 int offset = buffer[2 * i];
1031 int line = buffer[2 * i + 1];
1033 if (offset == 0xffffffff || line == 0xffffffff)
1040 uint32_t *bits = pict->bits + line*pict->rowstride;
1041 uint32_t pixel = READ(pict, (uint16_t *) bits + offset);
1043 r = ((pixel & 0xf800) | ((pixel & 0xe000) >> 5)) << 8;
1044 g = ((pixel & 0x07e0) | ((pixel & 0x0600) >> 6)) << 5;
1045 b = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) >> 2;
1046 buffer[i] = (0xff000000 | r | g | b);
1052 fbFetchPixel_b5g6r5 (bits_image_t *pict, uint32_t *buffer, int n_pixels)
1056 for (i = 0; i < n_pixels; ++i)
1058 int offset = buffer[2 * i];
1059 int line = buffer[2 * i + 1];
1061 if (offset == 0xffffffff || line == 0xffffffff)
1068 uint32_t *bits = pict->bits + line*pict->rowstride;
1069 uint32_t pixel = READ(pict, (uint16_t *) bits + offset);
1071 b = ((pixel & 0xf800) | ((pixel & 0xe000) >> 5)) >> 8;
1072 g = ((pixel & 0x07e0) | ((pixel & 0x0600) >> 6)) << 5;
1073 r = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) << 14;
1074 buffer[i] = (0xff000000 | r | g | b);
1080 fbFetchPixel_a1r5g5b5 (bits_image_t *pict, uint32_t *buffer, int n_pixels)
1084 for (i = 0; i < n_pixels; ++i)
1086 int offset = buffer[2 * i];
1087 int line = buffer[2 * i + 1];
1089 if (offset == 0xffffffff || line == 0xffffffff)
1096 uint32_t *bits = pict->bits + line*pict->rowstride;
1097 uint32_t pixel = READ(pict, (uint16_t *) bits + offset);
1099 a = (uint32_t) ((uint8_t) (0 - ((pixel & 0x8000) >> 15))) << 24;
1100 r = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) << 9;
1101 g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6;
1102 b = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) >> 2;
1103 buffer[i] = (a | r | g | b);
1109 fbFetchPixel_x1r5g5b5 (bits_image_t *pict, uint32_t *buffer, int n_pixels)
1113 for (i = 0; i < n_pixels; ++i)
1115 int offset = buffer[2 * i];
1116 int line = buffer[2 * i + 1];
1118 if (offset == 0xffffffff || line == 0xffffffff)
1125 uint32_t *bits = pict->bits + line*pict->rowstride;
1126 uint32_t pixel = READ(pict, (uint16_t *) bits + offset);
1128 r = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) << 9;
1129 g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6;
1130 b = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) >> 2;
1131 buffer[i] = (0xff000000 | r | g | b);
1137 fbFetchPixel_a1b5g5r5 (bits_image_t *pict, uint32_t *buffer, int n_pixels)
1141 for (i = 0; i < n_pixels; ++i)
1143 int offset = buffer[2 * i];
1144 int line = buffer[2 * i + 1];
1146 if (offset == 0xffffffff || line == 0xffffffff)
1153 uint32_t *bits = pict->bits + line*pict->rowstride;
1154 uint32_t pixel = READ(pict, (uint16_t *) bits + offset);
1156 a = (uint32_t) ((uint8_t) (0 - ((pixel & 0x8000) >> 15))) << 24;
1157 b = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) >> 7;
1158 g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6;
1159 r = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) << 14;
1160 buffer[i] = (a | r | g | b);
1166 fbFetchPixel_x1b5g5r5 (bits_image_t *pict, uint32_t *buffer, int n_pixels)
1170 for (i = 0; i < n_pixels; ++i)
1172 int offset = buffer[2 * i];
1173 int line = buffer[2 * i + 1];
1175 if (offset == 0xffffffff || line == 0xffffffff)
1182 uint32_t *bits = pict->bits + line*pict->rowstride;
1183 uint32_t pixel = READ(pict, (uint16_t *) bits + offset);
1185 b = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) >> 7;
1186 g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6;
1187 r = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) << 14;
1188 buffer[i] = (0xff000000 | r | g | b);
1194 fbFetchPixel_a4r4g4b4 (bits_image_t *pict, uint32_t *buffer, int n_pixels)
1198 for (i = 0; i < n_pixels; ++i)
1200 int offset = buffer[2 * i];
1201 int line = buffer[2 * i + 1];
1203 if (offset == 0xffffffff || line == 0xffffffff)
1210 uint32_t *bits = pict->bits + line*pict->rowstride;
1211 uint32_t pixel = READ(pict, (uint16_t *) bits + offset);
1213 a = ((pixel & 0xf000) | ((pixel & 0xf000) >> 4)) << 16;
1214 r = ((pixel & 0x0f00) | ((pixel & 0x0f00) >> 4)) << 12;
1215 g = ((pixel & 0x00f0) | ((pixel & 0x00f0) >> 4)) << 8;
1216 b = ((pixel & 0x000f) | ((pixel & 0x000f) << 4));
1217 buffer[i] = (a | r | g | b);
1223 fbFetchPixel_x4r4g4b4 (bits_image_t *pict, uint32_t *buffer, int n_pixels)
1227 for (i = 0; i < n_pixels; ++i)
1229 int offset = buffer[2 * i];
1230 int line = buffer[2 * i + 1];
1232 if (offset == 0xffffffff || line == 0xffffffff)
1239 uint32_t *bits = pict->bits + line*pict->rowstride;
1240 uint32_t pixel = READ(pict, (uint16_t *) bits + offset);
1242 r = ((pixel & 0x0f00) | ((pixel & 0x0f00) >> 4)) << 12;
1243 g = ((pixel & 0x00f0) | ((pixel & 0x00f0) >> 4)) << 8;
1244 b = ((pixel & 0x000f) | ((pixel & 0x000f) << 4));
1245 buffer[i] = (0xff000000 | r | g | b);
1251 fbFetchPixel_a4b4g4r4 (bits_image_t *pict, uint32_t *buffer, int n_pixels)
1255 for (i = 0; i < n_pixels; ++i)
1257 int offset = buffer[2 * i];
1258 int line = buffer[2 * i + 1];
1260 if (offset == 0xffffffff || line == 0xffffffff)
1267 uint32_t *bits = pict->bits + line*pict->rowstride;
1268 uint32_t pixel = READ(pict, (uint16_t *) bits + offset);
1270 a = ((pixel & 0xf000) | ((pixel & 0xf000) >> 4)) << 16;
1271 b = ((pixel & 0x0f00) | ((pixel & 0x0f00) >> 4)) >> 4;
1272 g = ((pixel & 0x00f0) | ((pixel & 0x00f0) >> 4)) << 8;
1273 r = ((pixel & 0x000f) | ((pixel & 0x000f) << 4)) << 16;
1274 buffer[i] = (a | r | g | b);
1280 fbFetchPixel_x4b4g4r4 (bits_image_t *pict, uint32_t *buffer, int n_pixels)
1284 for (i = 0; i < n_pixels; ++i)
1286 int offset = buffer[2 * i];
1287 int line = buffer[2 * i + 1];
1289 if (offset == 0xffffffff || line == 0xffffffff)
1296 uint32_t *bits = pict->bits + line*pict->rowstride;
1297 uint32_t pixel = READ(pict, (uint16_t *) bits + offset);
1299 b = ((pixel & 0x0f00) | ((pixel & 0x0f00) >> 4)) >> 4;
1300 g = ((pixel & 0x00f0) | ((pixel & 0x00f0) >> 4)) << 8;
1301 r = ((pixel & 0x000f) | ((pixel & 0x000f) << 4)) << 16;
1302 buffer[i] = (0xff000000 | r | g | b);
1308 fbFetchPixel_a8 (bits_image_t *pict, uint32_t *buffer, int n_pixels)
1312 for (i = 0; i < n_pixels; ++i)
1314 int offset = buffer[2 * i];
1315 int line = buffer[2 * i + 1];
1317 if (offset == 0xffffffff || line == 0xffffffff)
1323 uint32_t *bits = pict->bits + line*pict->rowstride;
1324 uint32_t pixel = READ(pict, (uint8_t *) bits + offset);
1326 buffer[i] = pixel << 24;
1332 fbFetchPixel_r3g3b2 (bits_image_t *pict, uint32_t *buffer, int n_pixels)
1336 for (i = 0; i < n_pixels; ++i)
1338 int offset = buffer[2 * i];
1339 int line = buffer[2 * i + 1];
1341 if (offset == 0xffffffff || line == 0xffffffff)
1348 uint32_t *bits = pict->bits + line*pict->rowstride;
1349 uint32_t pixel = READ(pict, (uint8_t *) bits + offset);
1351 r = ((pixel & 0xe0) | ((pixel & 0xe0) >> 3) | ((pixel & 0xc0) >> 6)) << 16;
1352 g = ((pixel & 0x1c) | ((pixel & 0x18) >> 3) | ((pixel & 0x1c) << 3)) << 8;
1353 b = (((pixel & 0x03) ) |
1354 ((pixel & 0x03) << 2) |
1355 ((pixel & 0x03) << 4) |
1356 ((pixel & 0x03) << 6));
1357 buffer[i] = (0xff000000 | r | g | b);
1363 fbFetchPixel_b2g3r3 (bits_image_t *pict, uint32_t *buffer, int n_pixels)
1367 for (i = 0; i < n_pixels; ++i)
1369 int offset = buffer[2 * i];
1370 int line = buffer[2 * i + 1];
1372 if (offset == 0xffffffff || line == 0xffffffff)
1379 uint32_t *bits = pict->bits + line*pict->rowstride;
1380 uint32_t pixel = READ(pict, (uint8_t *) bits + offset);
1382 b = (((pixel & 0xc0) ) |
1383 ((pixel & 0xc0) >> 2) |
1384 ((pixel & 0xc0) >> 4) |
1385 ((pixel & 0xc0) >> 6));
1386 g = ((pixel & 0x38) | ((pixel & 0x38) >> 3) | ((pixel & 0x30) << 2)) << 8;
1387 r = (((pixel & 0x07) ) |
1388 ((pixel & 0x07) << 3) |
1389 ((pixel & 0x06) << 6)) << 16;
1390 buffer[i] = (0xff000000 | r | g | b);
1396 fbFetchPixel_a2r2g2b2 (bits_image_t *pict, uint32_t *buffer, int n_pixels)
1400 for (i = 0; i < n_pixels; ++i)
1402 int offset = buffer[2 * i];
1403 int line = buffer[2 * i + 1];
1405 if (offset == 0xffffffff || line == 0xffffffff)
1412 uint32_t *bits = pict->bits + line*pict->rowstride;
1413 uint32_t pixel = READ(pict, (uint8_t *) bits + offset);
1415 a = ((pixel & 0xc0) * 0x55) << 18;
1416 r = ((pixel & 0x30) * 0x55) << 12;
1417 g = ((pixel & 0x0c) * 0x55) << 6;
1418 b = ((pixel & 0x03) * 0x55);
1419 buffer[i] = a|r|g|b;
1425 fbFetchPixel_a2b2g2r2 (bits_image_t *pict, uint32_t *buffer, int n_pixels)
1429 for (i = 0; i < n_pixels; ++i)
1431 int offset = buffer[2 * i];
1432 int line = buffer[2 * i + 1];
1434 if (offset == 0xffffffff || line == 0xffffffff)
1441 uint32_t *bits = pict->bits + line*pict->rowstride;
1442 uint32_t pixel = READ(pict, (uint8_t *) bits + offset);
1444 a = ((pixel & 0xc0) * 0x55) << 18;
1445 b = ((pixel & 0x30) * 0x55) >> 6;
1446 g = ((pixel & 0x0c) * 0x55) << 6;
1447 r = ((pixel & 0x03) * 0x55) << 16;
1448 buffer[i] = a|r|g|b;
1454 fbFetchPixel_c8 (bits_image_t *pict, uint32_t *buffer, int n_pixels)
1458 for (i = 0; i < n_pixels; ++i)
1460 int offset = buffer[2 * i];
1461 int line = buffer[2 * i + 1];
1463 if (offset == 0xffffffff || line == 0xffffffff)
1469 uint32_t *bits = pict->bits + line*pict->rowstride;
1470 uint32_t pixel = READ(pict, (uint8_t *) bits + offset);
1471 const pixman_indexed_t * indexed = pict->indexed;
1472 buffer[i] = indexed->rgba[pixel];
1478 fbFetchPixel_x4a4 (bits_image_t *pict, uint32_t *buffer, int n_pixels)
1482 for (i = 0; i < n_pixels; ++i)
1484 int offset = buffer[2 * i];
1485 int line = buffer[2 * i + 1];
1487 if (offset == 0xffffffff || line == 0xffffffff)
1493 uint32_t *bits = pict->bits + line*pict->rowstride;
1494 uint32_t pixel = READ(pict, (uint8_t *) bits + offset);
1496 buffer[i] = ((pixel & 0xf) | ((pixel & 0xf) << 4)) << 24;
1502 fbFetchPixel_a4 (bits_image_t *pict, uint32_t *buffer, int n_pixels)
1506 for (i = 0; i < n_pixels; ++i)
1508 int offset = buffer[2 * i];
1509 int line = buffer[2 * i + 1];
1511 if (offset == 0xffffffff || line == 0xffffffff)
1517 uint32_t *bits = pict->bits + line*pict->rowstride;
1518 uint32_t pixel = Fetch4(pict, bits, offset);
1520 pixel |= pixel << 4;
1521 buffer[i] = pixel << 24;
1527 fbFetchPixel_r1g2b1 (bits_image_t *pict, uint32_t *buffer, int n_pixels)
1531 for (i = 0; i < n_pixels; ++i)
1533 int offset = buffer[2 * i];
1534 int line = buffer[2 * i + 1];
1536 if (offset == 0xffffffff || line == 0xffffffff)
1543 uint32_t *bits = pict->bits + line*pict->rowstride;
1544 uint32_t pixel = Fetch4(pict, bits, offset);
1546 r = ((pixel & 0x8) * 0xff) << 13;
1547 g = ((pixel & 0x6) * 0x55) << 7;
1548 b = ((pixel & 0x1) * 0xff);
1549 buffer[i] = 0xff000000|r|g|b;
1555 fbFetchPixel_b1g2r1 (bits_image_t *pict, uint32_t *buffer, int n_pixels)
1559 for (i = 0; i < n_pixels; ++i)
1561 int offset = buffer[2 * i];
1562 int line = buffer[2 * i + 1];
1564 if (offset == 0xffffffff || line == 0xffffffff)
1571 uint32_t *bits = pict->bits + line*pict->rowstride;
1572 uint32_t pixel = Fetch4(pict, bits, offset);
1574 b = ((pixel & 0x8) * 0xff) >> 3;
1575 g = ((pixel & 0x6) * 0x55) << 7;
1576 r = ((pixel & 0x1) * 0xff) << 16;
1577 buffer[i] = 0xff000000|r|g|b;
1583 fbFetchPixel_a1r1g1b1 (bits_image_t *pict, uint32_t *buffer, int n_pixels)
1587 for (i = 0; i < n_pixels; ++i)
1589 int offset = buffer[2 * i];
1590 int line = buffer[2 * i + 1];
1592 if (offset == 0xffffffff || line == 0xffffffff)
1599 uint32_t *bits = pict->bits + line*pict->rowstride;
1600 uint32_t pixel = Fetch4(pict, bits, offset);
1602 a = ((pixel & 0x8) * 0xff) << 21;
1603 r = ((pixel & 0x4) * 0xff) << 14;
1604 g = ((pixel & 0x2) * 0xff) << 7;
1605 b = ((pixel & 0x1) * 0xff);
1606 buffer[i] = a|r|g|b;
1612 fbFetchPixel_a1b1g1r1 (bits_image_t *pict, uint32_t *buffer, int n_pixels)
1616 for (i = 0; i < n_pixels; ++i)
1618 int offset = buffer[2 * i];
1619 int line = buffer[2 * i + 1];
1621 if (offset == 0xffffffff || line == 0xffffffff)
1628 uint32_t *bits = pict->bits + line*pict->rowstride;
1629 uint32_t pixel = Fetch4(pict, bits, offset);
1631 a = ((pixel & 0x8) * 0xff) << 21;
1632 r = ((pixel & 0x4) * 0xff) >> 3;
1633 g = ((pixel & 0x2) * 0xff) << 7;
1634 b = ((pixel & 0x1) * 0xff) << 16;
1635 buffer[i] = a|r|g|b;
1641 fbFetchPixel_c4 (bits_image_t *pict, uint32_t *buffer, int n_pixels)
1645 for (i = 0; i < n_pixels; ++i)
1647 int offset = buffer[2 * i];
1648 int line = buffer[2 * i + 1];
1650 if (offset == 0xffffffff || line == 0xffffffff)
1656 uint32_t *bits = pict->bits + line*pict->rowstride;
1657 uint32_t pixel = Fetch4(pict, bits, offset);
1658 const pixman_indexed_t * indexed = pict->indexed;
1660 buffer[i] = indexed->rgba[pixel];
1667 fbFetchPixel_a1 (bits_image_t *pict, uint32_t *buffer, int n_pixels)
1671 for (i = 0; i < n_pixels; ++i)
1673 int offset = buffer[2 * i];
1674 int line = buffer[2 * i + 1];
1676 if (offset == 0xffffffff || line == 0xffffffff)
1682 uint32_t *bits = pict->bits + line*pict->rowstride;
1683 uint32_t pixel = READ(pict, bits + (offset >> 5));
1685 #ifdef WORDS_BIGENDIAN
1686 a = pixel >> (0x1f - (offset & 0x1f));
1688 a = pixel >> (offset & 0x1f);
1694 buffer[i] = a << 24;
1700 fbFetchPixel_g1 (bits_image_t *pict, uint32_t *buffer, int n_pixels)
1704 for (i = 0; i < n_pixels; ++i)
1706 int offset = buffer[2 * i];
1707 int line = buffer[2 * i + 1];
1709 if (offset == 0xffffffff || line == 0xffffffff)
1715 uint32_t *bits = pict->bits + line*pict->rowstride;
1716 uint32_t pixel = READ(pict, bits + (offset >> 5));
1717 const pixman_indexed_t * indexed = pict->indexed;
1719 #ifdef WORDS_BIGENDIAN
1720 a = pixel >> (0x1f - (offset & 0x1f));
1722 a = pixel >> (offset & 0x1f);
1725 buffer[i] = indexed->rgba[a];
1731 fbFetchPixel_yuy2 (bits_image_t *pict, uint32_t *buffer, int n_pixels)
1735 for (i = 0; i < n_pixels; ++i)
1737 int offset = buffer[2 * i];
1738 int line = buffer[2 * i + 1];
1740 if (offset == 0xffffffff || line == 0xffffffff)
1749 const uint32_t *bits = pict->bits + pict->rowstride * line;
1751 y = ((uint8_t *) bits)[offset << 1] - 16;
1752 u = ((uint8_t *) bits)[((offset << 1) & -4) + 1] - 128;
1753 v = ((uint8_t *) bits)[((offset << 1) & -4) + 3] - 128;
1755 /* R = 1.164(Y - 16) + 1.596(V - 128) */
1756 r = 0x012b27 * y + 0x019a2e * v;
1757 /* G = 1.164(Y - 16) - 0.813(V - 128) - 0.391(U - 128) */
1758 g = 0x012b27 * y - 0x00d0f2 * v - 0x00647e * u;
1759 /* B = 1.164(Y - 16) + 2.018(U - 128) */
1760 b = 0x012b27 * y + 0x0206a2 * u;
1762 buffer[i] = 0xff000000 |
1763 (r >= 0 ? r < 0x1000000 ? r & 0xff0000 : 0xff0000 : 0) |
1764 (g >= 0 ? g < 0x1000000 ? (g >> 8) & 0x00ff00 : 0x00ff00 : 0) |
1765 (b >= 0 ? b < 0x1000000 ? (b >> 16) & 0x0000ff : 0x0000ff : 0);
1771 fbFetchPixel_yv12 (bits_image_t *pict, uint32_t *buffer, int n_pixels)
1775 for (i = 0; i < n_pixels; ++i)
1777 int offset = buffer[2 * i];
1778 int line = buffer[2 * i + 1];
1780 if (offset == 0xffffffff || line == 0xffffffff)
1787 int16_t y = YV12_Y (line)[offset] - 16;
1788 int16_t u = YV12_U (line)[offset >> 1] - 128;
1789 int16_t v = YV12_V (line)[offset >> 1] - 128;
1792 /* R = 1.164(Y - 16) + 1.596(V - 128) */
1793 r = 0x012b27 * y + 0x019a2e * v;
1794 /* G = 1.164(Y - 16) - 0.813(V - 128) - 0.391(U - 128) */
1795 g = 0x012b27 * y - 0x00d0f2 * v - 0x00647e * u;
1796 /* B = 1.164(Y - 16) + 2.018(U - 128) */
1797 b = 0x012b27 * y + 0x0206a2 * u;
1799 buffer[i] = 0xff000000 |
1800 (r >= 0 ? r < 0x1000000 ? r & 0xff0000 : 0xff0000 : 0) |
1801 (g >= 0 ? g < 0x1000000 ? (g >> 8) & 0x00ff00 : 0x00ff00 : 0) |
1802 (b >= 0 ? b < 0x1000000 ? (b >> 16) & 0x0000ff : 0x0000ff : 0);
1807 /*********************************** Store ************************************/
1809 #define Splita(v) uint32_t a = ((v) >> 24), r = ((v) >> 16) & 0xff, g = ((v) >> 8) & 0xff, b = (v) & 0xff
1810 #define Split(v) uint32_t r = ((v) >> 16) & 0xff, g = ((v) >> 8) & 0xff, b = (v) & 0xff
1813 fbStore_a2b10g10r10 (pixman_image_t *image,
1814 uint32_t *bits, const uint64_t *values,
1818 uint32_t *pixel = bits + x;
1819 for (i = 0; i < width; ++i) {
1820 WRITE(image, pixel++,
1821 ((values[i] >> 32) & 0xc0000000) | // A
1822 ((values[i] >> 38) & 0x3ff) | // R
1823 ((values[i] >> 12) & 0xffc00) | // G
1824 ((values[i] << 14) & 0x3ff00000)); // B
1829 fbStore_x2b10g10r10 (pixman_image_t *image,
1830 uint32_t *bits, const uint64_t *values, int x, int width)
1833 uint32_t *pixel = bits + x;
1834 for (i = 0; i < width; ++i) {
1835 WRITE(image, pixel++,
1836 ((values[i] >> 38) & 0x3ff) | // R
1837 ((values[i] >> 12) & 0xffc00) | // G
1838 ((values[i] << 14) & 0x3ff00000)); // B
1843 fbStore_a8r8g8b8 (pixman_image_t *image,
1844 uint32_t *bits, const uint32_t *values, int x, int width)
1846 MEMCPY_WRAPPED(image, ((uint32_t *)bits) + x, values, width*sizeof(uint32_t));
1850 fbStore_x8r8g8b8 (pixman_image_t *image,
1851 uint32_t *bits, const uint32_t *values, int x, int width)
1854 uint32_t *pixel = (uint32_t *)bits + x;
1855 for (i = 0; i < width; ++i)
1856 WRITE(image, pixel++, values[i] & 0xffffff);
1860 fbStore_a8b8g8r8 (pixman_image_t *image,
1861 uint32_t *bits, const uint32_t *values, int x, int width)
1864 uint32_t *pixel = (uint32_t *)bits + x;
1865 for (i = 0; i < width; ++i)
1866 WRITE(image, pixel++, (values[i] & 0xff00ff00) | ((values[i] >> 16) & 0xff) | ((values[i] & 0xff) << 16));
1870 fbStore_x8b8g8r8 (pixman_image_t *image,
1871 uint32_t *bits, const uint32_t *values, int x, int width)
1874 uint32_t *pixel = (uint32_t *)bits + x;
1875 for (i = 0; i < width; ++i)
1876 WRITE(image, pixel++, (values[i] & 0x0000ff00) | ((values[i] >> 16) & 0xff) | ((values[i] & 0xff) << 16));
1880 fbStore_b8g8r8a8 (pixman_image_t *image,
1881 uint32_t *bits, const uint32_t *values, int x, int width)
1884 uint32_t *pixel = (uint32_t *)bits + x;
1885 for (i = 0; i < width; ++i)
1886 WRITE(image, pixel++,
1887 ((values[i] >> 24) & 0x000000ff) |
1888 ((values[i] >> 8) & 0x0000ff00) |
1889 ((values[i] << 8) & 0x00ff0000) |
1890 ((values[i] << 24) & 0xff000000));
1894 fbStore_b8g8r8x8 (pixman_image_t *image,
1895 uint32_t *bits, const uint32_t *values, int x, int width)
1898 uint32_t *pixel = (uint32_t *)bits + x;
1899 for (i = 0; i < width; ++i)
1900 WRITE(image, pixel++,
1901 ((values[i] >> 8) & 0x0000ff00) |
1902 ((values[i] << 8) & 0x00ff0000) |
1903 ((values[i] << 24) & 0xff000000));
1907 fbStore_r8g8b8 (pixman_image_t *image,
1908 uint32_t *bits, const uint32_t *values, int x, int width)
1911 uint8_t *pixel = ((uint8_t *) bits) + 3*x;
1912 for (i = 0; i < width; ++i)
1914 uint32_t val = values[i];
1915 #ifdef WORDS_BIGENDIAN
1916 WRITE(image, pixel++, (val & 0x00ff0000) >> 16);
1917 WRITE(image, pixel++, (val & 0x0000ff00) >> 8);
1918 WRITE(image, pixel++, (val & 0x000000ff) >> 0);
1920 WRITE(image, pixel++, (val & 0x000000ff) >> 0);
1921 WRITE(image, pixel++, (val & 0x0000ff00) >> 8);
1922 WRITE(image, pixel++, (val & 0x00ff0000) >> 16);
1928 fbStore_b8g8r8 (pixman_image_t *image,
1929 uint32_t *bits, const uint32_t *values, int x, int width)
1932 uint8_t *pixel = ((uint8_t *) bits) + 3*x;
1933 for (i = 0; i < width; ++i)
1935 uint32_t val = values[i];
1936 #ifdef WORDS_BIGENDIAN
1937 WRITE(image, pixel++, (val & 0x000000ff) >> 0);
1938 WRITE(image, pixel++, (val & 0x0000ff00) >> 8);
1939 WRITE(image, pixel++, (val & 0x00ff0000) >> 16);
1941 WRITE(image, pixel++, (val & 0x00ff0000) >> 16);
1942 WRITE(image, pixel++, (val & 0x0000ff00) >> 8);
1943 WRITE(image, pixel++, (val & 0x000000ff) >> 0);
1949 fbStore_r5g6b5 (pixman_image_t *image,
1950 uint32_t *bits, const uint32_t *values, int x, int width)
1953 uint16_t *pixel = ((uint16_t *) bits) + x;
1954 for (i = 0; i < width; ++i) {
1955 uint32_t s = values[i];
1956 WRITE(image, pixel++, ((s >> 3) & 0x001f) |
1957 ((s >> 5) & 0x07e0) |
1958 ((s >> 8) & 0xf800));
1963 fbStore_b5g6r5 (pixman_image_t *image,
1964 uint32_t *bits, const uint32_t *values, int x, int width)
1967 uint16_t *pixel = ((uint16_t *) bits) + x;
1968 for (i = 0; i < width; ++i) {
1970 WRITE(image, pixel++, ((b << 8) & 0xf800) |
1971 ((g << 3) & 0x07e0) |
1977 fbStore_a1r5g5b5 (pixman_image_t *image,
1978 uint32_t *bits, const uint32_t *values, int x, int width)
1981 uint16_t *pixel = ((uint16_t *) bits) + x;
1982 for (i = 0; i < width; ++i) {
1984 WRITE(image, pixel++, ((a << 8) & 0x8000) |
1985 ((r << 7) & 0x7c00) |
1986 ((g << 2) & 0x03e0) |
1992 fbStore_x1r5g5b5 (pixman_image_t *image,
1993 uint32_t *bits, const uint32_t *values, int x, int width)
1996 uint16_t *pixel = ((uint16_t *) bits) + x;
1997 for (i = 0; i < width; ++i) {
1999 WRITE(image, pixel++, ((r << 7) & 0x7c00) |
2000 ((g << 2) & 0x03e0) |
2006 fbStore_a1b5g5r5 (pixman_image_t *image,
2007 uint32_t *bits, const uint32_t *values, int x, int width)
2010 uint16_t *pixel = ((uint16_t *) bits) + x;
2011 for (i = 0; i < width; ++i) {
2013 WRITE(image, pixel++, ((a << 8) & 0x8000) |
2014 ((b << 7) & 0x7c00) |
2015 ((g << 2) & 0x03e0) |
2021 fbStore_x1b5g5r5 (pixman_image_t *image,
2022 uint32_t *bits, const uint32_t *values, int x, int width)
2025 uint16_t *pixel = ((uint16_t *) bits) + x;
2026 for (i = 0; i < width; ++i) {
2028 WRITE(image, pixel++, ((b << 7) & 0x7c00) |
2029 ((g << 2) & 0x03e0) |
2035 fbStore_a4r4g4b4 (pixman_image_t *image,
2036 uint32_t *bits, const uint32_t *values, int x, int width)
2039 uint16_t *pixel = ((uint16_t *) bits) + x;
2040 for (i = 0; i < width; ++i) {
2042 WRITE(image, pixel++, ((a << 8) & 0xf000) |
2043 ((r << 4) & 0x0f00) |
2050 fbStore_x4r4g4b4 (pixman_image_t *image,
2051 uint32_t *bits, const uint32_t *values, int x, int width)
2054 uint16_t *pixel = ((uint16_t *) bits) + x;
2055 for (i = 0; i < width; ++i) {
2057 WRITE(image, pixel++, ((r << 4) & 0x0f00) |
2064 fbStore_a4b4g4r4 (pixman_image_t *image,
2065 uint32_t *bits, const uint32_t *values, int x, int width)
2068 uint16_t *pixel = ((uint16_t *) bits) + x;
2069 for (i = 0; i < width; ++i) {
2071 WRITE(image, pixel++, ((a << 8) & 0xf000) |
2072 ((b << 4) & 0x0f00) |
2079 fbStore_x4b4g4r4 (pixman_image_t *image,
2080 uint32_t *bits, const uint32_t *values, int x, int width)
2083 uint16_t *pixel = ((uint16_t *) bits) + x;
2084 for (i = 0; i < width; ++i) {
2086 WRITE(image, pixel++, ((b << 4) & 0x0f00) |
2093 fbStore_a8 (pixman_image_t *image,
2094 uint32_t *bits, const uint32_t *values, int x, int width)
2097 uint8_t *pixel = ((uint8_t *) bits) + x;
2098 for (i = 0; i < width; ++i) {
2099 WRITE(image, pixel++, values[i] >> 24);
2104 fbStore_r3g3b2 (pixman_image_t *image,
2105 uint32_t *bits, const uint32_t *values, int x, int width)
2108 uint8_t *pixel = ((uint8_t *) bits) + x;
2109 for (i = 0; i < width; ++i) {
2111 WRITE(image, pixel++,
2119 fbStore_b2g3r3 (pixman_image_t *image,
2120 uint32_t *bits, const uint32_t *values, int x, int width)
2123 uint8_t *pixel = ((uint8_t *) bits) + x;
2124 for (i = 0; i < width; ++i) {
2126 WRITE(image, pixel++,
2134 fbStore_a2r2g2b2 (pixman_image_t *image,
2135 uint32_t *bits, const uint32_t *values, int x, int width)
2138 uint8_t *pixel = ((uint8_t *) bits) + x;
2139 for (i = 0; i < width; ++i) {
2141 WRITE(image, pixel++, ((a ) & 0xc0) |
2149 fbStore_a2b2g2r2 (pixman_image_t *image,
2150 uint32_t *bits, const uint32_t *values, int x, int width)
2153 uint8_t *pixel = ((uint8_t *) bits) + x;
2154 for (i = 0; i < width; ++i) {
2156 *(pixel++) = ((a ) & 0xc0) |
2164 fbStore_c8 (pixman_image_t *image,
2165 uint32_t *bits, const uint32_t *values, int x, int width)
2167 const pixman_indexed_t *indexed = image->bits.indexed;
2169 uint8_t *pixel = ((uint8_t *) bits) + x;
2170 for (i = 0; i < width; ++i) {
2171 WRITE(image, pixel++, miIndexToEnt24(indexed,values[i]));
2176 fbStore_x4a4 (pixman_image_t *image,
2177 uint32_t *bits, const uint32_t *values, int x, int width)
2180 uint8_t *pixel = ((uint8_t *) bits) + x;
2181 for (i = 0; i < width; ++i) {
2182 WRITE(image, pixel++, values[i] >> 28);
2186 #define Store8(img,l,o,v) (WRITE(img, (uint8_t *)(l) + ((o) >> 3), (v)))
2187 #ifdef WORDS_BIGENDIAN
2188 #define Store4(img,l,o,v) Store8(img,l,o,((o) & 4 ? \
2189 (Fetch8(img,l,o) & 0xf0) | (v) : \
2190 (Fetch8(img,l,o) & 0x0f) | ((v) << 4)))
2192 #define Store4(img,l,o,v) Store8(img,l,o,((o) & 4 ? \
2193 (Fetch8(img,l,o) & 0x0f) | ((v) << 4) : \
2194 (Fetch8(img,l,o) & 0xf0) | (v)))
2198 fbStore_a4 (pixman_image_t *image,
2199 uint32_t *bits, const uint32_t *values, int x, int width)
2202 for (i = 0; i < width; ++i) {
2203 Store4(image, bits, i + x, values[i]>>28);
2208 fbStore_r1g2b1 (pixman_image_t *image,
2209 uint32_t *bits, const uint32_t *values, int x, int width)
2212 for (i = 0; i < width; ++i) {
2216 pixel = (((r >> 4) & 0x8) |
2219 Store4(image, bits, i + x, pixel);
2224 fbStore_b1g2r1 (pixman_image_t *image,
2225 uint32_t *bits, const uint32_t *values, int x, int width)
2228 for (i = 0; i < width; ++i) {
2232 pixel = (((b >> 4) & 0x8) |
2235 Store4(image, bits, i + x, pixel);
2240 fbStore_a1r1g1b1 (pixman_image_t *image,
2241 uint32_t *bits, const uint32_t *values, int x, int width)
2244 for (i = 0; i < width; ++i) {
2247 pixel = (((a >> 4) & 0x8) |
2251 Store4(image, bits, i + x, pixel);
2256 fbStore_a1b1g1r1 (pixman_image_t *image,
2257 uint32_t *bits, const uint32_t *values, int x, int width)
2260 for (i = 0; i < width; ++i) {
2263 pixel = (((a >> 4) & 0x8) |
2267 Store4(image, bits, i + x, pixel);
2272 fbStore_c4 (pixman_image_t *image,
2273 uint32_t *bits, const uint32_t *values, int x, int width)
2275 const pixman_indexed_t *indexed = image->bits.indexed;
2277 for (i = 0; i < width; ++i) {
2280 pixel = miIndexToEnt24(indexed, values[i]);
2281 Store4(image, bits, i + x, pixel);
2286 fbStore_a1 (pixman_image_t *image,
2287 uint32_t *bits, const uint32_t *values, int x, int width)
2290 for (i = 0; i < width; ++i)
2292 uint32_t *pixel = ((uint32_t *) bits) + ((i+x) >> 5);
2294 #ifdef WORDS_BIGENDIAN
2295 mask = 1 << (0x1f - ((i+x) & 0x1f));
2297 mask = 1 << ((i+x) & 0x1f);
2299 v = values[i] & 0x80000000 ? mask : 0;
2300 WRITE(image, pixel, (READ(image, pixel) & ~mask) | v);
2305 fbStore_g1 (pixman_image_t *image,
2306 uint32_t *bits, const uint32_t *values, int x, int width)
2308 const pixman_indexed_t *indexed = image->bits.indexed;
2310 for (i = 0; i < width; ++i)
2312 uint32_t *pixel = ((uint32_t *) bits) + ((i+x) >> 5);
2314 #ifdef WORDS_BIGENDIAN
2315 mask = 1 << (0x1f - ((i+x) & 0x1f));
2317 mask = 1 << ((i + x) & 0x1f);
2319 v = miIndexToEntY24 (indexed, values[i]) ? mask : 0;
2320 WRITE(image, pixel, (READ(image, pixel) & ~mask) | v);
2325 * Contracts a 64bpp image to 32bpp and then stores it using a regular 32-bit
2329 fbStore64_generic (pixman_image_t *image,
2330 uint32_t *bits, const uint64_t *values, int x, int width)
2332 uint32_t *argb8Pixels;
2334 assert(image->common.type == BITS);
2336 argb8Pixels = pixman_malloc_ab (width, sizeof(uint32_t));
2340 /* Contract the scanline. We could do this in place if values weren't
2343 pixman_contract(argb8Pixels, values, width);
2345 image->bits.store_scanline_raw_32 (image, bits, argb8Pixels, x, width);
2351 fbFetch64_generic (bits_image_t *pict, int x, int y, int width, uint64_t *buffer)
2353 /* Fetch the pixels into the first half of buffer and then expand them in
2356 pict->fetch_scanline_raw_32 (pict, x, y, width, (uint32_t*)buffer);
2358 pixman_expand (buffer, (uint32_t*)buffer, pict->format, width);
2362 fbFetchPixel64_generic (bits_image_t *pict, uint64_t *buffer, int n_pixels)
2364 pict->fetch_pixels_raw_32 (pict, (uint32_t *)buffer, n_pixels);
2366 pixman_expand (buffer, (uint32_t *)buffer, pict->format, n_pixels);
2370 * XXX: The transformed fetch path only works at 32-bpp so far. When all paths
2371 * have wide versions, this can be removed.
2373 * WARNING: This function loses precision!
2376 fbFetchPixel32_generic_lossy (bits_image_t *pict, uint32_t *buffer, int n_pixels)
2378 /* Since buffer contains n_pixels coordinate pairs, it also has enough room for
2379 * n_pixels 64 bit pixels
2381 pict->fetch_pixels_raw_64 (pict, (uint64_t *)buffer, n_pixels);
2383 pixman_contract (buffer, (uint64_t *)buffer, n_pixels);
2388 pixman_format_code_t format;
2389 fetchProc32 fetch_scanline_raw_32;
2390 fetchProc64 fetch_scanline_raw_64;
2391 fetch_pixels_32_t fetch_pixels_raw_32;
2392 fetch_pixels_64_t fetch_pixels_raw_64;
2393 storeProc32 store_scanline_raw_32;
2394 storeProc64 store_scanline_raw_64;
2397 #define FORMAT_INFO(format) \
2400 fbFetch_##format, fbFetch64_generic, \
2401 fbFetchPixel_##format, fbFetchPixel64_generic, \
2402 fbStore_##format, fbStore64_generic \
2405 static const format_info_t accessors[] =
2407 /* 32 bpp formats */
2408 FORMAT_INFO (a8r8g8b8),
2409 FORMAT_INFO (x8r8g8b8),
2410 FORMAT_INFO (a8b8g8r8),
2411 FORMAT_INFO (x8b8g8r8),
2412 FORMAT_INFO (b8g8r8a8),
2413 FORMAT_INFO (b8g8r8x8),
2416 FORMAT_INFO (r8g8b8),
2417 FORMAT_INFO (b8g8r8),
2420 FORMAT_INFO (r5g6b5),
2421 FORMAT_INFO (b5g6r5),
2423 FORMAT_INFO (a1r5g5b5),
2424 FORMAT_INFO (x1r5g5b5),
2425 FORMAT_INFO (a1b5g5r5),
2426 FORMAT_INFO (x1b5g5r5),
2427 FORMAT_INFO (a4r4g4b4),
2428 FORMAT_INFO (x4r4g4b4),
2429 FORMAT_INFO (a4b4g4r4),
2430 FORMAT_INFO (x4b4g4r4),
2434 FORMAT_INFO (r3g3b2),
2435 FORMAT_INFO (b2g3r3),
2436 FORMAT_INFO (a2r2g2b2),
2437 FORMAT_INFO (a2b2g2r2),
2441 #define fbFetch_g8 fbFetch_c8
2442 #define fbFetchPixel_g8 fbFetchPixel_c8
2443 #define fbStore_g8 fbStore_c8
2445 #define fbFetch_x4c4 fbFetch_c8
2446 #define fbFetchPixel_x4c4 fbFetchPixel_c8
2447 #define fbStore_x4c4 fbStore_c8
2449 #define fbFetch_x4g4 fbFetch_c8
2450 #define fbFetchPixel_x4g4 fbFetchPixel_c8
2451 #define fbStore_x4g4 fbStore_c8
2458 FORMAT_INFO (r1g2b1),
2459 FORMAT_INFO (b1g2r1),
2460 FORMAT_INFO (a1r1g1b1),
2461 FORMAT_INFO (a1b1g1r1),
2464 #define fbFetch_g4 fbFetch_c4
2465 #define fbFetchPixel_g4 fbFetchPixel_c4
2466 #define fbStore_g4 fbStore_c4
2475 { PIXMAN_a2b10g10r10,
2476 NULL, fbFetch_a2b10g10r10,
2477 fbFetchPixel32_generic_lossy, fbFetchPixel_a2b10g10r10,
2478 NULL, fbStore_a2b10g10r10 },
2480 { PIXMAN_x2b10g10r10,
2481 NULL, fbFetch_x2b10g10r10,
2482 fbFetchPixel32_generic_lossy, fbFetchPixel_x2b10g10r10,
2483 NULL, fbStore_x2b10g10r10 },
2487 fbFetch_yuy2, fbFetch64_generic,
2488 fbFetchPixel_yuy2, fbFetchPixel64_generic,
2492 fbFetch_yv12, fbFetch64_generic,
2493 fbFetchPixel_yv12, fbFetchPixel64_generic,
2500 setup_accessors (bits_image_t *image)
2502 const format_info_t *info = accessors;
2504 while (info->format != PIXMAN_null)
2506 if (info->format == image->format)
2508 image->fetch_scanline_raw_32 = info->fetch_scanline_raw_32;
2509 image->fetch_scanline_raw_64 = info->fetch_scanline_raw_64;
2510 image->fetch_pixels_raw_32 = info->fetch_pixels_raw_32;
2511 image->fetch_pixels_raw_64 = info->fetch_pixels_raw_64;
2512 image->store_scanline_raw_32 = info->store_scanline_raw_32;
2513 image->store_scanline_raw_64 = info->store_scanline_raw_64;
2522 #ifndef PIXMAN_FB_ACCESSORS
2524 _pixman_bits_image_setup_raw_accessors_accessors (bits_image_t *image);
2527 _pixman_bits_image_setup_raw_accessors (bits_image_t *image)
2529 if (image->common.read_func || image->common.write_func)
2530 _pixman_bits_image_setup_raw_accessors_accessors (image);
2532 setup_accessors (image);
2538 _pixman_bits_image_setup_raw_accessors_accessors (bits_image_t *image)
2540 setup_accessors (image);