Revision: 27486
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27486
Author:   schlaile
Date:     2010-03-14 17:36:41 +0100 (Sun, 14 Mar 2010)

Log Message:
-----------
== Sequencer ==

This fixes [#21087] Opacity of 0 turns off effect rather than affecting 
transparency
and makes the whole early_out-business in strip stack a lot more readable.

The actual fix is just using the composited result in layer fall through
case (se1->ibuf_comp instead of se1->ibuf).

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/sequencer.c

Modified: trunk/blender/source/blender/blenkernel/intern/sequencer.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/sequencer.c  2010-03-14 
16:27:07 UTC (rev 27485)
+++ trunk/blender/source/blender/blenkernel/intern/sequencer.c  2010-03-14 
16:36:41 UTC (rev 27486)
@@ -2452,6 +2452,42 @@
        return se;
 }
 
+static int seq_must_swap_input_in_blend_mode(Sequence * seq)
+{
+       int swap_input = FALSE;
+
+       /* bad hack, to fix crazy input ordering of 
+          those two effects */
+
+       if (seq->blend_mode == SEQ_ALPHAOVER ||
+           seq->blend_mode == SEQ_ALPHAUNDER ||
+           seq->blend_mode == SEQ_OVERDROP) {
+               swap_input = TRUE;
+       }
+       
+       return swap_input;
+}
+
+static int seq_get_early_out_for_blend_mode(Sequence * seq)
+{
+       struct SeqEffectHandle sh = get_sequence_blend(seq);
+       float facf = seq->blend_opacity / 100.0;
+       int early_out = sh.early_out(seq, facf, facf);
+       
+       if (early_out < 1) {
+               return early_out;
+       }
+
+       if (seq_must_swap_input_in_blend_mode(seq)) {
+               if (early_out == 2) {
+                       return 1;
+               } else if (early_out == 1) {
+                       return 2;
+               }
+       }
+       return early_out;
+}
+
 static TStripElem* do_build_seq_array_recursively(Scene *scene,
        ListBase *seqbasep, int cfra, int chanshown, int render_size)
 {
@@ -2460,7 +2496,8 @@
        int i;
        TStripElem* se = 0;
 
-       count = get_shown_sequences(seqbasep, cfra, chanshown, (Sequence 
**)&seq_arr);
+       count = get_shown_sequences(seqbasep, cfra, chanshown, 
+                                   (Sequence **)&seq_arr);
 
        if (!count) {
                return 0;
@@ -2483,7 +2520,8 @@
 
        
        if(count == 1) {
-               se = do_build_seq_recursively(scene, seq_arr[0], cfra, 
render_size);
+               se = do_build_seq_recursively(scene, seq_arr[0],
+                                             cfra, render_size);
                if (se->ibuf) {
                        se->ibuf_comp = se->ibuf;
                        IMB_refImBuf(se->ibuf_comp);
@@ -2495,8 +2533,6 @@
        for (i = count - 1; i >= 0; i--) {
                int early_out;
                Sequence * seq = seq_arr[i];
-               struct SeqEffectHandle sh;
-               float facf;
 
                se = give_tstripelem(seq, cfra);
 
@@ -2506,7 +2542,9 @@
                        break;
                }
                if (seq->blend_mode == SEQ_BLEND_REPLACE) {
-                       do_build_seq_recursively(scene, seq, cfra, render_size);
+                       do_build_seq_recursively(
+                               scene, seq, cfra, render_size);
+
                        if (se->ibuf) {
                                se->ibuf_comp = se->ibuf;
                                IMB_refImBuf(se->ibuf);
@@ -2521,16 +2559,14 @@
                        break;
                }
 
-               sh = get_sequence_blend(seq);
+               early_out = seq_get_early_out_for_blend_mode(seq);
 
-               facf = seq->blend_opacity / 100.0;
-
-               early_out = sh.early_out(seq, facf, facf);
-
                switch (early_out) {
                case -1:
                case 2:
-                       do_build_seq_recursively(scene, seq, cfra, render_size);
+                       do_build_seq_recursively(
+                               scene, seq, cfra, render_size);
+
                        if (se->ibuf) {
                                se->ibuf_comp = se->ibuf;
                                IMB_refImBuf(se->ibuf_comp);
@@ -2554,7 +2590,9 @@
                        }
                        break;
                case 0:
-                       do_build_seq_recursively(scene, seq, cfra, render_size);
+                       do_build_seq_recursively(
+                               scene, seq, cfra, render_size);
+
                        if (!se->ibuf) {
                                se->ibuf = IMB_allocImBuf(
                                        (short)seqrectx, (short)seqrecty, 
@@ -2584,14 +2622,13 @@
                TStripElem* se2 = give_tstripelem(seq_arr[i], cfra);
 
                float facf = seq->blend_opacity / 100.0;
+               int swap_input = seq_must_swap_input_in_blend_mode(seq);
+               int early_out = seq_get_early_out_for_blend_mode(seq);
 
-               int early_out = sh.early_out(seq, facf, facf);
-
                switch (early_out) {
                case 0: {
                        int x= se2->ibuf->x;
                        int y= se2->ibuf->y;
-                       int swap_input = FALSE;
 
                        if(se1->ibuf_comp == NULL)
                                continue;
@@ -2626,15 +2663,6 @@
                                IMB_rect_from_float(se2->ibuf);
                        }
                        
-                       /* bad hack, to fix crazy input ordering of 
-                          those two effects */
-
-                       if (seq->blend_mode == SEQ_ALPHAOVER ||
-                           seq->blend_mode == SEQ_ALPHAUNDER ||
-                           seq->blend_mode == SEQ_OVERDROP) {
-                               swap_input = TRUE;
-                       }
-
                        if (swap_input) {
                                sh.execute(scene, seq, cfra, 
                                           facf, facf, x, y, 
@@ -2657,7 +2685,7 @@
                        break;
                }
                case 1: {
-                       se2->ibuf_comp = se1->ibuf;
+                       se2->ibuf_comp = se1->ibuf_comp;
                        if(se2->ibuf_comp)
                                IMB_refImBuf(se2->ibuf_comp);
 


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to