[Bf-blender-cvs] [4b4702ab8af] master: Sequencer: add many more color blend modes, and a new color mix strip.

Maikon Araujo noreply at git.blender.org
Wed Nov 29 18:13:39 CET 2017


Commit: 4b4702ab8af6f74edc20ba6735d74f61aa15ce47
Author: Maikon Araujo
Date:   Mon Nov 27 23:33:08 2017 +0100
Branches: master
https://developer.blender.org/rB4b4702ab8af6f74edc20ba6735d74f61aa15ce47

Sequencer: add many more color blend modes, and a new color mix strip.

Differential Revision: https://developer.blender.org/D2872

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

M	release/scripts/startup/bl_ui/space_sequencer.py
M	source/blender/blenkernel/intern/seqeffects.c
M	source/blender/blenkernel/intern/sequencer.c
M	source/blender/blenloader/intern/writefile.c
M	source/blender/editors/space_sequencer/sequencer_draw.c
M	source/blender/editors/space_sequencer/sequencer_edit.c
M	source/blender/makesdna/DNA_sequence_types.h
M	source/blender/makesrna/RNA_access.h
M	source/blender/makesrna/intern/rna_sequencer.c
M	source/blender/makesrna/intern/rna_sequencer_api.c

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

diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py
index 106e6695553..94924106542 100644
--- a/release/scripts/startup/bl_ui/space_sequencer.py
+++ b/release/scripts/startup/bl_ui/space_sequencer.py
@@ -361,6 +361,7 @@ class SEQUENCER_MT_add_effect(Menu):
         layout.operator("sequencer.effect_strip_add", text="Wipe").type = 'WIPE'
         layout.operator("sequencer.effect_strip_add", text="Glow").type = 'GLOW'
         layout.operator("sequencer.effect_strip_add", text="Text").type = 'TEXT'
+        layout.operator("sequencer.effect_strip_add", text="Color Mix").type = 'COLORMIX'
         layout.operator("sequencer.effect_strip_add", text="Transform").type = 'TRANSFORM'
         layout.operator("sequencer.effect_strip_add", text="Color").type = 'COLOR'
         layout.operator("sequencer.effect_strip_add", text="Speed Control").type = 'SPEED'
@@ -602,7 +603,7 @@ class SEQUENCER_PT_effect(SequencerButtonsPanel, Panel):
             'ADD', 'SUBTRACT', 'ALPHA_OVER', 'ALPHA_UNDER',
             'CROSS', 'GAMMA_CROSS', 'MULTIPLY', 'OVER_DROP',
             'WIPE', 'GLOW', 'TRANSFORM', 'COLOR', 'SPEED',
-            'MULTICAM', 'GAUSSIAN_BLUR', 'TEXT',
+            'MULTICAM', 'GAUSSIAN_BLUR', 'TEXT', 'COLORMIX'
         }
 
     def draw(self, context):
@@ -750,6 +751,12 @@ class SEQUENCER_PT_effect(SequencerButtonsPanel, Panel):
             row = col.row(align=True)
             row.prop(strip, "size_x")
             row.prop(strip, "size_y")
+        elif strip.type == 'COLORMIX':
+            split = layout.split(percentage=0.35)
+            split.label(text="Blend Mode:")
+            split.prop(strip, "blend_effect", text="")
+            row = layout.row(align=True)
+            row.prop(strip, "factor", slider=True)
 
 
 class SEQUENCER_PT_input(SequencerButtonsPanel, Panel):
@@ -770,7 +777,7 @@ class SEQUENCER_PT_input(SequencerButtonsPanel, Panel):
             'ADD', 'SUBTRACT', 'ALPHA_OVER', 'ALPHA_UNDER',
             'CROSS', 'GAMMA_CROSS', 'MULTIPLY', 'OVER_DROP',
             'WIPE', 'GLOW', 'TRANSFORM', 'COLOR',
-            'MULTICAM', 'SPEED', 'ADJUSTMENT',
+            'MULTICAM', 'SPEED', 'ADJUSTMENT', 'COLORMIX'
         }
 
     def draw(self, context):
@@ -1009,7 +1016,7 @@ class SEQUENCER_PT_filter(SequencerButtonsPanel, Panel):
             'META', 'ADD', 'SUBTRACT', 'ALPHA_OVER',
             'ALPHA_UNDER', 'CROSS', 'GAMMA_CROSS', 'MULTIPLY',
             'OVER_DROP', 'WIPE', 'GLOW', 'TRANSFORM', 'COLOR',
-            'MULTICAM', 'SPEED', 'ADJUSTMENT',
+            'MULTICAM', 'SPEED', 'ADJUSTMENT', 'COLORMIX'
         }
 
     def draw(self, context):
diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c
index a2c45057bf7..df21512a262 100644
--- a/source/blender/blenkernel/intern/seqeffects.c
+++ b/source/blender/blenkernel/intern/seqeffects.c
@@ -53,6 +53,8 @@
 #include "IMB_imbuf.h"
 #include "IMB_colormanagement.h"
 
+#include "BLI_math_color_blend.h"
+
 #include "RNA_access.h"
 
 #include "RE_pipeline.h"
@@ -1266,6 +1268,274 @@ static void do_mul_effect(const SeqRenderData *context, Sequence *UNUSED(seq), f
 	}
 }
 
+/*********************** Blend Mode ***************************************/
+typedef void (*IMB_blend_func_byte)(unsigned char *dst, const unsigned char *src1, const unsigned char *src2);
+typedef void (*IMB_blend_func_float)(float *dst, const float *src1, const float *src2);
+
+BLI_INLINE void apply_blend_function_byte(float facf0, float facf1, int x, int y, unsigned char *rect1, unsigned char *rect2, unsigned char *out, IMB_blend_func_byte blend_function)
+{
+	int xo;
+	unsigned char *rt1, *rt2, *rt;
+	unsigned int achannel;
+	xo = x;
+	rt1 = rect1;
+	rt2 = rect2;
+	rt = out;
+	while (y--) {		
+		for (x = xo; x > 0; x--) {
+			achannel = rt2[3];
+			rt2[3] = (unsigned int) achannel * facf0;
+			blend_function(rt, rt1, rt2);
+			rt2[3] = achannel;
+			rt[3] = rt2[3];
+			rt1 += 4;
+			rt2 += 4;
+			rt += 4;
+		}
+		if (y == 0) {
+			break;
+		}
+		y--;		
+		for (x = xo; x > 0; x--) {
+			achannel = rt2[3];
+			rt2[3] = (unsigned int) achannel * facf1;
+			blend_function(rt, rt1, rt2);
+			rt2[3] = achannel;
+			rt[3] = rt2[3];
+			rt1 += 4;
+			rt2 += 4;
+			rt += 4;
+		}
+	}
+}
+
+BLI_INLINE void apply_blend_function_float(float facf0, float facf1, int x, int y, float *rect1, float *rect2, float *out, IMB_blend_func_float blend_function)
+{
+	int xo;
+	float *rt1, *rt2, *rt;
+	float achannel;
+	xo = x;
+	rt1 = rect1;
+	rt2 = rect2;
+	rt = out;
+	while (y--) {		
+		for (x = xo; x > 0; x--) {
+			achannel = rt2[3];
+			rt2[3] = achannel * facf0;
+			blend_function(rt, rt1, rt2);
+			rt2[3] = achannel;
+			rt[3] = rt2[3];
+			rt1 += 4;
+			rt2 += 4;
+			rt += 4;
+		}
+		if (y == 0) {
+			break;
+		}
+		y--;		
+		for (x = xo; x > 0; x--) {
+			achannel = rt2[3];
+			rt2[3] = achannel * facf1;
+			blend_function(rt, rt1, rt2);
+			rt2[3] = achannel;
+			rt[3] = rt2[3];
+			rt1 += 4;
+			rt2 += 4;
+			rt += 4;
+		}
+	}
+}
+
+static void do_blend_effect_float(float facf0, float facf1, int x, int y, float *rect1, float *rect2, int btype, float *out)
+{
+	switch (btype) {
+		case SEQ_TYPE_ADD:
+			apply_blend_function_float(facf0, facf1, x, y, rect1, rect2, out, blend_color_add_float);
+			break;
+		case SEQ_TYPE_SUB:
+			apply_blend_function_float(facf0, facf1, x, y, rect1, rect2, out, blend_color_sub_float);
+			break;
+		case SEQ_TYPE_MUL:
+			apply_blend_function_float(facf0, facf1, x, y, rect1, rect2, out, blend_color_mul_float);
+			break;
+		case SEQ_TYPE_DARKEN:
+			apply_blend_function_float(facf0, facf1, x, y, rect1, rect2, out, blend_color_darken_float);
+			break;
+		case SEQ_TYPE_BURN:
+			apply_blend_function_float(facf0, facf1, x, y, rect1, rect2, out, blend_color_burn_float);
+			break;
+		case SEQ_TYPE_LINEAR_BURN:
+			apply_blend_function_float(facf0, facf1, x, y, rect1, rect2, out, blend_color_linearburn_float);
+			break;
+		case SEQ_TYPE_SCREEN:
+			apply_blend_function_float(facf0, facf1, x, y, rect1, rect2, out, blend_color_screen_float);
+			break;
+		case SEQ_TYPE_LIGHTEN:
+			apply_blend_function_float(facf0, facf1, x, y, rect1, rect2, out, blend_color_lighten_float);
+			break;
+		case SEQ_TYPE_DODGE:
+			apply_blend_function_float(facf0, facf1, x, y, rect1, rect2, out, blend_color_dodge_float);
+			break;
+		case SEQ_TYPE_OVERLAY:
+			apply_blend_function_float(facf0, facf1, x, y, rect1, rect2, out, blend_color_overlay_float);
+			break;
+		case SEQ_TYPE_SOFT_LIGHT:
+			apply_blend_function_float(facf0, facf1, x, y, rect1, rect2, out, blend_color_softlight_float);
+			break;
+		case SEQ_TYPE_HARD_LIGHT:
+			apply_blend_function_float(facf0, facf1, x, y, rect1, rect2, out, blend_color_hardlight_float);
+			break;
+		case SEQ_TYPE_PIN_LIGHT:
+			apply_blend_function_float(facf0, facf1, x, y, rect1, rect2, out, blend_color_pinlight_float);
+			break;
+		case SEQ_TYPE_LIN_LIGHT:
+			apply_blend_function_float(facf0, facf1, x, y, rect1, rect2, out, blend_color_linearlight_float);
+			break;
+		case SEQ_TYPE_VIVID_LIGHT:
+			apply_blend_function_float(facf0, facf1, x, y, rect1, rect2, out, blend_color_vividlight_float);
+			break;
+		case SEQ_TYPE_BLEND_COLOR:
+			apply_blend_function_float(facf0, facf1, x, y, rect1, rect2, out, blend_color_color_float);
+			break;
+		case SEQ_TYPE_HUE:
+			apply_blend_function_float(facf0, facf1, x, y, rect1, rect2, out, blend_color_hue_float);
+			break;
+		case SEQ_TYPE_SATURATION:
+			apply_blend_function_float(facf0, facf1, x, y, rect1, rect2, out, blend_color_saturation_float);
+			break;
+		case SEQ_TYPE_VALUE:
+			apply_blend_function_float(facf0, facf1, x, y, rect1, rect2, out, blend_color_luminosity_float);
+			break;
+		case SEQ_TYPE_DIFFERENCE:
+			apply_blend_function_float(facf0, facf1, x, y, rect1, rect2, out, blend_color_difference_float);
+			break;
+		case SEQ_TYPE_EXCLUSION:
+			apply_blend_function_float(facf0, facf1, x, y, rect1, rect2, out, blend_color_exclusion_float);
+			break;
+		default:
+			break;
+	}
+}
+
+static void do_blend_effect_byte(float facf0, float facf1, int x, int y, unsigned char *rect1, unsigned char *rect2, int btype, unsigned char *out)
+{
+	switch (btype) {
+		case SEQ_TYPE_ADD:
+			apply_blend_function_byte(facf0, facf1, x, y, rect1, rect2, out, blend_color_add_byte);
+			break;
+		case SEQ_TYPE_SUB:
+			apply_blend_function_byte(facf0, facf1, x, y, rect1, rect2, out, blend_color_sub_byte);
+			break;
+		case SEQ_TYPE_MUL:
+			apply_blend_function_byte(facf0, facf1, x, y, rect1, rect2, out, blend_color_mul_byte);
+			break;
+		case SEQ_TYPE_DARKEN:
+			apply_blend_function_byte(facf0, facf1, x, y, rect1, rect2, out, blend_color_darken_byte);
+			break;
+		case SEQ_TYPE_BURN:
+			apply_blend_function_byte(facf0, facf1, x, y, rect1, rect2, out, blend_color_burn_byte);
+			break;
+		case SEQ_TYPE_LINEAR_BURN:
+			apply_blend_function_byte(facf0, facf1, x, y, rect1, rect2, out, blend_color_linearburn_byte);
+			break;
+		case SEQ_TYPE_SCREEN:
+			apply_blend_function_byte(facf0, facf1, x, y, rect1, rect2, out, blend_color_screen_byte);
+			break;
+		case SEQ_TYPE_LIGHTEN:
+			apply_blend_function_byte(facf0, facf1, x, y, rect1, rect2, out, blend_color_lighten_byte);
+			break;
+		case SEQ_TYPE_DODGE:
+			apply_blend_function_byte(facf0, facf1, x, y, rect1, rect2, out, blend_color_dodge_byte);
+			break;
+		case SEQ_TYPE_OVERLAY:
+			apply_blend_function_byte(facf0, facf1, x, y, rect1, rect2, out, blend_color_overlay_byte);
+			break;
+		case SEQ_TYPE_SOFT_LIGHT:
+			apply_blend_function_byte(facf0, facf1, x, y, rect1, rect2, out, blend_color_softlight_byte);
+			break;
+		case SEQ_TYPE_HARD_LIGHT:
+			apply_blend_function_byte(facf0, facf1, x, y, rect1, rect2, out, blend_color_hardlight_byte);
+			break;
+		case SEQ_TYPE_PIN_LIGHT:
+			apply_blend_function_byte(facf0, facf1, x, y, rect1, rect2, out, blend_color_pinlight_byte);
+			break;
+		case SEQ_TYPE_LIN_LIGHT:
+			apply_blend_function_byte(facf0, facf1, x, y, rect1, rect2, out, blend_color_linearlight_byte);
+			break;
+		case SEQ_TYPE_VIVID_LIGHT:
+			apply_blend_function_byte(facf0, facf1, x, y, rect1, rect2, out, blend_color_vividlight_b

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list