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 r
= float_to_ubyte(rgba
[i
][0]);
136 g
= float_to_ubyte(rgba
[i
][1]);
137 b
= float_to_ubyte(rgba
[i
][2]);
138 a
= float_to_ubyte(rgba
[i
][3]);
145 case VG_lRGBX_8888
: {
146 VGint
*dst
= (VGint
*)dstAddr
;
147 for (i
= 0; i
< n
; ++i
) {
149 r
= float_to_ubyte(rgba
[i
][0]);
150 g
= float_to_ubyte(rgba
[i
][1]);
151 b
= float_to_ubyte(rgba
[i
][2]);
153 dst
[i
] = r
<< 24 | g
<< 16 | b
<< 8 | a
;
158 case VG_lRGBA_8888
: {
159 VGint
*dst
= (VGint
*)dstAddr
;
160 for (i
= 0; i
< n
; ++i
) {
162 r
= float_to_ubyte(rgba
[i
][0]);
163 g
= float_to_ubyte(rgba
[i
][1]);
164 b
= float_to_ubyte(rgba
[i
][2]);
165 a
= float_to_ubyte(rgba
[i
][3]);
166 dst
[i
] = r
<< 24 | g
<< 16 | b
<< 8 | a
;
170 case VG_lRGBA_8888_PRE
: {
171 VGint
*dst
= (VGint
*)dstAddr
;
172 for (i
= 0; i
< n
; ++i
) {
174 r
= float_to_ubyte(rgba
[i
][0]);
175 g
= float_to_ubyte(rgba
[i
][1]);
176 b
= float_to_ubyte(rgba
[i
][2]);
177 a
= float_to_ubyte(rgba
[i
][3]);
178 dst
[i
] = r
<< 24 | g
<< 16 | b
<< 8 | a
;
184 VGubyte
*dst
= (VGubyte
*)dstAddr
;
185 for (i
= 0; i
< n
; ++i
) {
187 r
= float_to_ubyte(rgba
[i
][0]);
188 g
= float_to_ubyte(rgba
[i
][1]);
189 b
= float_to_ubyte(rgba
[i
][2]);
190 a
= float_to_ubyte(rgba
[i
][3]);
197 VGubyte
*dst
= (VGubyte
*)dstAddr
;
198 for (i
= 0; i
< n
; ++i
) {
200 r
= float_to_ubyte(rgba
[i
][0]);
201 g
= float_to_ubyte(rgba
[i
][1]);
202 b
= float_to_ubyte(rgba
[i
][2]);
203 a
= float_to_ubyte(rgba
[i
][3]);
211 VGshort
*dst
= (VGshort
*)dstAddr
;
212 for (i
= 0; i
< n
; ++i
) {
215 r
= float_to_ubyte(rgba
[i
][0]);
216 g
= float_to_ubyte(rgba
[i
][1]);
217 b
= float_to_ubyte(rgba
[i
][2]);
218 a
= float_to_ubyte(rgba
[i
][3]);
220 res
= (r
+ g
+ b
+ a
)/4;
221 dst
[i
] = (res
& (128));
226 #ifdef OPENVG_VERSION_1_1
228 VGshort
*dst
= (VGshort
*)dstAddr
;
229 for (i
= 0; i
< n
; ++i
) {
231 r
= float_to_ubyte(rgba
[i
][0]);
232 g
= float_to_ubyte(rgba
[i
][1]);
233 b
= float_to_ubyte(rgba
[i
][2]);
234 a
= float_to_ubyte(rgba
[i
][3]);
236 dst
[i
] = (a
& (128));
242 VGshort
*dst
= (VGshort
*)dstAddr
;
243 for (i
= 0; i
< n
; ++i
) {
246 r
= float_to_ubyte(rgba
[i
][0]);
247 g
= float_to_ubyte(rgba
[i
][1]);
248 b
= float_to_ubyte(rgba
[i
][2]);
249 a
= float_to_ubyte(rgba
[i
][3]);
252 dst
[i
] = (res
& (128));
260 case VG_sARGB_8888
: {
261 VGint
*dst
= (VGint
*)dstAddr
;
262 for (i
= 0; i
< n
; ++i
) {
264 r
= float_to_ubyte(rgba
[i
][0]);
265 g
= float_to_ubyte(rgba
[i
][1]);
266 b
= float_to_ubyte(rgba
[i
][2]);
267 a
= float_to_ubyte(rgba
[i
][3]);
268 dst
[i
] = a
<< 24 | r
<< 16 | g
<< 8 | b
;
273 case VG_sARGB_8888_PRE
: {
274 VGint
*dst
= (VGint
*)dstAddr
;
275 for (i
= 0; i
< n
; ++i
) {
277 r
= float_to_ubyte(rgba
[i
][0]);
278 g
= float_to_ubyte(rgba
[i
][1]);
279 b
= float_to_ubyte(rgba
[i
][2]);
280 a
= float_to_ubyte(rgba
[i
][3]);
281 dst
[i
] = a
<< 24 | r
<< 16 | g
<< 8 | b
;
292 case VG_lARGB_8888
: {
293 VGint
*dst
= (VGint
*)dstAddr
;
294 for (i
= 0; i
< n
; ++i
) {
296 r
= float_to_ubyte(rgba
[i
][0]);
297 g
= float_to_ubyte(rgba
[i
][1]);
298 b
= float_to_ubyte(rgba
[i
][2]);
299 a
= float_to_ubyte(rgba
[i
][3]);
300 dst
[i
] = a
<< 24 | r
<< 16 | g
<< 8 | b
;
305 case VG_lARGB_8888_PRE
: {
306 VGint
*dst
= (VGint
*)dstAddr
;
307 for (i
= 0; i
< n
; ++i
) {
309 r
= float_to_ubyte(rgba
[i
][0]);
310 g
= float_to_ubyte(rgba
[i
][1]);
311 b
= float_to_ubyte(rgba
[i
][2]);
312 a
= float_to_ubyte(rgba
[i
][3]);
313 dst
[i
] = a
<< 24 | r
<< 16 | g
<< 8 | b
;
318 case VG_sBGRX_8888
: {
319 VGint
*dst
= (VGint
*)dstAddr
;
320 for (i
= 0; i
< n
; ++i
) {
322 r
= float_to_ubyte(rgba
[i
][0]);
323 g
= float_to_ubyte(rgba
[i
][1]);
324 b
= float_to_ubyte(rgba
[i
][2]);
326 dst
[i
] = b
<< 24 | g
<< 16 | r
<< 8 | a
;
331 case VG_sBGRA_8888
: {
332 VGint
*dst
= (VGint
*)dstAddr
;
333 for (i
= 0; i
< n
; ++i
) {
335 r
= float_to_ubyte(rgba
[i
][0]);
336 g
= float_to_ubyte(rgba
[i
][1]);
337 b
= float_to_ubyte(rgba
[i
][2]);
338 a
= float_to_ubyte(rgba
[i
][3]);
339 dst
[i
] = b
<< 24 | g
<< 16 | r
<< 8 | a
;
344 case VG_sBGRA_8888_PRE
: {
345 VGint
*dst
= (VGint
*)dstAddr
;
346 for (i
= 0; i
< n
; ++i
) {
348 r
= float_to_ubyte(rgba
[i
][0]);
349 g
= float_to_ubyte(rgba
[i
][1]);
350 b
= float_to_ubyte(rgba
[i
][2]);
351 a
= float_to_ubyte(rgba
[i
][3]);
352 dst
[i
] = b
<< 24 | g
<< 16 | r
<< 8 | a
;
363 case VG_lBGRX_8888
: {
364 VGint
*dst
= (VGint
*)dstAddr
;
365 for (i
= 0; i
< n
; ++i
) {
367 r
= float_to_ubyte(rgba
[i
][0]);
368 g
= float_to_ubyte(rgba
[i
][1]);
369 b
= float_to_ubyte(rgba
[i
][2]);
371 dst
[i
] = b
<< 24 | g
<< 16 | r
<< 8 | a
;
376 case VG_lBGRA_8888
: {
377 VGint
*dst
= (VGint
*)dstAddr
;
378 for (i
= 0; i
< n
; ++i
) {
380 r
= float_to_ubyte(rgba
[i
][0]);
381 g
= float_to_ubyte(rgba
[i
][1]);
382 b
= float_to_ubyte(rgba
[i
][2]);
383 a
= float_to_ubyte(rgba
[i
][3]);
384 dst
[i
] = b
<< 24 | g
<< 16 | r
<< 8 | a
;
389 case VG_lBGRA_8888_PRE
: {
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
] = b
<< 24 | g
<< 16 | r
<< 8 | a
;
404 case VG_sABGR_8888
: {
405 VGint
*dst
= (VGint
*)dstAddr
;
406 for (i
= 0; i
< n
; ++i
) {
408 r
= float_to_ubyte(rgba
[i
][0]);
409 g
= float_to_ubyte(rgba
[i
][1]);
410 b
= float_to_ubyte(rgba
[i
][2]);
411 a
= float_to_ubyte(rgba
[i
][3]);
412 dst
[i
] = a
<< 24 | b
<< 16 | g
<< 8 | r
;
417 case VG_sABGR_8888_PRE
: {
418 VGint
*dst
= (VGint
*)dstAddr
;
419 for (i
= 0; i
< n
; ++i
) {
421 r
= float_to_ubyte(rgba
[i
][0]);
422 g
= float_to_ubyte(rgba
[i
][1]);
423 b
= float_to_ubyte(rgba
[i
][2]);
424 a
= float_to_ubyte(rgba
[i
][3]);
425 dst
[i
] = a
<< 24 | b
<< 16 | g
<< 8 | r
;
436 case VG_lABGR_8888
: {
437 VGint
*dst
= (VGint
*)dstAddr
;
438 for (i
= 0; i
< n
; ++i
) {
440 r
= float_to_ubyte(rgba
[i
][0]);
441 g
= float_to_ubyte(rgba
[i
][1]);
442 b
= float_to_ubyte(rgba
[i
][2]);
443 a
= float_to_ubyte(rgba
[i
][3]);
444 dst
[i
] = a
<< 24 | b
<< 16 | g
<< 8 | r
;
449 case VG_lABGR_8888_PRE
: {
450 VGint
*dst
= (VGint
*)dstAddr
;
451 for (i
= 0; i
< n
; ++i
) {
453 r
= float_to_ubyte(rgba
[i
][0]);
454 g
= float_to_ubyte(rgba
[i
][1]);
455 b
= float_to_ubyte(rgba
[i
][2]);
456 a
= float_to_ubyte(rgba
[i
][3]);
457 dst
[i
] = a
<< 24 | b
<< 16 | g
<< 8 | r
;
463 assert(!"Unknown ReadPixels format");
466 assert(!"Not implemented ReadPixels format");
469 void _vega_unpack_float_span_rgba(struct vg_context
*ctx
,
473 VGImageFormat dataFormat
,
478 switch (dataFormat
) {
479 case VG_sRGBX_8888
: {
480 VGuint
*src
= (VGuint
*)data
;
482 for (i
= 0; i
< n
; ++i
) {
484 r
= (*src
>> 24) & 0xff;
485 g
= (*src
>> 16) & 0xff;
486 b
= (*src
>> 8) & 0xff;
489 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
,
495 case VG_sRGBA_8888
: {
496 VGuint
*src
= (VGuint
*)data
;
498 for (i
= 0; i
< n
; ++i
) {
500 r
= (*src
>> 24) & 0xff;
501 g
= (*src
>> 16) & 0xff;
502 b
= (*src
>> 8) & 0xff;
503 a
= (*src
>> 0) & 0xff;
505 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
,
512 case VG_sRGBA_8888_PRE
: {
513 VGint
*src
= (VGint
*)data
;
515 for (i
= 0; i
< n
; ++i
) {
517 r
= (*src
>> 24) & 0xff;
518 g
= (*src
>> 16) & 0xff;
519 b
= (*src
>> 8) & 0xff;
520 a
= (*src
>> 0) & 0xff;
522 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
,
530 VGshort
*src
= (VGshort
*)data
;
532 for (i
= 0; i
< n
; ++i
) {
534 clr
[0] = ((*src
>> 10) & 31)/31.;
535 clr
[1] = ((*src
>> 5) & 95)/95.;
536 clr
[2] = ((*src
>> 0) & 31)/31.;
539 util_pack_color(clr
, PIPE_FORMAT_R32G32B32A32_FLOAT
,
545 case VG_sRGBA_5551
: {
546 VGshort
*src
= (VGshort
*)data
;
548 for (i
= 0; i
< n
; ++i
) {
550 clr
[0] = ((*src
>> 10) & 31)/31.;
551 clr
[1] = ((*src
>> 5) & 31)/31.;
552 clr
[2] = ((*src
>> 1) & 31)/31.;
553 clr
[3] = ((*src
>> 0) & 1)/1.;
555 util_pack_color(clr
, PIPE_FORMAT_R32G32B32A32_FLOAT
,
561 case VG_sRGBA_4444
: {
562 VGshort
*src
= (VGshort
*)data
;
564 for (i
= 0; i
< n
; ++i
) {
566 clr
[0] = ((*src
>> 12) & 15)/15.;
567 clr
[1] = ((*src
>> 8) & 15)/15.;
568 clr
[2] = ((*src
>> 4) & 15)/15.;
569 clr
[3] = ((*src
>> 0) & 15)/15.;
571 util_pack_color(clr
, PIPE_FORMAT_R32G32B32A32_FLOAT
,
578 VGubyte
*src
= (VGubyte
*)data
;
580 for (i
= 0; i
< n
; ++i
) {
581 util_pack_color_ub(0xff, 0xff, 0xff, *src
, PIPE_FORMAT_R32G32B32A32_FLOAT
,
587 case VG_lRGBX_8888
: {
588 VGuint
*src
= (VGuint
*)data
;
590 for (i
= 0; i
< n
; ++i
) {
592 r
= (*src
>> 24) & 0xff;
593 g
= (*src
>> 16) & 0xff;
594 b
= (*src
>> 8) & 0xff;
597 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
,
603 case VG_lRGBA_8888
: {
604 VGint
*src
= (VGint
*)data
;
606 for (i
= 0; i
< n
; ++i
) {
608 r
= (*src
>> 24) & 0xff;
609 g
= (*src
>> 16) & 0xff;
610 b
= (*src
>> 8) & 0xff;
611 a
= (*src
>> 0) & 0xff;
613 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
,
620 case VG_lRGBA_8888_PRE
: {
621 VGint
*src
= (VGint
*)data
;
623 for (i
= 0; i
< n
; ++i
) {
625 r
= (*src
>> 24) & 0xff;
626 g
= (*src
>> 16) & 0xff;
627 b
= (*src
>> 8) & 0xff;
628 a
= (*src
>> 0) & 0xff;
630 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
,
638 VGubyte
*src
= (VGubyte
*)data
;
640 for (i
= 0; i
< n
; ++i
) {
641 util_pack_color_ub(0xff, 0xff, 0xff, *src
, PIPE_FORMAT_R32G32B32A32_FLOAT
,
648 VGubyte
*src
= (VGubyte
*)data
;
650 for (i
= 0; i
< n
; ++i
) {
651 util_pack_color_ub(0xff, 0xff, 0xff, *src
, PIPE_FORMAT_R32G32B32A32_FLOAT
,
658 VGubyte
*src
= (VGubyte
*)data
;
660 for (i
= 0; i
< n
; i
+= 8) {
663 for (j
= 0; j
< 8 && j
< n
; ++j
) {
665 clr
[0] = (((*src
) & (1<<shift
)) >> shift
);
670 util_pack_color(clr
, PIPE_FORMAT_R32G32B32A32_FLOAT
,
677 #ifdef OPENVG_VERSION_1_1
679 VGubyte
*src
= (VGubyte
*)data
;
681 for (i
= 0; i
< n
; i
+= 8) {
684 for (j
= 0; j
< 8 && j
< n
; ++j
) {
689 clr
[3] = (((*src
) & (1<<shift
)) >> shift
);
691 util_pack_color(clr
, PIPE_FORMAT_R32G32B32A32_FLOAT
,
699 VGubyte
*src
= (VGubyte
*)data
;
701 for (i
= 0; i
< n
; i
+= 2) {
704 for (j
= 0; j
< n
&& j
< 2; ++j
) {
716 clr
[3] = ((*src
) & (bitter
)) >> shift
;
718 util_pack_color(clr
, PIPE_FORMAT_R32G32B32A32_FLOAT
,
728 case VG_sARGB_8888
: {
729 VGuint
*src
= (VGuint
*)data
;
731 for (i
= 0; i
< n
; ++i
) {
733 a
= (*src
>> 24) & 0xff;
734 r
= (*src
>> 16) & 0xff;
735 g
= (*src
>> 8) & 0xff;
736 b
= (*src
>> 0) & 0xff;
738 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
,
745 case VG_sARGB_8888_PRE
: {
746 VGuint
*src
= (VGuint
*)data
;
748 for (i
= 0; i
< n
; ++i
) {
750 a
= (*src
>> 24) & 0xff;
751 r
= (*src
>> 16) & 0xff;
752 g
= (*src
>> 8) & 0xff;
753 b
= (*src
>> 0) & 0xff;
755 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
,
768 case VG_lARGB_8888
: {
769 VGint
*src
= (VGint
*)data
;
771 for (i
= 0; i
< n
; ++i
) {
773 a
= (*src
>> 24) & 0xff;
774 r
= (*src
>> 16) & 0xff;
775 g
= (*src
>> 8) & 0xff;
776 b
= (*src
>> 0) & 0xff;
778 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
,
785 case VG_lARGB_8888_PRE
: {
786 VGint
*src
= (VGint
*)data
;
788 for (i
= 0; i
< n
; ++i
) {
790 a
= (*src
>> 24) & 0xff;
791 r
= (*src
>> 16) & 0xff;
792 g
= (*src
>> 8) & 0xff;
793 b
= (*src
>> 0) & 0xff;
795 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
,
804 case VG_sBGRA_8888
: {
805 VGuint
*src
= (VGuint
*)data
;
807 for (i
= 0; i
< n
; ++i
) {
809 b
= (*src
>> 24) & 0xff;
810 g
= (*src
>> 16) & 0xff;
811 r
= (*src
>> 8) & 0xff;
812 a
= (*src
>> 0) & 0xff;
814 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
,
821 case VG_sBGRA_8888_PRE
: {
822 VGuint
*src
= (VGuint
*)data
;
824 for (i
= 0; i
< n
; ++i
) {
826 b
= (*src
>> 24) & 0xff;
827 g
= (*src
>> 16) & 0xff;
828 r
= (*src
>> 8) & 0xff;
829 a
= (*src
>> 0) & 0xff;
831 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
,
846 case VG_lBGRA_8888
: {
847 VGuint
*src
= (VGuint
*)data
;
849 for (i
= 0; i
< n
; ++i
) {
851 b
= (*src
>> 24) & 0xff;
852 g
= (*src
>> 16) & 0xff;
853 r
= (*src
>> 8) & 0xff;
854 a
= (*src
>> 0) & 0xff;
856 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
,
863 case VG_lBGRA_8888_PRE
: {
864 VGuint
*src
= (VGuint
*)data
;
866 for (i
= 0; i
< n
; ++i
) {
868 b
= (*src
>> 24) & 0xff;
869 g
= (*src
>> 16) & 0xff;
870 r
= (*src
>> 8) & 0xff;
871 a
= (*src
>> 0) & 0xff;
873 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
,
882 case VG_sABGR_8888
: {
883 VGuint
*src
= (VGuint
*)data
;
885 for (i
= 0; i
< n
; ++i
) {
887 a
= (*src
>> 24) & 0xff;
888 b
= (*src
>> 16) & 0xff;
889 g
= (*src
>> 8) & 0xff;
890 r
= (*src
>> 0) & 0xff;
892 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
,
899 case VG_sABGR_8888_PRE
: {
900 VGuint
*src
= (VGuint
*)data
;
902 for (i
= 0; i
< n
; ++i
) {
904 a
= (*src
>> 24) & 0xff;
905 b
= (*src
>> 16) & 0xff;
906 g
= (*src
>> 8) & 0xff;
907 r
= (*src
>> 0) & 0xff;
909 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
,
922 case VG_lABGR_8888
: {
923 VGuint
*src
= (VGuint
*)data
;
925 for (i
= 0; i
< n
; ++i
) {
927 a
= (*src
>> 24) & 0xff;
928 b
= (*src
>> 16) & 0xff;
929 g
= (*src
>> 8) & 0xff;
930 r
= (*src
>> 0) & 0xff;
932 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
,
939 case VG_lABGR_8888_PRE
: {
940 VGuint
*src
= (VGuint
*)data
;
942 for (i
= 0; i
< n
; ++i
) {
944 a
= (*src
>> 24) & 0xff;
945 b
= (*src
>> 16) & 0xff;
946 g
= (*src
>> 8) & 0xff;
947 r
= (*src
>> 0) & 0xff;
949 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
,
957 assert(!"Unknown ReadPixels format");
960 assert(!"Not implemented ReadPixels format");
963 VGint
_vega_size_for_format(VGImageFormat dataFormat
)
965 switch (dataFormat
) {
968 case VG_sRGBA_8888_PRE
:
978 case VG_lRGBA_8888_PRE
:
986 #ifdef OPENVG_VERSION_1_1
994 case VG_sARGB_8888_PRE
:
1001 case VG_lARGB_8888_PRE
:
1004 case VG_sBGRA_8888_PRE
:
1012 case VG_lBGRA_8888_PRE
:
1015 case VG_sABGR_8888_PRE
:
1022 case VG_lABGR_8888_PRE
:
1025 assert(!"Unknown ReadPixels format");
1028 assert(!"Not implemented ReadPixels format");