Flutter Engine
The Flutter Engine
SkColorSpacePriv.h
Go to the documentation of this file.
1/*
2 * Copyright 2016 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#ifndef SkColorSpacePriv_DEFINED
8#define SkColorSpacePriv_DEFINED
9
12#include "modules/skcms/skcms.h"
13
14// A gamut narrower than sRGB, useful for testing.
15static constexpr skcms_Matrix3x3 gNarrow_toXYZD50 = {{
16 { 0.190974f, 0.404865f, 0.368380f },
17 { 0.114746f, 0.582937f, 0.302318f },
18 { 0.032925f, 0.153615f, 0.638669f },
19}};
20
21static inline bool color_space_almost_equal(float a, float b) {
22 return SkTAbs(a - b) < 0.01f;
23}
24
25// Let's use a stricter version for transfer functions. Worst case, these are encoded
26// in ICC format, which offers 16-bits of fractional precision.
27static inline bool transfer_fn_almost_equal(float a, float b) {
28 return SkTAbs(a - b) < 0.001f;
29}
30
31static inline bool is_almost_srgb(const skcms_TransferFunction& coeffs) {
39}
40
41static inline bool is_almost_2dot2(const skcms_TransferFunction& coeffs) {
42 return transfer_fn_almost_equal(1.0f, coeffs.a) &&
46 coeffs.d <= 0.0f;
47}
48
50 // OutputVal = InputVal ^ 1.0f
51 const bool linearExp =
56 coeffs.d <= 0.0f;
57
58 // OutputVal = 1.0f * InputVal
59 const bool linearFn =
62 coeffs.d >= 1.0f;
63
64 return linearExp || linearFn;
65}
66
67// Return raw pointers to commonly used SkColorSpaces.
68// No need to ref/unref these, but if you do, do it in pairs.
71
72#endif // SkColorSpacePriv_DEFINED
SkColorSpace * sk_srgb_linear_singleton()
static bool is_almost_linear(const skcms_TransferFunction &coeffs)
static bool color_space_almost_equal(float a, float b)
SkColorSpace * sk_srgb_singleton()
static bool is_almost_2dot2(const skcms_TransferFunction &coeffs)
static constexpr skcms_Matrix3x3 gNarrow_toXYZD50
static bool is_almost_srgb(const skcms_TransferFunction &coeffs)
static bool transfer_fn_almost_equal(float a, float b)
static T SkTAbs(T value)
Definition: SkTemplates.h:43
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
Definition: main.cc:19
static bool b
struct MyStruct a[10]
static constexpr skcms_TransferFunction kSRGB
Definition: SkColorSpace.h:45