Blender V4.5
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 bool is_inveetible_ = false;
26
27 /* Mutable because they are lazily initialized and cached from the is_scene_linear() and
28 * is_srgb(). */
29 mutable bool is_info_cached_ = false;
30 mutable bool is_scene_linear_ = false;
31 mutable bool is_srgb_ = false;
32
33 CPUProcessorCache to_scene_linear_cpu_processor_;
34 CPUProcessorCache from_scene_linear_cpu_processor_;
35
36 public:
37 LibOCIOColorSpace(int index,
38 const OCIO_NAMESPACE::ConstConfigRcPtr &ocio_config,
39 const OCIO_NAMESPACE::ConstColorSpaceRcPtr &ocio_color_space);
40
41 StringRefNull name() const override
42 {
43 /* TODO(sergey): Avoid construction StringRefNull on every call? */
44 return ocio_color_space_->getName();
45 }
46 StringRefNull description() const override
47 {
48 return clean_description_;
49 }
50
51 bool is_invertible() const override
52 {
53 return is_inveetible_;
54 }
55
56 bool is_scene_linear() const override;
57 bool is_srgb() const override;
58
59 bool is_data() const override
60 {
61 return ocio_color_space_->isData();
62 }
63
64 const CPUProcessor *get_to_scene_linear_cpu_processor() const override;
65 const CPUProcessor *get_from_scene_linear_cpu_processor() const override;
66
67 MEM_CXX_CLASS_ALLOC_FUNCS("LibOCIOColorSpace");
68
69 private:
70 void ensure_srgb_scene_linear_info() const;
71};
72
73} // namespace blender::ocio
74
75#endif
Read Guarded memory(de)allocation.