File: skcolorspace_trfn.h

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (60 lines) | stat: -rw-r--r-- 2,268 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef SKIA_EXT_SKCOLORSPACE_TRFN_H_
#define SKIA_EXT_SKCOLORSPACE_TRFN_H_

#include "third_party/skia/include/core/SkColorSpace.h"

namespace skia {

// Returns a transfer function that is equal to `alpha` * `x`.
skcms_TransferFunction SK_API
ScaleTransferFunction(const skcms_TransferFunction& f, float alpha);

// Returns true if `y` = `alpha` * `x`, and computes and stores alpha if `alpha`
// is non-nullptr. Returns false is `x` is the zero function or `alpha` is zero.
bool SK_API IsScaledTransferFunction(const skcms_TransferFunction& x,
                                     const skcms_TransferFunction& y,
                                     float* alpha);

}  // namespace skia

namespace SkNamedTransferFnExt {

////////////////////////////////////////////////////////////////////////////////
// CSS Color Level 4 predefined color spaces.

// 'srgb', 'display-p3'
static constexpr skcms_TransferFunction kSRGB =
    SkNamedTransferFn::kIEC61966_2_1;

// 'rec2020' uses the same transfer function as kRec709.
static constexpr skcms_TransferFunction kRec2020 = SkNamedTransferFn::kRec709;

////////////////////////////////////////////////////////////////////////////////
// Additional helper transfer functions.

// Invalid primaries, initialized to zero.
static constexpr skcms_TransferFunction kInvalid = {0};

// The interpretation of kRec709 that is produced by accelerated video decode
// on macOS.
static constexpr skcms_TransferFunction kRec709Apple = {1.961f, 1.};

// If the sRGB transfer function is f(x), then this transfer function is
// f(x * 1023 / 510). This function gives 510 values to SDR content, and can
// reach a maximum brightnes of 4.99x SDR brightness.
static constexpr skcms_TransferFunction kSRGBExtended1023Over510 = {
    SkNamedTransferFnExt::kSRGB.g,
    SkNamedTransferFnExt::kSRGB.a * 1023 / 510,
    SkNamedTransferFnExt::kSRGB.b,
    SkNamedTransferFnExt::kSRGB.c * 1023 / 510,
    SkNamedTransferFnExt::kSRGB.d * 1023 / 510,
    SkNamedTransferFnExt::kSRGB.e,
    SkNamedTransferFnExt::kSRGB.f};

}  // namespace SkNamedTransferFnExt

#endif  // SKIA_EXT_SKCOLORSPACE_TRFN_H_