Commit: 1a337074175e51c705de0afd230264ff73e04b4b
Author: Clément Foucault
Date:   Sat Apr 7 14:03:32 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB1a337074175e51c705de0afd230264ff73e04b4b

UI: Fix waveform widget text drawing.

Flush the text cache so that we have proper scissor test and ordering.

===================================================================

M       source/blender/blenfont/BLF_api.h
M       source/blender/blenfont/intern/blf.c
M       source/blender/editors/interface/interface_draw.c

===================================================================

diff --git a/source/blender/blenfont/BLF_api.h 
b/source/blender/blenfont/BLF_api.h
index 3466f1665c6..668588435b4 100644
--- a/source/blender/blenfont/BLF_api.h
+++ b/source/blender/blenfont/BLF_api.h
@@ -98,6 +98,7 @@ void BLF_matrix(int fontid, const float m[16]);
 /* Batch drawcalls together as long as
  * the modelview matrix and the font remain unchanged. */
 void BLF_batch_draw_begin(void);
+void BLF_batch_draw_flush(void);
 void BLF_batch_draw_end(void);
 
 /* Draw the string using the default font, size and dpi. */
diff --git a/source/blender/blenfont/intern/blf.c 
b/source/blender/blenfont/intern/blf.c
index b94c6e35823..fafee125264 100644
--- a/source/blender/blenfont/intern/blf.c
+++ b/source/blender/blenfont/intern/blf.c
@@ -548,6 +548,13 @@ void BLF_batch_draw_begin(void)
        g_batch.enabled = true;
 }
 
+void BLF_batch_draw_flush(void)
+{
+       if (g_batch.enabled) {
+               blf_batch_draw();
+       }
+}
+
 void BLF_batch_draw_end(void)
 {
        BLI_assert(g_batch.enabled == true);
diff --git a/source/blender/editors/interface/interface_draw.c 
b/source/blender/editors/interface/interface_draw.c
index 786c3637e3d..f84347b97a4 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -910,6 +910,9 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, 
uiWidgetColors *UNUSED(wcol),
                }
        }
 
+       /* Flush text cache before changing scissors. */
+       BLF_batch_draw_flush();
+
        glEnable(GL_BLEND);
        glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, 
GL_ONE_MINUS_SRC_ALPHA);
 
@@ -934,6 +937,9 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, 
uiWidgetColors *UNUSED(wcol),
                BLF_draw_default(rect.xmin + 1, yofs - 5 + (i * 0.2f) * h, 0, 
str, sizeof(str) - 1);
        }
 
+       /* Flush text cache before drawing things on top. */
+       BLF_batch_draw_flush();
+
        glEnable(GL_BLEND);
        glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, 
GL_ONE_MINUS_SRC_ALPHA);

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to