summaryrefslogtreecommitdiffstats
path: root/src/gui/painting
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/painting')
-rw-r--r--src/gui/painting/qdrawutil.cpp179
-rw-r--r--src/gui/painting/qemulationpaintengine.cpp41
-rw-r--r--src/gui/painting/qemulationpaintengine_p.h5
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp28
-rw-r--r--src/gui/painting/qpaintengineex.cpp16
-rw-r--r--src/gui/painting/qpaintengineex_p.h4
-rw-r--r--src/gui/painting/qpainter.cpp46
-rw-r--r--src/gui/painting/qpainter.h2
-rw-r--r--src/gui/painting/qwindowsurface_qws.cpp2
9 files changed, 180 insertions, 143 deletions
diff --git a/src/gui/painting/qdrawutil.cpp b/src/gui/painting/qdrawutil.cpp
index 98294cb..1e98b05 100644
--- a/src/gui/painting/qdrawutil.cpp
+++ b/src/gui/painting/qdrawutil.cpp
@@ -1084,7 +1084,7 @@ void qDrawItem(QPainter *p, Qt::GUIStyle gs,
according to the \a margins structure.
*/
-typedef QVarLengthArray<QPainter::PixmapFragment, 16> QPixmapFragmentsArray;
+typedef QVarLengthArray<QRectF, 16> QRectFArray;
/*!
\since 4.6
@@ -1105,12 +1105,8 @@ void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargin
const QPixmap &pixmap, const QRect &sourceRect,const QMargins &sourceMargins,
const QTileRules &rules, QDrawBorderPixmap::DrawingHints hints)
{
- QPainter::PixmapFragment d;
- d.opacity = 1.0;
- d.rotation = 0.0;
-
- QPixmapFragmentsArray opaqueData;
- QPixmapFragmentsArray translucentData;
+ QRectFArray sourceData[2];
+ QRectFArray targetData[2];
// source center
const int sourceCenterTop = sourceRect.top() + sourceMargins.top();
@@ -1192,166 +1188,95 @@ void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargin
// corners
if (targetMargins.top() > 0 && targetMargins.left() > 0 && sourceMargins.top() > 0 && sourceMargins.left() > 0) { // top left
- d.x = (0.5 * (xTarget[1] + xTarget[0]));
- d.y = (0.5 * (yTarget[1] + yTarget[0]));
- d.sourceLeft = sourceRect.left();
- d.sourceTop = sourceRect.top();
- d.width = sourceMargins.left();
- d.height = sourceMargins.top();
- d.scaleX = qreal(xTarget[1] - xTarget[0]) / d.width;
- d.scaleY = qreal(yTarget[1] - yTarget[0]) / d.height;
- if (hints & QDrawBorderPixmap::OpaqueTopLeft)
- opaqueData.append(d);
- else
- translucentData.append(d);
+ int index = bool(hints & QDrawBorderPixmap::OpaqueTopLeft);
+ sourceData[index].append(QRectF(sourceRect.topLeft(), QSizeF(sourceMargins.left(), sourceMargins.top())));
+ targetData[index].append(QRectF(QPointF(xTarget[0], yTarget[0]), QPointF(xTarget[1], yTarget[1])));
}
if (targetMargins.top() > 0 && targetMargins.right() > 0 && sourceMargins.top() > 0 && sourceMargins.right() > 0) { // top right
- d.x = (0.5 * (xTarget[columns] + xTarget[columns - 1]));
- d.y = (0.5 * (yTarget[1] + yTarget[0]));
- d.sourceLeft = sourceCenterRight;
- d.sourceTop = sourceRect.top();
- d.width = sourceMargins.right();
- d.height = sourceMargins.top();
- d.scaleX = qreal(xTarget[columns] - xTarget[columns - 1]) / d.width;
- d.scaleY = qreal(yTarget[1] - yTarget[0]) / d.height;
- if (hints & QDrawBorderPixmap::OpaqueTopRight)
- opaqueData.append(d);
- else
- translucentData.append(d);
+ int index = bool(hints & QDrawBorderPixmap::OpaqueTopRight);
+ sourceData[index].append(QRectF(QPointF(sourceCenterRight, sourceRect.top()), QSizeF(sourceMargins.right(), sourceMargins.top())));
+ targetData[index].append(QRectF(QPointF(xTarget[columns-1], yTarget[0]), QPointF(xTarget[columns], yTarget[1])));
}
if (targetMargins.bottom() > 0 && targetMargins.left() > 0 && sourceMargins.bottom() > 0 && sourceMargins.left() > 0) { // bottom left
- d.x = (0.5 * (xTarget[1] + xTarget[0]));
- d.y =(0.5 * (yTarget[rows] + yTarget[rows - 1]));
- d.sourceLeft = sourceRect.left();
- d.sourceTop = sourceCenterBottom;
- d.width = sourceMargins.left();
- d.height = sourceMargins.bottom();
- d.scaleX = qreal(xTarget[1] - xTarget[0]) / d.width;
- d.scaleY = qreal(yTarget[rows] - yTarget[rows - 1]) / d.height;
- if (hints & QDrawBorderPixmap::OpaqueBottomLeft)
- opaqueData.append(d);
- else
- translucentData.append(d);
+ int index = bool(hints & QDrawBorderPixmap::OpaqueBottomLeft);
+ sourceData[index].append(QRectF(QPointF(sourceRect.left(), sourceCenterBottom), QSizeF(sourceMargins.left(), sourceMargins.bottom())));
+ targetData[index].append(QRectF(QPointF(xTarget[0], yTarget[rows - 1]), QPointF(xTarget[1], yTarget[rows])));
}
if (targetMargins.bottom() > 0 && targetMargins.right() > 0 && sourceMargins.bottom() > 0 && sourceMargins.right() > 0) { // bottom right
- d.x = (0.5 * (xTarget[columns] + xTarget[columns - 1]));
- d.y = (0.5 * (yTarget[rows] + yTarget[rows - 1]));
- d.sourceLeft = sourceCenterRight;
- d.sourceTop = sourceCenterBottom;
- d.width = sourceMargins.right();
- d.height = sourceMargins.bottom();
- d.scaleX = qreal(xTarget[columns] - xTarget[columns - 1]) / d.width;
- d.scaleY = qreal(yTarget[rows] - yTarget[rows - 1]) / d.height;
- if (hints & QDrawBorderPixmap::OpaqueBottomRight)
- opaqueData.append(d);
- else
- translucentData.append(d);
+ int index = bool(hints & QDrawBorderPixmap::OpaqueBottomRight);
+ sourceData[index].append(QRectF(QPointF(sourceCenterRight, sourceCenterBottom), QSizeF(sourceMargins.right(), sourceMargins.bottom())));
+ targetData[index].append(QRectF(QPointF(xTarget[columns - 1], yTarget[rows - 1]), QPointF(xTarget[columns], yTarget[rows])));
}
// horizontal edges
if (targetCenterWidth > 0 && sourceCenterWidth > 0) {
if (targetMargins.top() > 0 && sourceMargins.top() > 0) { // top
- QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueTop ? opaqueData : translucentData;
- d.sourceLeft = sourceCenterLeft;
- d.sourceTop = sourceRect.top();
- d.width = sourceCenterWidth;
- d.height = sourceMargins.top();
- d.y = (0.5 * (yTarget[1] + yTarget[0]));
- d.scaleX = dx / d.width;
- d.scaleY = qreal(yTarget[1] - yTarget[0]) / d.height;
+ int index = bool(hints & QDrawBorderPixmap::OpaqueTop);
for (int i = 1; i < columns - 1; ++i) {
- d.x = (0.5 * (xTarget[i + 1] + xTarget[i]));
- data.append(d);
+ if (rules.horizontal == Qt::RepeatTile && i == columns - 2) {
+ sourceData[index].append(QRectF(QPointF(sourceCenterLeft, sourceRect.top()), QSizeF(xTarget[i + 1] - xTarget[i], sourceMargins.top())));
+ } else {
+ sourceData[index].append(QRectF(QPointF(sourceCenterLeft, sourceRect.top()), QSizeF(sourceCenterWidth, sourceMargins.top())));
+ }
+ targetData[index].append(QRectF(QPointF(xTarget[i], yTarget[0]), QPointF(xTarget[i + 1], yTarget[1])));
}
- if (rules.horizontal == Qt::RepeatTile)
- data[data.size() - 1].width = ((xTarget[columns - 1] - xTarget[columns - 2]) / d.scaleX);
}
if (targetMargins.bottom() > 0 && sourceMargins.bottom() > 0) { // bottom
- QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueBottom ? opaqueData : translucentData;
- d.sourceLeft = sourceCenterLeft;
- d.sourceTop = sourceCenterBottom;
- d.width = sourceCenterWidth;
- d.height = sourceMargins.bottom();
- d.y = (0.5 * (yTarget[rows] + yTarget[rows - 1]));
- d.scaleX = dx / d.width;
- d.scaleY = qreal(yTarget[rows] - yTarget[rows - 1]) / d.height;
+ int index = bool(hints & QDrawBorderPixmap::OpaqueBottom);
for (int i = 1; i < columns - 1; ++i) {
- d.x = (0.5 * (xTarget[i + 1] + xTarget[i]));
- data.append(d);
+ if (rules.horizontal == Qt::RepeatTile && i == columns - 2) {
+ sourceData[index].append(QRectF(QPointF(sourceCenterLeft, sourceCenterBottom), QSizeF(xTarget[i + 1] - xTarget[i], sourceMargins.bottom())));
+ } else {
+ sourceData[index].append(QRectF(QPointF(sourceCenterLeft, sourceCenterBottom), QSizeF(sourceCenterWidth, sourceMargins.bottom())));
+ }
+ targetData[index].append(QRectF(QPointF(xTarget[i], yTarget[rows - 1]), QPointF(xTarget[i + 1], yTarget[rows])));
}
- if (rules.horizontal == Qt::RepeatTile)
- data[data.size() - 1].width = ((xTarget[columns - 1] - xTarget[columns - 2]) / d.scaleX);
}
}
// vertical edges
if (targetCenterHeight > 0 && sourceCenterHeight > 0) {
if (targetMargins.left() > 0 && sourceMargins.left() > 0) { // left
- QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueLeft ? opaqueData : translucentData;
- d.sourceLeft = sourceRect.left();
- d.sourceTop = sourceCenterTop;
- d.width = sourceMargins.left();
- d.height = sourceCenterHeight;
- d.x = (0.5 * (xTarget[1] + xTarget[0]));
- d.scaleX = qreal(xTarget[1] - xTarget[0]) / d.width;
- d.scaleY = dy / d.height;
+ int index = bool(hints & QDrawBorderPixmap::OpaqueLeft);
for (int i = 1; i < rows - 1; ++i) {
- d.y = (0.5 * (yTarget[i + 1] + yTarget[i]));
- data.append(d);
+ if (rules.vertical == Qt::RepeatTile && i == rows - 2) {
+ sourceData[index].append(QRectF(QPointF(sourceRect.left(), sourceCenterTop), QSizeF(sourceMargins.left(), yTarget[i + 1] - yTarget[i])));
+ } else {
+ sourceData[index].append(QRectF(QPointF(sourceRect.left(), sourceCenterTop), QSizeF(sourceMargins.left(), sourceCenterHeight)));
+ }
+ targetData[index].append(QRectF(QPointF(xTarget[0], yTarget[i]), QPointF(xTarget[1], yTarget[i + 1])));
}
- if (rules.vertical == Qt::RepeatTile)
- data[data.size() - 1].height = ((yTarget[rows - 1] - yTarget[rows - 2]) / d.scaleY);
}
if (targetMargins.right() > 0 && sourceMargins.right() > 0) { // right
- QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueRight ? opaqueData : translucentData;
- d.sourceLeft = sourceCenterRight;
- d.sourceTop = sourceCenterTop;
- d.width = sourceMargins.right();
- d.height = sourceCenterHeight;
- d.x = (0.5 * (xTarget[columns] + xTarget[columns - 1]));
- d.scaleX = qreal(xTarget[columns] - xTarget[columns - 1]) / d.width;
- d.scaleY = dy / d.height;
+ int index = bool(hints & QDrawBorderPixmap::OpaqueRight);
for (int i = 1; i < rows - 1; ++i) {
- d.y = (0.5 * (yTarget[i + 1] + yTarget[i]));
- data.append(d);
+ if (rules.vertical == Qt::RepeatTile && i == rows - 2) {
+ sourceData[index].append(QRectF(QPointF(sourceCenterRight, sourceCenterTop), QSizeF(sourceMargins.right(), yTarget[i + 1] - yTarget[i])));
+ } else {
+ sourceData[index].append(QRectF(QPointF(sourceCenterRight, sourceCenterTop), QSizeF(sourceMargins.right(), sourceCenterHeight)));
+ }
+ targetData[index].append(QRectF(QPointF(xTarget[columns - 1], yTarget[i]), QPointF(xTarget[columns], yTarget[i + 1])));
}
- if (rules.vertical == Qt::RepeatTile)
- data[data.size() - 1].height = ((yTarget[rows - 1] - yTarget[rows - 2]) / d.scaleY);
}
}
// center
if (targetCenterWidth > 0 && targetCenterHeight > 0 && sourceCenterWidth > 0 && sourceCenterHeight > 0) {
- QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueCenter ? opaqueData : translucentData;
- d.sourceLeft = sourceCenterLeft;
- d.sourceTop = sourceCenterTop;
- d.width = sourceCenterWidth;
- d.height = sourceCenterHeight;
- d.scaleX = dx / d.width;
- d.scaleY = dy / d.height;
-
- qreal repeatWidth = (xTarget[columns - 1] - xTarget[columns - 2]) / d.scaleX;
- qreal repeatHeight = (yTarget[rows - 1] - yTarget[rows - 2]) / d.scaleY;
-
+ int index = bool(hints & QDrawBorderPixmap::OpaqueCenter);
for (int j = 1; j < rows - 1; ++j) {
- d.y = (0.5 * (yTarget[j + 1] + yTarget[j]));
+ qreal sourceHeight = (rules.vertical == Qt::RepeatTile && j == rows - 2) ? yTarget[j + 1] - yTarget[j] : sourceCenterHeight;
for (int i = 1; i < columns - 1; ++i) {
- d.x = (0.5 * (xTarget[i + 1] + xTarget[i]));
- data.append(d);
+ qreal sourceWidth = (rules.horizontal == Qt::RepeatTile && i == columns - 2) ? xTarget[i + 1] - xTarget[i] : sourceCenterWidth;
+ sourceData[index].append(QRectF(QPointF(sourceCenterLeft, sourceCenterTop), QSizeF(sourceWidth, sourceHeight)));
+ targetData[index].append(QRectF(QPointF(xTarget[i], yTarget[j]), QPointF(xTarget[i + 1], yTarget[j + 1])));
}
- if (rules.horizontal == Qt::RepeatTile)
- data[data.size() - 1].width = repeatWidth;
- }
- if (rules.vertical == Qt::RepeatTile) {
- for (int i = 1; i < columns - 1; ++i)
- data[data.size() - i].height = repeatHeight;
}
}
- if (opaqueData.size())
- painter->drawPixmapFragments(opaqueData.data(), opaqueData.size(), pixmap, QPainter::OpaqueHint);
- if (translucentData.size())
- painter->drawPixmapFragments(translucentData.data(), translucentData.size(), pixmap);
+ for (int i = 0; i < 2; ++i) {
+ if (sourceData[i].size())
+ painter->drawPixmapFragments(targetData[i].data(), sourceData[i].data(), sourceData[i].size(), pixmap, i == 1 ? QPainter::OpaqueHint : QPainter::PixmapFragmentHint(0));
+ }
if (oldAA)
painter->setRenderHint(QPainter::Antialiasing, true);
diff --git a/src/gui/painting/qemulationpaintengine.cpp b/src/gui/painting/qemulationpaintengine.cpp
index 903ab1f..d7ad0f6 100644
--- a/src/gui/painting/qemulationpaintengine.cpp
+++ b/src/gui/painting/qemulationpaintengine.cpp
@@ -222,6 +222,47 @@ void QEmulationPaintEngine::drawImage(const QRectF &r, const QImage &pm, const Q
real_engine->drawImage(r, pm, sr, flags);
}
+void QEmulationPaintEngine::drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap,
+ QPainter::PixmapFragmentHints hints)
+{
+ if (state()->bgMode == Qt::OpaqueMode && pixmap.isQBitmap()) {
+ qreal oldOpacity = real_engine->state()->opacity;
+ QTransform oldTransform = real_engine->state()->matrix;
+
+ for (int i = 0; i < fragmentCount; ++i) {
+ QTransform transform = oldTransform;
+ transform.translate(fragments[i].x, fragments[i].y);
+ transform.rotate(fragments[i].rotation);
+ real_engine->state()->opacity = oldOpacity * fragments[i].opacity;
+ real_engine->state()->matrix = transform;
+ real_engine->opacityChanged();
+ real_engine->transformChanged();
+
+ qreal w = fragments[i].scaleX * fragments[i].width;
+ qreal h = fragments[i].scaleY * fragments[i].height;
+ fillBGRect(QRectF(-0.5 * w, -0.5 * h, w, h));
+ }
+
+ real_engine->state()->opacity = oldOpacity;
+ real_engine->state()->matrix = oldTransform;
+ real_engine->opacityChanged();
+ real_engine->transformChanged();
+ }
+
+ real_engine->drawPixmapFragments(fragments, fragmentCount, pixmap, hints);
+}
+
+void QEmulationPaintEngine::drawPixmapFragments(const QRectF *targetRects, const QRectF *sourceRects, int fragmentCount, const QPixmap &pixmap,
+ QPainter::PixmapFragmentHints hints)
+{
+ if (state()->bgMode == Qt::OpaqueMode && pixmap.isQBitmap()) {
+ for (int i = 0; i < fragmentCount; ++i)
+ fillBGRect(targetRects[i]);
+ }
+
+ real_engine->drawPixmapFragments(targetRects, sourceRects, fragmentCount, pixmap, hints);
+}
+
void QEmulationPaintEngine::clipEnabledChanged()
{
real_engine->clipEnabledChanged();
diff --git a/src/gui/painting/qemulationpaintengine_p.h b/src/gui/painting/qemulationpaintengine_p.h
index fdc3688..b4ed7e7 100644
--- a/src/gui/painting/qemulationpaintengine_p.h
+++ b/src/gui/painting/qemulationpaintengine_p.h
@@ -81,6 +81,11 @@ public:
virtual void drawStaticTextItem(QStaticTextItem *item);
virtual void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s);
virtual void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, Qt::ImageConversionFlags flags);
+
+ virtual void drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap,
+ QPainter::PixmapFragmentHints hints);
+ virtual void drawPixmapFragments(const QRectF *targetRects, const QRectF *sourceRects, int fragmentCount, const QPixmap &pixmap,
+ QPainter::PixmapFragmentHints hints);
virtual void clipEnabledChanged();
virtual void penChanged();
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index 9ba4592..76d7316 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -2396,12 +2396,18 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe
d->image_filler_xform.setupMatrix(copy, s->flags.bilinear);
if (!s->flags.antialiased && s->matrix.type() == QTransform::TxScale) {
- QRectF rr = s->matrix.mapRect(r);
+ QPointF rr_tl = s->matrix.map(r.topLeft());
+ QPointF rr_br = s->matrix.map(r.bottomRight());
- const int x1 = qRound(rr.x());
- const int y1 = qRound(rr.y());
- const int x2 = qRound(rr.right());
- const int y2 = qRound(rr.bottom());
+ int x1 = qRound(rr_tl.x());
+ int y1 = qRound(rr_tl.y());
+ int x2 = qRound(rr_br.x());
+ int y2 = qRound(rr_br.y());
+
+ if (x1 > x2)
+ qSwap(x1, x2);
+ if (y1 > y2)
+ qSwap(y1, y2);
fillRect_normalized(QRect(x1, y1, x2-x1, y2-y1), &d->image_filler_xform, d);
return;
@@ -2862,15 +2868,9 @@ bool QRasterPaintEngine::drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs,
} else
#endif
{
- QFontEngineGlyphCache::Type glyphType;
- if (fontEngine->glyphFormat >= 0) {
- glyphType = QFontEngineGlyphCache::Type(fontEngine->glyphFormat);
- } else if (s->matrix.type() > QTransform::TxTranslate
- && d->glyphCacheType == QFontEngineGlyphCache::Raster_RGBMask) {
- glyphType = QFontEngineGlyphCache::Raster_A8;
- } else {
- glyphType = d->glyphCacheType;
- }
+ QFontEngineGlyphCache::Type glyphType = fontEngine->glyphFormat >= 0
+ ? QFontEngineGlyphCache::Type(fontEngine->glyphFormat)
+ : d->glyphCacheType;
QImageTextureGlyphCache *cache =
static_cast<QImageTextureGlyphCache *>(fontEngine->glyphCache(0, glyphType, s->matrix));
diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp
index 5105d9a..6df410b 100644
--- a/src/gui/painting/qpaintengineex.cpp
+++ b/src/gui/painting/qpaintengineex.cpp
@@ -1003,6 +1003,22 @@ void QPaintEngineEx::drawPixmapFragments(const QPainter::PixmapFragment *fragmen
transformChanged();
}
+void QPaintEngineEx::drawPixmapFragments(const QRectF *targetRects, const QRectF *sourceRects, int fragmentCount,
+ const QPixmap &pixmap, QPainter::PixmapFragmentHints /*hints*/)
+{
+ if (pixmap.isNull())
+ return;
+
+ if (sourceRects) {
+ for (int i = 0; i < fragmentCount; ++i)
+ drawPixmap(targetRects[i], pixmap, sourceRects[i]);
+ } else {
+ QRectF sourceRect = pixmap.rect();
+ for (int i = 0; i < fragmentCount; ++i)
+ drawPixmap(targetRects[i], pixmap, sourceRect);
+ }
+}
+
void QPaintEngineEx::setState(QPainterState *s)
{
QPaintEngine::state = s;
diff --git a/src/gui/painting/qpaintengineex_p.h b/src/gui/painting/qpaintengineex_p.h
index c605685..275a6e0 100644
--- a/src/gui/painting/qpaintengineex_p.h
+++ b/src/gui/painting/qpaintengineex_p.h
@@ -198,7 +198,9 @@ public:
virtual void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s);
virtual void drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap,
- QFlags<QPainter::PixmapFragmentHint> hints);
+ QPainter::PixmapFragmentHints hints);
+ virtual void drawPixmapFragments(const QRectF *targetRects, const QRectF *sourceRects, int fragmentCount, const QPixmap &pixmap,
+ QPainter::PixmapFragmentHints hints);
virtual void updateState(const QPaintEngineState &state);
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index 1d10d75..8e64f3b 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -9248,6 +9248,52 @@ void QPainter::drawPixmapFragments(const PixmapFragment *fragments, int fragment
}
/*!
+ \since 4.8
+
+ This function is used to draw the same \a pixmap with multiple target
+ and source rectangles. If \a sourceRects is 0, the whole pixmap will be
+ rendered at each of the target rectangles. The \a hints parameter can be
+ used to pass in drawing hints.
+
+ This function is potentially faster than multiple calls to drawPixmap(),
+ since the backend can optimize state changes.
+
+ \sa QPainter::PixmapFragmentHint
+*/
+
+void QPainter::drawPixmapFragments(const QRectF *targetRects, const QRectF *sourceRects, int fragmentCount,
+ const QPixmap &pixmap, PixmapFragmentHints hints)
+{
+ Q_D(QPainter);
+
+ if (!d->engine || pixmap.isNull())
+ return;
+
+#ifndef QT_NO_DEBUG
+ if (sourceRects) {
+ for (int i = 0; i < fragmentCount; ++i) {
+ QRectF sourceRect = sourceRects[i];
+ if (!(QRectF(pixmap.rect()).contains(sourceRect)))
+ qWarning("QPainter::drawPixmapFragments - the source rect is not contained by the pixmap's rectangle");
+ }
+ }
+#endif
+
+ if (d->engine->isExtended()) {
+ d->extended->drawPixmapFragments(targetRects, sourceRects, fragmentCount, pixmap, hints);
+ } else {
+ if (sourceRects) {
+ for (int i = 0; i < fragmentCount; ++i)
+ drawPixmap(targetRects[i], pixmap, sourceRects[i]);
+ } else {
+ QRectF sourceRect = pixmap.rect();
+ for (int i = 0; i < fragmentCount; ++i)
+ drawPixmap(targetRects[i], pixmap, sourceRect);
+ }
+ }
+}
+
+/*!
\since 4.7
\class QPainter::PixmapFragment
diff --git a/src/gui/painting/qpainter.h b/src/gui/painting/qpainter.h
index 30f8da0..12a14a2 100644
--- a/src/gui/painting/qpainter.h
+++ b/src/gui/painting/qpainter.h
@@ -380,6 +380,8 @@ public:
void drawPixmapFragments(const PixmapFragment *fragments, int fragmentCount,
const QPixmap &pixmap, PixmapFragmentHints hints = 0);
+ void drawPixmapFragments(const QRectF *targetRects, const QRectF *sourceRects, int fragmentCount,
+ const QPixmap &pixmap, PixmapFragmentHints hints = 0);
void drawImage(const QRectF &targetRect, const QImage &image, const QRectF &sourceRect,
Qt::ImageConversionFlags flags = Qt::AutoColor);
diff --git a/src/gui/painting/qwindowsurface_qws.cpp b/src/gui/painting/qwindowsurface_qws.cpp
index 3789a33..96e2652 100644
--- a/src/gui/painting/qwindowsurface_qws.cpp
+++ b/src/gui/painting/qwindowsurface_qws.cpp
@@ -1087,7 +1087,7 @@ void QWSSharedMemSurface::setDirectRegion(const QRegion &r, int id)
const QRegion QWSSharedMemSurface::directRegion() const
{
- if (mem.address() && *(uint *)mem.address() == uint(directRegionId())
+ if (mem.address() && *(uint *)mem.address() == uint(directRegionId()))
return QWSMemorySurface::directRegion();
return QRegion();
}