aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/compute/color/color.h
blob: 36f1293b200389c345df97b377ddf1b3809dfc5a (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
/*
 * Copyright 2017 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can
 * be found in the LICENSE file.
 *
 */

//
// COLOR UTILITIES
//

#pragma once

//
//
//

#include <stdint.h>

//
// CONVERT FROM 0xAARRGGBB WORD ORDER INTO f32[4]
//

void color_rgb32_to_rgba_f32(float rgba[4], const uint32_t rgb, const float opacity);

void color_argb32_to_rgba_f32(float rgba[4], const uint32_t argb);

//
// PREMULTIPLY
//
// { r, g, b, a } ==> { r*a, g*a, b*a, a }
//

void color_premultiply_rgba_f32(float rgba[4]);

//
// SRGB<>LINEAR
//
// EXT_framebuffer_sRGB:
// https://www.opengl.org/registry/specs/EXT/framebuffer_sRGB.txt
//
//        {  cs / 12.92,                 cs <= 0.04045
//   cl = {
//        {  ((cs + 0.055)/1.055)^2.4,   cs >  0.04045
//
//
//        {  0.0,                          0         <= cl
//        {  12.92 * cl,                   0         <  cl <  0.0031308
//   cs = {  1.055 * cl^0.41666 - 0.055,   0.0031308 <= cl <  1
//        {  1.0,                                       cl >= 1
//

void color_srgb_to_linear_rgb_f32(float rgb[3]);

void color_linear_to_srgb_rgb_f32(float rgb[3]);

//
//
//

void color_linear_lerp_rgba_f32(float       rgba_m[4], 
                                float const rgba_a[4],
                                float const rgba_b[4],
                                float const t);

//
//
//