Blender V5.0
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#if defined(WITH_OPENCOLORIO)
8
9# include <string>
10
11# include "MEM_guardedalloc.h"
12
13# include "OCIO_colorspace.hh"
14
16# include "../opencolorio.hh"
17
18namespace blender::ocio {
19
20class LibOCIOColorSpace : public ColorSpace {
21 OCIO_NAMESPACE::ConstConfigRcPtr ocio_config_;
22 OCIO_NAMESPACE::ConstColorSpaceRcPtr ocio_color_space_;
23
24 std::string clean_description_;
25 StringRefNull interop_id_;
26 bool is_invertible_ = false;
27
28 /* Mutable because they are lazily initialized and cached from the is_scene_linear() and
29 * is_srgb(). */
30 mutable bool is_info_cached_ = false;
31 mutable bool is_scene_linear_ = false;
32 mutable bool is_srgb_ = false;
33
34 CPUProcessorCache to_scene_linear_cpu_processor_;
35 CPUProcessorCache from_scene_linear_cpu_processor_;
36
37 public:
38 LibOCIOColorSpace(int index,
39 const OCIO_NAMESPACE::ConstConfigRcPtr &ocio_config,
40 const OCIO_NAMESPACE::ConstColorSpaceRcPtr &ocio_color_space);
41
42 StringRefNull name() const override
43 {
44 /* TODO(sergey): Avoid construction StringRefNull on every call? */
45 return ocio_color_space_->getName();
46 }
47 StringRefNull description() const override
48 {
49 return clean_description_;
50 }
51
52 StringRefNull interop_id() const override
53 {
54 return interop_id_;
55 }
56
57 bool is_invertible() const override
58 {
59 return is_invertible_;
60 }
61
62 bool is_scene_linear() const override;
63 bool is_srgb() const override;
64
65 bool is_data() const override
66 {
67 return ocio_color_space_->isData();
68 }
69
70 bool is_display_referred() const override
71 {
72 return ocio_color_space_->getReferenceSpaceType() == OCIO_NAMESPACE::REFERENCE_SPACE_DISPLAY;
73 }
74
75 const CPUProcessor *get_to_scene_linear_cpu_processor() const override;
76 const CPUProcessor *get_from_scene_linear_cpu_processor() const override;
77
78 void clear_caches();
79
80 MEM_CXX_CLASS_ALLOC_FUNCS("LibOCIOColorSpace");
81
82 private:
83 void ensure_srgb_scene_linear_info() const;
84};
85
86} // namespace blender::ocio
87
88#endif
Read Guarded memory(de)allocation.
const char * name