1 /**************************************************************************
3 * Copyright 2009 VMware, Inc. All Rights Reserved.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sub license, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
13 * The above copyright notice and this permission notice (including the
14 * next paragraph) shall be included in all copies or substantial portions
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
20 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
21 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 **************************************************************************/
27 #include "vg_translate.h"
29 #include "pipe/p_format.h"
30 #include "util/u_pack_color.h"
32 void _vega_pack_rgba_span_float(struct vg_context
*ctx
,
33 VGuint n
, VGfloat rgba
[][4],
34 VGImageFormat dstFormat
,
41 VGint
*dst
= (VGint
*)dstAddr
;
42 for (i
= 0; i
< n
; ++i
) {
44 r
= float_to_ubyte(rgba
[i
][0]);
45 g
= float_to_ubyte(rgba
[i
][1]);
46 b
= float_to_ubyte(rgba
[i
][2]);
48 dst
[i
] = r
<< 24 | g
<< 16 | b
<< 8 | a
;
54 VGint
*dst
= (VGint
*)dstAddr
;
55 for (i
= 0; i
< n
; ++i
) {
57 r
= float_to_ubyte(rgba
[i
][0]);
58 g
= float_to_ubyte(rgba
[i
][1]);
59 b
= float_to_ubyte(rgba
[i
][2]);
60 a
= float_to_ubyte(rgba
[i
][3]);
61 dst
[i
] = r
<< 24 | g
<< 16 | b
<< 8 | a
;
66 case VG_sRGBA_8888_PRE
: {
67 VGint
*dst
= (VGint
*)dstAddr
;
68 for (i
= 0; i
< n
; ++i
) {
70 r
= float_to_ubyte(rgba
[i
][0]);
71 g
= float_to_ubyte(rgba
[i
][1]);
72 b
= float_to_ubyte(rgba
[i
][2]);
73 a
= float_to_ubyte(rgba
[i
][3]);
74 dst
[i
] = r
<< 24 | g
<< 16 | b
<< 8 | a
;
80 VGshort
*dst
= (VGshort
*)dstAddr
;
81 for (i
= 0; i
< n
; ++i
) {
83 r
= float_to_ubyte(rgba
[i
][0]);
84 g
= float_to_ubyte(rgba
[i
][1]);
85 b
= float_to_ubyte(rgba
[i
][2]);
90 dst
[i
] = b
| g
<< 5 | r
<< 11;
96 VGshort
*dst
= (VGshort
*)dstAddr
;
97 for (i
= 0; i
< n
; ++i
) {
99 r
= float_to_ubyte(rgba
[i
][0]);
100 g
= float_to_ubyte(rgba
[i
][1]);
101 b
= float_to_ubyte(rgba
[i
][2]);
102 a
= float_to_ubyte(rgba
[i
][3]);
103 r
= (r
/ 255.0) * 32;
104 g
= (g
/ 255.0) * 32;
105 b
= (b
/ 255.0) * 32;
108 dst
[i
] = a
| b
<< 1 | g
<< 6 | r
<< 11;
113 case VG_sRGBA_4444
: {
114 VGshort
*dst
= (VGshort
*)dstAddr
;
115 for (i
= 0; i
< n
; ++i
) {
117 r
= float_to_ubyte(rgba
[i
][0]);
118 g
= float_to_ubyte(rgba
[i
][1]);
119 b
= float_to_ubyte(rgba
[i
][2]);
120 a
= float_to_ubyte(rgba
[i
][3]);
121 r
= (r
/ 255.0) * 16;
122 g
= (g
/ 255.0) * 16;
123 b
= (b
/ 255.0) * 16;
124 a
= (a
/ 255.0) * 16;
126 dst
[i
] = a
| b
<< 4 | g
<< 8 | r
<< 12;
132 VGubyte
*dst
= (VGubyte
*)dstAddr
;
133 for (i
= 0; i
< n
; ++i
) {
135 a
= float_to_ubyte(rgba
[i
][3]);
142 case VG_lRGBX_8888
: {
143 VGint
*dst
= (VGint
*)dstAddr
;
144 for (i
= 0; i
< n
; ++i
) {
146 r
= float_to_ubyte(rgba
[i
][0]);
147 g
= float_to_ubyte(rgba
[i
][1]);
148 b
= float_to_ubyte(rgba
[i
][2]);
150 dst
[i
] = r
<< 24 | g
<< 16 | b
<< 8 | a
;
155 case VG_lRGBA_8888
: {
156 VGint
*dst
= (VGint
*)dstAddr
;
157 for (i
= 0; i
< n
; ++i
) {
159 r
= float_to_ubyte(rgba
[i
][0]);
160 g
= float_to_ubyte(rgba
[i
][1]);
161 b
= float_to_ubyte(rgba
[i
][2]);
162 a
= float_to_ubyte(rgba
[i
][3]);
163 dst
[i
] = r
<< 24 | g
<< 16 | b
<< 8 | a
;
167 case VG_lRGBA_8888_PRE
: {
168 VGint
*dst
= (VGint
*)dstAddr
;
169 for (i
= 0; i
< n
; ++i
) {
171 r
= float_to_ubyte(rgba
[i
][0]);
172 g
= float_to_ubyte(rgba
[i
][1]);
173 b
= float_to_ubyte(rgba
[i
][2]);
174 a
= float_to_ubyte(rgba
[i
][3]);
175 dst
[i
] = r
<< 24 | g
<< 16 | b
<< 8 | a
;
181 VGubyte
*dst
= (VGubyte
*)dstAddr
;
182 for (i
= 0; i
< n
; ++i
) {
184 a
= float_to_ubyte(rgba
[i
][3]);
191 VGubyte
*dst
= (VGubyte
*)dstAddr
;
192 for (i
= 0; i
< n
; ++i
) {
194 a
= float_to_ubyte(rgba
[i
][3]);
202 VGshort
*dst
= (VGshort
*)dstAddr
;
203 for (i
= 0; i
< n
; ++i
) {
206 r
= float_to_ubyte(rgba
[i
][0]);
207 g
= float_to_ubyte(rgba
[i
][1]);
208 b
= float_to_ubyte(rgba
[i
][2]);
209 a
= float_to_ubyte(rgba
[i
][3]);
211 res
= (r
+ g
+ b
+ a
)/4;
212 dst
[i
] = (res
& (128));
217 #ifdef OPENVG_VERSION_1_1
219 VGshort
*dst
= (VGshort
*)dstAddr
;
220 for (i
= 0; i
< n
; ++i
) {
222 a
= float_to_ubyte(rgba
[i
][3]);
224 dst
[i
] = (a
& (128));
230 VGshort
*dst
= (VGshort
*)dstAddr
;
231 for (i
= 0; i
< n
; ++i
) {
234 a
= float_to_ubyte(rgba
[i
][3]);
237 dst
[i
] = (res
& (128));
245 case VG_sARGB_8888
: {
246 VGint
*dst
= (VGint
*)dstAddr
;
247 for (i
= 0; i
< n
; ++i
) {
249 r
= float_to_ubyte(rgba
[i
][0]);
250 g
= float_to_ubyte(rgba
[i
][1]);
251 b
= float_to_ubyte(rgba
[i
][2]);
252 a
= float_to_ubyte(rgba
[i
][3]);
253 dst
[i
] = a
<< 24 | r
<< 16 | g
<< 8 | b
;
258 case VG_sARGB_8888_PRE
: {
259 VGint
*dst
= (VGint
*)dstAddr
;
260 for (i
= 0; i
< n
; ++i
) {
262 r
= float_to_ubyte(rgba
[i
][0]);
263 g
= float_to_ubyte(rgba
[i
][1]);
264 b
= float_to_ubyte(rgba
[i
][2]);
265 a
= float_to_ubyte(rgba
[i
][3]);
266 dst
[i
] = a
<< 24 | r
<< 16 | g
<< 8 | b
;
277 case VG_lARGB_8888
: {
278 VGint
*dst
= (VGint
*)dstAddr
;
279 for (i
= 0; i
< n
; ++i
) {
281 r
= float_to_ubyte(rgba
[i
][0]);
282 g
= float_to_ubyte(rgba
[i
][1]);
283 b
= float_to_ubyte(rgba
[i
][2]);
284 a
= float_to_ubyte(rgba
[i
][3]);
285 dst
[i
] = a
<< 24 | r
<< 16 | g
<< 8 | b
;
290 case VG_lARGB_8888_PRE
: {
291 VGint
*dst
= (VGint
*)dstAddr
;
292 for (i
= 0; i
< n
; ++i
) {
294 r
= float_to_ubyte(rgba
[i
][0]);
295 g
= float_to_ubyte(rgba
[i
][1]);
296 b
= float_to_ubyte(rgba
[i
][2]);
297 a
= float_to_ubyte(rgba
[i
][3]);
298 dst
[i
] = a
<< 24 | r
<< 16 | g
<< 8 | b
;
303 case VG_sBGRX_8888
: {
304 VGint
*dst
= (VGint
*)dstAddr
;
305 for (i
= 0; i
< n
; ++i
) {
307 r
= float_to_ubyte(rgba
[i
][0]);
308 g
= float_to_ubyte(rgba
[i
][1]);
309 b
= float_to_ubyte(rgba
[i
][2]);
311 dst
[i
] = b
<< 24 | g
<< 16 | r
<< 8 | a
;
316 case VG_sBGRA_8888
: {
317 VGint
*dst
= (VGint
*)dstAddr
;
318 for (i
= 0; i
< n
; ++i
) {
320 r
= float_to_ubyte(rgba
[i
][0]);
321 g
= float_to_ubyte(rgba
[i
][1]);
322 b
= float_to_ubyte(rgba
[i
][2]);
323 a
= float_to_ubyte(rgba
[i
][3]);
324 dst
[i
] = b
<< 24 | g
<< 16 | r
<< 8 | a
;
329 case VG_sBGRA_8888_PRE
: {
330 VGint
*dst
= (VGint
*)dstAddr
;
331 for (i
= 0; i
< n
; ++i
) {
333 r
= float_to_ubyte(rgba
[i
][0]);
334 g
= float_to_ubyte(rgba
[i
][1]);
335 b
= float_to_ubyte(rgba
[i
][2]);
336 a
= float_to_ubyte(rgba
[i
][3]);
337 dst
[i
] = b
<< 24 | g
<< 16 | r
<< 8 | a
;
348 case VG_lBGRX_8888
: {
349 VGint
*dst
= (VGint
*)dstAddr
;
350 for (i
= 0; i
< n
; ++i
) {
352 r
= float_to_ubyte(rgba
[i
][0]);
353 g
= float_to_ubyte(rgba
[i
][1]);
354 b
= float_to_ubyte(rgba
[i
][2]);
356 dst
[i
] = b
<< 24 | g
<< 16 | r
<< 8 | a
;
361 case VG_lBGRA_8888
: {
362 VGint
*dst
= (VGint
*)dstAddr
;
363 for (i
= 0; i
< n
; ++i
) {
365 r
= float_to_ubyte(rgba
[i
][0]);
366 g
= float_to_ubyte(rgba
[i
][1]);
367 b
= float_to_ubyte(rgba
[i
][2]);
368 a
= float_to_ubyte(rgba
[i
][3]);
369 dst
[i
] = b
<< 24 | g
<< 16 | r
<< 8 | a
;
374 case VG_lBGRA_8888_PRE
: {
375 VGint
*dst
= (VGint
*)dstAddr
;
376 for (i
= 0; i
< n
; ++i
) {
378 r
= float_to_ubyte(rgba
[i
][0]);
379 g
= float_to_ubyte(rgba
[i
][1]);
380 b
= float_to_ubyte(rgba
[i
][2]);
381 a
= float_to_ubyte(rgba
[i
][3]);
382 dst
[i
] = b
<< 24 | g
<< 16 | r
<< 8 | a
;
389 case VG_sABGR_8888
: {
390 VGint
*dst
= (VGint
*)dstAddr
;
391 for (i
= 0; i
< n
; ++i
) {
393 r
= float_to_ubyte(rgba
[i
][0]);
394 g
= float_to_ubyte(rgba
[i
][1]);
395 b
= float_to_ubyte(rgba
[i
][2]);
396 a
= float_to_ubyte(rgba
[i
][3]);
397 dst
[i
] = a
<< 24 | b
<< 16 | g
<< 8 | r
;
402 case VG_sABGR_8888_PRE
: {
403 VGint
*dst
= (VGint
*)dstAddr
;
404 for (i
= 0; i
< n
; ++i
) {
406 r
= float_to_ubyte(rgba
[i
][0]);
407 g
= float_to_ubyte(rgba
[i
][1]);
408 b
= float_to_ubyte(rgba
[i
][2]);
409 a
= float_to_ubyte(rgba
[i
][3]);
410 dst
[i
] = a
<< 24 | b
<< 16 | g
<< 8 | r
;
421 case VG_lABGR_8888
: {
422 VGint
*dst
= (VGint
*)dstAddr
;
423 for (i
= 0; i
< n
; ++i
) {
425 r
= float_to_ubyte(rgba
[i
][0]);
426 g
= float_to_ubyte(rgba
[i
][1]);
427 b
= float_to_ubyte(rgba
[i
][2]);
428 a
= float_to_ubyte(rgba
[i
][3]);
429 dst
[i
] = a
<< 24 | b
<< 16 | g
<< 8 | r
;
434 case VG_lABGR_8888_PRE
: {
435 VGint
*dst
= (VGint
*)dstAddr
;
436 for (i
= 0; i
< n
; ++i
) {
438 r
= float_to_ubyte(rgba
[i
][0]);
439 g
= float_to_ubyte(rgba
[i
][1]);
440 b
= float_to_ubyte(rgba
[i
][2]);
441 a
= float_to_ubyte(rgba
[i
][3]);
442 dst
[i
] = a
<< 24 | b
<< 16 | g
<< 8 | r
;
448 assert(!"Unknown ReadPixels format");
451 assert(!"Not implemented ReadPixels format");
454 void _vega_unpack_float_span_rgba(struct vg_context
*ctx
,
458 VGImageFormat dataFormat
,
464 switch (dataFormat
) {
465 case VG_sRGBX_8888
: {
466 VGuint
*src
= (VGuint
*)data
;
468 for (i
= 0; i
< n
; ++i
) {
470 r
= (*src
>> 24) & 0xff;
471 g
= (*src
>> 16) & 0xff;
472 b
= (*src
>> 8) & 0xff;
475 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
476 rgba
[i
][0] = uc
.f
[0];
477 rgba
[i
][1] = uc
.f
[1];
478 rgba
[i
][2] = uc
.f
[2];
479 rgba
[i
][3] = uc
.f
[3];
484 case VG_sRGBA_8888
: {
485 VGuint
*src
= (VGuint
*)data
;
487 for (i
= 0; i
< n
; ++i
) {
489 r
= (*src
>> 24) & 0xff;
490 g
= (*src
>> 16) & 0xff;
491 b
= (*src
>> 8) & 0xff;
492 a
= (*src
>> 0) & 0xff;
494 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
495 rgba
[i
][0] = uc
.f
[0];
496 rgba
[i
][1] = uc
.f
[1];
497 rgba
[i
][2] = uc
.f
[2];
498 rgba
[i
][3] = uc
.f
[3];
504 case VG_sRGBA_8888_PRE
: {
505 VGint
*src
= (VGint
*)data
;
507 for (i
= 0; i
< n
; ++i
) {
509 r
= (*src
>> 24) & 0xff;
510 g
= (*src
>> 16) & 0xff;
511 b
= (*src
>> 8) & 0xff;
512 a
= (*src
>> 0) & 0xff;
514 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
515 rgba
[i
][0] = uc
.f
[0];
516 rgba
[i
][1] = uc
.f
[1];
517 rgba
[i
][2] = uc
.f
[2];
518 rgba
[i
][3] = uc
.f
[3];
525 VGshort
*src
= (VGshort
*)data
;
527 for (i
= 0; i
< n
; ++i
) {
529 clr
[0] = ((*src
>> 10) & 31)/31.;
530 clr
[1] = ((*src
>> 5) & 95)/95.;
531 clr
[2] = ((*src
>> 0) & 31)/31.;
534 util_pack_color(clr
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
535 rgba
[i
][0] = uc
.f
[0];
536 rgba
[i
][1] = uc
.f
[1];
537 rgba
[i
][2] = uc
.f
[2];
538 rgba
[i
][3] = uc
.f
[3];
543 case VG_sRGBA_5551
: {
544 VGshort
*src
= (VGshort
*)data
;
546 for (i
= 0; i
< n
; ++i
) {
548 clr
[0] = ((*src
>> 10) & 31)/31.;
549 clr
[1] = ((*src
>> 5) & 31)/31.;
550 clr
[2] = ((*src
>> 1) & 31)/31.;
551 clr
[3] = ((*src
>> 0) & 1)/1.;
553 util_pack_color(clr
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
554 rgba
[i
][0] = uc
.f
[0];
555 rgba
[i
][1] = uc
.f
[1];
556 rgba
[i
][2] = uc
.f
[2];
557 rgba
[i
][3] = uc
.f
[3];
562 case VG_sRGBA_4444
: {
563 VGshort
*src
= (VGshort
*)data
;
565 for (i
= 0; i
< n
; ++i
) {
567 clr
[0] = ((*src
>> 12) & 15)/15.;
568 clr
[1] = ((*src
>> 8) & 15)/15.;
569 clr
[2] = ((*src
>> 4) & 15)/15.;
570 clr
[3] = ((*src
>> 0) & 15)/15.;
572 util_pack_color(clr
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
573 rgba
[i
][0] = uc
.f
[0];
574 rgba
[i
][1] = uc
.f
[1];
575 rgba
[i
][2] = uc
.f
[2];
576 rgba
[i
][3] = uc
.f
[3];
582 VGubyte
*src
= (VGubyte
*)data
;
584 for (i
= 0; i
< n
; ++i
) {
585 util_pack_color_ub(0xff, 0xff, 0xff, *src
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
586 rgba
[i
][0] = uc
.f
[0];
587 rgba
[i
][1] = uc
.f
[1];
588 rgba
[i
][2] = uc
.f
[2];
589 rgba
[i
][3] = uc
.f
[3];
594 case VG_lRGBX_8888
: {
595 VGuint
*src
= (VGuint
*)data
;
597 for (i
= 0; i
< n
; ++i
) {
599 r
= (*src
>> 24) & 0xff;
600 g
= (*src
>> 16) & 0xff;
601 b
= (*src
>> 8) & 0xff;
604 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
605 rgba
[i
][0] = uc
.f
[0];
606 rgba
[i
][1] = uc
.f
[1];
607 rgba
[i
][2] = uc
.f
[2];
608 rgba
[i
][3] = uc
.f
[3];
613 case VG_lRGBA_8888
: {
614 VGint
*src
= (VGint
*)data
;
616 for (i
= 0; i
< n
; ++i
) {
618 r
= (*src
>> 24) & 0xff;
619 g
= (*src
>> 16) & 0xff;
620 b
= (*src
>> 8) & 0xff;
621 a
= (*src
>> 0) & 0xff;
623 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
624 rgba
[i
][0] = uc
.f
[0];
625 rgba
[i
][1] = uc
.f
[1];
626 rgba
[i
][2] = uc
.f
[2];
627 rgba
[i
][3] = uc
.f
[3];
633 case VG_lRGBA_8888_PRE
: {
634 VGint
*src
= (VGint
*)data
;
636 for (i
= 0; i
< n
; ++i
) {
638 r
= (*src
>> 24) & 0xff;
639 g
= (*src
>> 16) & 0xff;
640 b
= (*src
>> 8) & 0xff;
641 a
= (*src
>> 0) & 0xff;
643 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
644 rgba
[i
][0] = uc
.f
[0];
645 rgba
[i
][1] = uc
.f
[1];
646 rgba
[i
][2] = uc
.f
[2];
647 rgba
[i
][3] = uc
.f
[3];
654 VGubyte
*src
= (VGubyte
*)data
;
656 for (i
= 0; i
< n
; ++i
) {
657 util_pack_color_ub(0xff, 0xff, 0xff, *src
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
658 rgba
[i
][0] = uc
.f
[0];
659 rgba
[i
][1] = uc
.f
[1];
660 rgba
[i
][2] = uc
.f
[2];
661 rgba
[i
][3] = uc
.f
[3];
667 VGubyte
*src
= (VGubyte
*)data
;
669 for (i
= 0; i
< n
; ++i
) {
670 util_pack_color_ub(0xff, 0xff, 0xff, *src
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
671 rgba
[i
][0] = uc
.f
[0];
672 rgba
[i
][1] = uc
.f
[1];
673 rgba
[i
][2] = uc
.f
[2];
674 rgba
[i
][3] = uc
.f
[3];
680 VGubyte
*src
= (VGubyte
*)data
;
682 for (i
= 0; i
< n
; i
+= 8) {
685 for (j
= 0; j
< 8 && j
< n
; ++j
) {
687 clr
[0] = (((*src
) & (1<<shift
)) >> shift
);
692 util_pack_color(clr
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
693 rgba
[i
+j
][0] = uc
.f
[0];
694 rgba
[i
+j
][1] = uc
.f
[1];
695 rgba
[i
+j
][2] = uc
.f
[2];
696 rgba
[i
+j
][3] = uc
.f
[3];
702 #ifdef OPENVG_VERSION_1_1
704 VGubyte
*src
= (VGubyte
*)data
;
706 for (i
= 0; i
< n
; i
+= 8) {
709 for (j
= 0; j
< 8 && j
< n
; ++j
) {
714 clr
[3] = (((*src
) & (1<<shift
)) >> shift
);
716 util_pack_color(clr
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
717 rgba
[i
+j
][0] = uc
.f
[0];
718 rgba
[i
+j
][1] = uc
.f
[1];
719 rgba
[i
+j
][2] = uc
.f
[2];
720 rgba
[i
+j
][3] = uc
.f
[3];
727 VGubyte
*src
= (VGubyte
*)data
;
729 for (i
= 0; i
< n
; i
+= 2) {
732 for (j
= 0; j
< n
&& j
< 2; ++j
) {
744 clr
[3] = ((*src
) & (bitter
)) >> shift
;
746 util_pack_color(clr
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
747 rgba
[i
+j
][0] = uc
.f
[0];
748 rgba
[i
+j
][1] = uc
.f
[1];
749 rgba
[i
+j
][2] = uc
.f
[2];
750 rgba
[i
+j
][3] = uc
.f
[3];
759 case VG_sARGB_8888
: {
760 VGuint
*src
= (VGuint
*)data
;
762 for (i
= 0; i
< n
; ++i
) {
764 a
= (*src
>> 24) & 0xff;
765 r
= (*src
>> 16) & 0xff;
766 g
= (*src
>> 8) & 0xff;
767 b
= (*src
>> 0) & 0xff;
769 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
770 rgba
[i
][0] = uc
.f
[0];
771 rgba
[i
][1] = uc
.f
[1];
772 rgba
[i
][2] = uc
.f
[2];
773 rgba
[i
][3] = uc
.f
[3];
779 case VG_sARGB_8888_PRE
: {
780 VGuint
*src
= (VGuint
*)data
;
782 for (i
= 0; i
< n
; ++i
) {
784 a
= (*src
>> 24) & 0xff;
785 r
= (*src
>> 16) & 0xff;
786 g
= (*src
>> 8) & 0xff;
787 b
= (*src
>> 0) & 0xff;
789 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
790 rgba
[i
][0] = uc
.f
[0];
791 rgba
[i
][1] = uc
.f
[1];
792 rgba
[i
][2] = uc
.f
[2];
793 rgba
[i
][3] = uc
.f
[3];
805 case VG_lARGB_8888
: {
806 VGint
*src
= (VGint
*)data
;
808 for (i
= 0; i
< n
; ++i
) {
810 a
= (*src
>> 24) & 0xff;
811 r
= (*src
>> 16) & 0xff;
812 g
= (*src
>> 8) & 0xff;
813 b
= (*src
>> 0) & 0xff;
815 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
816 rgba
[i
][0] = uc
.f
[0];
817 rgba
[i
][1] = uc
.f
[1];
818 rgba
[i
][2] = uc
.f
[2];
819 rgba
[i
][3] = uc
.f
[3];
825 case VG_lARGB_8888_PRE
: {
826 VGint
*src
= (VGint
*)data
;
828 for (i
= 0; i
< n
; ++i
) {
830 a
= (*src
>> 24) & 0xff;
831 r
= (*src
>> 16) & 0xff;
832 g
= (*src
>> 8) & 0xff;
833 b
= (*src
>> 0) & 0xff;
835 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
836 rgba
[i
][0] = uc
.f
[0];
837 rgba
[i
][1] = uc
.f
[1];
838 rgba
[i
][2] = uc
.f
[2];
839 rgba
[i
][3] = uc
.f
[3];
847 case VG_sBGRA_8888
: {
848 VGuint
*src
= (VGuint
*)data
;
850 for (i
= 0; i
< n
; ++i
) {
852 b
= (*src
>> 24) & 0xff;
853 g
= (*src
>> 16) & 0xff;
854 r
= (*src
>> 8) & 0xff;
855 a
= (*src
>> 0) & 0xff;
857 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
858 rgba
[i
][0] = uc
.f
[0];
859 rgba
[i
][1] = uc
.f
[1];
860 rgba
[i
][2] = uc
.f
[2];
861 rgba
[i
][3] = uc
.f
[3];
867 case VG_sBGRA_8888_PRE
: {
868 VGuint
*src
= (VGuint
*)data
;
870 for (i
= 0; i
< n
; ++i
) {
872 b
= (*src
>> 24) & 0xff;
873 g
= (*src
>> 16) & 0xff;
874 r
= (*src
>> 8) & 0xff;
875 a
= (*src
>> 0) & 0xff;
877 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
878 rgba
[i
][0] = uc
.f
[0];
879 rgba
[i
][1] = uc
.f
[1];
880 rgba
[i
][2] = uc
.f
[2];
881 rgba
[i
][3] = uc
.f
[3];
895 case VG_lBGRA_8888
: {
896 VGuint
*src
= (VGuint
*)data
;
898 for (i
= 0; i
< n
; ++i
) {
900 b
= (*src
>> 24) & 0xff;
901 g
= (*src
>> 16) & 0xff;
902 r
= (*src
>> 8) & 0xff;
903 a
= (*src
>> 0) & 0xff;
905 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
906 rgba
[i
][0] = uc
.f
[0];
907 rgba
[i
][1] = uc
.f
[1];
908 rgba
[i
][2] = uc
.f
[2];
909 rgba
[i
][3] = uc
.f
[3];
915 case VG_lBGRA_8888_PRE
: {
916 VGuint
*src
= (VGuint
*)data
;
918 for (i
= 0; i
< n
; ++i
) {
920 b
= (*src
>> 24) & 0xff;
921 g
= (*src
>> 16) & 0xff;
922 r
= (*src
>> 8) & 0xff;
923 a
= (*src
>> 0) & 0xff;
925 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
926 rgba
[i
][0] = uc
.f
[0];
927 rgba
[i
][1] = uc
.f
[1];
928 rgba
[i
][2] = uc
.f
[2];
929 rgba
[i
][3] = uc
.f
[3];
937 case VG_sABGR_8888
: {
938 VGuint
*src
= (VGuint
*)data
;
940 for (i
= 0; i
< n
; ++i
) {
942 a
= (*src
>> 24) & 0xff;
943 b
= (*src
>> 16) & 0xff;
944 g
= (*src
>> 8) & 0xff;
945 r
= (*src
>> 0) & 0xff;
947 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
948 rgba
[i
][0] = uc
.f
[0];
949 rgba
[i
][1] = uc
.f
[1];
950 rgba
[i
][2] = uc
.f
[2];
951 rgba
[i
][3] = uc
.f
[3];
957 case VG_sABGR_8888_PRE
: {
958 VGuint
*src
= (VGuint
*)data
;
960 for (i
= 0; i
< n
; ++i
) {
962 a
= (*src
>> 24) & 0xff;
963 b
= (*src
>> 16) & 0xff;
964 g
= (*src
>> 8) & 0xff;
965 r
= (*src
>> 0) & 0xff;
967 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
968 rgba
[i
][0] = uc
.f
[0];
969 rgba
[i
][1] = uc
.f
[1];
970 rgba
[i
][2] = uc
.f
[2];
971 rgba
[i
][3] = uc
.f
[3];
983 case VG_lABGR_8888
: {
984 VGuint
*src
= (VGuint
*)data
;
986 for (i
= 0; i
< n
; ++i
) {
988 a
= (*src
>> 24) & 0xff;
989 b
= (*src
>> 16) & 0xff;
990 g
= (*src
>> 8) & 0xff;
991 r
= (*src
>> 0) & 0xff;
993 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
994 rgba
[i
][0] = uc
.f
[0];
995 rgba
[i
][1] = uc
.f
[1];
996 rgba
[i
][2] = uc
.f
[2];
997 rgba
[i
][3] = uc
.f
[3];
1003 case VG_lABGR_8888_PRE
: {
1004 VGuint
*src
= (VGuint
*)data
;
1006 for (i
= 0; i
< n
; ++i
) {
1008 a
= (*src
>> 24) & 0xff;
1009 b
= (*src
>> 16) & 0xff;
1010 g
= (*src
>> 8) & 0xff;
1011 r
= (*src
>> 0) & 0xff;
1013 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
1014 rgba
[i
][0] = uc
.f
[0];
1015 rgba
[i
][1] = uc
.f
[1];
1016 rgba
[i
][2] = uc
.f
[2];
1017 rgba
[i
][3] = uc
.f
[3];
1024 assert(!"Unknown ReadPixels format");
1027 assert(!"Not implemented ReadPixels format");
1030 VGint
_vega_size_for_format(VGImageFormat dataFormat
)
1032 switch (dataFormat
) {
1035 case VG_sRGBA_8888_PRE
:
1045 case VG_lRGBA_8888_PRE
:
1053 #ifdef OPENVG_VERSION_1_1
1061 case VG_sARGB_8888_PRE
:
1068 case VG_lARGB_8888_PRE
:
1071 case VG_sBGRA_8888_PRE
:
1079 case VG_lBGRA_8888_PRE
:
1082 case VG_sABGR_8888_PRE
:
1089 case VG_lABGR_8888_PRE
:
1092 assert(!"Unknown ReadPixels format");
1095 assert(!"Not implemented ReadPixels format");