diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-02-11 17:18:55 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-02-11 17:19:04 +0300 |
commit | 804e90b42d728ecb1073af8d0bae15a91b13a469 (patch) | |
tree | 309de25d99c92286b10c9d27e547fd43a69299c1 /source/blender/draw/intern/draw_manager_exec.c | |
parent | 58cdab8b9759dd59b55895f2f76b9624addbb324 (diff) |
DRW: Color Management improvement
Reviewed By: brecht sergey jbakker
Differential Revision: http://developer.blender.org/D6729
Diffstat (limited to 'source/blender/draw/intern/draw_manager_exec.c')
-rw-r--r-- | source/blender/draw/intern/draw_manager_exec.c | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c index 75d5a5c73b9..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_ALPHA_UNDER_PREMUL | 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); @@ -248,8 +248,12 @@ void drw_state_set(DRWState state) GL_ONE, GL_ONE_MINUS_SRC_ALPHA); /* Alpha */ } - else if ((state & DRW_STATE_BLEND_ALPHA_UNDER_PREMUL) != 0) { - glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_ONE); + else if ((state & DRW_STATE_BLEND_BACKGROUND) != 0) { + /* Special blend to add color under and multiply dst by alpha. */ + glBlendFuncSeparate(GL_ONE_MINUS_DST_ALPHA, + GL_SRC_ALPHA, /* RGB */ + GL_ZERO, + GL_SRC_ALPHA); /* Alpha */ } else if ((state & DRW_STATE_BLEND_ALPHA_PREMUL) != 0) { glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); @@ -279,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); } @@ -324,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; |