r14408 by fschmid - Replaced most of the QImage::Format_ARGB32 uses by QImage::Format_ARGB32_Premultiplied for performance reasons. See http://labs.trolltech.com/blogs/2009/12/14/qt-graphics-and-performance-whats-hot-and-whats-not/ for an explanaition why.

scribus-commit scribus-commit at lists.scribus.net
Mon Dec 14 16:31:19 CET 2009


Revision: 14408
Author: fschmid
Date: 2009-12-14T04:16:16.396615Z
Commit message: Replaced most of the QImage::Format_ARGB32 uses by QImage::Format_ARGB32_Premultiplied for performance reasons. See http://labs.trolltech.com/blogs/2009/12/14/qt-graphics-and-performance-whats-hot-and-whats-not/ for an explanaition why.

Changeset: 
M  /trunk/Scribus/scribus/scpainter.cpp
M  /trunk/Scribus/scribus/ui/arrowchooser.cpp
M  /trunk/Scribus/scribus/scribusXml.cpp
M  /trunk/Scribus/scribus/scprintengine_gdi.cpp
M  /trunk/Scribus/scribus/pageitem.cpp
M  /trunk/Scribus/scribus/ui/charzoom.cpp
M  /trunk/Scribus/scribus/ui/dasheditor.cpp
M  /trunk/Scribus/scribus/ui/extimageprops.cpp
M  /trunk/Scribus/scribus/ui/transparencypalette.cpp
M  /trunk/Scribus/scribus/scribusview.cpp
M  /trunk/Scribus/scribus/chartablemodel.cpp
M  /trunk/Scribus/scribus/scpreview.cpp
M  /trunk/Scribus/scribus/plugins/import/ai/importai.cpp
M  /trunk/Scribus/scribus/canvas.cpp
M  /trunk/Scribus/scribus/ui/gradientpreview.cpp
M  /trunk/Scribus/scribus/fonts/scfontmetrics.cpp
M  /trunk/Scribus/scribus/pageitem_pathtext.cpp
M  /trunk/Scribus/scribus/util.cpp
M  /trunk/Scribus/scribus/ui/colorchart.cpp
M  /trunk/Scribus/scribus/ui/cpalette.cpp
M  /trunk/Scribus/scribus/ui/autoformbuttongroup.cpp
M  /trunk/Scribus/scribus/stencilreader.cpp

Diffs:
Index: scribus/util.cpp
===================================================================
--- scribus/util.cpp	(revision 14407)
+++ scribus/util.cpp	(revision 14408)
@@ -451,7 +451,7 @@
 	double savScale = view->scale();
 	view->setScale(1.0);
 	currentDoc->RePos = true;
-	QImage pgPix(10, 10, QImage::Format_ARGB32);
+	QImage pgPix(10, 10, QImage::Format_ARGB32_Premultiplied);
 	QRect rd; // = QRect(0,0,9,9);
 	ScPainter *painter = new ScPainter(&pgPix, pgPix.width(), pgPix.height());
 	for (int azz=0; azz<currentDoc->MasterItems.count(); ++azz)
Index: scribus/chartablemodel.cpp
===================================================================
--- scribus/chartablemodel.cpp	(revision 14407)
+++ scribus/chartablemodel.cpp	(revision 14408)
@@ -70,7 +70,7 @@
 		int size = baseSize + qRound(-face.descent() * baseSize) + 1;
 		double ww = baseSize - face.glyphWidth(gl, baseSize);
 
-		QImage pix(baseSize, size, QImage::Format_ARGB32);
+		QImage pix(baseSize, size, QImage::Format_ARGB32_Premultiplied);
 		ScPainter *p = new ScPainter(&pix, baseSize, size);
 		p->clear();
 		FPointArray gly = face.glyphOutline(gl, 1);
Index: scribus/scprintengine_gdi.cpp
===================================================================
--- scribus/scprintengine_gdi.cpp	(revision 14407)
+++ scribus/scprintengine_gdi.cpp	(revision 14408)
@@ -160,7 +160,7 @@
 	// Setup image
 	imagew = clipw * scale;
 	imageh = cliph * scale;
-	*image = QImage( imagew, imageh, QImage::Format_ARGB32 );
+	*image = QImage( imagew, imageh, QImage::Format_ARGB32_Premultiplied );
 	if (image->width() <= 0 || image->height() <= 0)
 		return false;
 
Index: scribus/fonts/scfontmetrics.cpp
===================================================================
--- scribus/fonts/scfontmetrics.cpp	(revision 14407)
+++ scribus/fonts/scfontmetrics.cpp	(revision 14408)
@@ -250,7 +250,7 @@
 		w = s * (ts.length()+1);
 	if (h < 1)
 		h = s;
-	QImage pm(w, h, QImage::Format_ARGB32);
+	QImage pm(w, h, QImage::Format_ARGB32_Premultiplied);
 	pen_x = 0;
 	ymax = 0.0;
 	ScPainter *p = new ScPainter(&pm, pm.width(), pm.height());
Index: scribus/stencilreader.cpp
===================================================================
--- scribus/stencilreader.cpp	(revision 14407)
+++ scribus/stencilreader.cpp	(revision 14408)
@@ -1110,7 +1110,7 @@
 	GrW = ScCLocale::toDoubleC(dims.attribute("w"), 50.0) + 10;
 	GrH = ScCLocale::toDoubleC(dims.attribute("h"), 50.0) + 10;
 	pmmax = 60 / qMax(GrW, GrH);
-	tmp = QImage(static_cast<int>(GrW), static_cast<int>(GrH), QImage::Format_ARGB32);
+	tmp = QImage(static_cast<int>(GrW), static_cast<int>(GrH), QImage::Format_ARGB32_Premultiplied);
 	pS = new ScPainter(&tmp, tmp.width(), tmp.height());
 	pS->clear();
 	pS->translate(5, 5);
Index: scribus/scribusXml.cpp
===================================================================
--- scribus/scribusXml.cpp	(revision 14407)
+++ scribus/scribusXml.cpp	(revision 14408)
@@ -2114,7 +2114,7 @@
 	writer.writeAttribute("Version", QString(VERSION));
 
 	double scaleI = 50.0 / qMax(selectionWidth, selectionHeight);
-	QImage retImg = QImage(50, 50, QImage::Format_ARGB32);
+	QImage retImg = QImage(50, 50, QImage::Format_ARGB32_Premultiplied);
 	retImg.fill( qRgba(0, 0, 0, 0) );
 	ScPainter *painter = new ScPainter(&retImg, retImg.width(), retImg.height(), 1, 0);
 	painter->setZoomFactor(scaleI);
Index: scribus/canvas.cpp
===================================================================
--- scribus/canvas.cpp	(revision 14407)
+++ scribus/canvas.cpp	(revision 14408)
@@ -882,7 +882,7 @@
 // 	qDebug() << "Canvas::drawContents" << clipx << clipy << clipw << cliph<<m_viewMode.forceRedraw<<m_viewMode.operItemSelecting;
 	uint docPagesCount=m_doc->Pages->count();
 	ScPainter *painter=0;
-	QImage img = QImage(clipw, cliph, QImage::Format_ARGB32);
+	QImage img = QImage(clipw, cliph, QImage::Format_ARGB32_Premultiplied);
 	painter = new ScPainter(&img, img.width(), img.height(), 1.0, 0);
 	painter->clear(palette().color(QPalette::Window));
 	painter->newPath();
Index: scribus/pageitem_pathtext.cpp
===================================================================
--- scribus/pageitem_pathtext.cpp	(revision 14407)
+++ scribus/pageitem_pathtext.cpp	(revision 14408)
@@ -60,7 +60,7 @@
 
 void PageItem_PathText::layout()
 {
-	QImage pgPix(10, 10, QImage::Format_ARGB32);
+	QImage pgPix(10, 10, QImage::Format_ARGB32_Premultiplied);
 	QRectF rd; // = QRect(0,0,9,9);
 	ScPainter *painter = new ScPainter(&pgPix, pgPix.width(), pgPix.height());	
 	DrawObj(painter, rd);
Index: scribus/scpainter.cpp
===================================================================
--- scribus/scpainter.cpp	(revision 14407)
+++ scribus/scpainter.cpp	(revision 14408)
@@ -678,7 +678,7 @@
 				brushm = QBrush(*m_maskPattern->getPattern());
 				brushm.setTransform(qmatrix);
 			}
-			QImage tmpImgM = QImage(m_image->width(), m_image->height(), QImage::Format_ARGB32);
+			QImage tmpImgM = QImage(m_image->width(), m_image->height(), QImage::Format_ARGB32_Premultiplied);
 			QPainter painterM;
 			painterM.begin(&tmpImgM);
 			painterM.setWorldTransform(painter.worldTransform());
@@ -686,7 +686,7 @@
 			painterM.setRenderHint(QPainter::SmoothPixmapTransform, true);
 			painterM.fillPath(painter.clipPath(), brushm);
 			painterM.end();
-			QImage tmpImgO = QImage(m_image->width(), m_image->height(), QImage::Format_ARGB32);
+			QImage tmpImgO = QImage(m_image->width(), m_image->height(), QImage::Format_ARGB32_Premultiplied);
 			QPainter painterO;
 			painterO.begin(&tmpImgO);
 			painterO.setWorldTransform(painter.worldTransform());
@@ -1614,7 +1614,7 @@
 					brushm = QBrush(*m_maskPattern->getPattern());
 					brushm.setTransform(qmatrix);
 				}
-				QImage tmpImgM = QImage(m_image->width(), m_image->height(), QImage::Format_ARGB32);
+				QImage tmpImgM = QImage(m_image->width(), m_image->height(), QImage::Format_ARGB32_Premultiplied);
 				QPainter painterM;
 				painterM.begin(&tmpImgM);
 				painterM.setWorldTransform(painter.worldTransform());
@@ -1622,7 +1622,7 @@
 				painterM.setRenderHint(QPainter::SmoothPixmapTransform, true);
 				painterM.fillPath(m_path, brushm);
 				painterM.end();
-				QImage tmpImgO = QImage(m_image->width(), m_image->height(), QImage::Format_ARGB32);
+				QImage tmpImgO = QImage(m_image->width(), m_image->height(), QImage::Format_ARGB32_Premultiplied);
 				QPainter painterO;
 				painterO.begin(&tmpImgO);
 				painterO.setWorldTransform(painter.worldTransform());
@@ -1769,7 +1769,7 @@
 					brushm = QBrush(*m_maskPattern->getPattern());
 					brushm.setTransform(qmatrix);
 				}
-				QImage tmpImgM = QImage(m_image->width(), m_image->height(), QImage::Format_ARGB32);
+				QImage tmpImgM = QImage(m_image->width(), m_image->height(), QImage::Format_ARGB32_Premultiplied);
 				QPainter painterM;
 				painterM.begin(&tmpImgM);
 				painterM.setWorldTransform(painter.worldTransform());
@@ -1777,7 +1777,7 @@
 				painterM.setRenderHint(QPainter::SmoothPixmapTransform, true);
 				painterM.fillPath(m_path, brushm);
 				painterM.end();
-				QImage tmpImgO = QImage(m_image->width(), m_image->height(), QImage::Format_ARGB32);
+				QImage tmpImgO = QImage(m_image->width(), m_image->height(), QImage::Format_ARGB32_Premultiplied);
 				QPainter painterO;
 				painterO.begin(&tmpImgO);
 				painterO.setWorldTransform(painter.worldTransform());
@@ -1890,7 +1890,7 @@
 					brushm = QBrush(*m_maskPattern->getPattern());
 					brush.setTransform(qmatrix);
 				}
-				QImage tmpImgM = QImage(m_image->width(), m_image->height(), QImage::Format_ARGB32);
+				QImage tmpImgM = QImage(m_image->width(), m_image->height(), QImage::Format_ARGB32_Premultiplied);
 				QPainter painterM;
 				painterM.begin(&tmpImgM);
 				painterM.setWorldTransform(painter.worldTransform());
@@ -1898,7 +1898,7 @@
 				painterM.setRenderHint(QPainter::SmoothPixmapTransform, true);
 				painterM.fillPath(m_path, brushm);
 				painterM.end();
-				QImage tmpImgO = QImage(m_image->width(), m_image->height(), QImage::Format_ARGB32);
+				QImage tmpImgO = QImage(m_image->width(), m_image->height(), QImage::Format_ARGB32_Premultiplied);
 				QPainter painterO;
 				painterO.begin(&tmpImgO);
 				painterO.setWorldTransform(painter.worldTransform());
@@ -2167,7 +2167,7 @@
 			qmatrix.shear(-mask_gradientSkew, 0);
 			qmatrix.translate(-x1, -y1);
 		}
-		QImage tmpImgM = QImage(m_image->width(), m_image->height(), QImage::Format_ARGB32);
+		QImage tmpImgM = QImage(m_image->width(), m_image->height(), QImage::Format_ARGB32_Premultiplied);
 		QPainter painterM;
 		painterM.begin(&tmpImgM);
 		painterM.setWorldTransform(painter.worldTransform());
@@ -2177,7 +2177,7 @@
 		brushm.setTransform(qmatrix);
 		painterM.fillPath(painter.clipPath(), brushm);
 		painterM.end();
-		QImage tmpImgO = QImage(m_image->width(), m_image->height(), QImage::Format_ARGB32);
+		QImage tmpImgO = QImage(m_image->width(), m_image->height(), QImage::Format_ARGB32_Premultiplied);
 		QPainter painterO;
 		painterO.begin(&tmpImgO);
 		painterO.setWorldTransform(painter.worldTransform());
Index: scribus/pageitem.cpp
===================================================================
--- scribus/pageitem.cpp	(revision 14407)
+++ scribus/pageitem.cpp	(revision 14408)
@@ -1911,7 +1911,7 @@
 
 QImage PageItem::DrawObj_toImage(QList<PageItem*> &emG)
 {
-	QImage retImg = QImage(qRound(gWidth), qRound(gHeight), QImage::Format_ARGB32);
+	QImage retImg = QImage(qRound(gWidth), qRound(gHeight), QImage::Format_ARGB32_Premultiplied);
 //	retImg.fill( qRgba(255, 255, 255, 0) );
 	retImg.fill( qRgba(0, 0, 0, 0) );
 	ScPainter *painter = new ScPainter(&retImg, retImg.width(), retImg.height(), 1, 0);
Index: scribus/scribusview.cpp
===================================================================
--- scribus/scribusview.cpp	(revision 14407)
+++ scribus/scribusview.cpp	(revision 14408)
@@ -2939,7 +2939,7 @@
 		setScale(1.0);
 		m_canvas->m_viewMode.previewMode = true;
 		m_canvas->m_viewMode.forceRedraw = true;
-		pm = QImage(clipw, cliph, QImage::Format_ARGB32);
+		pm = QImage(clipw, cliph, QImage::Format_ARGB32_Premultiplied);
 		ScPainter *painter = new ScPainter(&pm, pm.width(), pm.height(), 1.0, 0);
 		painter->clear(Doc->papColor);
 		painter->translate(-clipx, -clipy);
@@ -2991,7 +2991,7 @@
 	int cliph = qRound(Doc->DocPages.at(Nr)->height() * sc);
 	if ((clipw > 0) && (cliph > 0))
 	{
-		im = QImage(clipw, cliph, QImage::Format_ARGB32);
+		im = QImage(clipw, cliph, QImage::Format_ARGB32_Premultiplied);
 		if (!im.isNull())
 		{
 			double oldScale = m_canvas->scale();
Index: scribus/ui/cpalette.cpp
===================================================================
--- scribus/ui/cpalette.cpp	(revision 14407)
+++ scribus/ui/cpalette.cpp	(revision 14408)
@@ -332,7 +332,7 @@
 	namedGradientStroke->addItem( tr("Custom"));
 	for (QMap<QString, VGradient>::Iterator it = gradientList->begin(); it != gradientList->end(); ++it)
 	{
-		QImage pixm(48, 12, QImage::Format_ARGB32);
+		QImage pixm(48, 12, QImage::Format_ARGB32_Premultiplied);
 		QPainter pb;
 		QBrush b(QColor(205,205,205), loadIcon("testfill.png"));
 		pb.begin(&pixm);
Index: scribus/ui/colorchart.cpp
===================================================================
--- scribus/ui/colorchart.cpp	(revision 14407)
+++ scribus/ui/colorchart.cpp	(revision 14408)
@@ -59,7 +59,7 @@
 	QPainter p2;
 	p.begin(this);
 	p.setClipRect(e->rect());
-	QImage tmp = QImage(width(), height(), QImage::Format_ARGB32);
+	QImage tmp = QImage(width(), height(), QImage::Format_ARGB32_Premultiplied);
 	p2.begin(&tmp);
 	p2.drawPixmap(0, 0, pmx);
 	if (doDrawMark)
@@ -93,7 +93,7 @@
 {
 	int xSize = width();
 	int ySize = height();
-	QImage image(xSize, ySize, QImage::Format_ARGB32);
+	QImage image(xSize, ySize, QImage::Format_ARGB32_Premultiplied);
 	QColor color;
 	int x;
 	int y;
Index: scribus/ui/arrowchooser.cpp
===================================================================
--- scribus/ui/arrowchooser.cpp	(revision 14407)
+++ scribus/ui/arrowchooser.cpp	(revision 14408)
@@ -35,9 +35,10 @@
 	addItem(CommonStrings::tr_None);
 	for (int a = 0; a < arrowStyles->count(); ++a)
 	{
-		QImage image(22, 22, QImage::Format_ARGB32);
+		QImage image(22, 22, QImage::Format_ARGB32_Premultiplied);
+		image.fill(0);
 		ScPainter *painter = new ScPainter(&image, 22, 22);
-		painter->clear();
+//		painter->clear();
 		painter->setBrush(qRgb(0, 0, 0));
 		painter->setPen(qRgb(0, 0, 0));
 		painter->setFillMode(1);
@@ -62,7 +63,7 @@
 		painter->drawPolyLine();
 		painter->end();
 		delete painter;
-		int wi = image.width();
+/*		int wi = image.width();
 		int hi = image.height();
     	for( int yi=0; yi < hi; ++yi )
 		{
@@ -73,7 +74,7 @@
 					(*s) &= 0x00ffffff;
 				s++;
 			}
-    	}
+    	} */
     	QPixmap Ico;
 		Ico=QPixmap::fromImage(image);
 		addItem(Ico, arrowStyles->at(a).name);
Index: scribus/ui/dasheditor.cpp
===================================================================
--- scribus/ui/dasheditor.cpp	(revision 14407)
+++ scribus/ui/dasheditor.cpp	(revision 14408)
@@ -60,7 +60,7 @@
 	if (onlyselect)
 		StopM.clear();
 	int pWidth = width()-20;
-	QImage pixm(pWidth, 10, QImage::Format_ARGB32);
+	QImage pixm(pWidth, 10, QImage::Format_ARGB32_Premultiplied);
 	ScPainter *p = new ScPainter(&pixm, pWidth, 10);
 	p->clear(QColor(128, 128, 128));
 	double startX = 0.0;
Index: scribus/ui/extimageprops.cpp
===================================================================
--- scribus/ui/extimageprops.cpp	(revision 14407)
+++ scribus/ui/extimageprops.cpp	(revision 14408)
@@ -225,7 +225,7 @@
 	{
 		for (it = info->PDSpathData.begin(); it != info->PDSpathData.end(); ++it)
 		{
-			QImage pixm(40, 40, QImage::Format_ARGB32);
+			QImage pixm(40, 40, QImage::Format_ARGB32_Premultiplied);
 			ScPainter *p = new ScPainter(&pixm, 40, 40);
 			p->clear();
 			p->translate(3.0, 3.0);
Index: scribus/ui/gradientpreview.cpp
===================================================================
--- scribus/ui/gradientpreview.cpp	(revision 14407)
+++ scribus/ui/gradientpreview.cpp	(revision 14408)
@@ -81,7 +81,7 @@
 		int center = qRound(cstops.at(a)->rampPoint * (width()-20))+10;
 		StopM.append(center);
 	}
-	QImage pixm(width()-20, 37, QImage::Format_ARGB32);
+	QImage pixm(width()-20, 37, QImage::Format_ARGB32_Premultiplied);
 	QPainter pb;
 	QBrush b(QColor(205,205,205), loadIcon("testfill.png"));
 	pb.begin(&pixm);
Index: scribus/ui/autoformbuttongroup.cpp
===================================================================
--- scribus/ui/autoformbuttongroup.cpp	(revision 14407)
+++ scribus/ui/autoformbuttongroup.cpp	(revision 14408)
@@ -1231,7 +1231,7 @@
 			}
 		}
 	}
-	QImage Ico(32, 32, QImage::Format_ARGB32);
+	QImage Ico(32, 32, QImage::Format_ARGB32_Premultiplied);
 	Ico.fill(0);
 	int count = 0;
 	qreal* AutoShapes;
Index: scribus/ui/transparencypalette.cpp
===================================================================
--- scribus/ui/transparencypalette.cpp	(revision 14407)
+++ scribus/ui/transparencypalette.cpp	(revision 14408)
@@ -141,7 +141,7 @@
 	namedGradient->addItem( tr("Custom"));
 	for (QMap<QString, VGradient>::Iterator it = gradientList->begin(); it != gradientList->end(); ++it)
 	{
-		QImage pixm(48, 12, QImage::Format_ARGB32);
+		QImage pixm(48, 12, QImage::Format_ARGB32_Premultiplied);
 		QPainter pb;
 		QBrush b(QColor(205,205,205), loadIcon("testfill.png"));
 		pb.begin(&pixm);
Index: scribus/ui/charzoom.cpp
===================================================================
--- scribus/ui/charzoom.cpp	(revision 14407)
+++ scribus/ui/charzoom.cpp	(revision 14408)
@@ -21,7 +21,7 @@
 	setMaximumSize(sizex, sizey);
 	
 	pixm = QPixmap(size, size);
-	QImage pix(size, size, QImage::Format_ARGB32);
+	QImage pix(size, size, QImage::Format_ARGB32_Premultiplied);
 	ScPainter *p = new ScPainter(&pix, size, size);
 	p->clear();
 	pixm.fill(Qt::white);
Index: scribus/plugins/import/ai/importai.cpp
===================================================================
--- scribus/plugins/import/ai/importai.cpp	(revision 14407)
+++ scribus/plugins/import/ai/importai.cpp	(revision 14408)
@@ -2118,7 +2118,7 @@
 					currItem->AutoName = false;
 					m_Doc->DoDrawing = true;
 					QImage tmpImg = currItem->DrawObj_toImage();
-					QImage retImg = QImage(qRound(patternX2 - patternX1), qRound(patternY2 - patternY1), QImage::Format_ARGB32);
+					QImage retImg = QImage(qRound(patternX2 - patternX1), qRound(patternY2 - patternY1), QImage::Format_ARGB32_Premultiplied);
 					retImg.fill( qRgba(255, 255, 255, 0) );
 					QPainter p;
 					p.begin(&retImg);
Index: scribus/scpreview.cpp
===================================================================
--- scribus/scpreview.cpp	(revision 14407)
+++ scribus/scpreview.cpp	(revision 14408)
@@ -93,7 +93,7 @@
 	double GrW = ScCLocale::toDoubleC(elem.attribute("W"));
 	double GrH = ScCLocale::toDoubleC(elem.attribute("H"));
 	double pmmax = 60 / qMax(GrW+50, GrH+50);
-	QImage tmp = QImage(static_cast<int>(GrW)+50, static_cast<int>(GrH)+50, QImage::Format_ARGB32);
+	QImage tmp = QImage(static_cast<int>(GrW)+50, static_cast<int>(GrH)+50, QImage::Format_ARGB32_Premultiplied);
 	tmp.fill( qRgba(255, 255, 255, 0) );
 	ScPainter *pS = new ScPainter(&tmp, tmp.width(), tmp.height(), 1.0, 0);
 	pS->beginLayer(1.0, 0);




More information about the scribus-commit mailing list