Blender V4.5
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/* -------------------------------------------------------------------- */
106
108{
109 return &default_display_;
110}
111
113{
114 if (name == default_display_.name()) {
115 return &default_display_;
116 }
117 return nullptr;
118}
119
121{
122 return 1;
123}
124
126{
127 if (index != 0) {
128 return nullptr;
129 }
130 return &default_display_;
131}
132
134
135/* -------------------------------------------------------------------- */
138
140 const StringRefNull view) const
141{
142 if (display == default_display_.name() && view == default_display_.get_default_view()->name()) {
143 return &colorspace_srgb_;
144 }
145 return nullptr;
146}
147
149
150/* -------------------------------------------------------------------- */
153
155{
156 if (name == default_look_.name()) {
157 return &default_look_;
158 }
159 return nullptr;
160}
161
163{
164 return 1;
165}
166
168{
169 if (index != 0) {
170 return nullptr;
171 }
172 return &default_look_;
173}
174
176
177/* -------------------------------------------------------------------- */
180
181std::shared_ptr<const CPUProcessor> FallbackConfig::get_display_cpu_processor(
182 const DisplayParameters &display_parameters) const
183{
184 return create_fallback_display_cpu_processor(*this, display_parameters);
185}
186
187std::shared_ptr<const CPUProcessor> FallbackConfig::get_cpu_processor(
188 const StringRefNull from_colorspace, const StringRefNull to_colorspace) const
189{
190 return processor_cache_.get(from_colorspace, to_colorspace);
191}
192
194
195/* -------------------------------------------------------------------- */
198
200{
201 return gpu_shader_binder_;
202}
203
205
206} // 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 Look * get_look_by_name(StringRefNull name) 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