traverso-commit
[Top][All Lists]
Advanced

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

[Traverso-commit] traverso/src core/Song.cpp core/ViewPort.cpp tr...


From: Remon Sijrier
Subject: [Traverso-commit] traverso/src core/Song.cpp core/ViewPort.cpp tr...
Date: Mon, 07 Jan 2008 18:11:31 +0000

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

Modified files:
        src/core       : Song.cpp ViewPort.cpp 
        src/traverso/dialogs/settings: Pages.cpp 
        src/traverso/songcanvas: AudioClipView.cpp AudioClipView.h 

Log message:
        * added line based painting back, can be toggled on/off in config dialog
        CPU usage varies wildly, seems to be dependend on audioclip height.
        When audioclip height is not at the maximum, polygon and line based 
drawing seems equal in performance, but often line based is the big winner. 
Restart/recompile traverso: htop says yet something different.
        So it's up to the user which one to use: painting with lines or 
polygons.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Song.cpp?cvsroot=traverso&r1=1.168&r2=1.169
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/ViewPort.cpp?cvsroot=traverso&r1=1.26&r2=1.27
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/dialogs/settings/Pages.cpp?cvsroot=traverso&r1=1.32&r2=1.33
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/songcanvas/AudioClipView.cpp?cvsroot=traverso&r1=1.123&r2=1.124
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/songcanvas/AudioClipView.h?cvsroot=traverso&r1=1.36&r2=1.37

Patches:
Index: core/Song.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/Song.cpp,v
retrieving revision 1.168
retrieving revision 1.169
diff -u -b -r1.168 -r1.169

Index: core/ViewPort.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/ViewPort.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- core/ViewPort.cpp   12 Dec 2007 18:13:37 -0000      1.26
+++ core/ViewPort.cpp   7 Jan 2008 18:11:30 -0000       1.27
@@ -172,8 +172,8 @@
 
 void ViewPort::tabletEvent(QTabletEvent * event)
 {
-       printf("ViewPort tablet event:: x, y: %d, %d\n", (int)event->x(), 
(int)event->y());
-       printf("ViewPort tablet event:: high resolution x, y: %d, %d\n\n", 
+       PMESG("ViewPort tablet event:: x, y: %d, %d", (int)event->x(), 
(int)event->y());
+       PMESG("ViewPort tablet event:: high resolution x, y: %d, %d", 
                                (int)event->hiResGlobalX(), 
(int)event->hiResGlobalY());
        cpointer().set_point((int)event->x(), (int)event->y());
        

Index: traverso/dialogs/settings/Pages.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/traverso/dialogs/settings/Pages.cpp,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -b -r1.32 -r1.33
--- traverso/dialogs/settings/Pages.cpp 15 Dec 2007 16:50:18 -0000      1.32
+++ traverso/dialogs/settings/Pages.cpp 7 Jan 2008 18:11:31 -0000       1.33
@@ -570,6 +570,7 @@
        config().set_property("Themer", "usestylepallet", 
m_themepage->useStylePalletCheckBox->isChecked());
        config().set_property("Themer", "paintaudiorectified", 
m_themepage->rectifiedCheckBox->isChecked());
        config().set_property("Themer", "paintstereoaudioasmono", 
m_themepage->mergedCheckBox->isChecked());
+       config().set_property("Themer", "paintwavewithoutline", 
m_themepage->paintAudioWithOutlineCheckBox->isChecked());
 }
 
 void AppearancePage::load_config()
@@ -599,6 +600,8 @@
        bool usestylepallete = config().get_property("Themer", 
"usestylepallet", "").toBool();
        bool paintRectified = config().get_property("Themer", 
"paintaudiorectified", false).toBool();
        bool paintStereoAsMono = config().get_property("Themer", 
"paintstereoaudioasmono", false).toBool();
+       bool paintWaveWithLines = config().get_property("Themer", 
"paintwavewithoutline", true).toBool();
+
 
        int index = m_themepage->styleCombo->findText(style);
        m_themepage->styleCombo->setCurrentIndex(index);
@@ -609,6 +612,8 @@
        m_themepage->themePathLineEdit->setText(themepath);
        m_themepage->rectifiedCheckBox->setChecked(paintRectified);
        m_themepage->mergedCheckBox->setChecked(paintStereoAsMono);
+       
m_themepage->paintAudioWithOutlineCheckBox->setChecked(paintWaveWithLines);
+
 }
 
 void AppearancePage::reset_default_config()
@@ -644,6 +649,7 @@
        connect(pathSelectButton, SIGNAL(clicked()), this, 
SLOT(dirselect_button_clicked()));
        connect(rectifiedCheckBox, SIGNAL(toggled(bool)), this, 
SLOT(theme_option_changed()));
        connect(mergedCheckBox, SIGNAL(toggled(bool)), this, 
SLOT(theme_option_changed()));
+       connect(paintAudioWithOutlineCheckBox, SIGNAL(toggled(bool)), this, 
SLOT(theme_option_changed()));
 }
 
 void ThemeConfigPage::style_index_changed(const QString& text)
@@ -715,6 +721,7 @@
 {
        config().set_property("Themer", "paintaudiorectified", 
rectifiedCheckBox->isChecked());
        config().set_property("Themer", "paintstereoaudioasmono", 
mergedCheckBox->isChecked());
+       config().set_property("Themer", "paintwavewithoutline", 
paintAudioWithOutlineCheckBox->isChecked());
        themer()->load();
 }
 

Index: traverso/songcanvas/AudioClipView.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/traverso/songcanvas/AudioClipView.cpp,v
retrieving revision 1.123
retrieving revision 1.124
diff -u -b -r1.123 -r1.124
--- traverso/songcanvas/AudioClipView.cpp       6 Jan 2008 06:11:28 -0000       
1.123
+++ traverso/songcanvas/AudioClipView.cpp       7 Jan 2008 18:11:31 -0000       
1.124
@@ -127,7 +127,6 @@
        }
        
        painter->save();
-       
        painter->setClipRect(m_boundingRect);
        
        if (m_clip->is_readsource_invalid()) {
@@ -232,10 +231,9 @@
        // Painting 2 more pixels makes it getting clipped away.....
        pixelcount += 2;
        
-       bool microView = m_song->get_hzoom() > (Peak::MAX_ZOOM_USING_SOURCEFILE 
-1) ? 0 : 1;
        // boundary checking, important for microview only, macroview needs the 
additional
        // pixels to paint the waveform correctly
-       if ( /*microView &&*/ ((xstart + pixelcount) > m_boundingRect.width()) 
) {
+       if ((xstart + pixelcount) > m_boundingRect.width()) {
                pixelcount = (int) m_boundingRect.width() - xstart;
        }
        
@@ -245,47 +243,10 @@
                return;
        }
        
-/*     When painting skips one pixel at a time, we always have to start
-       at an even position for 'sample' accurate painting */
+       bool microView = m_song->get_hzoom() > 
(Peak::MAX_ZOOM_USING_SOURCEFILE) ? 0 : 1;
        TimeRef clipstartoffset = m_clip->get_source_start_location();
-       int adjustforevenpixel = 0;
-       if (xstart % 2) {
-               xstart -= 1;
-               pixelcount += 1;
-       }
-
-       if ( (clipstartoffset.to_frame(44100) / 
Peak::zoomStep[m_song->get_hzoom()]) % 2) {
-               clipstartoffset -= m_sv->timeref_scalefactor;
-               adjustforevenpixel -= 1;
-       }
-       
-       // Painting seems to start 1 pixel too much to the left
-       // this 'fixes it, but I'd rather like a real fix :D
-       adjustforevenpixel++;
-       
        int channels = m_clip->get_channels();
        int peakdatacount = microView ? pixelcount : pixelcount * 2;
-       
-       if (m_pathCache.size() != channels) {
-               m_pathCache.clear();
-               for(int i=0; i<channels; ++i) {
-                       PainterPathCache* cache =  new PainterPathCache;
-                       cache->length = -1;
-                       cache->xstart = -1;
-                       m_pathCache.append(cache);
-               }
-       }
-       
-       bool validPathCache = false;
-       if (m_pathCache.first()->xstart == xstart && 
m_pathCache.first()->length == pixelcount) {
-               validPathCache = true;
-       } else {
-               m_pathCache.first()->xstart = xstart;
-               m_pathCache.first()->length = pixelcount;
-               m_pathCache.first()->path = QPainterPath();
-       }
-               
-       
        float* pixeldata[channels];
        float curveDefaultValue = 1.0;
        int mixcurvedata = 0;
@@ -296,19 +257,18 @@
                curveDefaultValue = curveView->get_default_value();
        }
        
-       if (!validPathCache || microView) {
                // Load peak data for all channels, if no peakdata is returned
                // for a certain Peak object, schedule it for loading.
                for (int chan=0; chan < channels; ++chan) {
                        
                        int availpeaks = peak->calculate_peaks( chan,
                                        &pixeldata[chan],
-                                       microView ? m_song->get_hzoom() : 
m_song->get_hzoom() + 1,
+                               m_song->get_hzoom(),
                                        TimeRef(xstart * 
m_sv->timeref_scalefactor) + clipstartoffset,
-                                       microView ? peakdatacount : 
peakdatacount / 2 + 2);
+                               peakdatacount);
                        
                        if (peakdatacount != availpeaks) {
-       //                      PWARN("peakdatacount != availpeaks (%d, %d)", 
peakdatacount, availpeaks);
+//                     PWARN("peakdatacount != availpeaks (%d, %d)", 
peakdatacount, availpeaks);
                        }
        
                        if (availpeaks == Peak::NO_PEAK_FILE) {
@@ -323,28 +283,28 @@
                                return;
                        }               
                        
-       //              pixelcount = std::min(pixelcount, availpeaks);
+//             pixelcount = std::min(pixelcount, availpeaks);
                }
                
                
                float curvemixdown[peakdatacount];
                if (mixcurvedata) {
-                       mixcurvedata |= curveView->get_vector(xstart + offset, 
pixelcount, curvemixdown);
+               mixcurvedata |= curveView->get_vector(xstart + offset, 
peakdatacount, curvemixdown);
                }
                
                for (int i = 0; i < m_fadeViews.size(); ++i) {
                        FadeView* view = m_fadeViews.at(i);
-                       float fademixdown[pixelcount];
+               float fademixdown[peakdatacount];
                        int fademix = 0;
                        
                        if (mixcurvedata) {
-                               fademix = view->get_vector(xstart, pixelcount, 
fademixdown);
+                       fademix = view->get_vector(xstart, peakdatacount, 
fademixdown);
                        } else {
-                               fademix = view->get_vector(xstart, pixelcount, 
curvemixdown);
+                       fademix = view->get_vector(xstart, peakdatacount, 
curvemixdown);
                        }
                        
                        if (mixcurvedata && fademix) {
-                               for (int j=0; j<pixelcount; ++j) {
+                       for (int j=0; j<peakdatacount; ++j) {
                                        curvemixdown[j] *= fademixdown[j];
                                }
                        }
@@ -382,22 +342,19 @@
                                curvemixdownpos = 0;
                                if (m_classicView) {
                                        for (int i = 0; i < (pixelcount*2); 
++i) {
+                                       pixeldata[chan][i++] *= 
curvemixdown[curvemixdownpos];
                                                pixeldata[chan][i] *= 
curvemixdown[curvemixdownpos];
-                                               i++;
-                                               pixeldata[chan][i] *= 
curvemixdown[curvemixdownpos];
-                                               curvemixdownpos += 2;
+                                       curvemixdownpos++;
                                        }
                                } else {
                                        for (int i = 0; i < pixelcount; i++) {
                                                pixeldata[chan][i] *= 
curvemixdown[curvemixdownpos];
-                                               curvemixdownpos += 2;
+                                       curvemixdownpos++;
                                        }
                                }
                        }
                }
        
-       }
-               
        
        for (int chan=0; chan < channels; chan++) {
                p->save();
@@ -498,8 +455,6 @@
                        }
                        
                        // we add one start/stop point so reserve some more...
-                       m_polygontop.clear();
-                       m_polygontop.reserve(pixelcount + 3);
                        int bufferpos = 0;
 
                        if (m_classicView) {
@@ -510,30 +465,51 @@
                                        ytrans = (height / 2) + (chan * height);
                                }
                        
-                               p->setMatrix(matrix().translate(xstart + 
adjustforevenpixel, ytrans).scale(1, scaleFactor), true);
+                               p->setMatrix(matrix().translate(xstart, 
ytrans).scale(1, scaleFactor), true);
                                
-                               if (!validPathCache) {
+                               if (m_paintWithOutline) {
                                        QPainterPath pathtop;
                                        QPainterPath pathbottom;
                                        
                                        m_polygonbottom.clear();
-                                       m_polygonbottom.reserve(pixelcount + 3);
+                                       m_polygontop.clear();
+                                       m_polygonbottom.reserve(pixelcount+2);
+                                       m_polygontop.reserve(pixelcount+2);
                                        
-                                       for (int x = 0; x < pixelcount; x+=2) {
-                                               m_polygontop.append( QPointF(x, 
-1 * pixeldata[chan][bufferpos++]) );
-                                               m_polygonbottom.append( 
QPointF(x, 1 * pixeldata[chan][bufferpos++]) );
+                                       m_polygontop.append(QPointF(0,0));
+                                       for (int x = 0; x < pixelcount; x++) {
+                                               m_polygontop.append( QPointF(x, 
- pixeldata[chan][bufferpos+=2]) );
                                        }
+                                       
m_polygontop.append(QPointF(pixelcount-1, 0));
+                                       
+                                       bufferpos += 1;
+                                       
+                                       
m_polygonbottom.append(QPointF(pixelcount-1, 0));
+                                       for (int x = pixelcount - 1; x >= 0; 
x--) {
+                                               m_polygonbottom.append( 
QPointF(x, pixeldata[chan][bufferpos-=2]) );
+                                       }
+                                       m_polygonbottom.append(QPointF(0, 0));
                                        
                                        pathtop.addPolygon(m_polygontop);
                                        pathbottom.addPolygon(m_polygonbottom);
-                                       
pathtop.connectPath(pathbottom.toReversed());
                                        
-                                       m_pathCache.at(chan)->path = pathtop;
+                                                       
+                                       // Using a pen means the polygon is 
drawn twice:
+                                       // one for the outline (pen) and one 
for the brush (fill)
+/*                                     if (m_dragging) {
+                                               p->setPen(Qt::NoPen);
+                                       }*/
+                                       
+                                       p->drawPath(pathtop);
+                                       p->drawPath(pathbottom);
+
                                } else {
-//                                     printf("using existing path for 
painting\n");
+                                       for (int x = 0; x < pixelcount; x++) {
+                                               int ytop = -1 * 
(int)(pixeldata[chan][bufferpos++]);
+                                               int ymin = 
(int)(pixeldata[chan][bufferpos++]);
+                                               p->drawLine(x, ytop, x, ymin);
+                                       }
                                }
-                               
-                               p->drawPath(m_pathCache.at(chan)->path);
                                
                                // Draw 'the' -INF line
                                p->setPen(minINFLineColor);
@@ -548,26 +524,29 @@
                                        scaleFactor *= channels;
                                }
 
-                               if (!validPathCache) {
+                               p->setMatrix(matrix().translate(xstart, 
ytrans).scale(1, scaleFactor), true);
+                               
+                               if (m_paintWithOutline) {
+                                       
                                        QPainterPath path;
+                                       m_polygontop.clear();
+                                       m_polygontop.reserve(pixelcount + 2);
                                        
-                                       for (int x=0; x<pixelcount; x+=2) {
-                                               m_polygontop.append( QPointF(x, 
scaleFactor * pixeldata[chan][bufferpos]) );
-                                               bufferpos++;
+                                       for (int x=0; x<pixelcount; x++) {
+                                               m_polygontop.append( QPointF(x, 
pixeldata[chan][bufferpos++]) );
                                        }
                                        
                                        m_polygontop.append(QPointF(pixelcount, 
0));
                                        path.addPolygon(m_polygontop);
                                        path.lineTo(0, 0);
                                        
-                                       m_pathCache.at(chan)->path = path;
+                                       p->drawPath(path);
+                               
                                } else {
-//                                     printf("using existing path for 
painting\n");
+                                       for (int x = 0; x < pixelcount; x++) {
+                                               p->drawLine(x, 0, x, 
int(pixeldata[chan][bufferpos++]));
+                                       }
                                }
-                               
-                               p->setMatrix(matrix().translate(xstart + 
adjustforevenpixel, ytrans), true);
-                               
-                               p->drawPath(m_pathCache.at(chan)->path);
                        }
                        
                }
@@ -896,7 +875,8 @@
        m_classicView = ! config().get_property("Themer", 
"paintaudiorectified", false).toBool();
        m_mergedView = config().get_property("Themer", 
"paintstereoaudioasmono", false).toBool();
        m_fillwave = themer()->get_property("AudioClip:fillwave", 1).toInt();
-       minINFLineColor = 
themer()->get_color("AudioClip:wavemicroview").dark(115);
+       minINFLineColor = themer()->get_color("AudioClip:channelseperator");
+       m_paintWithOutline = config().get_property("Themer", 
"paintwavewithoutline", true).toBool();
        calculate_bounding_rect();
 }
 

Index: traverso/songcanvas/AudioClipView.h
===================================================================
RCS file: /sources/traverso/traverso/src/traverso/songcanvas/AudioClipView.h,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -b -r1.36 -r1.37
--- traverso/songcanvas/AudioClipView.h 29 Dec 2007 02:03:37 -0000      1.36
+++ traverso/songcanvas/AudioClipView.h 7 Jan 2008 18:11:31 -0000       1.37
@@ -82,9 +82,11 @@
        PositionIndicator* m_posIndicator;
        QPolygonF m_polygonbottom;
        QPolygonF m_polygontop;
+       QPixmap m_background;
        
        struct PainterPathCache {
-               QPainterPath path;
+               QPainterPath pathtop;
+               QPainterPath pathbottom;
                int xstart;
                int length;
        };
@@ -100,6 +102,7 @@
        bool m_mergedView;
        bool m_classicView;
        bool m_dragging;
+       bool m_paintWithOutline;
        int m_height;
        int m_infoAreaHeight;
        int m_mimimumheightforinfoarea;




reply via email to

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