diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-08-25 14:03:49 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-08-27 00:54:47 +0300 |
commit | f8c857ad72e29eb509bd04067f94cd3df8a54aa4 (patch) | |
tree | 1f69b176ad222c582abbb70bb1df5ebc8dca76f5 /source/blender/draw/intern/draw_common.c | |
parent | 6ee5e6a333c229aa105206b07817ee9bf4a75c2e (diff) |
DRW: Remove unecessary GL calls
Diffstat (limited to 'source/blender/draw/intern/draw_common.c')
-rw-r--r-- | source/blender/draw/intern/draw_common.c | 48 |
1 files changed, 26 insertions, 22 deletions
diff --git a/source/blender/draw/intern/draw_common.c b/source/blender/draw/intern/draw_common.c index 30b1ebe07cd..f90028d4486 100644 --- a/source/blender/draw/intern/draw_common.c +++ b/source/blender/draw/intern/draw_common.c @@ -47,6 +47,30 @@ GlobalsUboStorage ts; struct GPUUniformBuffer *globals_ubo = NULL; struct GPUTexture *globals_ramp = NULL; +static struct GPUTexture *create_weight_ramp_texture(void) +{ + ColorBand ramp = {0}; + float *colors; + int col_size; + + ramp.tot = 3; + ramp.data[0].b = 1.0f; + ramp.data[1].g = 1.0f; + ramp.data[2].r = 1.0f; + ramp.data[0].a = ramp.data[1].a = ramp.data[2].a = 1.0f; + ramp.data[0].pos = 0.0f; + ramp.data[1].pos = 0.5f; + ramp.data[2].pos = 1.0f; + + BKE_colorband_evaluate_table_rgba(&ramp, &colors, &col_size); + + struct GPUTexture *tex = GPU_texture_create_1D(col_size, GPU_RGBA8, colors, NULL); + + MEM_freeN(colors); + + return tex; +} + void DRW_globals_update(void) { UI_GetThemeColor4fv(TH_WIRE, ts.colorWire); @@ -131,29 +155,9 @@ void DRW_globals_update(void) DRW_uniformbuffer_update(globals_ubo, &ts); - 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; - - BKE_colorband_evaluate_table_rgba(&ramp, &colors, &col_size); - - if (globals_ramp) { - GPU_texture_free(globals_ramp); + if (globals_ramp == NULL) { + globals_ramp = create_weight_ramp_texture(); } - globals_ramp = GPU_texture_create_1D(col_size, GPU_RGBA8, colors, NULL); - - MEM_freeN(colors); } /* ********************************* SHGROUP ************************************* */ |