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