diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-07-11 14:09:22 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-07-11 16:21:41 +0300 |
commit | 114e7eaa0994b07d44b5a9ed5a4b8b14ef9b0791 (patch) | |
tree | cb5ddc3e98086fb47213ccdb90a2be45357974d9 /source/blender/editors/mesh/editface.c | |
parent | 02b36188737b3e15fe8173dec7a57da7da610922 (diff) |
Add WM_framebuffer_to_index_array
Convert buffer to index in one loop,
also minor cleanup to backbuf/selection functions.
- Use IMB_rectcpy instead of inline pixel copy.
- Redundant WM_framebuffer_to_index call.
Diffstat (limited to 'source/blender/editors/mesh/editface.c')
-rw-r--r-- | source/blender/editors/mesh/editface.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c index 35fc4483702..de37d5c0a0c 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.c @@ -426,13 +426,15 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, bool select, bool exten unsigned int *rt; char *selar; int a, index; - int sx = BLI_rcti_size_x(rect) + 1; - int sy = BLI_rcti_size_y(rect) + 1; + const int size[2] = { + BLI_rcti_size_x(rect) + 1, + BLI_rcti_size_y(rect) + 1}; me = BKE_mesh_from_object(ob); - if (me == NULL || me->totpoly == 0 || sx * sy <= 0) + if ((me == NULL) || (me->totpoly == 0) || (size[0] * size[1] <= 0)) { return OPERATOR_CANCELLED; + } selar = MEM_callocN(me->totpoly + 1, "selar"); @@ -448,16 +450,21 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, bool select, bool exten ED_view3d_backbuf_validate(vc); - ibuf = IMB_allocImBuf(sx, sy, 32, IB_rect); + ibuf = IMB_allocImBuf(size[0], size[1], 32, IB_rect); rt = ibuf->rect; - view3d_opengl_read_pixels(vc->ar, rect->xmin, rect->ymin, sx, sy, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); - if (ENDIAN_ORDER == B_ENDIAN) IMB_convert_rgba_to_abgr(ibuf); + view3d_opengl_read_pixels(vc->ar, rect->xmin, rect->ymin, size[0], size[1], GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); + if (ENDIAN_ORDER == B_ENDIAN) { + IMB_convert_rgba_to_abgr(ibuf); + } + WM_framebuffer_to_index_array(ibuf->rect, size[0] * size[1]); - a = sx * sy; + a = size[0] * size[1]; while (a--) { if (*rt) { - index = WM_framebuffer_to_index(*rt); - if (index <= me->totpoly) selar[index] = 1; + index = *rt; + if (index <= me->totpoly) { + selar[index] = 1; + } } rt++; } |