[Bf-blender-cvs] [436d38bb548] master: Cleanup: GPU: Move XOR logic op to gpu_state.c

Clément Foucault noreply at git.blender.org
Thu Jul 16 17:17:58 CEST 2020


Commit: 436d38bb548d904200337d58720552b6f78555cb
Author: Clément Foucault
Date:   Thu Jul 16 03:31:25 2020 +0200
Branches: master
https://developer.blender.org/rB436d38bb548d904200337d58720552b6f78555cb

Cleanup: GPU: Move XOR logic op to gpu_state.c

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

M	source/blender/editors/space_clip/clip_draw.c
M	source/blender/editors/util/ed_util_imbuf.c
M	source/blender/gpu/GPU_state.h
M	source/blender/gpu/intern/gpu_state.c

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

diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c
index 68ebd6fed7a..227aa30b277 100644
--- a/source/blender/editors/space_clip/clip_draw.c
+++ b/source/blender/editors/space_clip/clip_draw.c
@@ -373,8 +373,7 @@ static void draw_stabilization_border(
 
     /* Exclusive OR allows to get orig value when second operand is 0,
      * and negative of orig value when second operand is 1. */
-    glEnable(GL_COLOR_LOGIC_OP);
-    glLogicOp(GL_XOR);
+    GPU_logic_op_xor_set(true);
 
     GPU_matrix_push();
     GPU_matrix_translate_2f(x, y);
@@ -399,7 +398,7 @@ static void draw_stabilization_border(
 
     GPU_matrix_pop();
 
-    glDisable(GL_COLOR_LOGIC_OP);
+    GPU_logic_op_xor_set(false);
   }
 }
 
@@ -790,15 +789,14 @@ static void draw_marker_areas(SpaceClip *sc,
       immUniform1f("dash_width", 6.0f);
       immUniform1f("dash_factor", 0.5f);
 
-      glEnable(GL_COLOR_LOGIC_OP);
-      glLogicOp(GL_XOR);
+      GPU_logic_op_xor_set(true);
 
       immBegin(GPU_PRIM_LINES, 2);
       immVertex2fv(shdr_pos, pos);
       immVertex2fv(shdr_pos, marker_pos);
       immEnd();
 
-      glDisable(GL_COLOR_LOGIC_OP);
+      GPU_logic_op_xor_set(false);
     }
   }
 
diff --git a/source/blender/editors/util/ed_util_imbuf.c b/source/blender/editors/util/ed_util_imbuf.c
index 132a63a8249..3e85342e0d7 100644
--- a/source/blender/editors/util/ed_util_imbuf.c
+++ b/source/blender/editors/util/ed_util_imbuf.c
@@ -447,15 +447,16 @@ void ED_imbuf_sample_draw(const bContext *C, ARegion *region, void *arg_info)
           (float[2]){event->x - region->winrct.xmin, event->y - region->winrct.ymin},
           (float)(info->sample_size / 2.0f) * sima->zoom);
 
-      glEnable(GL_COLOR_LOGIC_OP);
-      glLogicOp(GL_XOR);
+      GPU_logic_op_xor_set(true);
+
       GPU_line_width(1.0f);
       imm_draw_box_wire_2d(pos,
                            (float)sample_rect_fl.xmin,
                            (float)sample_rect_fl.ymin,
                            (float)sample_rect_fl.xmax,
                            (float)sample_rect_fl.ymax);
-      glDisable(GL_COLOR_LOGIC_OP);
+
+      GPU_logic_op_xor_set(false);
 
       immUnbindProgram();
     }
diff --git a/source/blender/gpu/GPU_state.h b/source/blender/gpu/GPU_state.h
index 4daf3f8dba5..6c0c4897fef 100644
--- a/source/blender/gpu/GPU_state.h
+++ b/source/blender/gpu/GPU_state.h
@@ -69,7 +69,7 @@ void GPU_viewport_size_get_i(int coords[4]);
 void GPU_flush(void);
 void GPU_finish(void);
 
-void GPU_logic_op_invert_set(bool enable);
+void GPU_logic_op_xor_set(bool enable);
 
 /* Attribute push & pop. */
 typedef enum eGPUAttrMask {
diff --git a/source/blender/gpu/intern/gpu_state.c b/source/blender/gpu/intern/gpu_state.c
index 8a9fbac08a3..65acd5a7771 100644
--- a/source/blender/gpu/intern/gpu_state.c
+++ b/source/blender/gpu/intern/gpu_state.c
@@ -181,14 +181,13 @@ void GPU_finish(void)
   glFinish();
 }
 
-void GPU_logic_op_invert_set(bool enable)
+void GPU_logic_op_xor_set(bool enable)
 {
   if (enable) {
-    glLogicOp(GL_INVERT);
+    glLogicOp(GL_XOR);
     glEnable(GL_COLOR_LOGIC_OP);
   }
   else {
-    glLogicOp(GL_COPY);
     glDisable(GL_COLOR_LOGIC_OP);
   }
 }



More information about the Bf-blender-cvs mailing list