Blender V5.0
scene/colorspace.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#pragma once
6
7#include "util/param.h"
8
10
11extern ustring u_colorspace_auto;
12extern ustring u_colorspace_raw;
13extern ustring u_colorspace_srgb;
14
15class ColorSpaceProcessor;
16
18 public:
19 /* Convert used specified colorspace to a colorspace that we are able to
20 * convert to and from. If the colorspace is u_colorspace_auto, we auto
21 * detect a colospace. */
22 static ustring detect_known_colorspace(ustring colorspace,
23 const char *file_colorspace,
24 const char *file_format,
25 bool is_float);
26
27 /* Test if colorspace is for non-color data. */
28 static bool colorspace_is_data(ustring colorspace);
29
30 /* Convert pixels in the specified colorspace to scene linear color for
31 * rendering. Must be a colorspace returned from detect_known_colorspace. */
32 template<typename T>
33 static void to_scene_linear(ustring colorspace,
34 T *pixels,
35 const size_t num_pixels,
36 bool is_rgba,
37 bool compress_as_srgb,
38 bool ignore_alpha);
39
40 /* Efficiently convert pixels to scene linear colorspace at render time,
41 * for OSL where the image texture cache contains original pixels. The
42 * handle is valid for the lifetime of the application. */
43 static ColorSpaceProcessor *get_processor(ustring colorspace);
44 static void to_scene_linear(ColorSpaceProcessor *processor, float *pixel, const int channels);
45
46 /* Clear memory when the application exits. Invalidates all processors. */
47 static void free_memory();
48
49 /* Create a fallback color space configuration.
50 *
51 * This may be useful to allow regression test to create a configuration which is considered
52 * valid without knowing the actual configuration used by the final application. */
53 static void init_fallback_config();
54
55 private:
56 static void is_builtin_colorspace(ustring colorspace, bool &is_scene_linear, bool &is_srgb);
57};
58
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 void to_scene_linear(ustring colorspace, T *pixels, const size_t num_pixels, bool is_rgba, bool compress_as_srgb, bool ignore_alpha)
static void free_memory()
static ColorSpaceProcessor * get_processor(ustring colorspace)
static void init_fallback_config()
CCL_NAMESPACE_BEGIN ustring u_colorspace_auto
#define CCL_NAMESPACE_END
#define T
ustring u_colorspace_raw
ustring u_colorspace_srgb