cleanup specfile for packaging
[profile/ivi/cogl.git] / cogl / cogl-bitmap-packing.h
1 /*
2  * Cogl
3  *
4  * An object oriented GL/GLES Abstraction/Utility Layer
5  *
6  * Copyright (C) 2012 Intel Corporation.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
20  *
21  *
22  */
23
24 /* This file is included multiple times with different definitions for
25    the component_type type (either guint8 or guint16). The code ends
26    up exactly the same for both but we only want to end up hitting the
27    16-bit path when one of the types in the conversion is > 8 bits per
28    component. */
29
30 /* Unpacking to RGBA */
31
32 #define UNPACK_1(b) ((b) * ((1 << (sizeof (component_type) * 8)) - 1))
33 #define UNPACK_2(b) (((b) * ((1 << (sizeof (component_type) * 8)) - 1) + \
34                       1) / 3)
35 #define UNPACK_4(b) (((b) * ((1 << (sizeof (component_type) * 8)) - 1) + \
36                       7) / 15)
37 #define UNPACK_5(b) (((b) * ((1 << (sizeof (component_type) * 8)) - 1) + \
38                       15) / 31)
39 #define UNPACK_6(b) (((b) * ((1 << (sizeof (component_type) * 8)) - 1) + \
40                       31) / 63)
41 #define UNPACK_10(b) (((b) * ((1 << (sizeof (component_type) * 8)) - 1) + \
42                        511) / 1023)
43
44 inline static void
45 G_PASTE (_cogl_unpack_a_8_, component_type) (const guint8 *src,
46                                              component_type *dst,
47                                              int width)
48 {
49   while (width-- > 0)
50     {
51       dst[0] = 0;
52       dst[1] = 0;
53       dst[2] = 0;
54       dst[3] = UNPACK_BYTE (*src);
55       dst += 4;
56       src++;
57     }
58 }
59
60 inline static void
61 G_PASTE (_cogl_unpack_g_8_, component_type) (const guint8 *src,
62                                              component_type *dst,
63                                              int width)
64 {
65   /* FIXME: I'm not sure if this is right. It looks like Nvidia and
66      Mesa handle luminance textures differently. Maybe we should
67      consider just removing luminance textures for Cogl 2.0 because
68      they have been removed in GL 3.0 */
69   while (width-- > 0)
70     {
71       component_type v = UNPACK_BYTE (src[0]);
72       dst[0] = v;
73       dst[1] = v;
74       dst[2] = v;
75       dst[3] = UNPACK_BYTE (255);
76       dst += 4;
77       src++;
78     }
79 }
80
81 inline static void
82 G_PASTE (_cogl_unpack_rgb_888_, component_type) (const guint8 *src,
83                                                  component_type *dst,
84                                                  int width)
85 {
86   while (width-- > 0)
87     {
88       dst[0] = UNPACK_BYTE (src[0]);
89       dst[1] = UNPACK_BYTE (src[1]);
90       dst[2] = UNPACK_BYTE (src[2]);
91       dst[3] = UNPACK_BYTE (255);
92       dst += 4;
93       src += 3;
94     }
95 }
96
97 inline static void
98 G_PASTE (_cogl_unpack_bgr_888_, component_type) (const guint8 *src,
99                                                  component_type *dst,
100                                                  int width)
101 {
102   while (width-- > 0)
103     {
104       dst[0] = UNPACK_BYTE (src[2]);
105       dst[1] = UNPACK_BYTE (src[1]);
106       dst[2] = UNPACK_BYTE (src[0]);
107       dst[3] = UNPACK_BYTE (255);
108       dst += 4;
109       src += 3;
110     }
111 }
112
113 inline static void
114 G_PASTE (_cogl_unpack_bgra_8888_, component_type) (const guint8 *src,
115                                                    component_type *dst,
116                                                    int width)
117 {
118   while (width-- > 0)
119     {
120       dst[0] = UNPACK_BYTE (src[2]);
121       dst[1] = UNPACK_BYTE (src[1]);
122       dst[2] = UNPACK_BYTE (src[0]);
123       dst[3] = UNPACK_BYTE (src[3]);
124       dst += 4;
125       src += 4;
126     }
127 }
128
129 inline static void
130 G_PASTE (_cogl_unpack_argb_8888_, component_type) (const guint8 *src,
131                                                    component_type *dst,
132                                                    int width)
133 {
134   while (width-- > 0)
135     {
136       dst[0] = UNPACK_BYTE (src[1]);
137       dst[1] = UNPACK_BYTE (src[2]);
138       dst[2] = UNPACK_BYTE (src[3]);
139       dst[3] = UNPACK_BYTE (src[0]);
140       dst += 4;
141       src += 4;
142     }
143 }
144
145 inline static void
146 G_PASTE (_cogl_unpack_abgr_8888_, component_type) (const guint8 *src,
147                                                    component_type *dst,
148                                                    int width)
149 {
150   while (width-- > 0)
151     {
152       dst[0] = UNPACK_BYTE (src[3]);
153       dst[1] = UNPACK_BYTE (src[2]);
154       dst[2] = UNPACK_BYTE (src[1]);
155       dst[3] = UNPACK_BYTE (src[0]);
156       dst += 4;
157       src += 4;
158     }
159 }
160
161 inline static void
162 G_PASTE (_cogl_unpack_rgba_8888_, component_type) (const guint8 *src,
163                                                    component_type *dst,
164                                                    int width)
165 {
166   while (width-- > 0)
167     {
168       dst[0] = UNPACK_BYTE (src[0]);
169       dst[1] = UNPACK_BYTE (src[1]);
170       dst[2] = UNPACK_BYTE (src[2]);
171       dst[3] = UNPACK_BYTE (src[3]);
172       dst += 4;
173       src += 4;
174     }
175 }
176
177 inline static void
178 G_PASTE (_cogl_unpack_rgb_565_, component_type) (const guint8 *src,
179                                                  component_type *dst,
180                                                  int width)
181 {
182   while (width-- > 0)
183     {
184       guint16 v = *(const guint16 *) src;
185
186       dst[0] = UNPACK_5 (v >> 11);
187       dst[1] = UNPACK_6 ((v >> 5) & 63);
188       dst[2] = UNPACK_5 (v & 31);
189       dst[3] = UNPACK_BYTE (255);
190       dst += 4;
191       src += 2;
192     }
193 }
194
195 inline static void
196 G_PASTE (_cogl_unpack_rgba_4444_, component_type) (const guint8 *src,
197                                                    component_type *dst,
198                                                    int width)
199 {
200   while (width-- > 0)
201     {
202       guint16 v = *(const guint16 *) src;
203
204       dst[0] = UNPACK_4 (v >> 12);
205       dst[1] = UNPACK_4 ((v >> 8) & 15);
206       dst[2] = UNPACK_4 ((v >> 4) & 15);
207       dst[3] = UNPACK_4 (v & 15);
208       dst += 4;
209       src += 2;
210     }
211 }
212
213 inline static void
214 G_PASTE (_cogl_unpack_rgba_5551_, component_type) (const guint8 *src,
215                                                    component_type *dst,
216                                                    int width)
217 {
218   while (width-- > 0)
219     {
220       guint16 v = *(const guint16 *) src;
221
222       dst[0] = UNPACK_5 (v >> 11);
223       dst[1] = UNPACK_5 ((v >> 6) & 31);
224       dst[2] = UNPACK_5 ((v >> 1) & 31);
225       dst[3] = UNPACK_1 (v & 1);
226       dst += 4;
227       src += 2;
228     }
229 }
230
231 inline static void
232 G_PASTE (_cogl_unpack_rgba_1010102_, component_type) (const guint8 *src,
233                                                       component_type *dst,
234                                                       int width)
235 {
236   while (width-- > 0)
237     {
238       guint32 v = *(const guint32 *) src;
239
240       dst[0] = UNPACK_10 (v >> 22);
241       dst[1] = UNPACK_10 ((v >> 12) & 1023);
242       dst[2] = UNPACK_10 ((v >> 2) & 1023);
243       dst[3] = UNPACK_2 (v & 3);
244       dst += 4;
245       src += 2;
246     }
247 }
248
249 inline static void
250 G_PASTE (_cogl_unpack_bgra_1010102_, component_type) (const guint8 *src,
251                                                       component_type *dst,
252                                                       int width)
253 {
254   while (width-- > 0)
255     {
256       guint32 v = *(const guint32 *) src;
257
258       dst[2] = UNPACK_10 (v >> 22);
259       dst[1] = UNPACK_10 ((v >> 12) & 1023);
260       dst[0] = UNPACK_10 ((v >> 2) & 1023);
261       dst[3] = UNPACK_2 (v & 3);
262       dst += 4;
263       src += 2;
264     }
265 }
266
267 inline static void
268 G_PASTE (_cogl_unpack_argb_2101010_, component_type) (const guint8 *src,
269                                                       component_type *dst,
270                                                       int width)
271 {
272   while (width-- > 0)
273     {
274       guint32 v = *(const guint32 *) src;
275
276       dst[3] = UNPACK_2 (v >> 30);
277       dst[0] = UNPACK_10 ((v >> 20) & 1023);
278       dst[1] = UNPACK_10 ((v >> 10) & 1023);
279       dst[2] = UNPACK_10 (v & 1023);
280       dst += 4;
281       src += 2;
282     }
283 }
284
285 inline static void
286 G_PASTE (_cogl_unpack_abgr_2101010_, component_type) (const guint8 *src,
287                                                       component_type *dst,
288                                                       int width)
289 {
290   while (width-- > 0)
291     {
292       guint32 v = *(const guint32 *) src;
293
294       dst[3] = UNPACK_2 (v >> 30);
295       dst[2] = UNPACK_10 ((v >> 20) & 1023);
296       dst[1] = UNPACK_10 ((v >> 10) & 1023);
297       dst[0] = UNPACK_10 (v & 1023);
298       dst += 4;
299       src += 2;
300     }
301 }
302
303 #undef UNPACK_1
304 #undef UNPACK_2
305 #undef UNPACK_4
306 #undef UNPACK_5
307 #undef UNPACK_6
308 #undef UNPACK_10
309
310 inline static void
311 G_PASTE (_cogl_unpack_, component_type) (CoglPixelFormat format,
312                                          const guint8 *src,
313                                          component_type *dst,
314                                          int width)
315 {
316   switch (format)
317     {
318     case COGL_PIXEL_FORMAT_A_8:
319       G_PASTE (_cogl_unpack_a_8_, component_type) (src, dst, width);
320       break;
321     case COGL_PIXEL_FORMAT_G_8:
322       G_PASTE (_cogl_unpack_g_8_, component_type) (src, dst, width);
323       break;
324     case COGL_PIXEL_FORMAT_RGB_888:
325       G_PASTE (_cogl_unpack_rgb_888_, component_type) (src, dst, width);
326       break;
327     case COGL_PIXEL_FORMAT_BGR_888:
328       G_PASTE (_cogl_unpack_bgr_888_, component_type) (src, dst, width);
329       break;
330     case COGL_PIXEL_FORMAT_RGBA_8888:
331     case COGL_PIXEL_FORMAT_RGBA_8888_PRE:
332       G_PASTE (_cogl_unpack_rgba_8888_, component_type) (src, dst, width);
333       break;
334     case COGL_PIXEL_FORMAT_BGRA_8888:
335     case COGL_PIXEL_FORMAT_BGRA_8888_PRE:
336       G_PASTE (_cogl_unpack_bgra_8888_, component_type) (src, dst, width);
337       break;
338     case COGL_PIXEL_FORMAT_ARGB_8888:
339     case COGL_PIXEL_FORMAT_ARGB_8888_PRE:
340       G_PASTE (_cogl_unpack_argb_8888_, component_type) (src, dst, width);
341       break;
342     case COGL_PIXEL_FORMAT_ABGR_8888:
343     case COGL_PIXEL_FORMAT_ABGR_8888_PRE:
344       G_PASTE (_cogl_unpack_abgr_8888_, component_type) (src, dst, width);
345       break;
346     case COGL_PIXEL_FORMAT_RGB_565:
347       G_PASTE (_cogl_unpack_rgb_565_, component_type) (src, dst, width);
348       break;
349     case COGL_PIXEL_FORMAT_RGBA_4444:
350     case COGL_PIXEL_FORMAT_RGBA_4444_PRE:
351       G_PASTE (_cogl_unpack_rgba_4444_, component_type) (src, dst, width);
352       break;
353     case COGL_PIXEL_FORMAT_RGBA_5551:
354     case COGL_PIXEL_FORMAT_RGBA_5551_PRE:
355       G_PASTE (_cogl_unpack_rgba_5551_, component_type) (src, dst, width);
356       break;
357     case COGL_PIXEL_FORMAT_RGBA_1010102:
358     case COGL_PIXEL_FORMAT_RGBA_1010102_PRE:
359       G_PASTE (_cogl_unpack_rgba_1010102_, component_type) (src, dst, width);
360       break;
361     case COGL_PIXEL_FORMAT_BGRA_1010102:
362     case COGL_PIXEL_FORMAT_BGRA_1010102_PRE:
363       G_PASTE (_cogl_unpack_bgra_1010102_, component_type) (src, dst, width);
364       break;
365     case COGL_PIXEL_FORMAT_ARGB_2101010:
366     case COGL_PIXEL_FORMAT_ARGB_2101010_PRE:
367       G_PASTE (_cogl_unpack_argb_2101010_, component_type) (src, dst, width);
368       break;
369     case COGL_PIXEL_FORMAT_ABGR_2101010:
370     case COGL_PIXEL_FORMAT_ABGR_2101010_PRE:
371       G_PASTE (_cogl_unpack_abgr_2101010_, component_type) (src, dst, width);
372       break;
373     case COGL_PIXEL_FORMAT_ANY:
374     case COGL_PIXEL_FORMAT_YUV:
375       g_assert_not_reached ();
376     }
377 }
378
379 /* Packing from RGBA */
380
381 /* Pack and round to nearest */
382 #define PACK_SIZE(b, max) \
383   (((b) * (max) + (1 << (sizeof (component_type) * 8 - 1)) - 1) / \
384    ((1 << (sizeof (component_type) * 8)) - 1))
385
386 #define PACK_1(b) PACK_SIZE (b, 1)
387 #define PACK_2(b) PACK_SIZE (b, 3)
388 #define PACK_4(b) PACK_SIZE (b, 15)
389 #define PACK_5(b) PACK_SIZE (b, 31)
390 #define PACK_6(b) PACK_SIZE (b, 63)
391 #define PACK_10(b) PACK_SIZE (b, 1023)
392
393 inline static void
394 G_PASTE (_cogl_pack_a_8_, component_type) (const component_type *src,
395                                            guint8 *dst,
396                                            int width)
397 {
398   while (width-- > 0)
399     {
400       *dst = PACK_BYTE (src[3]);
401       src += 4;
402       dst++;
403     }
404 }
405
406 inline static void
407 G_PASTE (_cogl_pack_g_8_, component_type) (const component_type *src,
408                                            guint8 *dst,
409                                            int width)
410 {
411   /* FIXME: I'm not sure if this is right. It looks like Nvidia and
412      Mesa handle luminance textures differently. Maybe we should
413      consider just removing luminance textures for Cogl 2.0 because
414      they have been removed in GL 3.0 */
415   while (width-- > 0)
416     {
417       component_type v = (src[0] + src[1] + src[2]) / 3;
418       *dst = PACK_BYTE (v);
419       src += 4;
420       dst++;
421     }
422 }
423
424 inline static void
425 G_PASTE (_cogl_pack_rgb_888_, component_type) (const component_type *src,
426                                                guint8 *dst,
427                                                int width)
428 {
429   while (width-- > 0)
430     {
431       dst[0] = PACK_BYTE (src[0]);
432       dst[1] = PACK_BYTE (src[1]);
433       dst[2] = PACK_BYTE (src[2]);
434       src += 4;
435       dst += 3;
436     }
437 }
438
439 inline static void
440 G_PASTE (_cogl_pack_bgr_888_, component_type) (const component_type *src,
441                                                guint8 *dst,
442                                                int width)
443 {
444   while (width-- > 0)
445     {
446       dst[2] = PACK_BYTE (src[0]);
447       dst[1] = PACK_BYTE (src[1]);
448       dst[0] = PACK_BYTE (src[2]);
449       src += 4;
450       dst += 3;
451     }
452 }
453
454 inline static void
455 G_PASTE (_cogl_pack_bgra_8888_, component_type) (const component_type *src,
456                                                  guint8 *dst,
457                                                  int width)
458 {
459   while (width-- > 0)
460     {
461       dst[2] = PACK_BYTE (src[0]);
462       dst[1] = PACK_BYTE (src[1]);
463       dst[0] = PACK_BYTE (src[2]);
464       dst[3] = PACK_BYTE (src[3]);
465       src += 4;
466       dst += 4;
467     }
468 }
469
470 inline static void
471 G_PASTE (_cogl_pack_argb_8888_, component_type) (const component_type *src,
472                                                  guint8 *dst,
473                                                  int width)
474 {
475   while (width-- > 0)
476     {
477       dst[1] = PACK_BYTE (src[0]);
478       dst[2] = PACK_BYTE (src[1]);
479       dst[3] = PACK_BYTE (src[2]);
480       dst[0] = PACK_BYTE (src[3]);
481       src += 4;
482       dst += 4;
483     }
484 }
485
486 inline static void
487 G_PASTE (_cogl_pack_abgr_8888_, component_type) (const component_type *src,
488                                                  guint8 *dst,
489                                                  int width)
490 {
491   while (width-- > 0)
492     {
493       dst[3] = PACK_BYTE (src[0]);
494       dst[2] = PACK_BYTE (src[1]);
495       dst[1] = PACK_BYTE (src[2]);
496       dst[0] = PACK_BYTE (src[3]);
497       src += 4;
498       dst += 4;
499     }
500 }
501
502 inline static void
503 G_PASTE (_cogl_pack_rgba_8888_, component_type) (const component_type *src,
504                                                  guint8 *dst,
505                                                  int width)
506 {
507   while (width-- > 0)
508     {
509       dst[0] = PACK_BYTE (src[0]);
510       dst[1] = PACK_BYTE (src[1]);
511       dst[2] = PACK_BYTE (src[2]);
512       dst[3] = PACK_BYTE (src[3]);
513       src += 4;
514       dst += 4;
515     }
516 }
517
518 inline static void
519 G_PASTE (_cogl_pack_rgb_565_, component_type) (const component_type *src,
520                                                guint8 *dst,
521                                                int width)
522 {
523   while (width-- > 0)
524     {
525       guint16 *v = (guint16 *) dst;
526
527       *v = ((PACK_5 (src[0]) << 11) |
528             (PACK_6 (src[1]) << 5) |
529             PACK_5 (src[2]));
530       src += 4;
531       dst += 2;
532     }
533 }
534
535 inline static void
536 G_PASTE (_cogl_pack_rgba_4444_, component_type) (const component_type *src,
537                                                  guint8 *dst,
538                                                  int width)
539 {
540   while (width-- > 0)
541     {
542       guint16 *v = (guint16 *) dst;
543
544       *v = ((PACK_4 (src[0]) << 12) |
545             (PACK_4 (src[1]) << 8) |
546             (PACK_4 (src[2]) << 4) |
547             PACK_4 (src[3]));
548       src += 4;
549       dst += 2;
550     }
551 }
552
553 inline static void
554 G_PASTE (_cogl_pack_rgba_5551_, component_type) (const component_type *src,
555                                                  guint8 *dst,
556                                                  int width)
557 {
558   while (width-- > 0)
559     {
560       guint16 *v = (guint16 *) dst;
561
562       *v = ((PACK_5 (src[0]) << 11) |
563             (PACK_5 (src[1]) << 6) |
564             (PACK_5 (src[2]) << 1) |
565             PACK_1 (src[3]));
566       src += 4;
567       dst += 2;
568     }
569 }
570
571 inline static void
572 G_PASTE (_cogl_pack_rgba_1010102_, component_type) (const component_type *src,
573                                                     guint8 *dst,
574                                                     int width)
575 {
576   while (width-- > 0)
577     {
578       guint32 *v = (guint32 *) dst;
579
580       *v = ((PACK_10 (src[0]) << 22) |
581             (PACK_10 (src[1]) << 12) |
582             (PACK_10 (src[2]) << 2) |
583             PACK_2 (src[3]));
584       src += 4;
585       dst += 4;
586     }
587 }
588
589 inline static void
590 G_PASTE (_cogl_pack_bgra_1010102_, component_type) (const component_type *src,
591                                                     guint8 *dst,
592                                                     int width)
593 {
594   while (width-- > 0)
595     {
596       guint32 *v = (guint32 *) dst;
597
598       *v = ((PACK_10 (src[2]) << 22) |
599             (PACK_10 (src[1]) << 12) |
600             (PACK_10 (src[0]) << 2) |
601             PACK_2 (src[3]));
602       src += 4;
603       dst += 4;
604     }
605 }
606
607 inline static void
608 G_PASTE (_cogl_pack_argb_2101010_, component_type) (const component_type *src,
609                                                     guint8 *dst,
610                                                     int width)
611 {
612   while (width-- > 0)
613     {
614       guint32 *v = (guint32 *) dst;
615
616       *v = ((PACK_2 (src[3]) << 30) |
617             (PACK_10 (src[0]) << 20) |
618             (PACK_10 (src[1]) << 10) |
619             PACK_10 (src[2]));
620       src += 4;
621       dst += 4;
622     }
623 }
624
625 inline static void
626 G_PASTE (_cogl_pack_abgr_2101010_, component_type) (const component_type *src,
627                                                     guint8 *dst,
628                                                     int width)
629 {
630   while (width-- > 0)
631     {
632       guint32 *v = (guint32 *) dst;
633
634       *v = ((PACK_2 (src[3]) << 30) |
635             (PACK_10 (src[2]) << 20) |
636             (PACK_10 (src[1]) << 10) |
637             PACK_10 (src[0]));
638       src += 4;
639       dst += 4;
640     }
641 }
642
643 #undef PACK_SIZE
644 #undef PACK_1
645 #undef PACK_2
646 #undef PACK_4
647 #undef PACK_5
648 #undef PACK_6
649 #undef PACK_10
650
651 inline static void
652 G_PASTE (_cogl_pack_, component_type) (CoglPixelFormat format,
653                                        const component_type *src,
654                                        guint8 *dst,
655                                        int width)
656 {
657   switch (format)
658     {
659     case COGL_PIXEL_FORMAT_A_8:
660       G_PASTE (_cogl_pack_a_8_, component_type) (src, dst, width);
661       break;
662     case COGL_PIXEL_FORMAT_G_8:
663       G_PASTE (_cogl_pack_g_8_, component_type) (src, dst, width);
664       break;
665     case COGL_PIXEL_FORMAT_RGB_888:
666       G_PASTE (_cogl_pack_rgb_888_, component_type) (src, dst, width);
667       break;
668     case COGL_PIXEL_FORMAT_BGR_888:
669       G_PASTE (_cogl_pack_bgr_888_, component_type) (src, dst, width);
670       break;
671     case COGL_PIXEL_FORMAT_RGBA_8888:
672     case COGL_PIXEL_FORMAT_RGBA_8888_PRE:
673       G_PASTE (_cogl_pack_rgba_8888_, component_type) (src, dst, width);
674       break;
675     case COGL_PIXEL_FORMAT_BGRA_8888:
676     case COGL_PIXEL_FORMAT_BGRA_8888_PRE:
677       G_PASTE (_cogl_pack_bgra_8888_, component_type) (src, dst, width);
678       break;
679     case COGL_PIXEL_FORMAT_ARGB_8888:
680     case COGL_PIXEL_FORMAT_ARGB_8888_PRE:
681       G_PASTE (_cogl_pack_argb_8888_, component_type) (src, dst, width);
682       break;
683     case COGL_PIXEL_FORMAT_ABGR_8888:
684     case COGL_PIXEL_FORMAT_ABGR_8888_PRE:
685       G_PASTE (_cogl_pack_abgr_8888_, component_type) (src, dst, width);
686       break;
687     case COGL_PIXEL_FORMAT_RGB_565:
688       G_PASTE (_cogl_pack_rgb_565_, component_type) (src, dst, width);
689       break;
690     case COGL_PIXEL_FORMAT_RGBA_4444:
691     case COGL_PIXEL_FORMAT_RGBA_4444_PRE:
692       G_PASTE (_cogl_pack_rgba_4444_, component_type) (src, dst, width);
693       break;
694     case COGL_PIXEL_FORMAT_RGBA_5551:
695     case COGL_PIXEL_FORMAT_RGBA_5551_PRE:
696       G_PASTE (_cogl_pack_rgba_5551_, component_type) (src, dst, width);
697       break;
698     case COGL_PIXEL_FORMAT_RGBA_1010102:
699     case COGL_PIXEL_FORMAT_RGBA_1010102_PRE:
700       G_PASTE (_cogl_pack_rgba_1010102_, component_type) (src, dst, width);
701       break;
702     case COGL_PIXEL_FORMAT_BGRA_1010102:
703     case COGL_PIXEL_FORMAT_BGRA_1010102_PRE:
704       G_PASTE (_cogl_pack_bgra_1010102_, component_type) (src, dst, width);
705       break;
706     case COGL_PIXEL_FORMAT_ARGB_2101010:
707     case COGL_PIXEL_FORMAT_ARGB_2101010_PRE:
708       G_PASTE (_cogl_pack_argb_2101010_, component_type) (src, dst, width);
709       break;
710     case COGL_PIXEL_FORMAT_ABGR_2101010:
711     case COGL_PIXEL_FORMAT_ABGR_2101010_PRE:
712       G_PASTE (_cogl_pack_abgr_2101010_, component_type) (src, dst, width);
713       break;
714     case COGL_PIXEL_FORMAT_ANY:
715     case COGL_PIXEL_FORMAT_YUV:
716       g_assert_not_reached ();
717     }
718 }