[Bf-blender-cvs] [5e338f88d57] temp-pbvh-split: Cleanup: use 'num' / 'size' suffix instead of 'sz'

Campbell Barton noreply at git.blender.org
Fri Jun 3 01:16:27 CEST 2022


Commit: 5e338f88d57ad733832cc92a6234d82ac80300a6
Author: Campbell Barton
Date:   Wed May 11 13:37:10 2022 +1000
Branches: temp-pbvh-split
https://developer.blender.org/rB5e338f88d57ad733832cc92a6234d82ac80300a6

Cleanup: use 'num' / 'size' suffix instead of 'sz'

GPU code used `sz` as an abbreviation for size, as well as a few other
places. Use size where this represents a size in bytes, see: T85728.

===================================================================

M	source/blender/blenkernel/intern/main.c
M	source/blender/blenlib/BLI_fileops.h
M	source/blender/blenlib/intern/BLI_filelist.c
M	source/blender/blenlib/tests/performance/BLI_ghash_performance_test.cc
M	source/blender/blenloader/intern/readfile.c
M	source/blender/compositor/operations/COM_FastGaussianBlurOperation.cc
M	source/blender/editors/animation/keyframes_draw.c
M	source/blender/gpu/GPU_vertex_format.h
M	source/blender/gpu/intern/gpu_debug.cc
M	source/blender/gpu/intern/gpu_immediate.cc
M	source/blender/gpu/intern/gpu_vertex_buffer.cc
M	source/blender/gpu/intern/gpu_vertex_format.cc
M	source/blender/gpu/opengl/gl_vertex_array.cc
M	source/blender/nodes/texture/node_texture_util.c

===================================================================

diff --git a/source/blender/blenkernel/intern/main.c b/source/blender/blenkernel/intern/main.c
index 03e03dacfbc..b9ed783fa8c 100644
--- a/source/blender/blenkernel/intern/main.c
+++ b/source/blender/blenkernel/intern/main.c
@@ -502,13 +502,13 @@ BlendThumbnail *BKE_main_thumbnail_from_imbuf(Main *bmain, ImBuf *img)
   }
 
   if (img) {
-    const size_t sz = BLEN_THUMB_MEMSIZE(img->x, img->y);
-    data = MEM_mallocN(sz, __func__);
+    const size_t data_size = BLEN_THUMB_MEMSIZE(img->x, img->y);
+    data = MEM_mallocN(data_size, __func__);
 
     IMB_rect_from_float(img); /* Just in case... */
     data->width = img->x;
     data->height = img->y;
-    memcpy(data->rect, img->rect, sz - sizeof(*data));
+    memcpy(data->rect, img->rect, data_size - sizeof(*data));
   }
 
   if (bmain) {
diff --git a/source/blender/blenlib/BLI_fileops.h b/source/blender/blenlib/BLI_fileops.h
index 3ce2b90e729..9a24b09fc66 100644
--- a/source/blender/blenlib/BLI_fileops.h
+++ b/source/blender/blenlib/BLI_fileops.h
@@ -178,7 +178,7 @@ void BLI_filelist_free(struct direntry *filelist, unsigned int nrentries);
  * Convert given entry's size into human-readable strings.
  */
 void BLI_filelist_entry_size_to_string(const struct stat *st,
-                                       uint64_t sz,
+                                       uint64_t st_size_fallback,
                                        bool compact,
                                        char r_size[FILELIST_DIRENTRY_SIZE_LEN]);
 /**
diff --git a/source/blender/blenlib/intern/BLI_filelist.c b/source/blender/blenlib/intern/BLI_filelist.c
index 76fc5b6342a..c6178ebb3a0 100644
--- a/source/blender/blenlib/intern/BLI_filelist.c
+++ b/source/blender/blenlib/intern/BLI_filelist.c
@@ -237,7 +237,7 @@ unsigned int BLI_filelist_dir_contents(const char *dirname, struct direntry **r_
 }
 
 void BLI_filelist_entry_size_to_string(const struct stat *st,
-                                       const uint64_t sz,
+                                       const uint64_t st_size_fallback,
                                        /* Used to change MB -> M, etc. - is that really useful? */
                                        const bool UNUSED(compact),
                                        char r_size[FILELIST_DIRENTRY_SIZE_LEN])
@@ -247,7 +247,7 @@ void BLI_filelist_entry_size_to_string(const struct stat *st,
    * will buy us some time until files get bigger than 4GB or until
    * everyone starts using __USE_FILE_OFFSET64 or equivalent.
    */
-  double size = (double)(st ? st->st_size : sz);
+  double size = (double)(st ? st->st_size : st_size_fallback);
 #ifdef WIN32
   BLI_str_format_byte_unit(r_size, size, false);
 #else
diff --git a/source/blender/blenlib/tests/performance/BLI_ghash_performance_test.cc b/source/blender/blenlib/tests/performance/BLI_ghash_performance_test.cc
index 0ff488202c2..09bb1e7239f 100644
--- a/source/blender/blenlib/tests/performance/BLI_ghash_performance_test.cc
+++ b/source/blender/blenlib/tests/performance/BLI_ghash_performance_test.cc
@@ -57,23 +57,23 @@ static void str_ghash_tests(GHash *ghash, const char *id)
   printf("\n========== STARTING %s ==========\n", id);
 
 #ifdef TEXT_CORPUS_PATH
-  size_t sz = 0;
+  size_t data_size = 0;
   char *data;
   {
     struct stat st;
     if (stat(TEXT_CORPUS_PATH, &st) == 0)
-      sz = st.st_size;
+      data_size = st.st_size;
   }
-  if (sz != 0) {
+  if (data_size != 0) {
     FILE *f = fopen(TEXT_CORPUS_PATH, "r");
 
-    data = (char *)MEM_mallocN(sz + 1, __func__);
-    if (fread(data, sizeof(*data), sz, f) != sz) {
+    data = (char *)MEM_mallocN(data_size + 1, __func__);
+    if (fread(data, sizeof(*data), data_size, f) != data_size) {
       printf("ERROR in reading file %s!", TEXT_CORPUS_PATH);
       MEM_freeN(data);
       data = BLI_strdup(words10k);
     }
-    data[sz] = '\0';
+    data[data_size] = '\0';
     fclose(f);
   }
   else {
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 6ba97caa0ae..16bad11629a 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -1477,14 +1477,14 @@ BlendThumbnail *BLO_thumbnail_from_file(const char *filepath)
     const int width = fd_data[0];
     const int height = fd_data[1];
     if (BLEN_THUMB_MEMSIZE_IS_VALID(width, height)) {
-      const size_t sz = BLEN_THUMB_MEMSIZE(width, height);
-      data = MEM_mallocN(sz, __func__);
+      const size_t data_size = BLEN_THUMB_MEMSIZE(width, height);
+      data = MEM_mallocN(data_size, __func__);
       if (data) {
-        BLI_assert((sz - sizeof(*data)) ==
+        BLI_assert((data_size - sizeof(*data)) ==
                    (BLEN_THUMB_MEMSIZE_FILE(width, height) - (sizeof(*fd_data) * 2)));
         data->width = width;
         data->height = height;
-        memcpy(data->rect, &fd_data[2], sz - sizeof(*data));
+        memcpy(data->rect, &fd_data[2], data_size - sizeof(*data));
       }
     }
   }
@@ -3857,14 +3857,14 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath)
       const int width = data[0];
       const int height = data[1];
       if (BLEN_THUMB_MEMSIZE_IS_VALID(width, height)) {
-        const size_t sz = BLEN_THUMB_MEMSIZE(width, height);
-        bfd->main->blen_thumb = MEM_mallocN(sz, __func__);
+        const size_t data_size = BLEN_THUMB_MEMSIZE(width, height);
+        bfd->main->blen_thumb = MEM_mallocN(data_size, __func__);
 
-        BLI_assert((sz - sizeof(*bfd->main->blen_thumb)) ==
+        BLI_assert((data_size - sizeof(*bfd->main->blen_thumb)) ==
                    (BLEN_THUMB_MEMSIZE_FILE(width, height) - (sizeof(*data) * 2)));
         bfd->main->blen_thumb->width = width;
         bfd->main->blen_thumb->height = height;
-        memcpy(bfd->main->blen_thumb->rect, &data[2], sz - sizeof(*bfd->main->blen_thumb));
+        memcpy(bfd->main->blen_thumb->rect, &data[2], data_size - sizeof(*bfd->main->blen_thumb));
       }
     }
   }
diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cc b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cc
index 573a740dac8..725751d15af 100644
--- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cc
+++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cc
@@ -112,7 +112,7 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src,
   double *X, *Y, *W;
   const unsigned int src_width = src->get_width();
   const unsigned int src_height = src->get_height();
-  unsigned int x, y, sz;
+  unsigned int x, y, src_dim_max;
   unsigned int i;
   float *buffer = src->get_buffer();
   const uint8_t num_channels = src->get_num_channels();
@@ -202,10 +202,10 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src,
   (void)0
 
   /* Intermediate buffers. */
-  sz = MAX2(src_width, src_height);
-  X = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss X buf");
-  Y = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss Y buf");
-  W = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss W buf");
+  src_dim_max = MAX2(src_width, src_height);
+  X = (double *)MEM_callocN(src_dim_max * sizeof(double), "IIR_gauss X buf");
+  Y = (double *)MEM_callocN(src_dim_max * sizeof(double), "IIR_gauss Y buf");
+  W = (double *)MEM_callocN(src_dim_max * sizeof(double), "IIR_gauss W buf");
   if (xy & 1) { /* H. */
     int offset;
     for (y = 0; y < src_height; y++) {
diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c
index 58d093c678d..786204a52ed 100644
--- a/source/blender/editors/animation/keyframes_draw.c
+++ b/source/blender/editors/animation/keyframes_draw.c
@@ -168,11 +168,11 @@ void draw_keyframe_shape(float x,
 /* Common attributes shared between the draw calls. */
 typedef struct DrawKeylistUIData {
   float alpha;
-  float icon_sz;
-  float half_icon_sz;
-  float smaller_sz;
-  float ipo_sz;
-  float gpencil_sz;
+  float icon_size;
+  float half_icon_size;
+  float smaller_size;
+  float ipo_size;
+  float gpencil_size;
   float screenspace_margin;
   float sel_color[4];
   float unsel_color[4];
@@ -195,11 +195,11 @@ static void draw_keylist_ui_data_init(DrawKeylistUIData *ctx,
   /* TODO: allow this opacity factor to be themed? */
   ctx->alpha = channel_locked ? 0.25f : 1.0f;
 
-  ctx->icon_sz = U.widget_unit * 0.5f * yscale_fac;
-  ctx->half_icon_sz = 0.5f * ctx->icon_sz;
-  ctx->smaller_sz = 0.35f * ctx->icon_sz;
-  ctx->ipo_sz = 0.1f * ctx->icon_sz;
-  ctx->gpencil_sz = ctx->smaller_sz * 0.8f;
+  ctx->icon_size = U.widget_unit * 0.5f * yscale_fac;
+  ctx->half_icon_size = 0.5f * ctx->icon_size;
+  ctx->smaller_size = 0.35f * ctx->icon_size;
+  ctx->ipo_size = 0.1f * ctx->icon_size;
+  ctx->gpencil_size = ctx->smaller_size * 0.8f;
   ctx->screenspace_margin = (0.35f * (float)UI_UNIT_X) / UI_view2d_scale_get_x(v2d);
 
   ctx->show_ipo = (saction_flag & SACTION_SHOW_INTERPOLATION) != 0;
@@ -242,8 +242,8 @@ static void draw_keylist_block_gpencil(const DrawKeylistUIData *ctx,
       &(const rctf){
           .xmin = ab->cfra,
           .xmax = min_ff(ab->next->cfra - (ctx->screenspace_margin * size), ab->next->cfra),
-          .ymin = ypos - ctx->gpencil_sz,
-          .ymax = ypos + ctx->gpencil_sz,
+          .ymin = ypos - ctx->gpencil_size,
+          .ymax = ypos + ctx->gpencil_size,
       },
       true,
       0.25f * (float)UI_UNIT_X,
@@ -259,8 +259,8 @@ static void draw_keylist_block_moving_hold(const DrawKeylistUIData *ctx,
       &(const rctf){
           .xmin = ab->cfra,
           .xmax = ab->next->cfra,
-          .ymin = ypos - ctx->smaller_sz,
-          .ymax = ypos + ctx->smaller_sz,
+          .ymin = ypos - ctx->smaller_size,
+          .ymax = ypos + ctx->smaller_size,
       },
       true,
       3.0f,
@@ -275,8 +275,8 @@ static void draw_keylist_block_standard(const DrawKeylistUIData *ctx,
       &(const rctf){
           .xmin = ab->cfra,
           .xmax = ab->next->cfra,
-          .ymin = ypos - ctx->half_icon_sz,
-          .ymax = ypos + ctx->half_icon_sz,
+          .ymin = ypos - ctx->half_icon_size,
+          .ymax = ypos + ctx->half_icon_size,
       },
  

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list