Blender V4.5
draw_attributes.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2022 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#include "BKE_customdata.hh"
6
7#include "GPU_shader.hh"
8
9#include "draw_attributes.hh"
10
11namespace blender::draw {
12
14 const VectorSet<std::string> *src,
15 Mutex &render_mutex)
16{
17 if (src->is_empty()) {
18 return;
19 }
20 std::lock_guard lock{render_mutex};
21 dst->add_multiple(src->as_span());
22}
23
25{
26 for (const std::string &req : b->as_span()) {
27 if (!a->contains(req)) {
28 return false;
29 }
30 }
31
32 return true;
33}
34
36{
37 if (attrs->size() >= GPU_MAX_ATTR) {
38 return;
39 }
40 attrs->add_as(name);
41}
42
44 const StringRef name,
45 int *r_layer_index,
46 eCustomDataType *r_type)
47{
48 const eCustomDataType possible_attribute_types[11] = {
60 };
61
62 for (int i = 0; i < ARRAY_SIZE(possible_attribute_types); i++) {
63 const eCustomDataType attr_type = possible_attribute_types[i];
64 int layer_index = CustomData_get_named_layer(&custom_data, attr_type, name);
65 if (layer_index == -1) {
66 continue;
67 }
68
69 *r_layer_index = layer_index;
70 *r_type = attr_type;
71 return true;
72 }
73
74 return false;
75}
76
77} // namespace blender::draw
CustomData interface, see also DNA_customdata_types.h.
int CustomData_get_named_layer(const CustomData *data, eCustomDataType type, blender::StringRef name)
#define ARRAY_SIZE(arr)
@ CD_PROP_BYTE_COLOR
@ CD_PROP_FLOAT
@ CD_PROP_FLOAT3
@ CD_PROP_INT32_2D
@ CD_PROP_COLOR
@ CD_PROP_QUATERNION
@ CD_PROP_INT32
@ CD_PROP_FLOAT2
@ CD_PROP_INT16_2D
static constexpr int GPU_MAX_ATTR
Definition GPU_shader.hh:34
volatile int lock
bool add_as(ForwardKey &&key)
void add_multiple(Span< Key > keys)
int64_t size() const
bool contains(const Key &key) const
Span< Key > as_span() const
Utilities for rendering attributes.
void drw_attributes_add_request(VectorSet< std::string > *attrs, const StringRef name)
void drw_attributes_merge(VectorSet< std::string > *dst, const VectorSet< std::string > *src, Mutex &render_mutex)
bool drw_attributes_overlap(const VectorSet< std::string > *a, const VectorSet< std::string > *b)
bool drw_custom_data_match_attribute(const CustomData &custom_data, const StringRef name, int *r_layer_index, eCustomDataType *r_type)
std::mutex Mutex
Definition BLI_mutex.hh:47
i
Definition text_draw.cc:230