Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Functions | Variables
skcms_internals.h File Reference
#include <stdbool.h>
#include <stdint.h>

Go to the source code of this file.

Classes

struct  skcms_ICCTag
 

Macros

#define ARRAY_COUNT(arr)   (int)(sizeof((arr)) / sizeof(*(arr)))
 
#define SKCMS_FALLTHROUGH
 
#define SKCMS_HAS_MUSTTAIL   0
 
#define SKCMS_MAYBE_UNUSED
 
#define SAFE_SIZEOF(x)   ((uint64_t)sizeof(x))
 
#define SAFE_FIXED_SIZE(type)   ((uint64_t)offsetof(type, variable))
 
#define SKCMS_PORTABLE   1
 
#define SKCMS_DISABLE_HSW   1
 
#define SKCMS_DISABLE_SKX   1
 

Typedefs

typedef struct skcms_ICCTag skcms_ICCTag
 
typedef struct skcms_ICCProfile skcms_ICCProfile
 
typedef struct skcms_TransferFunction skcms_TransferFunction
 
typedef union skcms_Curve skcms_Curve
 

Functions

void skcms_GetTagByIndex (const skcms_ICCProfile *, uint32_t idx, skcms_ICCTag *)
 
bool skcms_GetTagBySignature (const skcms_ICCProfile *, uint32_t sig, skcms_ICCTag *)
 
float skcms_MaxRoundtripError (const skcms_Curve *curve, const skcms_TransferFunction *inv_tf)
 
static float floorf_ (float x)
 
static float fabsf_ (float x)
 
float powf_ (float, float)
 

Variables

const uint8_t skcms_252_random_bytes [252]
 

Macro Definition Documentation

◆ ARRAY_COUNT

#define ARRAY_COUNT (   arr)    (int)(sizeof((arr)) / sizeof(*(arr)))

Definition at line 22 of file skcms_internals.h.

◆ SAFE_FIXED_SIZE

#define SAFE_FIXED_SIZE (   type)    ((uint64_t)offsetof(type, variable))

Definition at line 83 of file skcms_internals.h.

◆ SAFE_SIZEOF

#define SAFE_SIZEOF (   x)    ((uint64_t)sizeof(x))

Definition at line 80 of file skcms_internals.h.

◆ SKCMS_DISABLE_HSW

#define SKCMS_DISABLE_HSW   1

Definition at line 97 of file skcms_internals.h.

◆ SKCMS_DISABLE_SKX

#define SKCMS_DISABLE_SKX   1

Definition at line 102 of file skcms_internals.h.

◆ SKCMS_FALLTHROUGH

#define SKCMS_FALLTHROUGH

Definition at line 58 of file skcms_internals.h.

◆ SKCMS_HAS_MUSTTAIL

#define SKCMS_HAS_MUSTTAIL   0

Definition at line 61 of file skcms_internals.h.

◆ SKCMS_MAYBE_UNUSED

#define SKCMS_MAYBE_UNUSED

Definition at line 72 of file skcms_internals.h.

◆ SKCMS_PORTABLE

#define SKCMS_PORTABLE   1

Definition at line 89 of file skcms_internals.h.

Typedef Documentation

◆ skcms_Curve

typedef union skcms_Curve skcms_Curve

Definition at line 116 of file skcms_internals.h.

◆ skcms_ICCProfile

Definition at line 114 of file skcms_internals.h.

◆ skcms_ICCTag

typedef struct skcms_ICCTag skcms_ICCTag

◆ skcms_TransferFunction

Definition at line 115 of file skcms_internals.h.

Function Documentation

◆ fabsf_()

static float fabsf_ ( float  x)
inlinestatic

Definition at line 133 of file skcms_internals.h.

133{ return x < 0 ? -x : x; }
double x

◆ floorf_()

static float floorf_ ( float  x)
inlinestatic

Definition at line 129 of file skcms_internals.h.

129 {
130 float roundtrip = (float)((int)x);
131 return roundtrip > x ? roundtrip - 1 : roundtrip;
132}

◆ powf_()

float powf_ ( float  x,
float  y 
)

Definition at line 93 of file skcms.cc.

93 {
94 if (x <= 0.f) {
95 return 0.f;
96 }
97 if (x == 1.f) {
98 return 1.f;
99 }
100 return exp2f_(log2f_(x) * y);
101}
double y
static float log2f_(float x)
Definition skcms.cc:44
static float exp2f_(float x)
Definition skcms.cc:65

◆ skcms_GetTagByIndex()

void skcms_GetTagByIndex ( const skcms_ICCProfile profile,
uint32_t  idx,
skcms_ICCTag tag 
)

Definition at line 1211 of file skcms.cc.

1211 {
1212 if (!profile || !profile->buffer || !tag) { return; }
1213 if (idx > profile->tag_count) { return; }
1214 const tag_Layout* tags = get_tag_table(profile);
1215 tag->signature = read_big_u32(tags[idx].signature);
1216 tag->size = read_big_u32(tags[idx].size);
1217 tag->buf = read_big_u32(tags[idx].offset) + profile->buffer;
1218 tag->type = read_big_u32(tag->buf);
1219}
static uint32_t read_big_u32(const uint8_t *ptr)
Definition skcms.cc:334
static const tag_Layout * get_tag_table(const skcms_ICCProfile *profile)
Definition skcms.cc:384
Point offset
const uint8_t * buf

◆ skcms_GetTagBySignature()

bool skcms_GetTagBySignature ( const skcms_ICCProfile profile,
uint32_t  sig,
skcms_ICCTag tag 
)

Definition at line 1221 of file skcms.cc.

1221 {
1222 if (!profile || !profile->buffer || !tag) { return false; }
1223 const tag_Layout* tags = get_tag_table(profile);
1224 for (uint32_t i = 0; i < profile->tag_count; ++i) {
1225 if (read_big_u32(tags[i].signature) == sig) {
1226 tag->signature = sig;
1227 tag->size = read_big_u32(tags[i].size);
1228 tag->buf = read_big_u32(tags[i].offset) + profile->buffer;
1229 tag->type = read_big_u32(tag->buf);
1230 return true;
1231 }
1232 }
1233 return false;
1234}

◆ skcms_MaxRoundtripError()

float skcms_MaxRoundtripError ( const skcms_Curve curve,
const skcms_TransferFunction inv_tf 
)

Definition at line 273 of file skcms.cc.

273 {
274 uint32_t N = curve->table_entries > 256 ? curve->table_entries : 256;
275 const float dx = 1.0f / static_cast<float>(N - 1);
276 float err = 0;
277 for (uint32_t i = 0; i < N; i++) {
278 float x = static_cast<float>(i) * dx,
279 y = eval_curve(curve, x);
280 err = fmaxf_(err, fabsf_(x - skcms_TransferFunction_eval(inv_tf, y)));
281 }
282 return err;
283}
#define N
Definition beziers.cpp:19
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
Definition SkRecords.h:208
static float eval_curve(const skcms_Curve *curve, float x)
Definition skcms.cc:247
float skcms_TransferFunction_eval(const skcms_TransferFunction *tf, float x)
Definition skcms.cc:212
static float fmaxf_(float x, float y)
Definition skcms.cc:108
static float fabsf_(float x)
uint32_t table_entries

Variable Documentation

◆ skcms_252_random_bytes

const uint8_t skcms_252_random_bytes[252]
extern

Definition at line 1602 of file skcms.cc.

1602 {
1603 8, 179, 128, 204, 253, 38, 134, 184, 68, 102, 32, 138, 99, 39, 169, 215,
1604 119, 26, 3, 223, 95, 239, 52, 132, 114, 74, 81, 234, 97, 116, 244, 205, 30,
1605 154, 173, 12, 51, 159, 122, 153, 61, 226, 236, 178, 229, 55, 181, 220, 191,
1606 194, 160, 126, 168, 82, 131, 18, 180, 245, 163, 22, 246, 69, 235, 252, 57,
1607 108, 14, 6, 152, 240, 255, 171, 242, 20, 227, 177, 238, 96, 85, 16, 211,
1608 70, 200, 149, 155, 146, 127, 145, 100, 151, 109, 19, 165, 208, 195, 164,
1609 137, 254, 182, 248, 64, 201, 45, 209, 5, 147, 207, 210, 113, 162, 83, 225,
1610 9, 31, 15, 231, 115, 37, 58, 53, 24, 49, 197, 56, 120, 172, 48, 21, 214,
1611 129, 111, 11, 50, 187, 196, 34, 60, 103, 71, 144, 47, 203, 77, 80, 232,
1612 140, 222, 250, 206, 166, 247, 139, 249, 221, 72, 106, 27, 199, 117, 54,
1613 219, 135, 118, 40, 79, 41, 251, 46, 93, 212, 92, 233, 148, 28, 121, 63,
1614 123, 158, 105, 59, 29, 42, 143, 23, 0, 107, 176, 87, 104, 183, 156, 193,
1615 189, 90, 188, 65, 190, 17, 198, 7, 186, 161, 1, 124, 78, 125, 170, 133,
1616 174, 218, 67, 157, 75, 101, 89, 217, 62, 33, 141, 228, 25, 35, 91, 230, 4,
1617 2, 13, 73, 86, 167, 237, 84, 243, 44, 185, 66, 130, 110, 150, 142, 216, 88,
1618 112, 36, 224, 136, 202, 76, 94, 98, 175, 213
1619};