Blender V5.3
libocio_colorspace.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#include <string>
8
9#include "MEM_guardedalloc.h"
10
11#include "BLI_set.hh"
12
13#include "OCIO_colorspace.hh"
14
16#include "../opencolorio.hh"
17
18namespace blender::ocio {
19
21 OCIO_NAMESPACE::ConstConfigRcPtr ocio_config_;
22 OCIO_NAMESPACE::ConstColorSpaceRcPtr ocio_color_space_;
23
24 std::string clean_description_;
25 std::string family_;
26 StringRefNull interop_id_;
27 bool is_primary_interop_id_ = false;
28 std::string alternate_interop_id_;
29
30 CPUProcessorCache to_scene_linear_cpu_processor_;
31 CPUProcessorCache from_scene_linear_cpu_processor_;
32
33 /* Configuration whose scene linear role is the target of the to/from scene linear processors.
34 * Usually this is #ocio_config_, but can also be something else if the color space is not
35 * part of a new config but still preserved. */
36 OCIO_NAMESPACE::ConstConfigRcPtr scene_linear_config_;
37
38 void initialize_alternate_interop_id();
39
40 public:
42 const OCIO_NAMESPACE::ConstConfigRcPtr &ocio_config,
43 const OCIO_NAMESPACE::ConstColorSpaceRcPtr &ocio_color_space,
44 Set<StringRef> &primary_interop_ids);
45
46 StringRefNull name() const override
47 {
48 /* TODO(sergey): Avoid construction StringRefNull on every call? */
49 return ocio_color_space_->getName();
50 }
51 StringRefNull description() const override
52 {
53 return clean_description_;
54 }
55 StringRefNull family() const override
56 {
57 return family_;
58 }
59
60 StringRefNull interop_id() const override
61 {
62 return interop_id_;
63 }
64 bool is_primary_interop_id() const override;
66 {
67 return alternate_interop_id_;
68 }
69
70 std::string icc_profile_path() const override;
71
72 bool is_scene_linear() const override;
73 bool is_srgb() const override;
74
75 bool is_data() const override
76 {
77 return ocio_color_space_->isData();
78 }
79
80 bool is_display_referred() const override
81 {
82 return ocio_color_space_->getReferenceSpaceType() == OCIO_NAMESPACE::REFERENCE_SPACE_DISPLAY;
83 }
84
85 const CPUProcessor *get_to_scene_linear_cpu_processor() const override;
87
88 void switch_scene_linear_config(const OCIO_NAMESPACE::ConstConfigRcPtr &ocio_config);
89
90 const OCIO_NAMESPACE::ConstColorSpaceRcPtr &ocio_color_space() const
91 {
92 return ocio_color_space_;
93 }
94
95 void clear_caches();
96
97 MEM_CXX_CLASS_ALLOC_FUNCS("LibOCIOColorSpace");
98};
99
100} // namespace blender::ocio
Read Blender memory allocation and freeing.
MEM_CXX_CLASS_ALLOC_FUNCS("LibOCIOColorSpace")
StringRefNull description() const override
StringRefNull family() const override
void switch_scene_linear_config(const OCIO_NAMESPACE::ConstConfigRcPtr &ocio_config)
StringRefNull name() const override
std::string icc_profile_path() const override
StringRefNull alternate_interop_id() const override
const CPUProcessor * get_from_scene_linear_cpu_processor() const override
LibOCIOColorSpace(int index, const OCIO_NAMESPACE::ConstConfigRcPtr &ocio_config, const OCIO_NAMESPACE::ConstColorSpaceRcPtr &ocio_color_space, Set< StringRef > &primary_interop_ids)
const OCIO_NAMESPACE::ConstColorSpaceRcPtr & ocio_color_space() const
bool is_display_referred() const override
bool is_primary_interop_id() const override
const CPUProcessor * get_to_scene_linear_cpu_processor() const override
StringRefNull interop_id() const override