Skia
2D Graphics Library
skcms_internal.h
Go to the documentation of this file.
1 /*
2  * Copyright 2018 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #pragma once
9 
10 // skcms_internal.h contains APIs shared by skcms' internals and its test tools.
11 // Please don't use this header from outside the skcms repo.
12 
13 #include "skcms.h"
14 #include <stdbool.h>
15 #include <stdint.h>
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 // ~~~~ General Helper Macros ~~~~
22  #define ARRAY_COUNT(arr) (int)(sizeof((arr)) / sizeof(*(arr)))
23 
24  typedef struct skcms_ICCTag {
25  uint32_t signature;
26  uint32_t type;
27  uint32_t size;
28  const uint8_t* buf;
30 
31  void skcms_GetTagByIndex (const skcms_ICCProfile*, uint32_t idx, skcms_ICCTag*);
32  bool skcms_GetTagBySignature(const skcms_ICCProfile*, uint32_t sig, skcms_ICCTag*);
33 
34  float skcms_MaxRoundtripError(const skcms_Curve* curve, const skcms_TransferFunction* inv_tf);
35 
36  // 252 of a random shuffle of all possible bytes.
37  // 252 is evenly divisible by 3 and 4. Only 192, 10, 241, and 43 are missing.
38  // Used for ICC profile equivalence testing.
39  extern const uint8_t skcms_252_random_bytes[252];
40 
41 // ~~~~ Portable Math ~~~~
42  static inline float floorf_(float x) {
43  float roundtrip = (float)((int)x);
44  return roundtrip > x ? roundtrip - 1 : roundtrip;
45  }
46  static inline float fabsf_(float x) { return x < 0 ? -x : x; }
47  float powf_(float, float);
48 
49 // ~~~~ Does this pixel format need a palette pointer to be usable? ~~~~
50  static inline bool needs_palette(skcms_PixelFormat fmt) {
51  return (fmt >> 1) == (skcms_PixelFormat_RGBA_8888_Palette8 >> 1);
52  }
53 
54 #ifdef __cplusplus
55 }
56 #endif
skcms_ICCTag
struct skcms_ICCTag skcms_ICCTag
skcms_252_random_bytes
const uint8_t skcms_252_random_bytes[252]
Definition: skcms.cc:1292
skcms_ICCTag::size
uint32_t size
Definition: skcms_internal.h:27
skcms_ICCTag::signature
uint32_t signature
Definition: skcms_internal.h:25
skcms_GetTagByIndex
void skcms_GetTagByIndex(const skcms_ICCProfile *, uint32_t idx, skcms_ICCTag *)
Definition: skcms.cc:1000
floorf_
static float floorf_(float x)
Definition: skcms_internal.h:42
fabsf_
static float fabsf_(float x)
Definition: skcms_internal.h:46
skcms_MaxRoundtripError
float skcms_MaxRoundtripError(const skcms_Curve *curve, const skcms_TransferFunction *inv_tf)
Definition: skcms.cc:259
powf_
float powf_(float, float)
Definition: skcms.cc:106
skcms_ICCTag::buf
const uint8_t * buf
Definition: skcms_internal.h:28
needs_palette
static bool needs_palette(skcms_PixelFormat fmt)
Definition: skcms_internal.h:50
skcms_ICCTag::type
uint32_t type
Definition: skcms_internal.h:26
skcms_ICCTag
Definition: skcms_internal.h:24
skcms_GetTagBySignature
bool skcms_GetTagBySignature(const skcms_ICCProfile *, uint32_t sig, skcms_ICCTag *)
Definition: skcms.cc:1010