[Kstars-devel] KDE/kdeedu/kstars/kstars
Jason Harris
kstars at 30doradus.org
Mon Jun 12 02:02:46 CEST 2006
SVN commit 550495 by harris:
FIxing an unnecessary bottleneck in the draw loop: I had been converting
the sky QPixmap to a QImage before calling drawImage() to render it on
the SkyMap widget. However, this conversion takes over 0.1 sec, so now
I simply call drawPixmap() instead.
Between this change and making antialiasing optional, KStars should feel
much "snappier" now.
The time elapsed for the drawing code is still about a factor of two
longer than it was under 3.5, but we're getting there. I added detailed
feedback messages for timing the various draw functions, but they are
commented out. If you want to enable them, look for "TIMING" labels in
the two files modified by this commit, and uncomment the relevant lines.
CCMAIL: kstars-devel at kde.org
M +38 -1 skycomponents/skymapcomposite.cpp
M +23 -4 skymapevents.cpp
--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/skymapcomposite.cpp #550494:550495
@@ -124,35 +124,72 @@
//should appear "behind" others should be drawn first.
void SkyMapComposite::draw(KStars *ks, QPainter& psky, double scale)
{
+ //TIMING
+// QTime t;
//1. Milky Way
+// t.start();
m_MilkyWay->draw( ks, psky, scale );
+// kDebug() << QString("Milky Way : %1 ms").arg( t.elapsed() ) << endl;
+
//2. Coordinate grid
+// t.start();
m_CoordinateGrid->draw( ks, psky, scale );
+// kDebug() << QString("Coord grid : %1 ms").arg( t.elapsed() ) << endl;
+
//3. Constellation boundaries
+// t.start();
m_CBounds->draw( ks, psky, scale );
+// kDebug() << QString("Cons Bound : %1 ms").arg( t.elapsed() ) << endl;
+
//4. Constellation lines
+// t.start();
m_CLines->draw( ks, psky, scale );
+// kDebug() << QString("Cons Lines : %1 ms").arg( t.elapsed() ) << endl;
+
//5. Constellation names
+// t.start();
m_CNames->draw( ks, psky, scale );
+// kDebug() << QString("Cons Names : %1 ms").arg( t.elapsed() ) << endl;
+
//6. Equator
+// t.start();
m_Equator->draw( ks, psky, scale );
+// kDebug() << QString("Equator : %1 ms").arg( t.elapsed() ) << endl;
+
//7. Ecliptic
+// t.start();
m_Ecliptic->draw( ks, psky, scale );
+// kDebug() << QString("Ecliptic : %1 ms").arg( t.elapsed() ) << endl;
+
//8. Deep sky
+// t.start();
m_DeepSky->draw( ks, psky, scale );
+// kDebug() << QString("Deep sky : %1 ms").arg( t.elapsed() ) << endl;
+
//9. Custom catalogs
+// t.start();
m_CustomCatalogs->draw( ks, psky, scale );
+// kDebug() << QString("Custom cat : %1 ms").arg( t.elapsed() ) << endl;
+
//10. Stars
+// t.start();
m_Stars->draw( ks, psky, scale );
+// kDebug() << QString("Stars : %1 ms").arg( t.elapsed() ) << endl;
+
//11. Solar system
+// t.start();
m_SolarSystem->draw( ks, psky, scale );
+// kDebug() << QString("Solar sys : %1 ms").arg( t.elapsed() ) << endl;
//Draw object name labels
+// t.start();
ks->map()->drawObjectLabels( labelObjects(), psky, scale );
+// kDebug() << QString("Name labels : %1 ms").arg( t.elapsed() ) << endl;
//13. Horizon (and ground)
+// t.start();
m_Horizon->draw( ks, psky, scale );
-
+// kDebug() << QString("Horizon : %1 ms").arg( t.elapsed() ) << endl;
}
//Select nearest object to the given skypoint, but give preference
--- trunk/KDE/kdeedu/kstars/kstars/skymapevents.cpp #550494:550495
@@ -687,8 +687,8 @@
}
//TIMING
- QTime t;
- t.start();
+// QTime t;
+// t.start();
QPainter psky;
setMapGeometry();
@@ -713,23 +713,42 @@
psky.fillRect( 0, 0, width(), height(), QBrush( data->colorScheme()->colorNamed( "SkyColor" ) ) );
+ //TIMING
+// QTime t2;
+// t2.start();
+
//Draw all sky elements
data->skyComposite()->draw( ks, psky );
+ //TIMING
+// kDebug() << QString("SkyMapComposite::draw() took %1 ms").arg(t2.elapsed()) << endl;
+
//Finish up
psky.end();
+ //TIMING
+// t2.start();
+
*sky2 = *sky;
drawOverlays( sky2 );
+ //TIMING
+// kDebug() << QString("drawOverlays() took %1 ms").arg(t2.elapsed()) << endl;
+
+ //TIMING
+// t2.start();
+
QPainter psky2;
psky2.begin( this );
- psky2.drawImage( 0, 0, sky2->toImage() );
+ psky2.drawPixmap( 0, 0, *sky2 );
psky2.end();
+ //TIMING
+// kDebug() << QString("drawImage() took %1 ms").arg(t2.elapsed()) << endl;
+
computeSkymap = false; // use forceUpdate() to compute new skymap else old pixmap will be shown
//TIMING
- kDebug() << QString("Skymap draw took %1 ms").arg(t.elapsed()) << endl;
+// kDebug() << QString("Skymap draw took %1 ms").arg(t.elapsed()) << endl;
}
More information about the Kstars-devel
mailing list