Graph Editor: Added option to turn off AA drawing for performance
authorJoshua Leung <aligorith@gmail.com>
Wed, 9 Feb 2011 02:09:25 +0000 (02:09 +0000)
committerJoshua Leung <aligorith@gmail.com>
Wed, 9 Feb 2011 02:09:25 +0000 (02:09 +0000)
gains when using really heavy files

release/scripts/ui/space_graph.py
source/blender/editors/space_graph/graph_draw.c
source/blender/makesdna/DNA_space_types.h
source/blender/makesrna/intern/rna_space.c

index 51c5ebc..235ed54 100644 (file)
@@ -80,6 +80,9 @@ class GRAPH_MT_view(bpy.types.Menu):
         layout.prop(st, "show_sliders")
         layout.prop(st, "use_auto_merge_keyframes")
 
+        layout.separator()
+        layout.prop(st, "use_fancy_drawing")
+
         layout.separator()
         if st.show_handles:
             layout.operator("graph.handles_view_toggle", icon='CHECKBOX_HLT', text="Show All Handles")
index b2e9f93..901ede9 100644 (file)
@@ -138,7 +138,7 @@ static void draw_fcurve_modifier_controls_envelope (FModifier *fcm, View2D *v2d)
 /* Points ---------------- */
 
 /* helper func - draw keyframe vertices only for an F-Curve */
-static void draw_fcurve_vertices_keyframes (FCurve *fcu, View2D *v2d, short edit, short sel)
+static void draw_fcurve_vertices_keyframes (FCurve *fcu, SpaceIpo *UNUSED(sipo), View2D *v2d, short edit, short sel)
 {
        BezTriple *bezt= fcu->bezt;
        const float fac= 0.05f * (v2d->cur.xmax - v2d->cur.xmin);
@@ -210,7 +210,7 @@ static void draw_fcurve_handle_control (float x, float y, float xscale, float ys
 }
 
 /* helper func - draw handle vertices only for an F-Curve (if it is not protected) */
-static void draw_fcurve_vertices_handles (FCurve *fcu, View2D *v2d, short sel, short sel_handle_only)
+static void draw_fcurve_vertices_handles (FCurve *fcu, SpaceIpo *sipo, View2D *v2d, short sel, short sel_handle_only)
 {
        BezTriple *bezt= fcu->bezt;
        BezTriple *prevbezt = NULL;
@@ -226,7 +226,7 @@ static void draw_fcurve_vertices_handles (FCurve *fcu, View2D *v2d, short sel, s
        else UI_ThemeColor(TH_HANDLE_VERTEX);
        
        /* anti-aliased lines for more consistent appearance */
-       glEnable(GL_LINE_SMOOTH);
+       if ((sipo->flag & SIPO_BEAUTYDRAW_OFF)==0) glEnable(GL_LINE_SMOOTH);
        glEnable(GL_BLEND);
        
        for (i=0; i < fcu->totvert; i++, prevbezt=bezt, bezt++) {
@@ -251,7 +251,7 @@ static void draw_fcurve_vertices_handles (FCurve *fcu, View2D *v2d, short sel, s
                }
        }
        
-       glDisable(GL_LINE_SMOOTH);
+       if ((sipo->flag & SIPO_BEAUTYDRAW_OFF)==0) glDisable(GL_LINE_SMOOTH);
        glDisable(GL_BLEND);
 }
 
@@ -275,7 +275,7 @@ static void set_fcurve_vertex_color (FCurve *fcu, short sel)
 }
 
 
-static void draw_fcurve_vertices (ARegion *ar, FCurve *fcu, short do_handles, short sel_handle_only)
+static void draw_fcurve_vertices (SpaceIpo *sipo, ARegion *ar, FCurve *fcu, short do_handles, short sel_handle_only)
 {
        View2D *v2d= &ar->v2d;
        
@@ -292,18 +292,18 @@ static void draw_fcurve_vertices (ARegion *ar, FCurve *fcu, short do_handles, sh
        if (do_handles)
        {
                set_fcurve_vertex_color(fcu, 0);
-               draw_fcurve_vertices_handles(fcu, v2d, 0, sel_handle_only);
+               draw_fcurve_vertices_handles(fcu, sipo, v2d, 0, sel_handle_only);
                
                set_fcurve_vertex_color(fcu, 1);
-               draw_fcurve_vertices_handles(fcu, v2d, 1, sel_handle_only);
+               draw_fcurve_vertices_handles(fcu, sipo, v2d, 1, sel_handle_only);
        }
                
        /* draw keyframes over the handles */
        set_fcurve_vertex_color(fcu, 0);
-       draw_fcurve_vertices_keyframes(fcu, v2d, !(fcu->flag & FCURVE_PROTECTED), 0);
+       draw_fcurve_vertices_keyframes(fcu, sipo, v2d, !(fcu->flag & FCURVE_PROTECTED), 0);
        
        set_fcurve_vertex_color(fcu, 1);
-       draw_fcurve_vertices_keyframes(fcu, v2d, !(fcu->flag & FCURVE_PROTECTED), 1);
+       draw_fcurve_vertices_keyframes(fcu, sipo, v2d, !(fcu->flag & FCURVE_PROTECTED), 1);
        
        glPointSize(1.0f);
 }
@@ -407,7 +407,7 @@ static void draw_fcurve_handles (SpaceIpo *sipo, FCurve *fcu)
                                        UI_GetThemeColor3ubv(basecol + bezt->h2, col);
                                        col[3]= drawFCurveFade(fcu) * 255;
                                        glColor4ubv((GLubyte *)col);
-
+                                       
                                        glVertex2fv(fp); glVertex2fv(fp+3); 
                                }
                        }
@@ -456,7 +456,7 @@ static void draw_fcurve_sample_control (float x, float y, float xscale, float ys
 }
 
 /* helper func - draw keyframe vertices only for an F-Curve */
-static void draw_fcurve_samples (ARegion *ar, FCurve *fcu)
+static void draw_fcurve_samples (SpaceIpo *sipo, ARegion *ar, FCurve *fcu)
 {
        FPoint *first, *last;
        float hsize, xscale, yscale;
@@ -476,14 +476,14 @@ static void draw_fcurve_samples (ARegion *ar, FCurve *fcu)
        /* draw */
        if (first && last) {
                /* anti-aliased lines for more consistent appearance */
-               glEnable(GL_LINE_SMOOTH);
+               if ((sipo->flag & SIPO_BEAUTYDRAW_OFF)==0) glEnable(GL_LINE_SMOOTH);
                glEnable(GL_BLEND);
                
                draw_fcurve_sample_control(first->vec[0], first->vec[1], xscale, yscale, hsize);
                draw_fcurve_sample_control(last->vec[0], last->vec[1], xscale, yscale, hsize);
                
                glDisable(GL_BLEND);
-               glDisable(GL_LINE_SMOOTH);
+               if ((sipo->flag & SIPO_BEAUTYDRAW_OFF)==0) glDisable(GL_LINE_SMOOTH);
        }
 }
 
@@ -794,7 +794,7 @@ void graph_draw_ghost_curves (bAnimContext *ac, SpaceIpo *sipo, ARegion *ar)
        glLineWidth(3.0f);
        
        /* anti-aliased lines for less jagged appearance */
-       glEnable(GL_LINE_SMOOTH);
+       if ((sipo->flag & SIPO_BEAUTYDRAW_OFF)==0) glEnable(GL_LINE_SMOOTH);
        glEnable(GL_BLEND);
        
        /* the ghost curves are simply sampled F-Curves stored in sipo->ghostCurves */
@@ -813,7 +813,7 @@ void graph_draw_ghost_curves (bAnimContext *ac, SpaceIpo *sipo, ARegion *ar)
        setlinestyle(0);
        glLineWidth(1.0f);
        
-       glDisable(GL_LINE_SMOOTH);
+       if ((sipo->flag & SIPO_BEAUTYDRAW_OFF)==0) glDisable(GL_LINE_SMOOTH);
        glDisable(GL_BLEND);
 }
 
@@ -871,7 +871,7 @@ void graph_draw_curves (bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGri
                        }
                        
                        /* anti-aliased lines for less jagged appearance */
-                       glEnable(GL_LINE_SMOOTH);
+                       if ((sipo->flag & SIPO_BEAUTYDRAW_OFF)==0) glEnable(GL_LINE_SMOOTH);
                        glEnable(GL_BLEND);
                        
                        /* draw F-Curve */
@@ -892,7 +892,7 @@ void graph_draw_curves (bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGri
                        /* restore settings */
                        setlinestyle(0);
                        
-                       glDisable(GL_LINE_SMOOTH);
+                       if ((sipo->flag & SIPO_BEAUTYDRAW_OFF)==0) glDisable(GL_LINE_SMOOTH);
                        glDisable(GL_BLEND);
                }
                
@@ -924,11 +924,11 @@ void graph_draw_curves (bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGri
                                                glDisable(GL_BLEND);
                                        }
                                        
-                                       draw_fcurve_vertices(ar, fcu, do_handles, sipo->flag&SIPO_SELVHANDLESONLY);
+                                       draw_fcurve_vertices(sipo, ar, fcu, do_handles, (sipo->flag & SIPO_SELVHANDLESONLY));
                                }
                                else {
                                        /* samples: only draw two indicators at either end as indicators */
-                                       draw_fcurve_samples(ar, fcu);
+                                       draw_fcurve_samples(sipo, ar, fcu);
                                }
                                
                                /* unapply unit mapping */
index 43bda96..287dcf4 100644 (file)
@@ -795,6 +795,8 @@ enum FileSortTypeE {
 #define SIPO_TEMP_NEEDCHANSYNC (1<<10)
        /* don't perform realtime updates */
 #define SIPO_NOREALTIMEUPDATES (1<<11)
+       /* don't draw curves with AA ("beauty-draw") for performance */
+#define SIPO_BEAUTYDRAW_OFF            (1<<12)
 
 /* SpaceIpo->mode (Graph Editor Mode) */
 enum {
index 0a1ae8f..2cade18 100644 (file)
@@ -1869,6 +1869,11 @@ static void rna_def_space_graph(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Only Selected Keyframes Handles", "Only show and edit handles of selected keyframes");
        RNA_def_property_update(prop, NC_SPACE|ND_SPACE_GRAPH, NULL);
        
+       prop= RNA_def_property(srna, "use_fancy_drawing", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SIPO_BEAUTYDRAW_OFF);
+       RNA_def_property_ui_text(prop, "Use Fancy Drawing", "Draw F-Curves using Anti-Aliasing and other fancy effects. Disable for better performance");
+       RNA_def_property_update(prop, NC_SPACE|ND_SPACE_GRAPH, NULL);
+       
        /* editing */
        prop= RNA_def_property(srna, "use_auto_merge_keyframes", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SIPO_NOTRANSKEYCULL);