src/gui/painting/qdrawutil.cpp
branchGCC_SURGE
changeset 31 5daf16870df6
parent 30 5dc02b23752f
child 33 3e2da88830cd
equal deleted inserted replaced
27:93b982ccede2 31:5daf16870df6
  1079     Draws the given \a pixmap into the given \a target rectangle, using the
  1079     Draws the given \a pixmap into the given \a target rectangle, using the
  1080     given \a painter. The pixmap will be split into nine segments and drawn
  1080     given \a painter. The pixmap will be split into nine segments and drawn
  1081     according to the \a margins structure.
  1081     according to the \a margins structure.
  1082 */
  1082 */
  1083 
  1083 
  1084 typedef QVarLengthArray<QDrawPixmaps::Data, 16> QDrawPixmapsDataArray;
  1084 typedef QVarLengthArray<QPainter::PixmapFragment, 16> QPixmapFragmentsArray;
  1085 
  1085 
  1086 /*!
  1086 /*!
  1087     \since 4.6
  1087     \since 4.6
  1088 
  1088 
  1089     Draws the indicated \a sourceRect rectangle from the given \a pixmap into
  1089     Draws the indicated \a sourceRect rectangle from the given \a pixmap into
  1100 
  1100 
  1101 void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargins &targetMargins,
  1101 void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargins &targetMargins,
  1102                        const QPixmap &pixmap, const QRect &sourceRect,const QMargins &sourceMargins,
  1102                        const QPixmap &pixmap, const QRect &sourceRect,const QMargins &sourceMargins,
  1103                        const QTileRules &rules, QDrawBorderPixmap::DrawingHints hints)
  1103                        const QTileRules &rules, QDrawBorderPixmap::DrawingHints hints)
  1104 {
  1104 {
  1105     QDrawPixmaps::Data d;
  1105     QPainter::PixmapFragment d;
  1106     d.opacity = 1.0;
  1106     d.opacity = 1.0;
  1107     d.rotation = 0.0;
  1107     d.rotation = 0.0;
  1108 
  1108 
  1109     QDrawPixmapsDataArray opaqueData;
  1109     QPixmapFragmentsArray opaqueData;
  1110     QDrawPixmapsDataArray translucentData;
  1110     QPixmapFragmentsArray translucentData;
  1111 
  1111 
  1112     // source center
  1112     // source center
  1113     const int sourceCenterTop = sourceRect.top() + sourceMargins.top();
  1113     const int sourceCenterTop = sourceRect.top() + sourceMargins.top();
  1114     const int sourceCenterLeft = sourceRect.left() + sourceMargins.left();
  1114     const int sourceCenterLeft = sourceRect.left() + sourceMargins.left();
  1115     const int sourceCenterBottom = sourceRect.bottom() - sourceMargins.bottom() + 1;
  1115     const int sourceCenterBottom = sourceRect.bottom() - sourceMargins.bottom() + 1;
  1135         rows = qMax(3, 2 + qCeil(targetCenterHeight / qreal(sourceCenterHeight)));
  1135         rows = qMax(3, 2 + qCeil(targetCenterHeight / qreal(sourceCenterHeight)));
  1136 
  1136 
  1137     xTarget.resize(columns + 1);
  1137     xTarget.resize(columns + 1);
  1138     yTarget.resize(rows + 1);
  1138     yTarget.resize(rows + 1);
  1139 
  1139 
       
  1140     bool oldAA = painter->testRenderHint(QPainter::Antialiasing);
       
  1141     if (painter->paintEngine()->type() != QPaintEngine::OpenGL
       
  1142         && painter->paintEngine()->type() != QPaintEngine::OpenGL2
       
  1143         && oldAA && painter->combinedTransform().type() != QTransform::TxNone) {
       
  1144         painter->setRenderHint(QPainter::Antialiasing, false);
       
  1145     }
       
  1146 
  1140     xTarget[0] = targetRect.left();
  1147     xTarget[0] = targetRect.left();
  1141     xTarget[1] = targetCenterLeft;
  1148     xTarget[1] = targetCenterLeft;
  1142     xTarget[columns - 1] = targetCenterRight;
  1149     xTarget[columns - 1] = targetCenterRight;
  1143     xTarget[columns] = targetRect.left() + targetRect.width();
  1150     xTarget[columns] = targetRect.left() + targetRect.width();
  1144 
  1151 
  1180     for (int i = 2; i < rows - 1; ++i)
  1187     for (int i = 2; i < rows - 1; ++i)
  1181         yTarget[i] = yTarget[i - 1] + dy;
  1188         yTarget[i] = yTarget[i - 1] + dy;
  1182 
  1189 
  1183     // corners
  1190     // corners
  1184     if (targetMargins.top() > 0 && targetMargins.left() > 0 && sourceMargins.top() > 0 && sourceMargins.left() > 0) { // top left
  1191     if (targetMargins.top() > 0 && targetMargins.left() > 0 && sourceMargins.top() > 0 && sourceMargins.left() > 0) { // top left
  1185         d.point.setX(0.5 * (xTarget[1] + xTarget[0]));
  1192         d.x = (0.5 * (xTarget[1] + xTarget[0]));
  1186         d.point.setY(0.5 * (yTarget[1] + yTarget[0]));
  1193         d.y = (0.5 * (yTarget[1] + yTarget[0]));
  1187         d.source = QRectF(sourceRect.left(), sourceRect.top(), sourceMargins.left(), sourceMargins.top());
  1194         d.sourceLeft = sourceRect.left();
  1188         d.scaleX = qreal(xTarget[1] - xTarget[0]) / d.source.width();
  1195         d.sourceTop = sourceRect.top();
  1189         d.scaleY = qreal(yTarget[1] - yTarget[0]) / d.source.height();
  1196         d.width = sourceMargins.left();
       
  1197         d.height = sourceMargins.top();
       
  1198         d.scaleX = qreal(xTarget[1] - xTarget[0]) / d.width;
       
  1199         d.scaleY = qreal(yTarget[1] - yTarget[0]) / d.height;
  1190         if (hints & QDrawBorderPixmap::OpaqueTopLeft)
  1200         if (hints & QDrawBorderPixmap::OpaqueTopLeft)
  1191             opaqueData.append(d);
  1201             opaqueData.append(d);
  1192         else
  1202         else
  1193             translucentData.append(d);
  1203             translucentData.append(d);
  1194     }
  1204     }
  1195     if (targetMargins.top() > 0 && targetMargins.right() > 0 && sourceMargins.top() > 0 && sourceMargins.right() > 0) { // top right
  1205     if (targetMargins.top() > 0 && targetMargins.right() > 0 && sourceMargins.top() > 0 && sourceMargins.right() > 0) { // top right
  1196         d.point.setX(0.5 * (xTarget[columns] + xTarget[columns - 1]));
  1206         d.x = (0.5 * (xTarget[columns] + xTarget[columns - 1]));
  1197         d.point.setY(0.5 * (yTarget[1] + yTarget[0]));
  1207         d.y = (0.5 * (yTarget[1] + yTarget[0]));
  1198         d.source = QRectF(sourceCenterRight, sourceRect.top(), sourceMargins.right(), sourceMargins.top());
  1208         d.sourceLeft = sourceCenterRight;
  1199         d.scaleX = qreal(xTarget[columns] - xTarget[columns - 1]) / d.source.width();
  1209         d.sourceTop = sourceRect.top();
  1200         d.scaleY = qreal(yTarget[1] - yTarget[0]) / d.source.height();
  1210         d.width = sourceMargins.right();
       
  1211         d.height = sourceMargins.top();
       
  1212         d.scaleX = qreal(xTarget[columns] - xTarget[columns - 1]) / d.width;
       
  1213         d.scaleY = qreal(yTarget[1] - yTarget[0]) / d.height;
  1201         if (hints & QDrawBorderPixmap::OpaqueTopRight)
  1214         if (hints & QDrawBorderPixmap::OpaqueTopRight)
  1202             opaqueData.append(d);
  1215             opaqueData.append(d);
  1203         else
  1216         else
  1204             translucentData.append(d);
  1217             translucentData.append(d);
  1205     }
  1218     }
  1206     if (targetMargins.bottom() > 0 && targetMargins.left() > 0 && sourceMargins.bottom() > 0 && sourceMargins.left() > 0) { // bottom left
  1219     if (targetMargins.bottom() > 0 && targetMargins.left() > 0 && sourceMargins.bottom() > 0 && sourceMargins.left() > 0) { // bottom left
  1207         d.point.setX(0.5 * (xTarget[1] + xTarget[0]));
  1220         d.x = (0.5 * (xTarget[1] + xTarget[0]));
  1208         d.point.setY(0.5 * (yTarget[rows] + yTarget[rows - 1]));
  1221         d.y =(0.5 * (yTarget[rows] + yTarget[rows - 1]));
  1209         d.source = QRectF(sourceRect.left(), sourceCenterBottom, sourceMargins.left(), sourceMargins.bottom());
  1222         d.sourceLeft = sourceRect.left();
  1210         d.scaleX = qreal(xTarget[1] - xTarget[0]) / d.source.width();
  1223         d.sourceTop = sourceCenterBottom;
  1211         d.scaleY = qreal(yTarget[rows] - yTarget[rows - 1]) / d.source.height();
  1224         d.width = sourceMargins.left();
       
  1225         d.height = sourceMargins.bottom();
       
  1226         d.scaleX = qreal(xTarget[1] - xTarget[0]) / d.width;
       
  1227         d.scaleY = qreal(yTarget[rows] - yTarget[rows - 1]) / d.height;
  1212         if (hints & QDrawBorderPixmap::OpaqueBottomLeft)
  1228         if (hints & QDrawBorderPixmap::OpaqueBottomLeft)
  1213             opaqueData.append(d);
  1229             opaqueData.append(d);
  1214         else
  1230         else
  1215             translucentData.append(d);
  1231             translucentData.append(d);
  1216     }
  1232     }
  1217     if (targetMargins.bottom() > 0 && targetMargins.right() > 0 && sourceMargins.bottom() > 0 && sourceMargins.right() > 0) { // bottom right
  1233     if (targetMargins.bottom() > 0 && targetMargins.right() > 0 && sourceMargins.bottom() > 0 && sourceMargins.right() > 0) { // bottom right
  1218         d.point.setX(0.5 * (xTarget[columns] + xTarget[columns - 1]));
  1234         d.x = (0.5 * (xTarget[columns] + xTarget[columns - 1]));
  1219         d.point.setY(0.5 * (yTarget[rows] + yTarget[rows - 1]));
  1235         d.y = (0.5 * (yTarget[rows] + yTarget[rows - 1]));
  1220         d.source = QRectF(sourceCenterRight, sourceCenterBottom, sourceMargins.right(), sourceMargins.bottom());
  1236         d.sourceLeft = sourceCenterRight;
  1221         d.scaleX = qreal(xTarget[columns] - xTarget[columns - 1]) / d.source.width();
  1237         d.sourceTop = sourceCenterBottom;
  1222         d.scaleY = qreal(yTarget[rows] - yTarget[rows - 1]) / d.source.height();
  1238         d.width = sourceMargins.right();
       
  1239         d.height = sourceMargins.bottom();
       
  1240         d.scaleX = qreal(xTarget[columns] - xTarget[columns - 1]) / d.width;
       
  1241         d.scaleY = qreal(yTarget[rows] - yTarget[rows - 1]) / d.height;
  1223         if (hints & QDrawBorderPixmap::OpaqueBottomRight)
  1242         if (hints & QDrawBorderPixmap::OpaqueBottomRight)
  1224             opaqueData.append(d);
  1243             opaqueData.append(d);
  1225         else
  1244         else
  1226             translucentData.append(d);
  1245             translucentData.append(d);
  1227     }
  1246     }
  1228 
  1247 
  1229     // horizontal edges
  1248     // horizontal edges
  1230     if (targetCenterWidth > 0 && sourceCenterWidth > 0) {
  1249     if (targetCenterWidth > 0 && sourceCenterWidth > 0) {
  1231         if (targetMargins.top() > 0 && sourceMargins.top() > 0) { // top
  1250         if (targetMargins.top() > 0 && sourceMargins.top() > 0) { // top
  1232             QDrawPixmapsDataArray &data = hints & QDrawBorderPixmap::OpaqueTop ? opaqueData : translucentData;
  1251             QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueTop ? opaqueData : translucentData;
  1233             d.source = QRectF(sourceCenterLeft, sourceRect.top(), sourceCenterWidth, sourceMargins.top());
  1252             d.sourceLeft = sourceCenterLeft;
  1234             d.point.setY(0.5 * (yTarget[1] + yTarget[0]));
  1253             d.sourceTop = sourceRect.top();
  1235             d.scaleX = dx / d.source.width();
  1254             d.width = sourceCenterWidth;
  1236             d.scaleY = qreal(yTarget[1] - yTarget[0]) / d.source.height();
  1255             d.height = sourceMargins.top();
       
  1256             d.y = (0.5 * (yTarget[1] + yTarget[0]));
       
  1257             d.scaleX = dx / d.width;
       
  1258             d.scaleY = qreal(yTarget[1] - yTarget[0]) / d.height;
  1237             for (int i = 1; i < columns - 1; ++i) {
  1259             for (int i = 1; i < columns - 1; ++i) {
  1238                 d.point.setX(0.5 * (xTarget[i + 1] + xTarget[i]));
  1260                 d.x = (0.5 * (xTarget[i + 1] + xTarget[i]));
  1239                 data.append(d);
  1261                 data.append(d);
  1240             }
  1262             }
  1241             if (rules.horizontal == Qt::RepeatTile)
  1263             if (rules.horizontal == Qt::RepeatTile)
  1242                 data[data.size() - 1].source.setWidth((xTarget[columns - 1] - xTarget[columns - 2]) / d.scaleX);
  1264                 data[data.size() - 1].width = ((xTarget[columns - 1] - xTarget[columns - 2]) / d.scaleX);
  1243         }
  1265         }
  1244         if (targetMargins.bottom() > 0 && sourceMargins.bottom() > 0) { // bottom
  1266         if (targetMargins.bottom() > 0 && sourceMargins.bottom() > 0) { // bottom
  1245             QDrawPixmapsDataArray &data = hints & QDrawBorderPixmap::OpaqueBottom ? opaqueData : translucentData;
  1267             QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueBottom ? opaqueData : translucentData;
  1246             d.source = QRectF(sourceCenterLeft, sourceCenterBottom, sourceCenterWidth, sourceMargins.bottom());;
  1268             d.sourceLeft = sourceCenterLeft;
  1247             d.point.setY(0.5 * (yTarget[rows] + yTarget[rows - 1]));
  1269             d.sourceTop = sourceCenterBottom;
  1248             d.scaleX = dx / d.source.width();
  1270             d.width = sourceCenterWidth;
  1249             d.scaleY = qreal(yTarget[rows] - yTarget[rows - 1]) / d.source.height();
  1271             d.height = sourceMargins.bottom();
       
  1272             d.y = (0.5 * (yTarget[rows] + yTarget[rows - 1]));
       
  1273             d.scaleX = dx / d.width;
       
  1274             d.scaleY = qreal(yTarget[rows] - yTarget[rows - 1]) / d.height;
  1250             for (int i = 1; i < columns - 1; ++i) {
  1275             for (int i = 1; i < columns - 1; ++i) {
  1251                 d.point.setX(0.5 * (xTarget[i + 1] + xTarget[i]));
  1276                 d.x = (0.5 * (xTarget[i + 1] + xTarget[i]));
  1252                 data.append(d);
  1277                 data.append(d);
  1253             }
  1278             }
  1254             if (rules.horizontal == Qt::RepeatTile)
  1279             if (rules.horizontal == Qt::RepeatTile)
  1255                 data[data.size() - 1].source.setWidth((xTarget[columns - 1] - xTarget[columns - 2]) / d.scaleX);
  1280                 data[data.size() - 1].width = ((xTarget[columns - 1] - xTarget[columns - 2]) / d.scaleX);
  1256         }
  1281         }
  1257     }
  1282     }
  1258 
  1283 
  1259     // vertical edges
  1284     // vertical edges
  1260     if (targetCenterHeight > 0 && sourceCenterHeight > 0) {
  1285     if (targetCenterHeight > 0 && sourceCenterHeight > 0) {
  1261         if (targetMargins.left() > 0 && sourceMargins.left() > 0) { // left
  1286         if (targetMargins.left() > 0 && sourceMargins.left() > 0) { // left
  1262             QDrawPixmapsDataArray &data = hints & QDrawBorderPixmap::OpaqueLeft ? opaqueData : translucentData;
  1287             QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueLeft ? opaqueData : translucentData;
  1263             d.source = QRectF(sourceRect.left(), sourceCenterTop, sourceMargins.left(), sourceCenterHeight);
  1288             d.sourceLeft = sourceRect.left();
  1264             d.point.setX(0.5 * (xTarget[1] + xTarget[0]));
  1289             d.sourceTop = sourceCenterTop;
  1265             d.scaleX = qreal(xTarget[1] - xTarget[0]) / d.source.width();
  1290             d.width = sourceMargins.left();
  1266             d.scaleY = dy / d.source.height();
  1291             d.height = sourceCenterHeight;
       
  1292             d.x = (0.5 * (xTarget[1] + xTarget[0]));
       
  1293             d.scaleX = qreal(xTarget[1] - xTarget[0]) / d.width;
       
  1294             d.scaleY = dy / d.height;
  1267             for (int i = 1; i < rows - 1; ++i) {
  1295             for (int i = 1; i < rows - 1; ++i) {
  1268                 d.point.setY(0.5 * (yTarget[i + 1] + yTarget[i]));
  1296                 d.y = (0.5 * (yTarget[i + 1] + yTarget[i]));
  1269                 data.append(d);
  1297                 data.append(d);
  1270             }
  1298             }
  1271             if (rules.vertical == Qt::RepeatTile)
  1299             if (rules.vertical == Qt::RepeatTile)
  1272                 data[data.size() - 1].source.setHeight((yTarget[rows - 1] - yTarget[rows - 2]) / d.scaleY);
  1300                 data[data.size() - 1].height = ((yTarget[rows - 1] - yTarget[rows - 2]) / d.scaleY);
  1273         }
  1301         }
  1274         if (targetMargins.right() > 0 && sourceMargins.right() > 0) { // right
  1302         if (targetMargins.right() > 0 && sourceMargins.right() > 0) { // right
  1275             QDrawPixmapsDataArray &data = hints & QDrawBorderPixmap::OpaqueRight ? opaqueData : translucentData;
  1303             QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueRight ? opaqueData : translucentData;
  1276             d.source = QRectF(sourceCenterRight, sourceCenterTop, sourceMargins.right(), sourceCenterHeight);
  1304             d.sourceLeft = sourceCenterRight;
  1277             d.point.setX(0.5 * (xTarget[columns] + xTarget[columns - 1]));
  1305             d.sourceTop = sourceCenterTop;
  1278             d.scaleX = qreal(xTarget[columns] - xTarget[columns - 1]) / d.source.width();
  1306             d.width = sourceMargins.right();
  1279             d.scaleY = dy / d.source.height();
  1307             d.height = sourceCenterHeight;
       
  1308             d.x = (0.5 * (xTarget[columns] + xTarget[columns - 1]));
       
  1309             d.scaleX = qreal(xTarget[columns] - xTarget[columns - 1]) / d.width;
       
  1310             d.scaleY = dy / d.height;
  1280             for (int i = 1; i < rows - 1; ++i) {
  1311             for (int i = 1; i < rows - 1; ++i) {
  1281                 d.point.setY(0.5 * (yTarget[i + 1] + yTarget[i]));
  1312                 d.y = (0.5 * (yTarget[i + 1] + yTarget[i]));
  1282                 data.append(d);
  1313                 data.append(d);
  1283             }
  1314             }
  1284             if (rules.vertical == Qt::RepeatTile)
  1315             if (rules.vertical == Qt::RepeatTile)
  1285                 data[data.size() - 1].source.setHeight((yTarget[rows - 1] - yTarget[rows - 2]) / d.scaleY);
  1316                 data[data.size() - 1].height = ((yTarget[rows - 1] - yTarget[rows - 2]) / d.scaleY);
  1286         }
  1317         }
  1287     }
  1318     }
  1288 
  1319 
  1289     // center
  1320     // center
  1290     if (targetCenterWidth > 0 && targetCenterHeight > 0 && sourceCenterWidth > 0 && sourceCenterHeight > 0) {
  1321     if (targetCenterWidth > 0 && targetCenterHeight > 0 && sourceCenterWidth > 0 && sourceCenterHeight > 0) {
  1291         QDrawPixmapsDataArray &data = hints & QDrawBorderPixmap::OpaqueCenter ? opaqueData : translucentData;
  1322         QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueCenter ? opaqueData : translucentData;
  1292         d.source = QRectF(sourceCenterLeft, sourceCenterTop, sourceCenterWidth, sourceCenterHeight);
  1323         d.sourceLeft = sourceCenterLeft;
  1293         d.scaleX = dx / d.source.width();
  1324         d.sourceTop = sourceCenterTop;
  1294         d.scaleY = dy / d.source.height();
  1325         d.width = sourceCenterWidth;
       
  1326         d.height = sourceCenterHeight;
       
  1327         d.scaleX = dx / d.width;
       
  1328         d.scaleY = dy / d.height;
  1295 
  1329 
  1296         qreal repeatWidth = (xTarget[columns - 1] - xTarget[columns - 2]) / d.scaleX;
  1330         qreal repeatWidth = (xTarget[columns - 1] - xTarget[columns - 2]) / d.scaleX;
  1297         qreal repeatHeight = (yTarget[rows - 1] - yTarget[rows - 2]) / d.scaleY;
  1331         qreal repeatHeight = (yTarget[rows - 1] - yTarget[rows - 2]) / d.scaleY;
  1298 
  1332 
  1299         for (int j = 1; j < rows - 1; ++j) {
  1333         for (int j = 1; j < rows - 1; ++j) {
  1300             d.point.setY(0.5 * (yTarget[j + 1] + yTarget[j]));
  1334             d.y = (0.5 * (yTarget[j + 1] + yTarget[j]));
  1301             for (int i = 1; i < columns - 1; ++i) {
  1335             for (int i = 1; i < columns - 1; ++i) {
  1302                 d.point.setX(0.5 * (xTarget[i + 1] + xTarget[i]));
  1336                 d.x = (0.5 * (xTarget[i + 1] + xTarget[i]));
  1303                 data.append(d);
  1337                 data.append(d);
  1304             }
  1338             }
  1305             if (rules.horizontal == Qt::RepeatTile)
  1339             if (rules.horizontal == Qt::RepeatTile)
  1306                 data[data.size() - 1].source.setWidth(repeatWidth);
  1340                 data[data.size() - 1].width = repeatWidth;
  1307         }
  1341         }
  1308         if (rules.vertical == Qt::RepeatTile) {
  1342         if (rules.vertical == Qt::RepeatTile) {
  1309             for (int i = 1; i < columns - 1; ++i)
  1343             for (int i = 1; i < columns - 1; ++i)
  1310                 data[data.size() - i].source.setHeight(repeatHeight);
  1344                 data[data.size() - i].height = repeatHeight;
  1311         }
  1345         }
  1312     }
  1346     }
  1313 
  1347 
  1314     if (opaqueData.size())
  1348     if (opaqueData.size())
  1315         qDrawPixmaps(painter, opaqueData.data(), opaqueData.size(), pixmap, QDrawPixmaps::OpaqueHint);
  1349         painter->drawPixmapFragments(opaqueData.data(), opaqueData.size(), pixmap, QPainter::OpaqueHint);
  1316     if (translucentData.size())
  1350     if (translucentData.size())
  1317         qDrawPixmaps(painter, translucentData.data(), translucentData.size(), pixmap);
  1351         painter->drawPixmapFragments(translucentData.data(), translucentData.size(), pixmap);
  1318 }
  1352 
  1319 
  1353     if (oldAA)
  1320 /*!
  1354         painter->setRenderHint(QPainter::Antialiasing, true);
  1321     \class QDrawPixmaps::Data
       
  1322     \since 4.6
       
  1323     \internal
       
  1324 
       
  1325     This structure is used with the qDrawPixmaps() function.
       
  1326 
       
  1327     QPointF point:  Specifies the center of the target rectangle.
       
  1328     QRectF source:  Specifies the source rectangle in the pixmap passed into the qDrawPixmaps() call.
       
  1329     qreal scaleX:   Specifies the horizontal scale of the target rectangle.
       
  1330     qreal scaleY:   Specifies the vertical scale of the target rectangle.
       
  1331     qreal rotation: Specifies the rotation of the target rectangle in degrees.
       
  1332                     The target rectangle is rotated after scaling.
       
  1333     qreal opacity:  Specifies the opacity of the rectangle.
       
  1334 */
       
  1335 
       
  1336 /*!
       
  1337     \enum QDrawPixmaps::DrawingHint
       
  1338     \internal
       
  1339 */
       
  1340 
       
  1341 /*!
       
  1342     \internal
       
  1343     \since 4.6
       
  1344 
       
  1345     This function is used to draw \a pixmap, or a sub-rectangle of \a pixmap, at multiple positions
       
  1346     with different scale, rotation and opacity on \a painter. \a drawingData is an array of \a
       
  1347     dataCount elements specifying the parameters used to draw each pixmap instance.
       
  1348     This can be used for example to implement a particle system.
       
  1349 */
       
  1350 void qDrawPixmaps(QPainter *painter, const QDrawPixmaps::Data *drawingData, int dataCount, const QPixmap &pixmap, QDrawPixmaps::DrawingHints hints)
       
  1351 {
       
  1352     QPaintEngine *engine = painter->paintEngine();
       
  1353     if (!engine)
       
  1354         return;
       
  1355 
       
  1356     if (engine->isExtended()) {
       
  1357         static_cast<QPaintEngineEx *>(engine)->drawPixmaps(drawingData, dataCount, pixmap, hints);
       
  1358     } else {
       
  1359         qreal oldOpacity = painter->opacity();
       
  1360         QTransform oldTransform = painter->transform();
       
  1361 
       
  1362         for (int i = 0; i < dataCount; ++i) {
       
  1363             QTransform transform = oldTransform;
       
  1364             qreal xOffset = 0;
       
  1365             qreal yOffset = 0;
       
  1366             if (drawingData[i].rotation == 0) {
       
  1367                 xOffset = drawingData[i].point.x();
       
  1368                 yOffset = drawingData[i].point.y();
       
  1369             } else {
       
  1370                 transform.translate(drawingData[i].point.x(), drawingData[i].point.y());
       
  1371                 transform.rotate(drawingData[i].rotation);
       
  1372             }
       
  1373             painter->setTransform(transform);
       
  1374             painter->setOpacity(oldOpacity * drawingData[i].opacity);
       
  1375 
       
  1376             qreal w = drawingData[i].scaleX * drawingData[i].source.width();
       
  1377             qreal h = drawingData[i].scaleY * drawingData[i].source.height();
       
  1378             painter->drawPixmap(QRectF(-0.5 * w + xOffset, -0.5 * h + yOffset, w, h), pixmap, drawingData[i].source);
       
  1379         }
       
  1380 
       
  1381         painter->setOpacity(oldOpacity);
       
  1382         painter->setTransform(oldTransform);
       
  1383     }
       
  1384 }
  1355 }
  1385 
  1356 
  1386 QT_END_NAMESPACE
  1357 QT_END_NAMESPACE