[Kst] extragear/graphics/kst/kst
George Staikos
staikos at kde.org
Wed Oct 26 06:35:04 CEST 2005
SVN commit 474335 by staikos:
some debug cleanup and add a couple flush() which reduce the draw time a bit
M +31 -32 kst2dplot.cpp
--- trunk/extragear/graphics/kst/kst/kst2dplot.cpp #474334:474335
@@ -1851,7 +1851,6 @@
double xtick_len_px, ytick_len_px;
int x_px, y_px;
-
// resize labels based on window size.
x_px = geometry().width();
y_px = geometry().height();
@@ -2285,26 +2284,24 @@
double Lx, Hx, Ly, Hy;
double m_X, m_Y, b_X, b_Y;
bool offsetX, offsetY;
- int x_px, y_px;
- int penWidth;
#ifdef BENCHMARK
++KstDebug::self()->drawCounter()[tagName()];
kstdDebug() << ">>>>>>>>>>>>>>>>>>>> DRAWING PLOT " << tagName() << endl;
- QTime bench_time;
- int i_bt=0, bt[15];
+ QTime benchTime;
+ int i_bt = 0, bt[15];
QString bt_label[15];
-
- bench_time.start();
+ benchTime.start();
#endif
- p.setWindow(0, 0, (int)(p.viewport().width() * resolutionEnhancement),
- (int)(p.viewport().height() * resolutionEnhancement));
+ p.setWindow(0, 0, int(p.viewport().width() * resolutionEnhancement),
+ int(p.viewport().height() * resolutionEnhancement));
- x_px = p.window().width();
- y_px = p.window().height();
+ QRect winRect = p.window();
+ int x_px = winRect.width();
+ int y_px = winRect.height();
- if (resolutionEnhancement>1) {
+ if (resolutionEnhancement > 1) {
// if we have boosted resolution for printing, reset the font sizes....
_xLabel->updateAbsFontSize(x_px, y_px);
_yLabel->updateAbsFontSize(x_px, y_px);
@@ -2320,9 +2317,9 @@
}
getLScale(x_min, y_min, x_max, y_max);
- p.fillRect(0, 0, p.window().width(), p.window().height(), _backgroundColor);
+ p.fillRect(0, 0, winRect.width(), winRect.height(), _backgroundColor);
- penWidth = x_px / 999;
+ int penWidth = x_px / 999;
if (penWidth == 1) {
penWidth = 0;
}
@@ -2332,6 +2329,7 @@
setBorders(xleft_bdr_px, xright_bdr_px, ytop_bdr_px, ybot_bdr_px,
tpx, tpy, p, offsetX, offsetY, xtick_len_px, ytick_len_px);
+ p.flush();
// use a common plot region for plots that are aligned and of the same
// dimension, in either the horizontal or vertical sense...
@@ -2389,12 +2387,13 @@
#ifdef BENCHMARK
bt_label[i_bt] = "Initialization";
- bt[i_bt++] = bench_time.elapsed();
+ bt[i_bt++] = benchTime.elapsed();
#endif
plotLabels(p, x_px, y_px, xleft_bdr_px, ytop_bdr_px);
+ p.flush();
#ifdef BENCHMARK
bt_label[i_bt] = "Plot Labels";
- bt[i_bt++] = bench_time.elapsed();
+ bt[i_bt++] = benchTime.elapsed();
#endif
// plot the legend now if its in the background
@@ -2403,8 +2402,8 @@
d2i(xleft_bdr_px + double(RelPlotRegion.width()) * Legend->x()),
d2i(ytop_bdr_px + double(RelPlotRegion.height()) * Legend->y()));
#ifdef BENCHMARK
- bt_label[i_bt] = "plot Legend";
- bt[i_bt++] = bench_time.elapsed();
+ bt_label[i_bt] = "Plot Legend";
+ bt[i_bt++] = benchTime.elapsed();
#endif
}
@@ -2418,6 +2417,7 @@
}
// create the context
KstCurveRenderContext context;
+ // FIXME: someone document what these things mean
context.p = &p;
context.Lx = Lx;
context.Hx = Hx;
@@ -2454,7 +2454,7 @@
}
#ifdef BENCHMARK
bt_label[i_bt] = "Plot Curves";
- bt[i_bt++] = bench_time.elapsed();
+ bt[i_bt++] = benchTime.elapsed();
#endif
// must plot grid lines before axes
plotGridLines(p, tpx.tick, xleft_bdr_px, xright_bdr_px, x_orig_px, xtick_px,
@@ -2463,7 +2463,7 @@
#ifdef BENCHMARK
bt_label[i_bt] = "Plot Grid Lines";
- bt[i_bt++] = bench_time.elapsed();
+ bt[i_bt++] = benchTime.elapsed();
#endif
p.setPen(QPen(_foregroundColor, penWidth));
plotAxes(p, RelPlotRegion,
@@ -2471,8 +2471,8 @@
tpy, ytop_bdr_px, ybot_bdr_px, y_orig_px, ytick_px, ytick_len_px, y_px,
offsetX, offsetY);
#ifdef BENCHMARK
- bt_label[i_bt] = "plot Axes";
- bt[i_bt++] = bench_time.elapsed();
+ bt_label[i_bt] = "Plot Axes";
+ bt[i_bt++] = benchTime.elapsed();
#endif
if (_xReversed) {
p.scale(-1,1);
@@ -2484,8 +2484,8 @@
p.translate(d2i(-1 * Hx - Lx), 0);
}
#ifdef BENCHMARK
- bt_label[i_bt] = "plot Markers";
- bt[i_bt++] = bench_time.elapsed();
+ bt_label[i_bt] = "Plot Markers";
+ bt[i_bt++] = benchTime.elapsed();
#endif
// plot the legend now if its in the foreground
if (Legend->front()) {
@@ -2493,26 +2493,25 @@
d2i(xleft_bdr_px + double(RelPlotRegion.width()) * Legend->x()),
d2i(ytop_bdr_px + double(RelPlotRegion.height()) * Legend->y()));
#ifdef BENCHMARK
- bt_label[i_bt] = "plot Legend";
- bt[i_bt++] = bench_time.elapsed();
+ bt_label[i_bt] = "Plot Legend";
+ bt[i_bt++] = benchTime.elapsed();
#endif
}
#ifdef BENCHMARK
- bt_label[i_bt] = "plot arbitrary Labels";
- bt[i_bt++] = bench_time.elapsed();
+ bt_label[i_bt] = "Plot arbitrary Labels";
+ bt[i_bt++] = benchTime.elapsed();
#endif
p.flush();
#ifdef BENCHMARK
bt_label[i_bt] = "Flush Painter";
- bt[i_bt++] = bench_time.elapsed();
+ bt[i_bt++] = benchTime.elapsed();
- int j;
kstdDebug() << "Plot Benchmark stats:" << endl;
kstdDebug() << " " << bt_label[0] << ": " << bt[0] << "ms" << endl;
- for (j=1; j<i_bt; j++) {
+ for (int j = 1; j < i_bt; ++j) {
kstdDebug() << " " << bt_label[j] << ": " << bt[j]-bt[j-1] << "ms" << endl;
}
kstdDebug() << "Plot Total: " << bt[i_bt-1] << "ms" << endl;
@@ -2520,7 +2519,7 @@
} else {
// if the plot is too small to draw then denote this with a cross pattern
p.fillRect(RelWinRegion, QBrush(foregroundColor(), Qt::DiagCrossPattern));
- p.drawRect(RelWinRegion );
+ p.drawRect(RelWinRegion);
}
p.setWindow(old_window);
More information about the Kst
mailing list