Blender V5.3
util/colorspace.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2026 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#pragma once
6
7#include "util/param.h"
8#include "util/string.h"
9
11
12/* Automatically determine colorspace. */
13extern ustring u_colorspace_auto;
14/* Non-color data. */
15extern ustring u_colorspace_data;
16/* Scene linear colorspace used for rendering. */
17extern ustring u_colorspace_scene_linear;
18/* Scene linear + sRGB transfer function . */
20/* sRGB. */
21extern ustring u_colorspace_srgb;
22
23class ColorSpaceProcessor;
24struct Transform;
25
27 public:
28 /* Convert used specified colorspace to a colorspace that we are able to
29 * convert to and from. If the colorspace is u_colorspace_auto, we auto
30 * detect a colorspace. */
31 static ustring detect_known_colorspace(ustring colorspace,
32 const char *file_colorspace,
33 const char *file_format,
34 bool is_float);
35
36 /* Test if colorspace is for non-color data. */
37 static bool colorspace_is_data(ustring colorspace);
38 /* Return color interop forum interop ID. */
39 static const char *colorspace_interop_id(ustring colorspace);
40
41 /* Convert pixels in the specified colorspace to scene linear color for
42 * rendering. Must be a colorspace returned from detect_known_colorspace. */
43 template<typename T>
44 static void to_scene_linear(ustring colorspace,
45 T *pixels,
46 const int64_t width,
47 const int64_t height,
48 const int64_t y_stride,
49 bool is_rgba,
50 bool compress_as_srgb,
51 bool ignore_alpha);
52
53 /* Clear memory when the application exits. Invalidates all processors. */
54 static void free_memory();
55
56 /* Create a fallback color space configuration.
57 *
58 * This may be useful to allow regression test to create a configuration which is considered
59 * valid without knowing the actual configuration used by the final application. */
60 static void init_fallback_config();
61
62 /* Compute matrix to convert from XYZ to scene linear RGB, based on the config. */
67 /* Compute unique string for texture cache hashing and metadata. */
69 /* Determine if scene linear is a common known space. */
70 static const char *get_scene_linear_interop_id(const bool srgb_encoded = false);
71
72 private:
73 static ColorSpaceProcessor *get_processor(ustring colorspace);
74 static void is_builtin_colorspace(ustring colorspace,
75 bool &is_scene_linear,
76 bool &is_scene_linear_srgb);
77};
78
long long int int64_t
static bool colorspace_is_data(ustring colorspace)
static ustring detect_known_colorspace(ustring colorspace, const char *file_colorspace, const char *file_format, bool is_float)
static string get_xyz_to_scene_linear_rgb_string()
static Transform get_xyz_to_scene_linear_rgb()
static Transform get_xyz_to_rec2020()
static void to_scene_linear(ustring colorspace, T *pixels, const int64_t width, const int64_t height, const int64_t y_stride, bool is_rgba, bool compress_as_srgb, bool ignore_alpha)
static Transform get_xyz_to_rec709()
static void free_memory()
static const char * colorspace_interop_id(ustring colorspace)
static void init_fallback_config()
static Transform get_xyz_to_acescg()
static const char * get_scene_linear_interop_id(const bool srgb_encoded=false)
CCL_NAMESPACE_BEGIN ustring u_colorspace_auto
#define CCL_NAMESPACE_END
#define T
ustring u_colorspace_scene_linear_srgb
ustring u_colorspace_scene_linear
ustring u_colorspace_srgb
ustring u_colorspace_data