Cleanup: Draw: Use StringRef for attribute names

Avoid the need to measure string length potentially many times.
This commit is contained in:
Hans Goudey
2025-05-15 14:53:11 -04:00
parent 8ec093a2d8
commit cbcf421db7
4 changed files with 9 additions and 8 deletions

View File

@@ -12,6 +12,7 @@
#include "BLI_math_matrix_types.hh"
#include "BLI_span.hh"
#include "BLI_string_ref.hh"
struct GPUMaterial;
namespace blender::gpu {
@@ -138,7 +139,7 @@ blender::gpu::Batch *DRW_lattice_batch_cache_get_edit_verts(Lattice *lt);
* stored, which will be filled by #DRW_shgroup_curves_create_sub.
*/
gpu::VertBuf **DRW_curves_texture_for_evaluated_attribute(Curves *curves,
const char *name,
StringRef name,
bool *r_is_point_domain);
blender::gpu::Batch *DRW_curves_batch_cache_get_edit_points(Curves *curves);
@@ -156,7 +157,7 @@ void DRW_curves_batch_cache_create_requested(Object *ob);
gpu::VertBuf *DRW_pointcloud_position_and_radius_buffer_get(Object *ob);
gpu::VertBuf **DRW_pointcloud_evaluated_attribute(PointCloud *pointcloud, const char *name);
gpu::VertBuf **DRW_pointcloud_evaluated_attribute(PointCloud *pointcloud, StringRef name);
blender::gpu::Batch *DRW_pointcloud_batch_cache_get_dots(Object *ob);
blender::gpu::Batch *DRW_pointcloud_batch_cache_get_edit_dots(PointCloud *pointcloud);

View File

@@ -874,7 +874,7 @@ static bool ensure_attributes(const Curves &curves,
return need_tf_update;
}
static void request_attribute(Curves &curves, const char *name)
static void request_attribute(Curves &curves, const StringRef name)
{
CurvesBatchCache &cache = get_batch_cache(curves);
CurvesEvalFinalCache &final_cache = cache.eval_cache.final;
@@ -1033,7 +1033,7 @@ gpu::Batch *DRW_curves_batch_cache_get_edit_curves_lines(Curves *curves)
}
gpu::VertBuf **DRW_curves_texture_for_evaluated_attribute(Curves *curves,
const char *name,
const StringRef name,
bool *r_is_point_domain)
{
CurvesBatchCache &cache = get_batch_cache(*curves);

View File

@@ -201,7 +201,7 @@ static DRW_MeshCDMask mesh_cd_calc_used_gpu_layers(const Object &object,
}
ListBase gpu_attrs = GPU_material_attributes(gpumat);
LISTBASE_FOREACH (GPUMaterialAttribute *, gpu_attr, &gpu_attrs) {
const char *name = gpu_attr->name;
StringRef name = gpu_attr->name;
eCustomDataType type = static_cast<eCustomDataType>(gpu_attr->type);
int layer = -1;
std::optional<bke::AttrDomain> domain;
@@ -689,8 +689,8 @@ static void request_active_and_default_color_attributes(const Object &object,
const CustomData &cd_vdata = mesh_cd_vdata_get_from_mesh(me_final);
const CustomData &cd_ldata = mesh_cd_ldata_get_from_mesh(me_final);
auto request_color_attribute = [&](const char *name) {
if (name) {
auto request_color_attribute = [&](const StringRef name) {
if (!name.is_empty()) {
int layer_index;
eCustomDataType type;
if (drw_custom_data_match_attribute(cd_vdata, name, &layer_index, &type)) {

View File

@@ -400,7 +400,7 @@ gpu::VertBuf *DRW_pointcloud_position_and_radius_buffer_get(Object *ob)
return pointcloud_position_and_radius_get(&pointcloud);
}
gpu::VertBuf **DRW_pointcloud_evaluated_attribute(PointCloud *pointcloud, const char *name)
gpu::VertBuf **DRW_pointcloud_evaluated_attribute(PointCloud *pointcloud, const StringRef name)
{
const bke::AttributeAccessor attributes = pointcloud->attributes();
PointCloudBatchCache &cache = *pointcloud_batch_cache_get(*pointcloud);