Blender V5.0
libocio_display.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 <memory>
10
11# include "MEM_guardedalloc.h"
12
13# include "BLI_vector.hh"
14
15# include "OCIO_display.hh"
16
18
19# include "libocio_view.hh"
20
21namespace blender::ocio {
22
23class LibOCIOConfig;
24class LibOCIOCPUProcessor;
25
26class LibOCIODisplay : public Display {
27 /* Store by pointer to allow move semantic.
28 * In practice this must never be nullable. */
29 const LibOCIOConfig *config_ = nullptr;
30
31 StringRefNull name_;
32 std::string ui_name_;
33 StringRefNull description_;
34 Vector<LibOCIOView> views_;
35 const LibOCIOView *untonemapped_view_ = nullptr;
36 bool is_hdr_ = false;
37
38 CPUProcessorCache to_scene_linear_cpu_processor_;
39 CPUProcessorCache to_scene_linear_emulation_cpu_processor_;
40 CPUProcessorCache from_scene_linear_cpu_processor_;
41 CPUProcessorCache from_scene_linear_emulation_cpu_processor_;
42
43 public:
44 LibOCIODisplay(int index, const LibOCIOConfig &config);
45 LibOCIODisplay(const LibOCIODisplay &other) = delete;
46 LibOCIODisplay(LibOCIODisplay &&other) noexcept = default;
47
48 ~LibOCIODisplay() override = default;
49
50 LibOCIODisplay &operator=(const LibOCIODisplay &other) = delete;
51 LibOCIODisplay &operator=(LibOCIODisplay &&other) = default;
52
53 StringRefNull name() const override
54 {
55 return name_;
56 }
57
58 StringRefNull ui_name() const override
59 {
60 return (ui_name_.empty()) ? name_ : ui_name_.c_str();
61 }
62
63 StringRefNull description() const override
64 {
65 return description_;
66 }
67
68 const View *get_default_view() const override
69 {
70 /* Matches the behavior of OpenColorIO, but avoids using API which potentially throws exception
71 * and requires string lookups. */
72 return get_view_by_index(0);
73 }
74
75 const View *get_untonemapped_view() const override;
76
77 const View *get_view_by_name(StringRefNull name) const override;
78 int get_num_views() const override;
79 const View *get_view_by_index(int index) const override;
80
81 const CPUProcessor *get_to_scene_linear_cpu_processor(bool use_display_emulation) const override;
82 const CPUProcessor *get_from_scene_linear_cpu_processor(
83 bool use_display_emulation) const override;
84
85 bool is_hdr() const override
86 {
87 return is_hdr_;
88 }
89
90 void clear_caches();
91
92 MEM_CXX_CLASS_ALLOC_FUNCS("LibOCIOConfig");
93
94 protected:
95 std::unique_ptr<LibOCIOCPUProcessor> create_scene_linear_cpu_processor(
96 const bool use_display_emulation, const bool inverse) const;
97};
98
99} // namespace blender::ocio
100
101#endif
static void View(GHOST_IWindow *window, bool stereo, int eye=0)
Read Guarded memory(de)allocation.
btGeneric6DofConstraint & operator=(btGeneric6DofConstraint &other)
constexpr const char * c_str() const
MatBase< C, R > inverse(MatBase< C, R >) RET
const char * name