[Bf-blender-cvs] [02c77e4e5c9] master: Fix animation player checkerboard drawing with alpha channels

Campbell Barton noreply at git.blender.org
Thu Apr 30 09:45:52 CEST 2020


Commit: 02c77e4e5c953202aaac0fb5ab673b6da293a257
Author: Campbell Barton
Date:   Thu Apr 30 17:45:02 2020 +1000
Branches: master
https://developer.blender.org/rB02c77e4e5c953202aaac0fb5ab673b6da293a257

Fix animation player checkerboard drawing with alpha channels

Was using uninitialized theme values.

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

M	source/blender/gpu/GPU_immediate_util.h
M	source/blender/gpu/intern/gpu_immediate_util.c
M	source/blender/windowmanager/intern/wm_playanim.c

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

diff --git a/source/blender/gpu/GPU_immediate_util.h b/source/blender/gpu/GPU_immediate_util.h
index 1cf6475408f..47b44b59461 100644
--- a/source/blender/gpu/GPU_immediate_util.h
+++ b/source/blender/gpu/GPU_immediate_util.h
@@ -70,6 +70,13 @@ void imm_draw_disk_partial_fill_2d(uint pos,
 void imm_draw_box_wire_2d(uint pos, float x1, float y1, float x2, float y2);
 void imm_draw_box_wire_3d(uint pos, float x1, float y1, float x2, float y2);
 
+void imm_draw_box_checker_2d_ex(float x1,
+                                float y1,
+                                float x2,
+                                float y2,
+                                const float color_primary[4],
+                                const float color_secondary[4],
+                                int checker_size);
 void imm_draw_box_checker_2d(float x1, float y1, float x2, float y2);
 
 void imm_draw_cube_fill_3d(uint pos, const float co[3], const float aspect[3]);
diff --git a/source/blender/gpu/intern/gpu_immediate_util.c b/source/blender/gpu/intern/gpu_immediate_util.c
index 7266f595447..77b6f237f03 100644
--- a/source/blender/gpu/intern/gpu_immediate_util.c
+++ b/source/blender/gpu/intern/gpu_immediate_util.c
@@ -361,25 +361,35 @@ void imm_draw_box_wire_3d(uint pos, float x1, float y1, float x2, float y2)
 /**
  * Draw a standard checkerboard to indicate transparent backgrounds.
  */
-void imm_draw_box_checker_2d(float x1, float y1, float x2, float y2)
+void imm_draw_box_checker_2d_ex(float x1,
+                                float y1,
+                                float x2,
+                                float y2,
+                                const float color_primary[4],
+                                const float color_secondary[4],
+                                const int checker_size)
 {
   uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
-  float checker_primary[4];
-  float checker_secondary[4];
-  int checker_size = UI_GetThemeValue(TH_TRANSPARENT_CHECKER_SIZE);
 
   immBindBuiltinProgram(GPU_SHADER_2D_CHECKER);
-  UI_GetThemeColor4fv(TH_TRANSPARENT_CHECKER_PRIMARY, checker_primary);
-  UI_GetThemeColor4fv(TH_TRANSPARENT_CHECKER_SECONDARY, checker_secondary);
 
-  immUniform4fv("color1", checker_primary);
-  immUniform4fv("color2", checker_secondary);
+  immUniform4fv("color1", color_primary);
+  immUniform4fv("color2", color_secondary);
   immUniform1i("size", checker_size);
 
   immRectf(pos, x1, y1, x2, y2);
 
   immUnbindProgram();
 }
+void imm_draw_box_checker_2d(float x1, float y1, float x2, float y2)
+{
+  float checker_primary[4];
+  float checker_secondary[4];
+  UI_GetThemeColor4fv(TH_TRANSPARENT_CHECKER_PRIMARY, checker_primary);
+  UI_GetThemeColor4fv(TH_TRANSPARENT_CHECKER_SECONDARY, checker_secondary);
+  int checker_size = UI_GetThemeValue(TH_TRANSPARENT_CHECKER_SIZE);
+  imm_draw_box_checker_2d_ex(x1, y1, x2, y2, checker_primary, checker_secondary, checker_size);
+}
 
 void imm_draw_cube_fill_3d(uint pos, const float co[3], const float aspect[3])
 {
diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c
index 84f099b0dbc..948e8d9fb74 100644
--- a/source/blender/windowmanager/intern/wm_playanim.c
+++ b/source/blender/windowmanager/intern/wm_playanim.c
@@ -317,7 +317,13 @@ static void playanim_toscreen(
     GPU_blend(true);
     glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
 
-    imm_draw_box_checker_2d(offs_x, offs_y, offs_x + span_x, offs_y + span_y);
+    imm_draw_box_checker_2d_ex(offs_x,
+                               offs_y,
+                               offs_x + span_x,
+                               offs_y + span_y,
+                               (const float[4]){0.15, 0.15, 0.15, 1.0},
+                               (const float[4]){0.20, 0.20, 0.20, 1.0},
+                               8);
   }
 
   IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);



More information about the Bf-blender-cvs mailing list