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
,
479 switch (dataFormat
) {
480 case VG_sRGBX_8888
: {
481 VGuint
*src
= (VGuint
*)data
;
483 for (i
= 0; i
< n
; ++i
) {
485 r
= (*src
>> 24) & 0xff;
486 g
= (*src
>> 16) & 0xff;
487 b
= (*src
>> 8) & 0xff;
490 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
491 rgba
[i
][0] = uc
.f
[0];
492 rgba
[i
][1] = uc
.f
[1];
493 rgba
[i
][2] = uc
.f
[2];
494 rgba
[i
][3] = uc
.f
[3];
499 case VG_sRGBA_8888
: {
500 VGuint
*src
= (VGuint
*)data
;
502 for (i
= 0; i
< n
; ++i
) {
504 r
= (*src
>> 24) & 0xff;
505 g
= (*src
>> 16) & 0xff;
506 b
= (*src
>> 8) & 0xff;
507 a
= (*src
>> 0) & 0xff;
509 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
510 rgba
[i
][0] = uc
.f
[0];
511 rgba
[i
][1] = uc
.f
[1];
512 rgba
[i
][2] = uc
.f
[2];
513 rgba
[i
][3] = uc
.f
[3];
519 case VG_sRGBA_8888_PRE
: {
520 VGint
*src
= (VGint
*)data
;
522 for (i
= 0; i
< n
; ++i
) {
524 r
= (*src
>> 24) & 0xff;
525 g
= (*src
>> 16) & 0xff;
526 b
= (*src
>> 8) & 0xff;
527 a
= (*src
>> 0) & 0xff;
529 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
530 rgba
[i
][0] = uc
.f
[0];
531 rgba
[i
][1] = uc
.f
[1];
532 rgba
[i
][2] = uc
.f
[2];
533 rgba
[i
][3] = uc
.f
[3];
540 VGshort
*src
= (VGshort
*)data
;
542 for (i
= 0; i
< n
; ++i
) {
544 clr
[0] = ((*src
>> 10) & 31)/31.;
545 clr
[1] = ((*src
>> 5) & 95)/95.;
546 clr
[2] = ((*src
>> 0) & 31)/31.;
549 util_pack_color(clr
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
550 rgba
[i
][0] = uc
.f
[0];
551 rgba
[i
][1] = uc
.f
[1];
552 rgba
[i
][2] = uc
.f
[2];
553 rgba
[i
][3] = uc
.f
[3];
558 case VG_sRGBA_5551
: {
559 VGshort
*src
= (VGshort
*)data
;
561 for (i
= 0; i
< n
; ++i
) {
563 clr
[0] = ((*src
>> 10) & 31)/31.;
564 clr
[1] = ((*src
>> 5) & 31)/31.;
565 clr
[2] = ((*src
>> 1) & 31)/31.;
566 clr
[3] = ((*src
>> 0) & 1)/1.;
568 util_pack_color(clr
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
569 rgba
[i
][0] = uc
.f
[0];
570 rgba
[i
][1] = uc
.f
[1];
571 rgba
[i
][2] = uc
.f
[2];
572 rgba
[i
][3] = uc
.f
[3];
577 case VG_sRGBA_4444
: {
578 VGshort
*src
= (VGshort
*)data
;
580 for (i
= 0; i
< n
; ++i
) {
582 clr
[0] = ((*src
>> 12) & 15)/15.;
583 clr
[1] = ((*src
>> 8) & 15)/15.;
584 clr
[2] = ((*src
>> 4) & 15)/15.;
585 clr
[3] = ((*src
>> 0) & 15)/15.;
587 util_pack_color(clr
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
588 rgba
[i
][0] = uc
.f
[0];
589 rgba
[i
][1] = uc
.f
[1];
590 rgba
[i
][2] = uc
.f
[2];
591 rgba
[i
][3] = uc
.f
[3];
597 VGubyte
*src
= (VGubyte
*)data
;
599 for (i
= 0; i
< n
; ++i
) {
600 util_pack_color_ub(0xff, 0xff, 0xff, *src
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
601 rgba
[i
][0] = uc
.f
[0];
602 rgba
[i
][1] = uc
.f
[1];
603 rgba
[i
][2] = uc
.f
[2];
604 rgba
[i
][3] = uc
.f
[3];
609 case VG_lRGBX_8888
: {
610 VGuint
*src
= (VGuint
*)data
;
612 for (i
= 0; i
< n
; ++i
) {
614 r
= (*src
>> 24) & 0xff;
615 g
= (*src
>> 16) & 0xff;
616 b
= (*src
>> 8) & 0xff;
619 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
620 rgba
[i
][0] = uc
.f
[0];
621 rgba
[i
][1] = uc
.f
[1];
622 rgba
[i
][2] = uc
.f
[2];
623 rgba
[i
][3] = uc
.f
[3];
628 case VG_lRGBA_8888
: {
629 VGint
*src
= (VGint
*)data
;
631 for (i
= 0; i
< n
; ++i
) {
633 r
= (*src
>> 24) & 0xff;
634 g
= (*src
>> 16) & 0xff;
635 b
= (*src
>> 8) & 0xff;
636 a
= (*src
>> 0) & 0xff;
638 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
639 rgba
[i
][0] = uc
.f
[0];
640 rgba
[i
][1] = uc
.f
[1];
641 rgba
[i
][2] = uc
.f
[2];
642 rgba
[i
][3] = uc
.f
[3];
648 case VG_lRGBA_8888_PRE
: {
649 VGint
*src
= (VGint
*)data
;
651 for (i
= 0; i
< n
; ++i
) {
653 r
= (*src
>> 24) & 0xff;
654 g
= (*src
>> 16) & 0xff;
655 b
= (*src
>> 8) & 0xff;
656 a
= (*src
>> 0) & 0xff;
658 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
659 rgba
[i
][0] = uc
.f
[0];
660 rgba
[i
][1] = uc
.f
[1];
661 rgba
[i
][2] = uc
.f
[2];
662 rgba
[i
][3] = uc
.f
[3];
669 VGubyte
*src
= (VGubyte
*)data
;
671 for (i
= 0; i
< n
; ++i
) {
672 util_pack_color_ub(0xff, 0xff, 0xff, *src
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
673 rgba
[i
][0] = uc
.f
[0];
674 rgba
[i
][1] = uc
.f
[1];
675 rgba
[i
][2] = uc
.f
[2];
676 rgba
[i
][3] = uc
.f
[3];
682 VGubyte
*src
= (VGubyte
*)data
;
684 for (i
= 0; i
< n
; ++i
) {
685 util_pack_color_ub(0xff, 0xff, 0xff, *src
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
686 rgba
[i
][0] = uc
.f
[0];
687 rgba
[i
][1] = uc
.f
[1];
688 rgba
[i
][2] = uc
.f
[2];
689 rgba
[i
][3] = uc
.f
[3];
695 VGubyte
*src
= (VGubyte
*)data
;
697 for (i
= 0; i
< n
; i
+= 8) {
700 for (j
= 0; j
< 8 && j
< n
; ++j
) {
702 clr
[0] = (((*src
) & (1<<shift
)) >> shift
);
707 util_pack_color(clr
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
708 rgba
[i
+j
][0] = uc
.f
[0];
709 rgba
[i
+j
][1] = uc
.f
[1];
710 rgba
[i
+j
][2] = uc
.f
[2];
711 rgba
[i
+j
][3] = uc
.f
[3];
717 #ifdef OPENVG_VERSION_1_1
719 VGubyte
*src
= (VGubyte
*)data
;
721 for (i
= 0; i
< n
; i
+= 8) {
724 for (j
= 0; j
< 8 && j
< n
; ++j
) {
729 clr
[3] = (((*src
) & (1<<shift
)) >> shift
);
731 util_pack_color(clr
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
732 rgba
[i
+j
][0] = uc
.f
[0];
733 rgba
[i
+j
][1] = uc
.f
[1];
734 rgba
[i
+j
][2] = uc
.f
[2];
735 rgba
[i
+j
][3] = uc
.f
[3];
742 VGubyte
*src
= (VGubyte
*)data
;
744 for (i
= 0; i
< n
; i
+= 2) {
747 for (j
= 0; j
< n
&& j
< 2; ++j
) {
759 clr
[3] = ((*src
) & (bitter
)) >> shift
;
761 util_pack_color(clr
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
762 rgba
[i
+j
][0] = uc
.f
[0];
763 rgba
[i
+j
][1] = uc
.f
[1];
764 rgba
[i
+j
][2] = uc
.f
[2];
765 rgba
[i
+j
][3] = uc
.f
[3];
774 case VG_sARGB_8888
: {
775 VGuint
*src
= (VGuint
*)data
;
777 for (i
= 0; i
< n
; ++i
) {
779 a
= (*src
>> 24) & 0xff;
780 r
= (*src
>> 16) & 0xff;
781 g
= (*src
>> 8) & 0xff;
782 b
= (*src
>> 0) & 0xff;
784 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
785 rgba
[i
][0] = uc
.f
[0];
786 rgba
[i
][1] = uc
.f
[1];
787 rgba
[i
][2] = uc
.f
[2];
788 rgba
[i
][3] = uc
.f
[3];
794 case VG_sARGB_8888_PRE
: {
795 VGuint
*src
= (VGuint
*)data
;
797 for (i
= 0; i
< n
; ++i
) {
799 a
= (*src
>> 24) & 0xff;
800 r
= (*src
>> 16) & 0xff;
801 g
= (*src
>> 8) & 0xff;
802 b
= (*src
>> 0) & 0xff;
804 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
805 rgba
[i
][0] = uc
.f
[0];
806 rgba
[i
][1] = uc
.f
[1];
807 rgba
[i
][2] = uc
.f
[2];
808 rgba
[i
][3] = uc
.f
[3];
820 case VG_lARGB_8888
: {
821 VGint
*src
= (VGint
*)data
;
823 for (i
= 0; i
< n
; ++i
) {
825 a
= (*src
>> 24) & 0xff;
826 r
= (*src
>> 16) & 0xff;
827 g
= (*src
>> 8) & 0xff;
828 b
= (*src
>> 0) & 0xff;
830 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
831 rgba
[i
][0] = uc
.f
[0];
832 rgba
[i
][1] = uc
.f
[1];
833 rgba
[i
][2] = uc
.f
[2];
834 rgba
[i
][3] = uc
.f
[3];
840 case VG_lARGB_8888_PRE
: {
841 VGint
*src
= (VGint
*)data
;
843 for (i
= 0; i
< n
; ++i
) {
845 a
= (*src
>> 24) & 0xff;
846 r
= (*src
>> 16) & 0xff;
847 g
= (*src
>> 8) & 0xff;
848 b
= (*src
>> 0) & 0xff;
850 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
851 rgba
[i
][0] = uc
.f
[0];
852 rgba
[i
][1] = uc
.f
[1];
853 rgba
[i
][2] = uc
.f
[2];
854 rgba
[i
][3] = uc
.f
[3];
862 case VG_sBGRA_8888
: {
863 VGuint
*src
= (VGuint
*)data
;
865 for (i
= 0; i
< n
; ++i
) {
867 b
= (*src
>> 24) & 0xff;
868 g
= (*src
>> 16) & 0xff;
869 r
= (*src
>> 8) & 0xff;
870 a
= (*src
>> 0) & 0xff;
872 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
873 rgba
[i
][0] = uc
.f
[0];
874 rgba
[i
][1] = uc
.f
[1];
875 rgba
[i
][2] = uc
.f
[2];
876 rgba
[i
][3] = uc
.f
[3];
882 case VG_sBGRA_8888_PRE
: {
883 VGuint
*src
= (VGuint
*)data
;
885 for (i
= 0; i
< n
; ++i
) {
887 b
= (*src
>> 24) & 0xff;
888 g
= (*src
>> 16) & 0xff;
889 r
= (*src
>> 8) & 0xff;
890 a
= (*src
>> 0) & 0xff;
892 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
893 rgba
[i
][0] = uc
.f
[0];
894 rgba
[i
][1] = uc
.f
[1];
895 rgba
[i
][2] = uc
.f
[2];
896 rgba
[i
][3] = uc
.f
[3];
910 case VG_lBGRA_8888
: {
911 VGuint
*src
= (VGuint
*)data
;
913 for (i
= 0; i
< n
; ++i
) {
915 b
= (*src
>> 24) & 0xff;
916 g
= (*src
>> 16) & 0xff;
917 r
= (*src
>> 8) & 0xff;
918 a
= (*src
>> 0) & 0xff;
920 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
921 rgba
[i
][0] = uc
.f
[0];
922 rgba
[i
][1] = uc
.f
[1];
923 rgba
[i
][2] = uc
.f
[2];
924 rgba
[i
][3] = uc
.f
[3];
930 case VG_lBGRA_8888_PRE
: {
931 VGuint
*src
= (VGuint
*)data
;
933 for (i
= 0; i
< n
; ++i
) {
935 b
= (*src
>> 24) & 0xff;
936 g
= (*src
>> 16) & 0xff;
937 r
= (*src
>> 8) & 0xff;
938 a
= (*src
>> 0) & 0xff;
940 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
941 rgba
[i
][0] = uc
.f
[0];
942 rgba
[i
][1] = uc
.f
[1];
943 rgba
[i
][2] = uc
.f
[2];
944 rgba
[i
][3] = uc
.f
[3];
952 case VG_sABGR_8888
: {
953 VGuint
*src
= (VGuint
*)data
;
955 for (i
= 0; i
< n
; ++i
) {
957 a
= (*src
>> 24) & 0xff;
958 b
= (*src
>> 16) & 0xff;
959 g
= (*src
>> 8) & 0xff;
960 r
= (*src
>> 0) & 0xff;
962 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
963 rgba
[i
][0] = uc
.f
[0];
964 rgba
[i
][1] = uc
.f
[1];
965 rgba
[i
][2] = uc
.f
[2];
966 rgba
[i
][3] = uc
.f
[3];
972 case VG_sABGR_8888_PRE
: {
973 VGuint
*src
= (VGuint
*)data
;
975 for (i
= 0; i
< n
; ++i
) {
977 a
= (*src
>> 24) & 0xff;
978 b
= (*src
>> 16) & 0xff;
979 g
= (*src
>> 8) & 0xff;
980 r
= (*src
>> 0) & 0xff;
982 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
983 rgba
[i
][0] = uc
.f
[0];
984 rgba
[i
][1] = uc
.f
[1];
985 rgba
[i
][2] = uc
.f
[2];
986 rgba
[i
][3] = uc
.f
[3];
998 case VG_lABGR_8888
: {
999 VGuint
*src
= (VGuint
*)data
;
1001 for (i
= 0; i
< n
; ++i
) {
1003 a
= (*src
>> 24) & 0xff;
1004 b
= (*src
>> 16) & 0xff;
1005 g
= (*src
>> 8) & 0xff;
1006 r
= (*src
>> 0) & 0xff;
1008 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
1009 rgba
[i
][0] = uc
.f
[0];
1010 rgba
[i
][1] = uc
.f
[1];
1011 rgba
[i
][2] = uc
.f
[2];
1012 rgba
[i
][3] = uc
.f
[3];
1018 case VG_lABGR_8888_PRE
: {
1019 VGuint
*src
= (VGuint
*)data
;
1021 for (i
= 0; i
< n
; ++i
) {
1023 a
= (*src
>> 24) & 0xff;
1024 b
= (*src
>> 16) & 0xff;
1025 g
= (*src
>> 8) & 0xff;
1026 r
= (*src
>> 0) & 0xff;
1028 util_pack_color_ub(r
, g
, b
, a
, PIPE_FORMAT_R32G32B32A32_FLOAT
, &uc
);
1029 rgba
[i
][0] = uc
.f
[0];
1030 rgba
[i
][1] = uc
.f
[1];
1031 rgba
[i
][2] = uc
.f
[2];
1032 rgba
[i
][3] = uc
.f
[3];
1039 assert(!"Unknown ReadPixels format");
1042 assert(!"Not implemented ReadPixels format");
1045 VGint
_vega_size_for_format(VGImageFormat dataFormat
)
1047 switch (dataFormat
) {
1050 case VG_sRGBA_8888_PRE
:
1060 case VG_lRGBA_8888_PRE
:
1068 #ifdef OPENVG_VERSION_1_1
1076 case VG_sARGB_8888_PRE
:
1083 case VG_lARGB_8888_PRE
:
1086 case VG_sBGRA_8888_PRE
:
1094 case VG_lBGRA_8888_PRE
:
1097 case VG_sABGR_8888_PRE
:
1104 case VG_lABGR_8888_PRE
:
1107 assert(!"Unknown ReadPixels format");
1110 assert(!"Not implemented ReadPixels format");