Added RGBA|RGB channels toggle to sequencer preview
authorSergey Sharybin <sergey.vfx@gmail.com>
Wed, 27 Feb 2013 10:26:58 +0000 (10:26 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Wed, 27 Feb 2013 10:26:58 +0000 (10:26 +0000)
Main purpose of this is to be more compatible with older
versions of blender (before alpha cleanup) where sequencer
used to display premultiplied image on an straight opengl
viewport.

Now sequencer preview would behave closer to image editor
However adding Alpha and R|G|B displays is not so simple
because sequencer is using 2D textures. Would be nice to
implement this options as well, but this is not so much
important IMO.

This hall fix
- #34453: VSE: Subtract function does not work properly

TODO: Make RGBA display default for our startup.blend

release/scripts/startup/bl_ui/space_sequencer.py
source/blender/editors/space_sequencer/sequencer_draw.c
source/blender/editors/space_sequencer/space_sequencer.c
source/blender/makesdna/DNA_space_types.h
source/blender/makesrna/intern/rna_space.c

index 7841acf01b3c694c273690ecfea0aeb9ae143e2a..aa445b9500d2f93574ca0e222aa71c6aaabd6684 100644 (file)
@@ -89,6 +89,7 @@ class SEQUENCER_HT_header(Header):
                 layout.separator()
                 layout.operator("sequencer.refresh_all")
 
+            layout.prop(st, "preview_channels", expand=True, text="")
             layout.prop(st, "display_channel", text="Channel")
 
             ed = context.scene.sequence_editor
index 249ba986fd368ea286a2c1a4bb1a54992f0c7392..396878cbfebc130bbf81cd840745683f67828d53 100644 (file)
@@ -1059,8 +1059,10 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
 
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, ibuf->x, ibuf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer);
 
-       glEnable(GL_BLEND);
-       glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+       if (sseq->flag & SEQ_USE_ALPHA) {
+               glEnable(GL_BLEND);
+               glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+       }
 
        glBegin(GL_QUADS);
 
@@ -1093,7 +1095,8 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
        glEnd();
        glBindTexture(GL_TEXTURE_2D, last_texid);
        glDisable(GL_TEXTURE_2D);
-       glDisable(GL_BLEND);
+       if (sseq->flag & SEQ_USE_ALPHA)
+               glDisable(GL_BLEND);
        glDeleteTextures(1, &texid);
 
        if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
index d541e1d6c07dd6ea69ce2361a044f1132a3556bc..4c6b909882cc6a94ef9f3a31dbe20de1104a4675 100644 (file)
@@ -120,7 +120,7 @@ static SpaceLink *sequencer_new(const bContext *C)
        sseq->chanshown = 0;
        sseq->view = SEQ_VIEW_SEQUENCE;
        sseq->mainb = SEQ_DRAW_IMG_IMBUF;
-       sseq->flag = SEQ_SHOW_GPENCIL;
+       sseq->flag = SEQ_SHOW_GPENCIL | SEQ_USE_ALPHA;
 
        /* header */
        ar = MEM_callocN(sizeof(ARegion), "header for sequencer");
index 1dfcff4a3c46529b43e04f7f249f5976c0652611..b8ba58d7a6dd7492f64e2dbb15ef7ff6a1920c7f 100644 (file)
@@ -497,6 +497,7 @@ typedef enum eSpaceSeq_Flag {
        SEQ_DRAW_SAFE_MARGINS       = (1 << 3),
        SEQ_SHOW_GPENCIL            = (1 << 4),
        SEQ_NO_DRAW_CFRANUM         = (1 << 5),
+       SEQ_USE_ALPHA               = (1 << 6), /* use RGBA display mode for preview */
 } eSpaceSeq_Flag;
 
 /* sseq->view */
index 0ab74fb617ffd5670524e5d16b81a5d354857c55..6db863a267bfee9260964899ea6ff1cc9a7884d1 100644 (file)
@@ -2248,6 +2248,13 @@ static void rna_def_space_sequencer(BlenderRNA *brna)
                {0, NULL, 0, NULL, NULL}
        };
 
+       static EnumPropertyItem preview_channels_items[] = {
+               {SEQ_USE_ALPHA, "COLOR_ALPHA", ICON_IMAGE_RGB_ALPHA, "Color and Alpha",
+                               "Draw image with RGB colors and alpha transparency"},
+               {0, "COLOR", ICON_IMAGE_RGB, "Color", "Draw image with RGB colors"},
+               {0, NULL, 0, NULL, NULL}
+       };
+
        srna = RNA_def_struct(brna, "SpaceSequenceEditor", "Space");
        RNA_def_struct_sdna(srna, "SpaceSeq");
        RNA_def_struct_ui_text(srna, "Space Sequence Editor", "Sequence editor space data");
@@ -2265,7 +2272,7 @@ static void rna_def_space_sequencer(BlenderRNA *brna)
        RNA_def_property_enum_items(prop, display_mode_items);
        RNA_def_property_ui_text(prop, "Display Mode", "View mode to use for displaying sequencer output");
        RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL);
-               
+
        /* flags */
        prop = RNA_def_property(srna, "show_frame_indicator", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SEQ_NO_DRAW_CFRANUM);
@@ -2310,7 +2317,13 @@ static void rna_def_space_sequencer(BlenderRNA *brna)
                                 "The channel number shown in the image preview. 0 is the result of all strips combined");
        RNA_def_property_range(prop, -5, MAXSEQ);
        RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL);
-       
+
+       prop = RNA_def_property(srna, "preview_channels", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
+       RNA_def_property_enum_items(prop, preview_channels_items);
+       RNA_def_property_ui_text(prop, "Draw Channels", "Channels of the preview to draw");
+       RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL);
+
        prop = RNA_def_property(srna, "draw_overexposed", PROP_INT, PROP_NONE);
        RNA_def_property_int_sdna(prop, NULL, "zebra");
        RNA_def_property_ui_text(prop, "Show Overexposed", "Show overexposed areas with zebra stripes");