Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authormano-wii <germano.costa@ig.com.br>2019-03-31 21:58:29 +0300
committermano-wii <germano.costa@ig.com.br>2019-04-01 17:53:04 +0300
commitb5382c92cf9e265714862a19dbdcce1ec81e202a (patch)
tree03d22a9c1b66876ca9039ce00be62645ebedee1f /source
parentfa6c2c7dba909e5d8a88817854b215990eea7051 (diff)
Edit Mesh Selection: Clear out buffer that indicates out of bounds pixels.
This prevents the use of uninitialized buffer. In addition, use `memset` instead of assigning in a loop.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/space_view3d/view3d_draw_legacy.c2
-rw-r--r--source/blender/gpu/intern/gpu_select.c27
2 files changed, 15 insertions, 14 deletions
diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c
index 9498f007910..454315afa57 100644
--- a/source/blender/editors/space_view3d/view3d_draw_legacy.c
+++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c
@@ -303,7 +303,7 @@ uint *ED_view3d_select_id_read_rect(ViewContext *vc, const rcti *clip, uint *r_b
uint width = BLI_rcti_size_x(clip);
uint height = BLI_rcti_size_y(clip);
uint buf_len = width * height;
- uint *buf = MEM_callocN(buf_len * sizeof(*buf), __func__);
+ uint *buf = MEM_mallocN(buf_len * sizeof(*buf), __func__);
DRW_framebuffer_select_id_read(clip, buf);
diff --git a/source/blender/gpu/intern/gpu_select.c b/source/blender/gpu/intern/gpu_select.c
index 1cb51458cb3..875bcdcc674 100644
--- a/source/blender/gpu/intern/gpu_select.c
+++ b/source/blender/gpu/intern/gpu_select.c
@@ -219,32 +219,33 @@ const uint *GPU_select_buffer_near(const uint *buffer, int hits)
void GPU_select_buffer_stride_realign(
const rcti *src, const rcti *dst, uint *r_buf)
{
- const int src_x = BLI_rcti_size_x(src);
- // const int src_y = BLI_rcti_size_y(src);
- int dst_x = BLI_rcti_size_x(dst);
- int dst_y = BLI_rcti_size_y(dst);
- int x = dst->xmin - src->xmin;
- int y = dst->ymin - src->ymin;
+ const int x = dst->xmin - src->xmin;
+ const int y = dst->ymin - src->ymin;
BLI_assert(src->xmin <= dst->xmin && src->ymin <= dst->ymin &&
src->xmax >= dst->xmax && src->ymax >= dst->ymax);
BLI_assert(x >= 0 && y >= 0);
+ const int src_x = BLI_rcti_size_x(src);
+ const int src_y = BLI_rcti_size_y(src);
+ const int dst_x = BLI_rcti_size_x(dst);
+ const int dst_y = BLI_rcti_size_y(dst);
+
int last_px_written = dst_x * dst_y - 1;
int last_px_id = src_x * (y + dst_y - 1) + (x + dst_x - 1);
+ const int skip = src_x - dst_x;
- int skip = src_x - dst_x;
- while (dst_y--) {
- int i;
- for (i = dst_x; i--;) {
+ memset(&r_buf[last_px_id + 1], 0, (src_x * src_y - (last_px_id + 1)) * sizeof(*r_buf));
+
+ while (true) {
+ for (int i = dst_x; i--;) {
r_buf[last_px_id--] = r_buf[last_px_written--];
}
if (last_px_written < 0) {
break;
}
- for (i = skip; i--;) {
- r_buf[last_px_id--] = 0u;
- }
+ last_px_id -= skip;
+ memset(&r_buf[last_px_id + 1], 0, skip * sizeof(*r_buf));
}
memset(r_buf, 0, (last_px_id + 1) * sizeof(*r_buf));
}