Blender V5.3
COM_string_image.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2026 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
7#include <cstdint>
8#include <memory>
9#include <optional>
10#include <string>
11
12#include "BLI_map.hh"
13
14#include "DNA_node_types.h"
15#include "DNA_vfont_types.h"
16
18#include "COM_result.hh"
19
20namespace blender::compositor {
21
22class Context;
23
25 Left = 0,
26 Center = 1,
27 Right = 2,
28};
29
37
38/* ------------------------------------------------------------------------------------------------
39 * String Image Key.
40 */
42 public:
43 const std::string string;
44 const VFont *font;
45 const float size;
48 const std::optional<int> wrap_width;
49
50 StringImageKey(const std::string string,
51 const VFont *font,
52 const float size,
55 const std::optional<int> wrap_width);
56
57 uint64_t hash() const;
58 friend bool operator==(const StringImageKey &a, const StringImageKey &b) = default;
59};
60
61/* -------------------------------------------------------------------------------------------------
62 * String Image.
63 *
64 * A cached resource that computes and caches a result containing a string with the given
65 * parameters. */
67 public:
69
70 StringImage(Context &context,
71 const std::string string,
72 const VFont *font,
73 const float size,
74 const HorizontalAlignment horizontal_alignment,
75 const VerticalAlignment vertical_alignment,
76 const std::optional<int> wrap_width);
77
79};
80
81/* ------------------------------------------------------------------------------------------------
82 * String Image Container.
83 */
85 private:
87
88 public:
89 void reset() override;
90
91 /* Check if there is an available StringImage cached resource with the given parameters in the
92 * container, if one exists, return it, otherwise, return a newly created one and add it to the
93 * container. In both cases, tag the cached resource as needed to keep it cached for the next
94 * evaluation. */
95 Result &get(Context &context,
96 const std::string string,
97 const VFont *font,
98 const float size,
99 const HorizontalAlignment horizontal_alignment,
100 const VerticalAlignment vertical_alignment,
101 const std::optional<int> wrap_width);
102};
103
104} // namespace blender::compositor
Result & get(Context &context, const std::string string, const VFont *font, const float size, const HorizontalAlignment horizontal_alignment, const VerticalAlignment vertical_alignment, const std::optional< int > wrap_width)
StringImageKey(const std::string string, const VFont *font, const float size, const HorizontalAlignment horizontal_alignment, const VerticalAlignment vertical_alignment, const std::optional< int > wrap_width)
friend bool operator==(const StringImageKey &a, const StringImageKey &b)=default
const VerticalAlignment vertical_alignment
const HorizontalAlignment horizontal_alignment
const std::optional< int > wrap_width
StringImage(Context &context, const std::string string, const VFont *font, const float size, const HorizontalAlignment horizontal_alignment, const VerticalAlignment vertical_alignment, const std::optional< int > wrap_width)
unsigned __int64 uint64_t
Definition BKE_text.h:91
unsigned char uint8_t
Definition BKE_text.h:79