blob: cc6d578ba07497c27bcf498b082dffe09e3c6620 [file] [log] [blame]
skcms-skia-autoroll@skia-buildbots.google.com.iam.gserviceaccount.comf5768392018-07-02 18:40:45 +00001/*
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
skcms-skia-autoroll@skia-buildbots.google.com.iam.gserviceaccount.comaae58022018-07-02 20:24:31 +000017#ifdef __cplusplus
skcms-skia-autoroll@skia-buildbots.google.com.iam.gserviceaccount.comf5768392018-07-02 18:40:45 +000018extern "C" {
19#endif
20
21// ~~~~ General Helper Macros ~~~~
skcms-skia-autoroll@skia-buildbots.google.com.iam.gserviceaccount.com2f046f12018-07-02 19:40:45 +000022 #define ARRAY_COUNT(arr) (int)(sizeof((arr)) / sizeof(*(arr)))
skcms-skia-autoroll@skia-buildbots.google.com.iam.gserviceaccount.comf5768392018-07-02 18:40:45 +000023
skia-autoroll4a098152019-11-11 17:27:28 +000024 typedef struct skcms_ICCTag {
25 uint32_t signature;
26 uint32_t type;
27 uint32_t size;
28 const uint8_t* buf;
29 } skcms_ICCTag;
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
skia-autorolld95243b2019-11-20 19:40:25 +000034 float skcms_MaxRoundtripError(const skcms_Curve* curve, const skcms_TransferFunction* inv_tf);
35
skcms-skia-autoroll@skia-buildbots.google.com.iam.gserviceaccount.comf5768392018-07-02 18:40:45 +000036 // 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
skcms-skia-autoroll@skia-buildbots.google.com.iam.gserviceaccount.comf5768392018-07-02 18:40:45 +000041// ~~~~ Portable Math ~~~~
skcms-skia-autoroll@skia-buildbots.google.com.iam.gserviceaccount.comf5768392018-07-02 18:40:45 +000042 static inline float floorf_(float x) {
43 float roundtrip = (float)((int)x);
44 return roundtrip > x ? roundtrip - 1 : roundtrip;
45 }
skcms-skia-autoroll@skia-buildbots.google.com.iam.gserviceaccount.comf5768392018-07-02 18:40:45 +000046 static inline float fabsf_(float x) { return x < 0 ? -x : x; }
skcms-skia-autoroll@skia-buildbots.google.com.iam.gserviceaccount.comf5768392018-07-02 18:40:45 +000047 float powf_(float, float);
48
skia-autoroll@skia-public.iam.gserviceaccount.com1cb0e3a2018-10-18 19:20:14 +000049// ~~~~ 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
skcms-skia-autoroll@skia-buildbots.google.com.iam.gserviceaccount.comaae58022018-07-02 20:24:31 +000054#ifdef __cplusplus
55}
skcms-skia-autoroll@skia-buildbots.google.com.iam.gserviceaccount.comf5768392018-07-02 18:40:45 +000056#endif