Blender V4.5
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(
34 ustring colorspace, T *pixels, const size_t num_pixels, bool is_rgba, bool compress_as_srgb);
35
36 /* Efficiently convert pixels to scene linear colorspace at render time,
37 * for OSL where the image texture cache contains original pixels. The
38 * handle is valid for the lifetime of the application. */
39 static ColorSpaceProcessor *get_processor(ustring colorspace);
40 static void to_scene_linear(ColorSpaceProcessor *processor, float *pixel, const int channels);
41
42 /* Clear memory when the application exits. Invalidates all processors. */
43 static void free_memory();
44
45 /* Create a fallback color space configuration.
46 *
47 * This may be useful to allow regression test to create a configuration which is considered
48 * valid without knowing the actual configuration used by the final application. */
49 static void init_fallback_config();
50
51 private:
52 static void is_builtin_colorspace(ustring colorspace, bool &is_scene_linear, bool &is_srgb);
53};
54
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 free_memory()
static ColorSpaceProcessor * get_processor(ustring colorspace)
static void init_fallback_config()
static void to_scene_linear(ustring colorspace, T *pixels, const size_t num_pixels, bool is_rgba, bool compress_as_srgb)
CCL_NAMESPACE_BEGIN ustring u_colorspace_auto
#define CCL_NAMESPACE_END
#define T
ustring u_colorspace_raw
ustring u_colorspace_srgb