57 float alpha, inv_alpha;
59 if (srgb[3] == 1.0f || srgb[3] == 0.0f) {
65 inv_alpha = 1.0f / alpha;
68 linear[0] = srgb[0] * inv_alpha;
69 linear[1] = srgb[1] * inv_alpha;
70 linear[2] = srgb[2] * inv_alpha;
80 float alpha, inv_alpha;
82 if (linear[3] == 1.0f || linear[3] == 0.0f) {
88 inv_alpha = 1.0f / alpha;
91 srgb[0] = linear[0] * inv_alpha;
92 srgb[1] = linear[1] * inv_alpha;
93 srgb[2] = linear[2] * inv_alpha;
110 linear[3] = srgb[3] * (1.0f / 255.0f);
118 if (srgb[3] == 255 || srgb[3] == 0) {
123 for (i = 0; i < 4; i++) {
124 fsrgb[i] = srgb[i] * (1.0f / 255.0f);
132 r_col[0] =
float(col_ub[0]) * (1.0f / 255.0f);
133 r_col[1] =
float(col_ub[1]) * (1.0f / 255.0f);
134 r_col[2] =
float(col_ub[2]) * (1.0f / 255.0f);
139 r_col[0] =
float(col_ub[0]) * (1.0f / 255.0f);
140 r_col[1] =
float(col_ub[1]) * (1.0f / 255.0f);
141 r_col[2] =
float(col_ub[2]) * (1.0f / 255.0f);
142 r_col[3] =
float(col_ub[3]) * (1.0f / 255.0f);
165 float col[4],
const float r,
const float g,
const float b,
const float a)
186 r_col[0] = ((pack) >> 0) & 0xFF;
187 r_col[1] = ((pack) >> 8) & 0xFF;
188 r_col[2] = ((pack) >> 16) & 0xFF;
210 return (0.2126f * rgb[0]) + (0.7152f * rgb[1]) + (0.0722f * rgb[2]);
217 return static_cast<unsigned char>(((54 *
static_cast<unsigned short>(rgb[0])) +
218 (182 *
static_cast<unsigned short>(rgb[1])) +
219 (19 *
static_cast<unsigned short>(rgb[2]))) /
230 const unsigned char col_b[3],
233 const int r = int(col_a[0]) - int(col_b[0]);
234 if (
abs(r) < limit) {
235 const int g = int(col_a[1]) - int(col_b[1]);
236 if (
abs(g) < limit) {
237 const int b = int(col_a[2]) - int(col_b[2]);
238 if (
abs(
b) < limit) {
251 const uint32_t qx = 1103515245u * ((
x >> 1u) ^ (
y));
252 const uint32_t qy = 1103515245u * ((
y >> 1u) ^ (
x));
253 const uint32_t n = 1103515245u * ((qx) ^ (qy >> 3u));
254 return float(n) * (1.0f /
float(0xffffffffu));
268 unsigned char b[3],
const float f[3],
float dither,
int x,
int y)
285 if (premul[3] == 0.0f || premul[3] == 1.0f) {
286 straight[0] = premul[0];
287 straight[1] = premul[1];
288 straight[2] = premul[2];
289 straight[3] = premul[3];
292 const float alpha_inv = 1.0f / premul[3];
293 straight[0] = premul[0] * alpha_inv;
294 straight[1] = premul[1] * alpha_inv;
295 straight[2] = premul[2] * alpha_inv;
296 straight[3] = premul[3];
307 const float alpha = straight[3];
308 premul[0] = straight[0] * alpha;
309 premul[1] = straight[1] * alpha;
310 premul[2] = straight[2] * alpha;
311 premul[3] = straight[3];
321 const float alpha =
color[3] * (1.0f / 255.0f);
322 const float fac = alpha * (1.0f / 255.0f);
339 const float alpha_inv = 1.0f /
color[3];
#define unit_float_to_uchar_clamp_v4(v1, v2)
#define unit_float_to_uchar_clamp_v3(v1, v2)
MINLINE void rgba_uchar_to_float(float r_col[4], const unsigned char col_ub[4])
MINLINE void linearrgb_to_srgb_uchar3(unsigned char srgb[3], const float linear[3])
MINLINE unsigned char unit_float_to_uchar_clamp(float val)
void linearrgb_to_srgb_v3_v3(float srgb[3], const float linear[3])
MINLINE float hash_iqint3_f(const uint32_t x, const uint32_t y)
MINLINE unsigned char srgb_to_grayscale_byte(const unsigned char rgb[3])
MINLINE void linearrgb_to_srgb_v4(float srgb[4], const float linear[4])
MINLINE void srgb_to_linearrgb_uchar4(float linear[4], const unsigned char srgb[4])
void srgb_to_linearrgb_v3_v3(float linear[3], const float srgb[3])
MINLINE void rgba_uchar_args_set(unsigned char col[4], unsigned char r, unsigned char g, unsigned char b, unsigned char a)
MINLINE void srgb_to_linearrgb_v4(float linear[4], const float srgb[4])
MINLINE void straight_to_premul_v4_v4(float premul[4], const float straight[4])
ATTR_WARN_UNUSED_RESULT const BMVert * v
MINLINE void rgb_float_to_uchar(unsigned char r_col[3], const float col_f[3])
MINLINE float srgb_to_grayscale(const float rgb[3])
float BLI_color_from_srgb_table[256]
MINLINE float dither_random_value(int x, int y)
MINLINE float signf(float f)
MINLINE void premul_to_straight_v4(float color[4])
MINLINE void linearrgb_to_srgb_predivide_v4(float srgb[4], const float linear[4])
MINLINE void float_to_byte_dither_v3(unsigned char b[3], const float f[3], float dither, int x, int y)
MINLINE void cpack_cpy_3ub(unsigned char r_col[3], unsigned int pack)
MINLINE void straight_uchar_to_premul_float(float result[4], const unsigned char color[4])
MINLINE void srgb_to_linearrgb_predivide_v4(float linear[4], const float srgb[4])
MINLINE void rgb_uchar_to_float(float r_col[3], const unsigned char col_ub[3])
MINLINE void linearrgb_to_srgb_uchar4(unsigned char srgb[4], const float linear[4])
MINLINE int compare_rgb_uchar(const unsigned char col_a[3], const unsigned char col_b[3], int limit)
MINLINE void premul_float_to_straight_uchar(unsigned char *result, const float color[4])
MINLINE void rgba_uchar_args_test_set(unsigned char col[4], unsigned char r, unsigned char g, unsigned char b, unsigned char a)
MINLINE void straight_to_premul_v4(float color[4])
MINLINE void srgb_to_linearrgb_uchar4_predivide(float linear[4], const unsigned char srgb[4])
MINLINE void rgba_float_to_uchar(unsigned char r_col[4], const float col_f[4])
MINLINE void premul_to_straight_v4_v4(float straight[4], const float premul[4])
MINLINE void rgba_float_args_set(float col[4], float r, float g, float b, float a)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float