update only the stars - cuts CPU useage in half on my machine
authornemo
Sun, 17 May 2009 00:44:30 +0000
changeset 2069 f7fad4ad4455
parent 2068 9d683de175d7
child 2070 28891bb36ba5
update only the stars - cuts CPU useage in half on my machine
QTfrontend/bgwidget.cpp
--- a/QTfrontend/bgwidget.cpp	Sat May 16 20:54:43 2009 +0000
+++ b/QTfrontend/bgwidget.cpp	Sun May 17 00:44:30 2009 +0000
@@ -80,13 +80,12 @@
 
 		QPainter p;
 		p.begin(rotatedSprites[i]);
-		p.setRenderHint(QPainter::Antialiasing);
+	//	p.setRenderHint(QPainter::Antialiasing);
 		p.setRenderHint(QPainter::SmoothPixmapTransform);
 		p.translate(translate.x(), translate.y());
 		p.rotate(i);
 		p.translate(-1*translate.x(), -1*translate.y());
 		p.drawImage(0, 0, sprite);
-
 	}
 
 	timerAnimation = new QTimer();
@@ -116,9 +115,10 @@
 
 void BGWidget::animate()
 {
-	repaint();
 	for (int i = 0; i < SPRITE_MAX; i++)
 	{
+        // bottom edge of star *seems* clipped, but in fact, if I switch to just plain old repaint()/update() it is still clipped - artifact of transform?  As for 5, is arbitrary number. 4 was noticeably clipping, 5 seemed same as update() - I assume extra room is due to rotation and value really should be calculated proportional to width/height
+        update(spritePositions[i]->pos().x(),spritePositions[i]->pos().y(), sprite.width()+5, sprite.height()+5);
 		spritePositions[i]->move();
 	}
 }