Blender V5.0
fallback_config.cc
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#include "fallback_config.hh"
6
7#include "OCIO_display.hh"
8#include "OCIO_matrix.hh"
9
12
13namespace blender::ocio {
14/* -------------------------------------------------------------------- */
17
19{
20 /* Here we simply use the older Blender assumed primaries of ITU-BT.709 / sRGB, or
21 * 0.2126729 0.7151522 0.0721750. Brute force stupid, but only plausible option given no color
22 * management system in place. */
23
24 return float3(0.2126f, 0.7152f, 0.0722f);
25}
26
28{
29 /* Default to ITU-BT.709. */
30 return XYZ_TO_REC709;
31}
32
33const char *FallbackConfig::get_color_space_from_filepath(const char * /*filepath*/) const
34{
35 return nullptr;
36}
37
39
40/* -------------------------------------------------------------------- */
43
45{
46 for (const ColorSpace *color_space : color_spaces_) {
47 if (color_space->name() == name) {
48 return color_space;
49 }
50 }
51
52 if (name == "scene_linear") {
53 return &colorspace_linear_;
54 }
55 if (name == "color_picking") {
56 return &colorspace_srgb_;
57 }
58 if (name == "texture_paint") {
59 return &colorspace_linear_;
60 }
61 if (name == "default_byte") {
62 return &colorspace_srgb_;
63 }
64 if (name == "default_float") {
65 return &colorspace_linear_;
66 }
67 if (name == "default_sequencer") {
68 return &colorspace_srgb_;
69 }
70 if (name == "Linear") {
71 return &colorspace_linear_;
72 }
73 if (name == "sRGB") {
74 return &colorspace_srgb_;
75 }
76 if (name == "data") {
77 return &colorspace_data_;
78 }
79
80 return nullptr;
81}
82
84{
85 return color_spaces_.size();
86}
87
89{
90 if (index < 0 || index >= color_spaces_.size()) {
91 return nullptr;
92 }
93 return color_spaces_[index];
94}
95
97{
98 return get_color_space_by_index(index);
99}
100
102{
103 if (interop_id == "lin_rec709_scene") {
104 return &colorspace_linear_;
105 }
106 if (interop_id == "srgb_rec709_display") {
107 return &colorspace_srgb_;
108 }
109 if (interop_id == "data") {
110 return &colorspace_data_;
111 }
112
113 return nullptr;
114}
115
120
122
123/* -------------------------------------------------------------------- */
126
128
130
131/* -------------------------------------------------------------------- */
134
136{
137 return &default_display_;
138}
139
141{
142 if (name == default_display_.name()) {
143 return &default_display_;
144 }
145 return nullptr;
146}
147
149{
150 return 1;
151}
152
154{
155 if (index != 0) {
156 return nullptr;
157 }
158 return &default_display_;
159}
160
162
163/* -------------------------------------------------------------------- */
166
168 const StringRefNull view) const
169{
170 if (display == default_display_.name() && view == default_display_.get_default_view()->name()) {
171 return &colorspace_srgb_;
172 }
173 return nullptr;
174}
175
177
178/* -------------------------------------------------------------------- */
181
183{
184 if (name == default_look_.name()) {
185 return &default_look_;
186 }
187 return nullptr;
188}
189
191{
192 return 1;
193}
194
196{
197 if (index != 0) {
198 return nullptr;
199 }
200 return &default_look_;
201}
202
204
205/* -------------------------------------------------------------------- */
208
209std::shared_ptr<const CPUProcessor> FallbackConfig::get_display_cpu_processor(
210 const DisplayParameters &display_parameters) const
211{
212 return create_fallback_display_cpu_processor(*this, display_parameters);
213}
214
215std::shared_ptr<const CPUProcessor> FallbackConfig::get_cpu_processor(
216 const StringRefNull from_colorspace, const StringRefNull to_colorspace) const
217{
218 return processor_cache_.get(from_colorspace, to_colorspace);
219}
220
222
223/* -------------------------------------------------------------------- */
226
228{
229 return gpu_shader_binder_;
230}
231
233
234} // namespace blender::ocio
static AppView * view
const char * get_color_space_from_filepath(const char *filepath) const override
std::shared_ptr< const CPUProcessor > get_cpu_processor(StringRefNull from_colorspace, StringRefNull to_colorspace) const override
const ColorSpace * get_color_space(StringRefNull name) const override
int get_num_displays() const override
const Look * get_look_by_index(int index) const override
std::shared_ptr< const CPUProcessor > get_display_cpu_processor(const DisplayParameters &display_parameters) const override
const Display * get_display_by_name(StringRefNull name) const override
const ColorSpace * get_sorted_color_space_by_index(int index) const override
const ColorSpace * get_color_space_for_hdr_image(StringRefNull name) const override
void set_scene_linear_role(StringRefNull name) override
const Look * get_look_by_name(StringRefNull name) const override
const ColorSpace * get_color_space_by_interop_id(StringRefNull interop_id) const override
const Display * get_default_display() const override
int get_num_color_spaces() const override
float3 get_default_luma_coefs() const override
int get_num_looks() const override
const ColorSpace * get_color_space_by_index(int index) const override
const GPUShaderBinder & get_gpu_shader_binder() const override
const ColorSpace * get_display_view_color_space(StringRefNull display, StringRefNull view) const override
float3x3 get_xyz_to_scene_linear_matrix() const override
const Display * get_display_by_index(int index) const override
std::shared_ptr< const CPUProcessor > create_fallback_display_cpu_processor(const Config &config, const DisplayParameters &display_parameters)
static const float3x3 XYZ_TO_REC709
MatBase< float, 3, 3 > float3x3
VecBase< float, 3 > float3
const char * name