traverso-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Traverso-commit] traverso/src/traverso/songcanvas CurveView.cpp


From: Remon Sijrier
Subject: [Traverso-commit] traverso/src/traverso/songcanvas CurveView.cpp
Date: Mon, 19 Nov 2007 18:54:01 +0000

CVSROOT:        /sources/traverso
Module name:    traverso
Changes by:     Remon Sijrier <r_sijrier>       07/11/19 18:54:01

Modified files:
        src/traverso/songcanvas: CurveView.cpp 

Log message:
        * handle the special case when the curve is only a line, it's then 
painted as a line, greatly reducing cpu load
        * paint the curve before and after the last node as a line, again 
reducing cpu load
        * TODO: maybe detect all line segments, and paint those as a line 
instead of using an (anti-aliased) painterpath ?

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/songcanvas/CurveView.cpp?cvsroot=traverso&r1=1.66&r2=1.67

Patches:
Index: CurveView.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/traverso/songcanvas/CurveView.cpp,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -b -r1.66 -r1.67
--- CurveView.cpp       19 Nov 2007 11:18:54 -0000      1.66
+++ CurveView.cpp       19 Nov 2007 18:54:01 -0000      1.67
@@ -190,10 +190,10 @@
        Q_UNUSED(widget);
        PENTER2;
        
-       painter->save();
        
-       painter->setClipRect(m_boundingRect);
-       painter->setRenderHint(QPainter::Antialiasing);
+       int xstart = (int) option->exposedRect.x();
+       int pixelcount = (int) option->exposedRect.width();
+       int height = int(m_boundingRect.height());
        
        QPen pen;
        
@@ -203,11 +203,40 @@
                pen.setColor(themer()->get_color("Curve:inactive"));
        }
        
+       painter->save();
        painter->setPen(pen);
        
-       QPolygonF polygon;
-       int xstart = (int) option->exposedRect.x();
-       int pixelcount = (int) option->exposedRect.width();
+       
+       if (m_nodeViews.size() == 1) {
+               int y = int(height - (m_nodeViews.first()->value * height));
+               painter->drawLine(xstart, y, xstart + pixelcount, y);
+               painter->restore();
+               return;
+       }
+       
+       if (m_nodeViews.first()->when > xstart) {
+               int y = int(height - (m_nodeViews.first()->value * height));
+               int length = int(m_nodeViews.first()->when) - xstart;
+               painter->drawLine(xstart, y, xstart + length, y);
+               xstart += length;
+               pixelcount -= length;
+               if (pixelcount <= 0) {
+                       painter->restore();
+                       return;
+               }
+       }
+       
+       if (m_nodeViews.last()->when < (xstart + pixelcount)) {
+               int y = int(height - (m_nodeViews.last()->value * height));
+               int length = (xstart + pixelcount) - 
int(m_nodeViews.last()->when);
+               painter->drawLine(int(m_nodeViews.last()->when), y, 
int(m_nodeViews.last()->when + length) -1 , y);
+               pixelcount -= length;
+               if (pixelcount <= 0) {
+                       painter->restore();
+                       return;
+               }
+       }
+       
        
        // Path's need an additional pixel righ/left to be painted correctly.
        // FadeView get_curve adjusts for this, if changing these 
@@ -217,7 +246,11 @@
        if (xstart < 0) {
                xstart = 0;
        }
-       float height = m_boundingRect.height();
+       
+       painter->setClipRect(m_boundingRect);
+       painter->setRenderHint(QPainter::Antialiasing);
+       
+       QPolygonF polygon;
        float vector[pixelcount];
        
 //     printf("range: %d\n", (int)m_nodeViews.last()->pos().x());
@@ -255,7 +288,7 @@
        
        painter->drawPath(path);
        
-       if (xstart <= 80) {
+       if (xstart <= 100) {
                
painter->setFont(themer()->get_font("CurveView:fontscale:label"));
                painter->drawText(10, (int)(m_boundingRect.height() - 14), 
"Gain Curve");
        }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]