Cleanup: DRW: Remove unused API functions
Pull Request: https://projects.blender.org/blender/blender/pulls/134461
This commit is contained in:
@@ -206,12 +206,6 @@ void DRW_viewport_data_free(DRWData *drw_data);
|
||||
bool DRW_gpu_context_release();
|
||||
void DRW_gpu_context_activate(bool drw_state);
|
||||
|
||||
/**
|
||||
* We may want to move this into a more general location.
|
||||
* \note This doesn't require the draw context to be in use.
|
||||
*/
|
||||
void DRW_draw_cursor_2d_ex(const ARegion *region, const float cursor[2]);
|
||||
|
||||
void DRW_cdlayer_attr_aliases_add(GPUVertFormat *format,
|
||||
const char *base_name,
|
||||
int data_type,
|
||||
|
||||
@@ -63,28 +63,6 @@ using blender::Span;
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Internal Types
|
||||
* \{ */
|
||||
|
||||
/* Batch's only (freed as an array). */
|
||||
static struct DRWShapeCache {
|
||||
blender::gpu::Batch *drw_cursor;
|
||||
blender::gpu::Batch *drw_cursor_only_circle;
|
||||
} SHC = {nullptr};
|
||||
|
||||
void DRW_shape_cache_free()
|
||||
{
|
||||
uint i = sizeof(SHC) / sizeof(blender::gpu::Batch *);
|
||||
blender::gpu::Batch **batch = (blender::gpu::Batch **)&SHC;
|
||||
while (i--) {
|
||||
GPU_BATCH_DISCARD_SAFE(*batch);
|
||||
batch++;
|
||||
}
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Common
|
||||
* \{ */
|
||||
@@ -520,101 +498,6 @@ blender::gpu::Batch *DRW_cache_particles_get_edit_tip_points(Object *object,
|
||||
return DRW_particles_batch_cache_get_edit_tip_points(object, psys, edit);
|
||||
}
|
||||
|
||||
blender::gpu::Batch *DRW_cache_cursor_get(bool crosshair_lines)
|
||||
{
|
||||
blender::gpu::Batch **drw_cursor = crosshair_lines ? &SHC.drw_cursor :
|
||||
&SHC.drw_cursor_only_circle;
|
||||
|
||||
if (*drw_cursor == nullptr) {
|
||||
const float f5 = 0.25f;
|
||||
const float f10 = 0.5f;
|
||||
const float f20 = 1.0f;
|
||||
|
||||
const int segments = 16;
|
||||
const int vert_len = segments + 8;
|
||||
const int index_len = vert_len + 5;
|
||||
|
||||
const float red[3] = {1.0f, 0.0f, 0.0f};
|
||||
const float white[3] = {1.0f, 1.0f, 1.0f};
|
||||
|
||||
static GPUVertFormat format = {0};
|
||||
static struct {
|
||||
uint pos, color;
|
||||
} attr_id;
|
||||
if (format.attr_len == 0) {
|
||||
attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
||||
attr_id.color = GPU_vertformat_attr_add(&format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
|
||||
}
|
||||
|
||||
GPUIndexBufBuilder elb;
|
||||
GPU_indexbuf_init_ex(&elb, GPU_PRIM_LINE_STRIP, index_len, vert_len);
|
||||
|
||||
blender::gpu::VertBuf *vbo = GPU_vertbuf_create_with_format(format);
|
||||
GPU_vertbuf_data_alloc(*vbo, vert_len);
|
||||
|
||||
int v = 0;
|
||||
for (int i = 0; i < segments; i++) {
|
||||
float angle = float(2 * M_PI) * (float(i) / float(segments));
|
||||
float x = f10 * cosf(angle);
|
||||
float y = f10 * sinf(angle);
|
||||
|
||||
GPU_vertbuf_attr_set(vbo, attr_id.color, v, (i % 2 == 0) ? red : white);
|
||||
|
||||
GPU_vertbuf_attr_set(vbo, attr_id.pos, v, blender::float2{x, y});
|
||||
GPU_indexbuf_add_generic_vert(&elb, v++);
|
||||
}
|
||||
GPU_indexbuf_add_generic_vert(&elb, 0);
|
||||
|
||||
if (crosshair_lines) {
|
||||
float crosshair_color[3];
|
||||
UI_GetThemeColor3fv(TH_VIEW_OVERLAY, crosshair_color);
|
||||
|
||||
/* TODO(fclem): Remove primitive restart. Incompatible with wide lines. */
|
||||
GPU_indexbuf_add_primitive_restart(&elb);
|
||||
|
||||
GPU_vertbuf_attr_set(vbo, attr_id.pos, v, blender::float2{-f20, 0});
|
||||
GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
|
||||
GPU_indexbuf_add_generic_vert(&elb, v++);
|
||||
GPU_vertbuf_attr_set(vbo, attr_id.pos, v, blender::float2{-f5, 0});
|
||||
GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
|
||||
GPU_indexbuf_add_generic_vert(&elb, v++);
|
||||
|
||||
GPU_indexbuf_add_primitive_restart(&elb);
|
||||
|
||||
GPU_vertbuf_attr_set(vbo, attr_id.pos, v, blender::float2{+f5, 0});
|
||||
GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
|
||||
GPU_indexbuf_add_generic_vert(&elb, v++);
|
||||
GPU_vertbuf_attr_set(vbo, attr_id.pos, v, blender::float2{+f20, 0});
|
||||
GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
|
||||
GPU_indexbuf_add_generic_vert(&elb, v++);
|
||||
|
||||
GPU_indexbuf_add_primitive_restart(&elb);
|
||||
|
||||
GPU_vertbuf_attr_set(vbo, attr_id.pos, v, blender::float2{0, -f20});
|
||||
GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
|
||||
GPU_indexbuf_add_generic_vert(&elb, v++);
|
||||
GPU_vertbuf_attr_set(vbo, attr_id.pos, v, blender::float2{0, -f5});
|
||||
GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
|
||||
GPU_indexbuf_add_generic_vert(&elb, v++);
|
||||
|
||||
GPU_indexbuf_add_primitive_restart(&elb);
|
||||
|
||||
GPU_vertbuf_attr_set(vbo, attr_id.pos, v, blender::float2{0, +f5});
|
||||
GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
|
||||
GPU_indexbuf_add_generic_vert(&elb, v++);
|
||||
GPU_vertbuf_attr_set(vbo, attr_id.pos, v, blender::float2{0, +f20});
|
||||
GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
|
||||
GPU_indexbuf_add_generic_vert(&elb, v++);
|
||||
}
|
||||
|
||||
blender::gpu::IndexBuf *ibo = GPU_indexbuf_build(&elb);
|
||||
|
||||
*drw_cursor = GPU_batch_create_ex(
|
||||
GPU_PRIM_LINE_STRIP, vbo, ibo, GPU_BATCH_OWNS_VBO | GPU_BATCH_OWNS_INDEX);
|
||||
}
|
||||
return *drw_cursor;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
@@ -37,10 +37,6 @@ enum eDRWLevelOfDetail {
|
||||
DRW_LOD_MAX, /* Max number of level of detail */
|
||||
};
|
||||
|
||||
void DRW_shape_cache_free();
|
||||
|
||||
/* 3D cursor */
|
||||
blender::gpu::Batch *DRW_cache_cursor_get(bool crosshair_lines);
|
||||
/* Common Object */
|
||||
|
||||
blender::gpu::Batch *DRW_cache_object_all_edges_get(Object *ob);
|
||||
|
||||
@@ -2895,7 +2895,6 @@ void DRW_engines_free()
|
||||
DRW_pointcloud_free();
|
||||
DRW_curves_free();
|
||||
DRW_volume_free();
|
||||
DRW_shape_cache_free();
|
||||
DRW_globals_free();
|
||||
|
||||
drw_debug_module_free(DST.debug);
|
||||
|
||||
@@ -54,89 +54,6 @@ void DRW_draw_region_info()
|
||||
GPU_debug_group_end();
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name 2D Cursor
|
||||
* \{ */
|
||||
|
||||
static bool is_cursor_visible_2d(const DRWContextState *draw_ctx)
|
||||
{
|
||||
SpaceInfo *space_data = (SpaceInfo *)draw_ctx->space_data;
|
||||
if (space_data == nullptr) {
|
||||
return false;
|
||||
}
|
||||
if (space_data->spacetype != SPACE_IMAGE) {
|
||||
return false;
|
||||
}
|
||||
SpaceImage *sima = (SpaceImage *)space_data;
|
||||
switch (sima->mode) {
|
||||
case SI_MODE_VIEW:
|
||||
return false;
|
||||
break;
|
||||
case SI_MODE_PAINT:
|
||||
return false;
|
||||
break;
|
||||
case SI_MODE_MASK:
|
||||
break;
|
||||
case SI_MODE_UV:
|
||||
break;
|
||||
}
|
||||
return (sima->overlay.flag & SI_OVERLAY_SHOW_OVERLAYS) != 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Generic Cursor
|
||||
* \{ */
|
||||
|
||||
void DRW_draw_cursor_2d_ex(const ARegion *region, const float cursor[2])
|
||||
{
|
||||
int co[2];
|
||||
UI_view2d_view_to_region(®ion->v2d, cursor[0], cursor[1], &co[0], &co[1]);
|
||||
|
||||
/* Draw nice Anti Aliased cursor. */
|
||||
GPU_line_width(1.0f);
|
||||
GPU_blend(GPU_BLEND_ALPHA);
|
||||
GPU_line_smooth(true);
|
||||
|
||||
/* Draw lines */
|
||||
float original_proj[4][4];
|
||||
GPU_matrix_projection_get(original_proj);
|
||||
GPU_matrix_push();
|
||||
ED_region_pixelspace(region);
|
||||
GPU_matrix_translate_2f(co[0] + 0.5f, co[1] + 0.5f);
|
||||
GPU_matrix_scale_2f(U.widget_unit, U.widget_unit);
|
||||
|
||||
blender::gpu::Batch *cursor_batch = DRW_cache_cursor_get(true);
|
||||
|
||||
GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_FLAT_COLOR);
|
||||
GPU_batch_set_shader(cursor_batch, shader);
|
||||
|
||||
GPU_batch_draw(cursor_batch);
|
||||
|
||||
GPU_blend(GPU_BLEND_NONE);
|
||||
GPU_line_smooth(false);
|
||||
GPU_matrix_pop();
|
||||
GPU_matrix_projection_set(original_proj);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
void DRW_draw_cursor_2d()
|
||||
{
|
||||
const DRWContextState *draw_ctx = DRW_context_state_get();
|
||||
ARegion *region = draw_ctx->region;
|
||||
|
||||
GPU_color_mask(true, true, true, true);
|
||||
GPU_depth_mask(false);
|
||||
GPU_depth_test(GPU_DEPTH_NONE);
|
||||
|
||||
if (is_cursor_visible_2d(draw_ctx)) {
|
||||
const SpaceImage *sima = (SpaceImage *)draw_ctx->space_data;
|
||||
DRW_draw_cursor_2d_ex(region, sima->cursor);
|
||||
}
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* **************************** 3D Gizmo ******************************** */
|
||||
|
||||
void DRW_draw_gizmo_3d()
|
||||
|
||||
@@ -9,7 +9,5 @@
|
||||
#pragma once
|
||||
|
||||
void DRW_draw_region_info();
|
||||
void DRW_draw_cursor();
|
||||
void DRW_draw_cursor_2d();
|
||||
void DRW_draw_gizmo_3d();
|
||||
void DRW_draw_gizmo_2d();
|
||||
|
||||
@@ -125,8 +125,6 @@ static void test_draw_pass_all_commands()
|
||||
expected << " .barrier(2)" << std::endl;
|
||||
|
||||
EXPECT_EQ(result, expected.str());
|
||||
|
||||
DRW_shape_cache_free();
|
||||
}
|
||||
DRAW_TEST(draw_pass_all_commands)
|
||||
|
||||
@@ -205,8 +203,6 @@ static void test_draw_pass_simple_draw()
|
||||
expected << " .draw(inst_len=3, vert_len=80, vert_first=8, res_id=8)" << std::endl;
|
||||
|
||||
EXPECT_EQ(result, expected.str());
|
||||
|
||||
DRW_shape_cache_free();
|
||||
}
|
||||
DRAW_TEST(draw_pass_simple_draw)
|
||||
|
||||
@@ -248,8 +244,6 @@ static void test_draw_pass_multi_draw()
|
||||
expected << " .proto(instance_len=1, resource_id=1, front_face)" << std::endl;
|
||||
|
||||
EXPECT_EQ(result, expected.str());
|
||||
|
||||
DRW_shape_cache_free();
|
||||
}
|
||||
DRAW_TEST(draw_pass_multi_draw)
|
||||
|
||||
@@ -274,8 +268,6 @@ static void test_draw_pass_sortable()
|
||||
expected << " .Sub5" << std::endl;
|
||||
|
||||
EXPECT_EQ(result, expected.str());
|
||||
|
||||
DRW_shape_cache_free();
|
||||
}
|
||||
DRAW_TEST(draw_pass_sortable)
|
||||
|
||||
@@ -360,8 +352,6 @@ static void test_draw_resource_id_gen()
|
||||
}
|
||||
|
||||
GPU_render_end();
|
||||
|
||||
DRW_shape_cache_free();
|
||||
DRW_shaders_free();
|
||||
}
|
||||
DRAW_TEST(draw_resource_id_gen)
|
||||
@@ -414,8 +404,6 @@ static void test_draw_visibility()
|
||||
EXPECT_EQ(result.str(), "11111111111111111111111111111011");
|
||||
|
||||
GPU_render_end();
|
||||
|
||||
DRW_shape_cache_free();
|
||||
DRW_shaders_free();
|
||||
}
|
||||
DRAW_TEST(draw_visibility)
|
||||
|
||||
Reference in New Issue
Block a user