diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-12-11 23:25:17 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-12-11 23:25:17 +0300 |
commit | c541f3abef105e7a1f3a35c0a070464472d443d7 (patch) | |
tree | 28e1582ec39bd25a0765c64ef8195f0d0a1a22db /source/blender | |
parent | bf2e0c759843e50c85eefd0654e7c4c5efe612d9 (diff) |
DRW: Fix redundant texture creation
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/draw/intern/draw_common.c | 37 |
1 files changed, 18 insertions, 19 deletions
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; |