skcms-skia-autoroll@skia-buildbots.google.com.iam.gserviceaccount.com | f576839 | 2018-07-02 18:40:45 +0000 | [diff] [blame] | 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 | |
skcms-skia-autoroll@skia-buildbots.google.com.iam.gserviceaccount.com | aae5802 | 2018-07-02 20:24:31 +0000 | [diff] [blame] | 17 | #ifdef __cplusplus |
skcms-skia-autoroll@skia-buildbots.google.com.iam.gserviceaccount.com | f576839 | 2018-07-02 18:40:45 +0000 | [diff] [blame] | 18 | extern "C" { |
| 19 | #endif |
| 20 | |
| 21 | // ~~~~ General Helper Macros ~~~~ |
skcms-skia-autoroll@skia-buildbots.google.com.iam.gserviceaccount.com | 2f046f1 | 2018-07-02 19:40:45 +0000 | [diff] [blame] | 22 | #define ARRAY_COUNT(arr) (int)(sizeof((arr)) / sizeof(*(arr))) |
skcms-skia-autoroll@skia-buildbots.google.com.iam.gserviceaccount.com | f576839 | 2018-07-02 18:40:45 +0000 | [diff] [blame] | 23 | |
skia-autoroll | 4a09815 | 2019-11-11 17:27:28 +0000 | [diff] [blame] | 24 | 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-autoroll | d95243b | 2019-11-20 19:40:25 +0000 | [diff] [blame] | 34 | float skcms_MaxRoundtripError(const skcms_Curve* curve, const skcms_TransferFunction* inv_tf); |
| 35 | |
skcms-skia-autoroll@skia-buildbots.google.com.iam.gserviceaccount.com | f576839 | 2018-07-02 18:40:45 +0000 | [diff] [blame] | 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 | |
skcms-skia-autoroll@skia-buildbots.google.com.iam.gserviceaccount.com | f576839 | 2018-07-02 18:40:45 +0000 | [diff] [blame] | 41 | // ~~~~ Portable Math ~~~~ |
skcms-skia-autoroll@skia-buildbots.google.com.iam.gserviceaccount.com | f576839 | 2018-07-02 18:40:45 +0000 | [diff] [blame] | 42 | 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.com | f576839 | 2018-07-02 18:40:45 +0000 | [diff] [blame] | 46 | static inline float fabsf_(float x) { return x < 0 ? -x : x; } |
skcms-skia-autoroll@skia-buildbots.google.com.iam.gserviceaccount.com | f576839 | 2018-07-02 18:40:45 +0000 | [diff] [blame] | 47 | float powf_(float, float); |
| 48 | |
skia-autoroll@skia-public.iam.gserviceaccount.com | 1cb0e3a | 2018-10-18 19:20:14 +0000 | [diff] [blame] | 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 | |
skcms-skia-autoroll@skia-buildbots.google.com.iam.gserviceaccount.com | aae5802 | 2018-07-02 20:24:31 +0000 | [diff] [blame] | 54 | #ifdef __cplusplus |
| 55 | } |
skcms-skia-autoroll@skia-buildbots.google.com.iam.gserviceaccount.com | f576839 | 2018-07-02 18:40:45 +0000 | [diff] [blame] | 56 | #endif |