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
diff options
context:
space:
mode:
authormano-wii <germano.costa@ig.com.br>2019-08-06 00:02:43 +0300
committermano-wii <germano.costa@ig.com.br>2019-08-07 18:43:31 +0300
commit9d7d34c12af5525d969a8806bc059dbb7a499d0f (patch)
treeb895cfb53d10e40bf12eee9d5be034ca17cb4a59 /source/blender/draw/engines/select
parentdafecfa683a8d7e1684bd930da02dfaa01aabadb (diff)
Select utils refactor: remove lagacy `ED_view3d_select_id_read_rect`
`ED_view3d_select_id_read_rect` serves only as a bridge to `DRW_framebuffer_select_id_read`. Keeping these codes similar only increases the complexity of some functions. Reviewers: campbellbarton Differential Revision: https://developer.blender.org/D5415
Diffstat (limited to 'source/blender/draw/engines/select')
-rw-r--r--source/blender/draw/engines/select/select_engine.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/source/blender/draw/engines/select/select_engine.c b/source/blender/draw/engines/select/select_engine.c
index 1f00a116499..8bce61b3031 100644
--- a/source/blender/draw/engines/select/select_engine.c
+++ b/source/blender/draw/engines/select/select_engine.c
@@ -344,7 +344,7 @@ uint DRW_select_context_elem_len(void)
}
/* Read a block of pixels from the select frame buffer. */
-void DRW_framebuffer_select_id_read(const rcti *rect, uint *r_buf)
+uint *DRW_framebuffer_select_id_read(const rcti *rect, uint *r_buf_len)
{
/* clamp rect by texture */
rcti r = {
@@ -356,6 +356,9 @@ void DRW_framebuffer_select_id_read(const rcti *rect, uint *r_buf)
rcti rect_clamp = *rect;
if (BLI_rcti_isect(&r, &rect_clamp, &rect_clamp)) {
+ size_t buf_len = BLI_rcti_size_x(rect) * BLI_rcti_size_y(rect);
+ uint *r_buf = MEM_mallocN(buf_len * sizeof(*r_buf), __func__);
+
DRW_opengl_context_enable();
GPU_framebuffer_bind(e_data.framebuffer_select_id);
glReadBuffer(GL_COLOR_ATTACHMENT0);
@@ -373,12 +376,14 @@ void DRW_framebuffer_select_id_read(const rcti *rect, uint *r_buf)
if (!BLI_rcti_compare(rect, &rect_clamp)) {
GPU_select_buffer_stride_realign(rect, &rect_clamp, r_buf);
}
- }
- else {
- size_t buf_size = BLI_rcti_size_x(rect) * BLI_rcti_size_y(rect) * sizeof(*r_buf);
- memset(r_buf, 0, buf_size);
+ if (r_buf_len) {
+ *r_buf_len = buf_len;
+ }
+
+ return r_buf;
}
+ return NULL;
}
void DRW_select_context_create(Base **UNUSED(bases), const uint bases_len, short select_mode)