Blender V5.0
libocio_config.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2025 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
7#if defined(WITH_OPENCOLORIO)
8
9# include "MEM_guardedalloc.h"
10
11# include "BLI_vector.hh"
12
13# include "OCIO_config.hh"
14
15# include "libocio_colorspace.hh"
16# include "libocio_display.hh"
18# include "libocio_look.hh"
19
20# include "../opencolorio.hh"
21
22namespace blender::ocio {
23
24class ColorSpace;
25class Display;
26class View;
27
28class LibOCIOConfig : public Config {
29 OCIO_NAMESPACE::ConstConfigRcPtr ocio_config_;
30
31 /* Storage of for Blender-side representation of OpenColorIO configuration.
32 * Note that the color spaces correspond to color spaces from OpenColorIO configuration: this
33 * array does not contain aliases or roles. If role or alias is to be resolved OpenColorIO is to
34 * be used first to provide color space name which then can be looked up in this array. */
35 Vector<LibOCIOColorSpace> color_spaces_;
36 Vector<LibOCIOColorSpace> inactive_color_spaces_;
37 Vector<LibOCIOLook> looks_;
38 Vector<LibOCIODisplay> displays_;
39
40 /* Array with indices into color_spaces_.
41 * color_spaces_[sorted_color_space_index_[i]] provides alphabetically sorted access. */
42 Vector<int> sorted_color_space_index_;
43
44 LibOCIOGPUShaderBinder gpu_shader_binder_{*this};
45
46 public:
47 ~LibOCIOConfig();
48
49 static std::unique_ptr<Config> create_from_environment();
50 static std::unique_ptr<Config> create_from_file(StringRefNull filename);
51
52 /* Color space information. */
53 float3 get_default_luma_coefs() const override;
54 float3x3 get_xyz_to_scene_linear_matrix() const override;
55 const char *get_color_space_from_filepath(const char *filepath) const override;
56
57 /* Color space API. */
58 const ColorSpace *get_color_space(StringRefNull name) const override;
59 int get_num_color_spaces() const override;
60 const ColorSpace *get_color_space_by_index(int index) const override;
61 const ColorSpace *get_sorted_color_space_by_index(int index) const override;
62 const ColorSpace *get_color_space_by_interop_id(StringRefNull interop_id) const override;
63 const ColorSpace *get_color_space_for_hdr_image(StringRefNull name) const override;
64
65 /* Working space API. */
66 void set_scene_linear_role(StringRefNull name) override;
67
68 /* Display API. */
69 const Display *get_default_display() const override;
70 const Display *get_display_by_name(StringRefNull name) const override;
71 int get_num_displays() const override;
72 const Display *get_display_by_index(int index) const override;
73
74 /* Display colorspace API. */
75 const ColorSpace *get_display_view_color_space(StringRefNull display,
76 StringRefNull view) const override;
77
78 /* Look API. */
79 const Look *get_look_by_name(StringRefNull name) const override;
80 int get_num_looks() const override;
81 const Look *get_look_by_index(int index) const override;
82
83 /* Processor API. */
84 std::shared_ptr<const CPUProcessor> get_display_cpu_processor(
85 const DisplayParameters &display_parameters) const override;
86 std::shared_ptr<const CPUProcessor> get_cpu_processor(
87 StringRefNull from_colorspace, StringRefNull to_colorspace) const override;
88
89 /* Processor API. */
90 const GPUShaderBinder &get_gpu_shader_binder() const override;
91
92 /* Integration with the OpenColorIO specific routines. */
93 const OCIO_NAMESPACE::ConstConfigRcPtr &get_ocio_config() const
94 {
95 return ocio_config_;
96 }
97
98 MEM_CXX_CLASS_ALLOC_FUNCS("LibOCIOConfig");
99
100 private:
101 explicit LibOCIOConfig(const OCIO_NAMESPACE::ConstConfigRcPtr &ocio_config);
102
103 /* Initialize BLender-side representation of color spaces, displays, etc. from the current
104 * OpenColorIO configuration. */
105 void initialize_active_color_spaces();
106 void initialize_inactive_color_spaces();
107 void initialize_hdr_color_spaces();
108 void initialize_looks();
109 void initialize_displays();
110};
111
112} // namespace blender::ocio
113
114#endif
blender::ocio::ColorSpace ColorSpace
Definition BLF_api.hh:38
static AppView * view
#define Display
Read Guarded memory(de)allocation.
MatBase< 3, 3 > float3x3
VecBase< float, 3 > float3
const char * name