[Bf-blender-cvs] [c0675868a3f] draw-colormanagement: Overlay: Fix edit text overlay invert logic op not working

Clément Foucault noreply at git.blender.org
Fri Jan 31 23:58:54 CET 2020


Commit: c0675868a3fac2e9c38d3d2bb9f22c5e8b0679b9
Author: Clément Foucault
Date:   Fri Jan 31 23:58:37 2020 +0100
Branches: draw-colormanagement
https://developer.blender.org/rBc0675868a3fac2e9c38d3d2bb9f22c5e8b0679b9

Overlay: Fix edit text overlay invert logic op not working

The result is still different as the inversion is done in scene refered
linear and not in sRGB space as it used to be.

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

M	source/blender/draw/engines/overlay/overlay_edit_text.c
M	source/blender/draw/intern/draw_manager_exec.c

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

diff --git a/source/blender/draw/engines/overlay/overlay_edit_text.c b/source/blender/draw/engines/overlay/overlay_edit_text.c
index 72b5ae74255..3de0155d6e0 100644
--- a/source/blender/draw/engines/overlay/overlay_edit_text.c
+++ b/source/blender/draw/engines/overlay/overlay_edit_text.c
@@ -56,7 +56,9 @@ void OVERLAY_edit_text_cache_init(OVERLAY_Data *vedata)
     DRW_PASS_CREATE(psl->edit_text_overlay_ps, state | pd->clipping_state);
 
     sh = OVERLAY_shader_uniform_color();
-    pd->edit_text_overlay_grp = DRW_shgroup_create(sh, psl->edit_text_overlay_ps);
+    pd->edit_text_overlay_grp = grp = DRW_shgroup_create(sh, psl->edit_text_overlay_ps);
+
+    DRW_shgroup_uniform_vec4_copy(grp, "color", (float[4]){1.0f, 1.0f, 1.0f, 1.0f});
   }
 }
 
diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c
index 68c5b8994d0..23a3e0b05d4 100644
--- a/source/blender/draw/intern/draw_manager_exec.c
+++ b/source/blender/draw/intern/draw_manager_exec.c
@@ -234,11 +234,11 @@ void drw_state_set(DRWState state)
   /* Blending (all buffer) */
   {
     int test;
-    if (CHANGED_ANY_STORE_VAR(DRW_STATE_BLEND_ALPHA | DRW_STATE_BLEND_ALPHA_PREMUL |
-                                  DRW_STATE_BLEND_ADD | DRW_STATE_BLEND_MUL |
-                                  DRW_STATE_BLEND_ADD_FULL | DRW_STATE_BLEND_OIT |
-                                  DRW_STATE_BLEND_BACKGROUND | DRW_STATE_BLEND_CUSTOM,
-                              test)) {
+    if (CHANGED_ANY_STORE_VAR(
+            DRW_STATE_BLEND_ALPHA | DRW_STATE_BLEND_ALPHA_PREMUL | DRW_STATE_BLEND_ADD |
+                DRW_STATE_BLEND_MUL | DRW_STATE_BLEND_ADD_FULL | DRW_STATE_BLEND_OIT |
+                DRW_STATE_BLEND_BACKGROUND | DRW_STATE_BLEND_CUSTOM | DRW_STATE_LOGIC_INVERT,
+            test)) {
       if (test) {
         glEnable(GL_BLEND);
 
@@ -283,6 +283,13 @@ void drw_state_set(DRWState state)
            * Can only be used with one Draw Buffer. */
           glBlendFunc(GL_ONE, GL_SRC1_COLOR);
         }
+        else if ((state & DRW_STATE_LOGIC_INVERT) != 0) {
+          /* Replace logic op by blend func to support floating point framebuffer. */
+          glBlendFuncSeparate(GL_ONE_MINUS_DST_COLOR,
+                              GL_ZERO, /* RGB */
+                              GL_ZERO,
+                              GL_ONE); /* Alpha */
+        }
         else {
           BLI_assert(0);
         }
@@ -328,21 +335,6 @@ void drw_state_set(DRWState state)
     }
   }
 
-  /* Logic Ops */
-  {
-    int test;
-    if ((test = CHANGED_TO(DRW_STATE_LOGIC_INVERT))) {
-      if (test == 1) {
-        glLogicOp(GL_INVERT);
-        glEnable(GL_COLOR_LOGIC_OP);
-      }
-      else {
-        glLogicOp(GL_COPY);
-        glDisable(GL_COLOR_LOGIC_OP);
-      }
-    }
-  }
-
   /* Clip Planes */
   {
     int test;



More information about the Bf-blender-cvs mailing list