diff options
author | mano-wii <germano.costa@ig.com.br> | 2019-03-28 21:59:51 +0300 |
---|---|---|
committer | mano-wii <germano.costa@ig.com.br> | 2019-03-28 22:00:37 +0300 |
commit | fbfa5890bff48dfa49115aa9a1e3d296ea3018ac (patch) | |
tree | 043f0b516b1a61feb4e798788f61134be2bcd3f9 /source/blender/gpu/intern | |
parent | 7b62c61d6e7436a3491f48641021aff4bc373f63 (diff) |
Fix build errors
From rBd5cb425b8745
Diffstat (limited to 'source/blender/gpu/intern')
-rw-r--r-- | source/blender/gpu/intern/gpu_select.c | 37 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_select_pick.c | 24 |
2 files changed, 37 insertions, 24 deletions
diff --git a/source/blender/gpu/intern/gpu_select.c b/source/blender/gpu/intern/gpu_select.c index adc5f5a9864..1cb51458cb3 100644 --- a/source/blender/gpu/intern/gpu_select.c +++ b/source/blender/gpu/intern/gpu_select.c @@ -23,6 +23,7 @@ * Interface for accessing gpu-related methods for selection. The semantics are * similar to glRenderMode(GL_SELECT) from older OpenGL versions. */ +#include <string.h> #include <stdlib.h> #include "GPU_select.h" @@ -31,6 +32,8 @@ #include "MEM_guardedalloc.h" +#include "BLI_rect.h" + #include "DNA_userdef_types.h" #include "BLI_utildefines.h" @@ -211,3 +214,37 @@ const uint *GPU_select_buffer_near(const uint *buffer, int hits) } return buffer_near; } + +/* Part of the solution copied from `rect_subregion_stride_calc`. */ +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; + + BLI_assert(src->xmin <= dst->xmin && src->ymin <= dst->ymin && + src->xmax >= dst->xmax && src->ymax >= dst->ymax); + BLI_assert(x >= 0 && y >= 0); + + int last_px_written = dst_x * dst_y - 1; + int last_px_id = src_x * (y + dst_y - 1) + (x + dst_x - 1); + + int skip = src_x - dst_x; + while (dst_y--) { + int i; + for (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; + } + } + memset(r_buf, 0, (last_px_id + 1) * sizeof(*r_buf)); +} diff --git a/source/blender/gpu/intern/gpu_select_pick.c b/source/blender/gpu/intern/gpu_select_pick.c index bfd2f3c1ee7..22388deccdb 100644 --- a/source/blender/gpu/intern/gpu_select_pick.c +++ b/source/blender/gpu/intern/gpu_select_pick.c @@ -90,30 +90,6 @@ static void rect_subregion_stride_calc(const rcti *src, const rcti *dst, SubRect r_sub->skip = (uint)(src_x - dst_x); } -void GPU_select_buffer_stride_realign( - const rcti *src, const rcti *dst, uint *r_buf) -{ - SubRectStride sub; - rect_subregion_stride_calc(src, dst, &sub); - - int last_px_written = sub.span * sub.span_len - 1; - int last_px_id = sub.start + last_px_written + (sub.span_len - 1) * sub.skip; - - while (sub.span_len--) { - int i; - for (i = sub.span; i--;) { - r_buf[last_px_id--] = r_buf[last_px_written--]; - } - if (last_px_written < 0) { - break; - } - for (i = sub.skip; i--;) { - r_buf[last_px_id--] = 0u; - } - } - memset(r_buf, 0, (last_px_id + 1) * sizeof(*r_buf)); -} - /** * Ignore depth clearing as a change, * only check if its been changed _and_ filled in (ignore clearing since XRAY does this). |