Blender V4.5
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_;
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
63 /* Display API. */
64 const Display *get_default_display() const override;
65 const Display *get_display_by_name(StringRefNull name) const override;
66 int get_num_displays() const override;
67 const Display *get_display_by_index(int index) const override;
68
69 /* Display colorspace API. */
70 const ColorSpace *get_display_view_color_space(StringRefNull display,
71 StringRefNull view) const override;
72
73 /* Look API. */
74 const Look *get_look_by_name(StringRefNull name) const override;
75 int get_num_looks() const override;
76 const Look *get_look_by_index(int index) const override;
77
78 /* Processor API. */
79 std::shared_ptr<const CPUProcessor> get_display_cpu_processor(
80 const DisplayParameters &display_parameters) const override;
81 std::shared_ptr<const CPUProcessor> get_cpu_processor(
82 StringRefNull from_colorspace, StringRefNull to_colorspace) const override;
83
84 /* Processor API. */
85 const GPUShaderBinder &get_gpu_shader_binder() const override;
86
87 /* Integration with the OpenColorIO specific routines. */
88 const OCIO_NAMESPACE::ConstConfigRcPtr &get_ocio_config() const
89 {
90 return ocio_config_;
91 }
92
93 MEM_CXX_CLASS_ALLOC_FUNCS("LibOCIOConfig");
94
95 private:
96 explicit LibOCIOConfig(const OCIO_NAMESPACE::ConstConfigRcPtr &ocio_config);
97
98 /* Initialize BLender-side representation of color spaces, displays, etc. from the current
99 * OpenColorIO configuration. */
100 void initialize_active_color_spaces();
101 void initialize_inactive_color_spaces();
102 void initialize_looks();
103 void initialize_displays();
104};
105
106} // namespace blender::ocio
107
108#endif
float[3] Vector
static AppView * view
#define Display
blender::ocio::ColorSpace ColorSpace
Read Guarded memory(de)allocation.
VecBase< float, 3 > float3
MatBase< 3, 3 > float3x3