[Bf-blender-cvs] [38630072f33] greasepencil-refactor: GPencil: More cleanup
Antonio Vazquez
noreply at git.blender.org
Wed Jan 8 15:46:23 CET 2020
Commit: 38630072f3382248ca2a2a677c876641273750e6
Author: Antonio Vazquez
Date: Wed Jan 8 13:54:15 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB38630072f3382248ca2a2a677c876641273750e6
GPencil: More cleanup
===================================================================
M source/blender/draw/CMakeLists.txt
M source/blender/draw/engines/gpencil/gpencil_cache_utils.c
M source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
D source/blender/draw/engines/gpencil/gpencil_draw_utils.c
M source/blender/draw/engines/gpencil/gpencil_engine.c
M source/blender/draw/engines/gpencil/gpencil_engine.h
===================================================================
diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt
index fc2da11bc4e..27d5280d914 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -115,7 +115,6 @@ set(SRC
engines/gpencil/gpencil_cache_utils.c
engines/gpencil/gpencil_draw_cache_impl.c
engines/gpencil/gpencil_draw_data.c
- engines/gpencil/gpencil_draw_utils.c
engines/gpencil/gpencil_engine.c
engines/gpencil/gpencil_engine.h
engines/gpencil/gpencil_render.c
diff --git a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
index 04de3d9634a..da21d1a0c21 100644
--- a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
@@ -357,52 +357,6 @@ tGPencilObjectCache *gpencil_object_cache_add(tGPencilObjectCache *cache_array,
return cache_array;
}
-/* add a shading group to the cache to create later */
-GpencilBatchGroup *gpencil_group_cache_add(GpencilBatchGroup *cache_array,
- bGPDlayer *gpl,
- bGPDframe *gpf,
- bGPDstroke *gps,
- const short type,
- const bool onion,
- const int vertex_idx,
- int *grp_size,
- int *grp_used)
-{
- GpencilBatchGroup *cache_elem = NULL;
- GpencilBatchGroup *p = NULL;
-
- /* By default a cache is created with one block with a predefined number of free slots,
- * if the size is not enough, the cache is reallocated adding a new block of free slots.
- * This is done in order to keep cache small. */
- if (*grp_used + 1 > *grp_size) {
- if ((*grp_size == 0) || (cache_array == NULL)) {
- p = MEM_callocN(sizeof(struct GpencilBatchGroup) * GPENCIL_GROUPS_BLOCK_SIZE,
- "GpencilBatchGroup");
- *grp_size = GPENCIL_GROUPS_BLOCK_SIZE;
- }
- else {
- *grp_size += GPENCIL_GROUPS_BLOCK_SIZE;
- p = MEM_recallocN(cache_array, sizeof(struct GpencilBatchGroup) * *grp_size);
- }
- cache_array = p;
- }
- /* zero out all data */
- cache_elem = &cache_array[*grp_used];
- memset(cache_elem, 0, sizeof(*cache_elem));
-
- cache_elem->gpl = gpl;
- cache_elem->gpf = gpf;
- cache_elem->gps = gps;
- cache_elem->type = type;
- cache_elem->onion = onion;
- cache_elem->vertex_idx = vertex_idx;
-
- /* increase slots used in cache */
- (*grp_used)++;
-
- return cache_array;
-}
-
/* get current cache data */
static GpencilBatchCache *gpencil_batch_get_element(Object *ob)
{
@@ -472,25 +426,6 @@ static void gpencil_batch_cache_clear(GpencilBatchCache *cache)
return;
}
- GPU_BATCH_DISCARD_SAFE(cache->b_stroke.batch);
- GPU_BATCH_DISCARD_SAFE(cache->b_point.batch);
- GPU_BATCH_DISCARD_SAFE(cache->b_fill.batch);
- GPU_BATCH_DISCARD_SAFE(cache->b_edit.batch);
- GPU_BATCH_DISCARD_SAFE(cache->b_edlin.batch);
-
- MEM_SAFE_FREE(cache->b_stroke.batch);
- MEM_SAFE_FREE(cache->b_point.batch);
- MEM_SAFE_FREE(cache->b_fill.batch);
- MEM_SAFE_FREE(cache->b_edit.batch);
- MEM_SAFE_FREE(cache->b_edlin.batch);
-
- /* internal format data */
- MEM_SAFE_FREE(cache->b_stroke.format);
- MEM_SAFE_FREE(cache->b_point.format);
- MEM_SAFE_FREE(cache->b_fill.format);
- MEM_SAFE_FREE(cache->b_edit.format);
- MEM_SAFE_FREE(cache->b_edlin.format);
-
MEM_SAFE_FREE(cache->grp_cache);
cache->grp_size = 0;
cache->grp_used = 0;
@@ -511,4 +446,4 @@ GpencilBatchCache *gpencil_batch_cache_get(Object *ob, int cfra)
else {
return cache;
}
-}
\ No newline at end of file
+}
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
index 4dfbd083a6d..4466f1e7bea 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -43,618 +43,6 @@
#include "gpencil_engine.h"
-/* Helper to add stroke point to vbo */
-static void gpencil_set_stroke_point(GPUVertBuf *vbo,
- const bGPDspoint *pt,
- int idx,
- uint pos_id,
- uint color_id,
- uint thickness_id,
- uint uvdata_id,
- short thickness,
- const bool attenuate,
- const float ink[4])
-{
- float alpha = ink[3] * pt->strength;
-
- /* If using vertex paint mask, attenuate not selected. */
- if ((attenuate) && ((pt->flag & GP_SPOINT_SELECT) == 0)) {
- alpha *= GP_VERTEX_MASK_ATTENUATE;
- }
-
- CLAMP(alpha, GPENCIL_STRENGTH_MIN, 1.0f);
- float col[4];
- ARRAY_SET_ITEMS(col, ink[0], ink[1], ink[2], alpha);
-
- GPU_vertbuf_attr_set(vbo, color_id, idx, col);
-
- /* transfer both values using the same shader variable */
- float uvdata[2] = {pt->uv_fac, pt->uv_rot};
- GPU_vertbuf_attr_set(vbo, uvdata_id, idx, uvdata);
-
- /* the thickness of the stroke must be affected by zoom, so a pixel scale is calculated */
- float thick = max_ff(pt->pressure * thickness, 1.0f);
- GPU_vertbuf_attr_set(vbo, thickness_id, idx, &thick);
-
- GPU_vertbuf_attr_set(vbo, pos_id, idx, &pt->x);
-}
-
-/* Helper to add buffer_stroke point to vbo */
-static void gpencil_set_buffer_stroke_point(GPUVertBuf *vbo,
- const bGPDspoint *pt,
- int idx,
- uint pos_id,
- uint color_id,
- uint thickness_id,
- uint uvdata_id,
- uint prev_pos_id,
- const float ref_pt[3],
- short thickness,
- const float ink[4])
-{
-
- float alpha = ink[3] * pt->strength;
- CLAMP(alpha, GPENCIL_STRENGTH_MIN, 1.0f);
- float col[4];
- ARRAY_SET_ITEMS(col, ink[0], ink[1], ink[2], alpha);
-
- GPU_vertbuf_attr_set(vbo, color_id, idx, col);
-
- /* transfer both values using the same shader variable */
- float uvdata[2] = {pt->uv_fac, pt->uv_rot};
- GPU_vertbuf_attr_set(vbo, uvdata_id, idx, uvdata);
-
- /* the thickness of the stroke must be affected by zoom, so a pixel scale is calculated */
- float thick = max_ff(pt->pressure * thickness, 1.0f);
- GPU_vertbuf_attr_set(vbo, thickness_id, idx, &thick);
-
- GPU_vertbuf_attr_set(vbo, pos_id, idx, &pt->x);
- /* reference point to follow drawing path */
- GPU_vertbuf_attr_set(vbo, prev_pos_id, idx, ref_pt);
-}
-
-/* Helper to add a new fill point and texture coordinates to vertex buffer */
-static void gpencil_set_fill_point(GPUVertBuf *vbo,
- int idx,
- bGPDspoint *pt,
- const float fcolor[4],
- uint pos_id,
- uint color_id,
- uint text_id)
-{
- GPU_vertbuf_attr_set(vbo, pos_id, idx, &pt->x);
- GPU_vertbuf_attr_set(vbo, color_id, idx, fcolor);
- GPU_vertbuf_attr_set(vbo, text_id, idx, pt->uv_fill);
-}
-
-static void gpencil_vbo_ensure_size(GpencilBatchCacheElem *be, int totvertex)
-{
- if (be->vbo->vertex_alloc <= be->vbo_len + totvertex) {
- uint newsize = be->vbo->vertex_alloc +
- (((totvertex / GPENCIL_VBO_BLOCK_SIZE) + 1) * GPENCIL_VBO_BLOCK_SIZE);
- GPU_vertbuf_data_resize(be->vbo, newsize);
- }
-}
-
-static void gpencil_elem_format_ensure(GpencilBatchCacheElem *be)
-{
- if (be->format == NULL) {
- be->format = MEM_callocN(sizeof(GPUVertFormat), __func__);
- }
-}
-
-/* create batch geometry data for points stroke shader */
-void gpencil_get_point_geom(GpencilBatchCacheElem *be,
- bGPDlayer *gpl,
- bGPDstroke *gps,
- short thickness,
- const float ink[4],
- const float tintcolor[4],
- const int alignment_mode,
- const bool onion)
-{
- const DRWContextState *draw_ctx = DRW_context_state_get();
- View3D *v3d = draw_ctx->v3d;
- ToolSettings *ts = draw_ctx->scene->toolsettings;
- Object *ob = draw_ctx->obact;
- bGPdata *gpd = ob ? (bGPdata *)ob->data : NULL;
- int totvertex = gps->totpoints;
- float mix_color[4];
- zero_v4(mix_color);
-
- const float vpaint_mix = gpencil_get_vertex_paint_factor(v3d);
- const bool attenuate = (GPENCIL_VERTEX_MODE(gpd) &&
- GPENCIL_ANY_VERTEX_MASK(ts->gpencil_selectmode_vertex));
-
- if (be->vbo == NULL) {
- gpencil_elem_format_ensure(be);
- be->pos_id = GPU_vertformat_attr_add(be->format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
- be->color_id = GPU_vertformat_attr_add(be->format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
- be->thickness_id = GPU_vertformat_attr_add(
- be->format, "thickness", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
- be->uvdata_id = GPU_vertformat_attr_add(
- be->format, "uvdata", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
- be->prev_pos_id = GPU_vertformat_attr_add(
- be->format, "prev_pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
-
- be->vbo = GPU_vertbuf_create_with_format(be->format);
- GPU_vertbuf_data_alloc(be->vbo, be->tot_vertex);
- be->vbo_len = 0;
- }
- gpencil_vbo_ensure_size(be, totvertex);
-
- /* draw stroke curve */
- const bGPDspoint *pt = gps->points;
- float alpha;
- float col[4];
-
- for (int i = 0; i < gps->totpoints; i++, pt++) {
- /* set point */
- alpha = ink[3] * pt->strength;
- CLAMP(alpha, GPENCIL_STRENGTH_MIN, 1.0f);
- /* Apply the
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list