[Kst] branches/work/kst/portto4/kst/src
Adam Treat
treat at kde.org
Wed Oct 3 00:28:31 CEST 2007
SVN commit 720290 by treat:
* Debug and fixup the curve drawing. I *think*
we are comparable to the performance in 1.4.x now.
Doubtless more bugs, but still...
M +1 -1 libkstapp/plotrenderitem.cpp
M +6 -6 libkstapp/vectorcurverenderitem.cpp
M +26 -0 libkstmath/kstvcurve.cpp
--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitem.cpp #720289:720290
@@ -15,7 +15,7 @@
#include "plotitem.h"
-//#define CURVE_DRAWING_TIME
+// #define CURVE_DRAWING_TIME
namespace Kst {
--- branches/work/kst/portto4/kst/src/libkstapp/vectorcurverenderitem.cpp #720289:720290
@@ -47,13 +47,12 @@
KstCurveRenderContext context;
context.painter = painter;
- context.window = QRect();//plotRect().toRect(); //no idea if this should be floating point
+ context.window = QRect(); //no idea if this should be floating point
+ context.penWidth = 1.0;
//FIXME rename these methods in kstvcurve
- QRectF vectorRect(relation->minX(),
- relation->minY(),
- relation->maxX(),
- relation->maxY());
+ QRectF vectorRect(QPointF(relation->minX(), relation->minY()),
+ QPointF(relation->maxX(), relation->maxY()));
QTransform t;
qreal scaleFactor = 1.0;
@@ -82,7 +81,7 @@
context.Hy = plotRect().bottom();
//To convert between the last two...
- double m_X = double(plotRect().width()-1)/(context.XMax - context.XMin);
+ double m_X = double(plotRect().width()-1)/(context.XMax - context.XMin);
double m_Y = -double(plotRect().height()-1)/(context.YMax - context.YMin);
double b_X = context.Lx - m_X * context.XMin;
double b_Y = context.Ly - m_Y * context.YMax;
@@ -93,6 +92,7 @@
context.b_Y = b_Y;
painter->save();
+ painter->setRenderHint(QPainter::Antialiasing, false);
relation->paint(context);
painter->restore();
}
--- branches/work/kst/portto4/kst/src/libkstmath/kstvcurve.cpp #720289:720290
@@ -879,6 +879,7 @@
int b_1 = 0, b_2 = 0, b_3 = 0, b_4 = 0;
bench_time.start();
benchtmp.start();
+ int numberOfLinesDrawn = 0;
#endif
int pointDim = KstCurvePointSymbol::dim(context.window);
@@ -978,6 +979,9 @@
#ifdef DEBUG_VECTOR_CURVE
qDebug() << __LINE__ << "drawPolyline" << poly << endl;
#endif
+#ifdef BENCHMARK
+ ++numberOfLinesDrawn;
+#endif
p->drawPolyline(poly);
}
index = 0;
@@ -991,6 +995,9 @@
#ifdef DEBUG_VECTOR_CURVE
qDebug() << __LINE__ << "drawLine" << QLine(d2i(X2), d2i(minY), d2i(X2), d2i(maxY)) << endl;
#endif
+#ifdef BENCHMARK
+ ++numberOfLinesDrawn;
+#endif
p->drawLine(d2i(X2), d2i(minY), d2i(X2), d2i(maxY));
}
}
@@ -1044,6 +1051,9 @@
#ifdef DEBUG_VECTOR_CURVE
qDebug() << __LINE__ << "drawPolyline" << poly << endl;
#endif
+#ifdef BENCHMARK
+ ++numberOfLinesDrawn;
+#endif
p->drawPolyline(poly);
index = 0;
}
@@ -1093,12 +1103,18 @@
#ifdef DEBUG_VECTOR_CURVE
qDebug() << __LINE__ << "drawPolyline" << poly << endl;
#endif
+#ifdef BENCHMARK
+ ++numberOfLinesDrawn;
+#endif
p->drawPolyline(poly);
index = 0;
}
#ifdef DEBUG_VECTOR_CURVE
qDebug() << __LINE__ << "drawLine" << QLine(X2i, d2i(minY), X2i, d2i(maxY)) << endl;
#endif
+#ifdef BENCHMARK
+ ++numberOfLinesDrawn;
+#endif
p->drawLine(X2i, d2i(minY), X2i, d2i(maxY));
}
}
@@ -1229,6 +1245,9 @@
#ifdef DEBUG_VECTOR_CURVE
qDebug() << __LINE__ << "drawPolyline" << poly << endl;
#endif
+#ifdef BENCHMARK
+ ++numberOfLinesDrawn;
+#endif
p->drawPolyline(poly);
}
index = 0;
@@ -1253,6 +1272,9 @@
#ifdef DEBUG_VECTOR_CURVE
qDebug() << __LINE__ << "drawPolyline" << poly << endl;
#endif
+#ifdef BENCHMARK
+ ++numberOfLinesDrawn;
+#endif
p->drawPolyline(poly);
index = 0;
}
@@ -1270,6 +1292,9 @@
#ifdef DEBUG_VECTOR_CURVE
qDebug() << __LINE__ << "drawLine" << QLine(d2i(X2), d2i(minY), d2i(X2), d2i(maxY)) << endl;
#endif
+#ifdef BENCHMARK
+ ++numberOfLinesDrawn;
+#endif
p->drawLine(d2i(X2), d2i(minY), d2i(X2), d2i(maxY));
}
}
@@ -1662,6 +1687,7 @@
int i = bench_time.elapsed();
qDebug() << "Plotting curve " << (void *)this << ": " << i << "ms" << endl;
qDebug() << " Without locks: " << b_4 << "ms" << endl;
+ qDebug() << " Nnumber of lines drawn:" << numberOfLinesDrawn << endl;
if (b_1 > 0) qDebug() << " Lines: " << b_1 << "ms" << endl;
if (b_2 - b_1 > 0) qDebug() << " Bars: " << (b_2 - b_1) << "ms" << endl;
if (b_3 - b_2 > 0) qDebug() << " Points: " << (b_3 - b_2) << "ms" << endl;
More information about the Kst
mailing list