summaryrefslogtreecommitdiffstats
path: root/gfx/angle/src/image_util/imageformats.h
blob: b4ff04482f87077a85113df8fe915d628c5c24eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
//
// Copyright (c) 2013-2015 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//

// imageformats.h: Defines image format types with functions for mip generation
// and copying.

#ifndef IMAGEUTIL_IMAGEFORMATS_H_
#define IMAGEUTIL_IMAGEFORMATS_H_

#include "common/Color.h"

#include <cstdint>

namespace angle
{

// Several structures share functionality for reading, writing or mipmapping but the layout
// must match the texture format which the structure represents. If collapsing or typedefing
// structs in this header, make sure the functionality and memory layout is exactly the same.

struct L8
{
    uint8_t L;

    static void readColor(gl::ColorF *dst, const L8 *src);
    static void writeColor(L8 *dst, const gl::ColorF *src);
    static void average(L8 *dst, const L8 *src1, const L8 *src2);
};

struct R8
{
    uint8_t R;

    static void readColor(gl::ColorF *dst, const R8 *src);
    static void readColor(gl::ColorUI *dst, const R8 *src);
    static void writeColor(R8 *dst, const gl::ColorF *src);
    static void writeColor(R8 *dst, const gl::ColorUI *src);
    static void average(R8 *dst, const R8 *src1, const R8 *src2);
};

struct A8
{
    uint8_t A;

    static void readColor(gl::ColorF *dst, const A8 *src);
    static void writeColor(A8 *dst, const gl::ColorF *src);
    static void average(A8 *dst, const A8 *src1, const A8 *src2);
};

struct L8A8
{
    uint8_t L;
    uint8_t A;

    static void readColor(gl::ColorF *dst, const L8A8 *src);
    static void writeColor(L8A8 *dst, const gl::ColorF *src);
    static void average(L8A8 *dst, const L8A8 *src1, const L8A8 *src2);
};

struct A8L8
{
    uint8_t A;
    uint8_t L;

    static void readColor(gl::ColorF *dst, const A8L8 *src);
    static void writeColor(A8L8 *dst, const gl::ColorF *src);
    static void average(A8L8 *dst, const A8L8 *src1, const A8L8 *src2);
};

struct R8G8
{
    uint8_t R;
    uint8_t G;

    static void readColor(gl::ColorF *dst, const R8G8 *src);
    static void readColor(gl::ColorUI *dst, const R8G8 *src);
    static void writeColor(R8G8 *dst, const gl::ColorF *src);
    static void writeColor(R8G8 *dst, const gl::ColorUI *src);
    static void average(R8G8 *dst, const R8G8 *src1, const R8G8 *src2);
};

struct R8G8B8
{
    uint8_t R;
    uint8_t G;
    uint8_t B;

    static void readColor(gl::ColorF *dst, const R8G8B8 *src);
    static void readColor(gl::ColorUI *dst, const R8G8B8 *src);
    static void writeColor(R8G8B8 *dst, const gl::ColorF *src);
    static void writeColor(R8G8B8 *dst, const gl::ColorUI *src);
    static void average(R8G8B8 *dst, const R8G8B8 *src1, const R8G8B8 *src2);
};

struct B8G8R8
{
    uint8_t B;
    uint8_t G;
    uint8_t R;

    static void readColor(gl::ColorF *dst, const B8G8R8 *src);
    static void readColor(gl::ColorUI *dst, const B8G8R8 *src);
    static void writeColor(B8G8R8 *dst, const gl::ColorF *src);
    static void writeColor(B8G8R8 *dst, const gl::ColorUI *src);
    static void average(B8G8R8 *dst, const B8G8R8 *src1, const B8G8R8 *src2);
};

struct R5G6B5
{
    // OpenGL ES 2.0.25 spec Section 3.6.2: "Components are packed with the first component in the
    // most significant bits of the bitfield, and successive component occupying progressively less
    // significant locations"
    uint16_t RGB;

    static void readColor(gl::ColorF *dst, const R5G6B5 *src);
    static void writeColor(R5G6B5 *dst, const gl::ColorF *src);
    static void average(R5G6B5 *dst, const R5G6B5 *src1, const R5G6B5 *src2);
};

struct B5G6R5
{
    uint16_t BGR;

    static void readColor(gl::ColorF *dst, const B5G6R5 *src);
    static void writeColor(B5G6R5 *dst, const gl::ColorF *src);
    static void average(B5G6R5 *dst, const B5G6R5 *src1, const B5G6R5 *src2);
};

struct A8R8G8B8
{
    uint8_t A;
    uint8_t R;
    uint8_t G;
    uint8_t B;

    static void readColor(gl::ColorF *dst, const A8R8G8B8 *src);
    static void readColor(gl::ColorUI *dst, const A8R8G8B8 *src);
    static void writeColor(A8R8G8B8 *dst, const gl::ColorF *src);
    static void writeColor(A8R8G8B8 *dst, const gl::ColorUI *src);
    static void average(A8R8G8B8 *dst, const A8R8G8B8 *src1, const A8R8G8B8 *src2);
};

struct R8G8B8A8
{
    uint8_t R;
    uint8_t G;
    uint8_t B;
    uint8_t A;

    static void readColor(gl::ColorF *dst, const R8G8B8A8 *src);
    static void readColor(gl::ColorUI *dst, const R8G8B8A8 *src);
    static void writeColor(R8G8B8A8 *dst, const gl::ColorF *src);
    static void writeColor(R8G8B8A8 *dst, const gl::ColorUI *src);
    static void average(R8G8B8A8 *dst, const R8G8B8A8 *src1, const R8G8B8A8 *src2);
};

struct B8G8R8A8
{
    uint8_t B;
    uint8_t G;
    uint8_t R;
    uint8_t A;

    static void readColor(gl::ColorF *dst, const B8G8R8A8 *src);
    static void readColor(gl::ColorUI *dst, const B8G8R8A8 *src);
    static void writeColor(B8G8R8A8 *dst, const gl::ColorF *src);
    static void writeColor(B8G8R8A8 *dst, const gl::ColorUI *src);
    static void average(B8G8R8A8 *dst, const B8G8R8A8 *src1, const B8G8R8A8 *src2);
};

struct B8G8R8X8
{
    uint8_t B;
    uint8_t G;
    uint8_t R;
    uint8_t X;

    static void readColor(gl::ColorF *dst, const B8G8R8X8 *src);
    static void readColor(gl::ColorUI *dst, const B8G8R8X8 *src);
    static void writeColor(B8G8R8X8 *dst, const gl::ColorF *src);
    static void writeColor(B8G8R8X8 *dst, const gl::ColorUI *src);
    static void average(B8G8R8X8 *dst, const B8G8R8X8 *src1, const B8G8R8X8 *src2);
};

struct A1R5G5B5
{
    uint16_t ARGB;

    static void readColor(gl::ColorF *dst, const A1R5G5B5 *src);
    static void writeColor(A1R5G5B5 *dst, const gl::ColorF *src);
    static void average(A1R5G5B5 *dst, const A1R5G5B5 *src1, const A1R5G5B5 *src2);
};

struct R5G5B5A1
{
    // OpenGL ES 2.0.25 spec Section 3.6.2: "Components are packed with the first component in the
    // most significant
    // bits of the bitfield, and successive component occupying progressively less significant
    // locations"
    uint16_t RGBA;

    static void readColor(gl::ColorF *dst, const R5G5B5A1 *src);
    static void writeColor(R5G5B5A1 *dst, const gl::ColorF *src);
    static void average(R5G5B5A1 *dst, const R5G5B5A1 *src1, const R5G5B5A1 *src2);
};

struct R4G4B4A4
{
    // OpenGL ES 2.0.25 spec Section 3.6.2: "Components are packed with the first component in the
    // most significant
    // bits of the bitfield, and successive component occupying progressively less significant
    // locations"
    uint16_t RGBA;

    static void readColor(gl::ColorF *dst, const R4G4B4A4 *src);
    static void writeColor(R4G4B4A4 *dst, const gl::ColorF *src);
    static void average(R4G4B4A4 *dst, const R4G4B4A4 *src1, const R4G4B4A4 *src2);
};

struct A4R4G4B4
{
    uint16_t ARGB;

    static void readColor(gl::ColorF *dst, const A4R4G4B4 *src);
    static void writeColor(A4R4G4B4 *dst, const gl::ColorF *src);
    static void average(A4R4G4B4 *dst, const A4R4G4B4 *src1, const A4R4G4B4 *src2);
};

struct R16
{
    uint16_t R;

    static void readColor(gl::ColorF *dst, const R16 *src);
    static void readColor(gl::ColorUI *dst, const R16 *src);
    static void writeColor(R16 *dst, const gl::ColorF *src);
    static void writeColor(R16 *dst, const gl::ColorUI *src);
    static void average(R16 *dst, const R16 *src1, const R16 *src2);
};

struct R16G16
{
    uint16_t R;
    uint16_t G;

    static void readColor(gl::ColorF *dst, const R16G16 *src);
    static void readColor(gl::ColorUI *dst, const R16G16 *src);
    static void writeColor(R16G16 *dst, const gl::ColorF *src);
    static void writeColor(R16G16 *dst, const gl::ColorUI *src);
    static void average(R16G16 *dst, const R16G16 *src1, const R16G16 *src2);
};

struct R16G16B16
{
    uint16_t R;
    uint16_t G;
    uint16_t B;

    static void readColor(gl::ColorF *dst, const R16G16B16 *src);
    static void readColor(gl::ColorUI *dst, const R16G16B16 *src);
    static void writeColor(R16G16B16 *dst, const gl::ColorF *src);
    static void writeColor(R16G16B16 *dst, const gl::ColorUI *src);
    static void average(R16G16B16 *dst, const R16G16B16 *src1, const R16G16B16 *src2);
};

struct R16G16B16A16
{
    uint16_t R;
    uint16_t G;
    uint16_t B;
    uint16_t A;

    static void readColor(gl::ColorF *dst, const R16G16B16A16 *src);
    static void readColor(gl::ColorUI *dst, const R16G16B16A16 *src);
    static void writeColor(R16G16B16A16 *dst, const gl::ColorF *src);
    static void writeColor(R16G16B16A16 *dst, const gl::ColorUI *src);
    static void average(R16G16B16A16 *dst, const R16G16B16A16 *src1, const R16G16B16A16 *src2);
};

struct R32
{
    uint32_t R;

    static void readColor(gl::ColorF *dst, const R32 *src);
    static void readColor(gl::ColorUI *dst, const R32 *src);
    static void writeColor(R32 *dst, const gl::ColorF *src);
    static void writeColor(R32 *dst, const gl::ColorUI *src);
    static void average(R32 *dst, const R32 *src1, const R32 *src2);
};

struct R32G32
{
    uint32_t R;
    uint32_t G;

    static void readColor(gl::ColorF *dst, const R32G32 *src);
    static void readColor(gl::ColorUI *dst, const R32G32 *src);
    static void writeColor(R32G32 *dst, const gl::ColorF *src);
    static void writeColor(R32G32 *dst, const gl::ColorUI *src);
    static void average(R32G32 *dst, const R32G32 *src1, const R32G32 *src2);
};

struct R32G32B32
{
    uint32_t R;
    uint32_t G;
    uint32_t B;

    static void readColor(gl::ColorF *dst, const R32G32B32 *src);
    static void readColor(gl::ColorUI *dst, const R32G32B32 *src);
    static void writeColor(R32G32B32 *dst, const gl::ColorF *src);
    static void writeColor(R32G32B32 *dst, const gl::ColorUI *src);
    static void average(R32G32B32 *dst, const R32G32B32 *src1, const R32G32B32 *src2);
};

struct R32G32B32A32
{
    uint32_t R;
    uint32_t G;
    uint32_t B;
    uint32_t A;

    static void readColor(gl::ColorF *dst, const R32G32B32A32 *src);
    static void readColor(gl::ColorUI *dst, const R32G32B32A32 *src);
    static void writeColor(R32G32B32A32 *dst, const gl::ColorF *src);
    static void writeColor(R32G32B32A32 *dst, const gl::ColorUI *src);
    static void average(R32G32B32A32 *dst, const R32G32B32A32 *src1, const R32G32B32A32 *src2);
};

struct R8S
{
    int8_t R;

    static void readColor(gl::ColorF *dst, const R8S *src);
    static void readColor(gl::ColorI *dst, const R8S *src);
    static void writeColor(R8S *dst, const gl::ColorF *src);
    static void writeColor(R8S *dst, const gl::ColorI *src);
    static void average(R8S *dst, const R8S *src1, const R8S *src2);
};

struct R8G8S
{
    int8_t R;
    int8_t G;

    static void readColor(gl::ColorF *dst, const R8G8S *src);
    static void readColor(gl::ColorI *dst, const R8G8S *src);
    static void writeColor(R8G8S *dst, const gl::ColorF *src);
    static void writeColor(R8G8S *dst, const gl::ColorI *src);
    static void average(R8G8S *dst, const R8G8S *src1, const R8G8S *src2);
};

struct R8G8B8S
{
    int8_t R;
    int8_t G;
    int8_t B;

    static void readColor(gl::ColorF *dst, const R8G8B8S *src);
    static void readColor(gl::ColorI *dst, const R8G8B8S *src);
    static void writeColor(R8G8B8S *dst, const gl::ColorF *src);
    static void writeColor(R8G8B8S *dst, const gl::ColorI *src);
    static void average(R8G8B8S *dst, const R8G8B8S *src1, const R8G8B8S *src2);
};

struct R8G8B8A8S
{
    int8_t R;
    int8_t G;
    int8_t B;
    int8_t A;

    static void readColor(gl::ColorF *dst, const R8G8B8A8S *src);
    static void readColor(gl::ColorI *dst, const R8G8B8A8S *src);
    static void writeColor(R8G8B8A8S *dst, const gl::ColorF *src);
    static void writeColor(R8G8B8A8S *dst, const gl::ColorI *src);
    static void average(R8G8B8A8S *dst, const R8G8B8A8S *src1, const R8G8B8A8S *src2);
};

struct R16S
{
    int16_t R;

    static void readColor(gl::ColorF *dst, const R16S *src);
    static void readColor(gl::ColorI *dst, const R16S *src);
    static void writeColor(R16S *dst, const gl::ColorF *src);
    static void writeColor(R16S *dst, const gl::ColorI *src);
    static void average(R16S *dst, const R16S *src1, const R16S *src2);
};

struct R16G16S
{
    int16_t R;
    int16_t G;

    static void readColor(gl::ColorF *dst, const R16G16S *src);
    static void readColor(gl::ColorI *dst, const R16G16S *src);
    static void writeColor(R16G16S *dst, const gl::ColorF *src);
    static void writeColor(R16G16S *dst, const gl::ColorI *src);
    static void average(R16G16S *dst, const R16G16S *src1, const R16G16S *src2);
};

struct R16G16B16S
{
    int16_t R;
    int16_t G;
    int16_t B;

    static void readColor(gl::ColorF *dst, const R16G16B16S *src);
    static void readColor(gl::ColorI *dst, const R16G16B16S *src);
    static void writeColor(R16G16B16S *dst, const gl::ColorF *src);
    static void writeColor(R16G16B16S *dst, const gl::ColorI *src);
    static void average(R16G16B16S *dst, const R16G16B16S *src1, const R16G16B16S *src2);
};

struct R16G16B16A16S
{
    int16_t R;
    int16_t G;
    int16_t B;
    int16_t A;

    static void readColor(gl::ColorF *dst, const R16G16B16A16S *src);
    static void readColor(gl::ColorI *dst, const R16G16B16A16S *src);
    static void writeColor(R16G16B16A16S *dst, const gl::ColorF *src);
    static void writeColor(R16G16B16A16S *dst, const gl::ColorI *src);
    static void average(R16G16B16A16S *dst, const R16G16B16A16S *src1, const R16G16B16A16S *src2);
};

struct R32S
{
    int32_t R;

    static void readColor(gl::ColorF *dst, const R32S *src);
    static void readColor(gl::ColorI *dst, const R32S *src);
    static void writeColor(R32S *dst, const gl::ColorF *src);
    static void writeColor(R32S *dst, const gl::ColorI *src);
    static void average(R32S *dst, const R32S *src1, const R32S *src2);
};

struct R32G32S
{
    int32_t R;
    int32_t G;

    static void readColor(gl::ColorF *dst, const R32G32S *src);
    static void readColor(gl::ColorI *dst, const R32G32S *src);
    static void writeColor(R32G32S *dst, const gl::ColorF *src);
    static void writeColor(R32G32S *dst, const gl::ColorI *src);
    static void average(R32G32S *dst, const R32G32S *src1, const R32G32S *src2);
};

struct R32G32B32S
{
    int32_t R;
    int32_t G;
    int32_t B;

    static void readColor(gl::ColorF *dst, const R32G32B32S *src);
    static void readColor(gl::ColorI *dst, const R32G32B32S *src);
    static void writeColor(R32G32B32S *dst, const gl::ColorF *src);
    static void writeColor(R32G32B32S *dst, const gl::ColorI *src);
    static void average(R32G32B32S *dst, const R32G32B32S *src1, const R32G32B32S *src2);
};

struct R32G32B32A32S
{
    int32_t R;
    int32_t G;
    int32_t B;
    int32_t A;

    static void readColor(gl::ColorF *dst, const R32G32B32A32S *src);
    static void readColor(gl::ColorI *dst, const R32G32B32A32S *src);
    static void writeColor(R32G32B32A32S *dst, const gl::ColorF *src);
    static void writeColor(R32G32B32A32S *dst, const gl::ColorI *src);
    static void average(R32G32B32A32S *dst, const R32G32B32A32S *src1, const R32G32B32A32S *src2);
};

struct A16B16G16R16F
{
    uint16_t A;
    uint16_t R;
    uint16_t G;
    uint16_t B;

    static void readColor(gl::ColorF *dst, const A16B16G16R16F *src);
    static void writeColor(A16B16G16R16F *dst, const gl::ColorF *src);
    static void average(A16B16G16R16F *dst, const A16B16G16R16F *src1, const A16B16G16R16F *src2);
};

struct R16G16B16A16F
{
    uint16_t R;
    uint16_t G;
    uint16_t B;
    uint16_t A;

    static void readColor(gl::ColorF *dst, const R16G16B16A16F *src);
    static void writeColor(R16G16B16A16F *dst, const gl::ColorF *src);
    static void average(R16G16B16A16F *dst, const R16G16B16A16F *src1, const R16G16B16A16F *src2);
};

struct R16F
{
    uint16_t R;

    static void readColor(gl::ColorF *dst, const R16F *src);
    static void writeColor(R16F *dst, const gl::ColorF *src);
    static void average(R16F *dst, const R16F *src1, const R16F *src2);
};

struct A16F
{
    uint16_t A;

    static void readColor(gl::ColorF *dst, const A16F *src);
    static void writeColor(A16F *dst, const gl::ColorF *src);
    static void average(A16F *dst, const A16F *src1, const A16F *src2);
};

struct L16F
{
    uint16_t L;

    static void readColor(gl::ColorF *dst, const L16F *src);
    static void writeColor(L16F *dst, const gl::ColorF *src);
    static void average(L16F *dst, const L16F *src1, const L16F *src2);
};

struct L16A16F
{
    uint16_t L;
    uint16_t A;

    static void readColor(gl::ColorF *dst, const L16A16F *src);
    static void writeColor(L16A16F *dst, const gl::ColorF *src);
    static void average(L16A16F *dst, const L16A16F *src1, const L16A16F *src2);
};

struct R16G16F
{
    uint16_t R;
    uint16_t G;

    static void readColor(gl::ColorF *dst, const R16G16F *src);
    static void writeColor(R16G16F *dst, const gl::ColorF *src);
    static void average(R16G16F *dst, const R16G16F *src1, const R16G16F *src2);
};

struct R16G16B16F
{
    uint16_t R;
    uint16_t G;
    uint16_t B;

    static void readColor(gl::ColorF *dst, const R16G16B16F *src);
    static void writeColor(R16G16B16F *dst, const gl::ColorF *src);
    static void average(R16G16B16F *dst, const R16G16B16F *src1, const R16G16B16F *src2);
};

struct A32B32G32R32F
{
    float A;
    float R;
    float G;
    float B;

    static void readColor(gl::ColorF *dst, const A32B32G32R32F *src);
    static void writeColor(A32B32G32R32F *dst, const gl::ColorF *src);
    static void average(A32B32G32R32F *dst, const A32B32G32R32F *src1, const A32B32G32R32F *src2);
};

struct R32G32B32A32F
{
    float R;
    float G;
    float B;
    float A;

    static void readColor(gl::ColorF *dst, const R32G32B32A32F *src);
    static void writeColor(R32G32B32A32F *dst, const gl::ColorF *src);
    static void average(R32G32B32A32F *dst, const R32G32B32A32F *src1, const R32G32B32A32F *src2);
};

struct R32F
{
    float R;

    static void readColor(gl::ColorF *dst, const R32F *src);
    static void writeColor(R32F *dst, const gl::ColorF *src);
    static void average(R32F *dst, const R32F *src1, const R32F *src2);
};

struct A32F
{
    float A;

    static void readColor(gl::ColorF *dst, const A32F *src);
    static void writeColor(A32F *dst, const gl::ColorF *src);
    static void average(A32F *dst, const A32F *src1, const A32F *src2);
};

struct L32F
{
    float L;

    static void readColor(gl::ColorF *dst, const L32F *src);
    static void writeColor(L32F *dst, const gl::ColorF *src);
    static void average(L32F *dst, const L32F *src1, const L32F *src2);
};

struct L32A32F
{
    float L;
    float A;

    static void readColor(gl::ColorF *dst, const L32A32F *src);
    static void writeColor(L32A32F *dst, const gl::ColorF *src);
    static void average(L32A32F *dst, const L32A32F *src1, const L32A32F *src2);
};

struct R32G32F
{
    float R;
    float G;

    static void readColor(gl::ColorF *dst, const R32G32F *src);
    static void writeColor(R32G32F *dst, const gl::ColorF *src);
    static void average(R32G32F *dst, const R32G32F *src1, const R32G32F *src2);
};

struct R32G32B32F
{
    float R;
    float G;
    float B;

    static void readColor(gl::ColorF *dst, const R32G32B32F *src);
    static void writeColor(R32G32B32F *dst, const gl::ColorF *src);
    static void average(R32G32B32F *dst, const R32G32B32F *src1, const R32G32B32F *src2);
};

struct R10G10B10A2
{
    uint32_t R : 10;
    uint32_t G : 10;
    uint32_t B : 10;
    uint32_t A : 2;

    static void readColor(gl::ColorF *dst, const R10G10B10A2 *src);
    static void readColor(gl::ColorUI *dst, const R10G10B10A2 *src);
    static void writeColor(R10G10B10A2 *dst, const gl::ColorF *src);
    static void writeColor(R10G10B10A2 *dst, const gl::ColorUI *src);
    static void average(R10G10B10A2 *dst, const R10G10B10A2 *src1, const R10G10B10A2 *src2);
};
static_assert(sizeof(R10G10B10A2) == 4, "R10G10B10A2 struct not 32-bits.");

struct R9G9B9E5
{
    uint32_t R : 9;
    uint32_t G : 9;
    uint32_t B : 9;
    uint32_t E : 5;

    static void readColor(gl::ColorF *dst, const R9G9B9E5 *src);
    static void writeColor(R9G9B9E5 *dst, const gl::ColorF *src);
    static void average(R9G9B9E5 *dst, const R9G9B9E5 *src1, const R9G9B9E5 *src2);
};
static_assert(sizeof(R9G9B9E5) == 4, "R9G9B9E5 struct not 32-bits.");

struct R11G11B10F
{
    uint32_t R : 11;
    uint32_t G : 11;
    uint32_t B : 10;

    static void readColor(gl::ColorF *dst, const R11G11B10F *src);
    static void writeColor(R11G11B10F *dst, const gl::ColorF *src);
    static void average(R11G11B10F *dst, const R11G11B10F *src1, const R11G11B10F *src2);
};
static_assert(sizeof(R11G11B10F) == 4, "R11G11B10F struct not 32-bits.");

}  // namespace angle

#endif  // IMAGEUTIL_IMAGEFORMATS_H_