From c541f3abef105e7a1f3a35c0a070464472d443d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Tue, 11 Dec 2018 21:25:17 +0100 Subject: DRW: Fix redundant texture creation --- source/blender/draw/intern/draw_common.c | 37 ++++++++++++++++---------------- 1 file changed, 18 insertions(+), 19 deletions(-) (limited to 'source/blender/draw') diff --git a/source/blender/draw/intern/draw_common.c b/source/blender/draw/intern/draw_common.c index e3fde3d8a5d..35f060bd3ba 100644 --- a/source/blender/draw/intern/draw_common.c +++ b/source/blender/draw/intern/draw_common.c @@ -163,29 +163,28 @@ void DRW_globals_update(void) DRW_uniformbuffer_update(globals_ubo, &ts); - ColorBand ramp = {0}; - float *colors; - int col_size; + if (!globals_ramp) { + ColorBand ramp = {0}; + float *colors; + int col_size; - ramp.tot = 3; - ramp.data[0].a = 1.0f; - ramp.data[0].b = 1.0f; - ramp.data[0].pos = 0.0f; - ramp.data[1].a = 1.0f; - ramp.data[1].g = 1.0f; - ramp.data[1].pos = 0.5f; - ramp.data[2].a = 1.0f; - ramp.data[2].r = 1.0f; - ramp.data[2].pos = 1.0f; + ramp.tot = 3; + ramp.data[0].a = 1.0f; + ramp.data[0].b = 1.0f; + ramp.data[0].pos = 0.0f; + ramp.data[1].a = 1.0f; + ramp.data[1].g = 1.0f; + ramp.data[1].pos = 0.5f; + ramp.data[2].a = 1.0f; + ramp.data[2].r = 1.0f; + ramp.data[2].pos = 1.0f; - BKE_colorband_evaluate_table_rgba(&ramp, &colors, &col_size); + BKE_colorband_evaluate_table_rgba(&ramp, &colors, &col_size); - if (globals_ramp) { - GPU_texture_free(globals_ramp); - } - globals_ramp = GPU_texture_create_1D(col_size, GPU_RGBA8, colors, NULL); + globals_ramp = GPU_texture_create_1D(col_size, GPU_RGBA8, colors, NULL); - MEM_freeN(colors); + MEM_freeN(colors); + } /* Weight Painting color ramp texture */ bool user_weight_ramp = (U.flag & USER_CUSTOM_RANGE) != 0; -- cgit v1.2.3