diff options
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/kernel/qwidget_p.h | 3 | ||||
-rw-r--r-- | src/widgets/kernel/qwidgetbackingstore.cpp | 10 | ||||
-rw-r--r-- | src/widgets/styles/qwindowsxpstyle.cpp | 36 | ||||
-rw-r--r-- | src/widgets/styles/qwindowsxpstyle_p_p.h | 4 | ||||
-rw-r--r-- | src/widgets/widgets/qmainwindow.cpp | 6 |
5 files changed, 32 insertions, 27 deletions
diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h index 19b7238a70..4426a6d415 100644 --- a/src/widgets/kernel/qwidget_p.h +++ b/src/widgets/kernel/qwidget_p.h @@ -401,9 +401,6 @@ public: const QRegion &rgn, const QPoint &offset, int flags, QPainter *sharedPainter, QWidgetBackingStore *backingStore); - - QPainter *beginSharedPainter(); - bool endSharedPainter(); #ifndef QT_NO_GRAPHICSVIEW static QGraphicsProxyWidget * nearestGraphicsProxyWidget(const QWidget *origin); #endif diff --git a/src/widgets/kernel/qwidgetbackingstore.cpp b/src/widgets/kernel/qwidgetbackingstore.cpp index ac8902c9e6..185a66731b 100644 --- a/src/widgets/kernel/qwidgetbackingstore.cpp +++ b/src/widgets/kernel/qwidgetbackingstore.cpp @@ -112,6 +112,7 @@ void QWidgetBackingStore::qt_flush(QWidget *widget, const QRegion ®ion, QBack if (widget != tlw) offset += widget->mapTo(tlw, QPoint()); + QRegion effectiveRegion = region; #ifndef QT_NO_OPENGL const bool compositionWasActive = widget->d_func()->renderToTextureComposeActive; if (!widgetTextures) { @@ -125,6 +126,11 @@ void QWidgetBackingStore::qt_flush(QWidget *widget, const QRegion ®ion, QBack } else { widget->d_func()->renderToTextureComposeActive = true; } + // When changing the composition status, make sure the dirty region covers + // the entire widget. Just having e.g. the shown/hidden render-to-texture + // widget's area marked as dirty is incorrect when changing flush paths. + if (compositionWasActive != widget->d_func()->renderToTextureComposeActive) + effectiveRegion = widget->rect(); // re-test since we may have been forced to this path via the dummy texture list above if (widgetTextures) { @@ -136,12 +142,12 @@ void QWidgetBackingStore::qt_flush(QWidget *widget, const QRegion ®ion, QBack const bool translucentBackground = widget->testAttribute(Qt::WA_TranslucentBackground); // Use the tlw's context, not widget's. The difference is important with native child // widgets where tlw != widget. - backingStore->handle()->composeAndFlush(widget->windowHandle(), region, offset, widgetTextures, + backingStore->handle()->composeAndFlush(widget->windowHandle(), effectiveRegion, offset, widgetTextures, tlw->d_func()->shareContext(), translucentBackground); widget->window()->d_func()->sendComposeStatus(widget->window(), true); } else #endif - backingStore->flush(region, widget->windowHandle(), offset); + backingStore->flush(effectiveRegion, widget->windowHandle(), offset); } #ifndef QT_NO_PAINT_DEBUG diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp index 9fb18f63e8..1aa53de486 100644 --- a/src/widgets/styles/qwindowsxpstyle.cpp +++ b/src/widgets/styles/qwindowsxpstyle.cpp @@ -811,7 +811,7 @@ bool QWindowsXPStylePrivate::drawBackground(XPThemeData &themeData) bool translucentToplevel = false; const QPaintDevice *paintDevice = painter->device(); - const qreal aditionalDevicePixelRatio = themeData.widget ? themeData.widget->devicePixelRatio() : 1; + const qreal aditionalDevicePixelRatio = themeData.widget ? themeData.widget->devicePixelRatioF() : qreal(1); if (paintDevice->devType() == QInternal::Widget) { const QWidget *window = static_cast<const QWidget *>(paintDevice)->window(); translucentToplevel = window->testAttribute(Qt::WA_TranslucentBackground); @@ -840,28 +840,28 @@ bool QWindowsXPStylePrivate::drawBackground(XPThemeData &themeData) const HDC dc = canDrawDirectly ? hdcForWidgetBackingStore(themeData.widget) : HDC(0); const bool result = dc - ? drawBackgroundDirectly(dc, themeData, qRound(aditionalDevicePixelRatio)) - : drawBackgroundThruNativeBuffer(themeData, qRound(aditionalDevicePixelRatio)); + ? drawBackgroundDirectly(dc, themeData, aditionalDevicePixelRatio) + : drawBackgroundThruNativeBuffer(themeData, aditionalDevicePixelRatio); painter->restore(); return result; } -static inline QRect scaleRect(const QRect &r, int factor) +static inline QRectF scaleRect(const QRectF &r, qreal factor) { return r.isValid() && factor > 1 - ? QRect(r.topLeft() * factor, r.size() * factor) + ? QRectF(r.topLeft() * factor, r.size() * factor) : r; } -static QRegion scaleRegion(const QRegion ®ion, int factor) +static QRegion scaleRegion(const QRegion ®ion, qreal factor) { - if (region.isEmpty() || factor == 1) + if (region.isEmpty() || qFuzzyCompare(factor, qreal(1))) return region; if (region.rectCount() == 1) - return QRegion(scaleRect(region.boundingRect(), factor)); + return QRegion(scaleRect(QRectF(region.boundingRect()), factor).toRect()); QRegion result; foreach (const QRect &rect, region.rects()) - result += QRect(rect.topLeft() * factor, rect.size() * factor); + result += QRectF(QPointF(rect.topLeft()) * factor, QSizeF(rect.size() * factor)).toRect(); return result; } @@ -870,13 +870,12 @@ static QRegion scaleRegion(const QRegion ®ion, int factor) Do not use this if you need to perform other transformations on the resulting data. */ -bool QWindowsXPStylePrivate::drawBackgroundDirectly(HDC dc, XPThemeData &themeData, int additionalDevicePixelRatio) +bool QWindowsXPStylePrivate::drawBackgroundDirectly(HDC dc, XPThemeData &themeData, qreal additionalDevicePixelRatio) { QPainter *painter = themeData.painter; - QPoint redirectionDelta(int(painter->deviceMatrix().dx()), - int(painter->deviceMatrix().dy())); - QRect area = scaleRect(themeData.rect, additionalDevicePixelRatio).translated(redirectionDelta); + const QPointF redirectionDelta(painter->deviceMatrix().dx(), painter->deviceMatrix().dy()); + const QRect area = scaleRect(QRectF(themeData.rect), additionalDevicePixelRatio).translated(redirectionDelta).toRect(); QRegion sysRgn = painter->paintEngine()->systemClip(); if (sysRgn.isEmpty()) @@ -884,7 +883,7 @@ bool QWindowsXPStylePrivate::drawBackgroundDirectly(HDC dc, XPThemeData &themeDa else sysRgn &= area; if (painter->hasClipping()) - sysRgn &= scaleRegion(painter->clipRegion(), additionalDevicePixelRatio).translated(redirectionDelta); + sysRgn &= scaleRegion(painter->clipRegion(), additionalDevicePixelRatio).translated(redirectionDelta.toPoint()); HRGN hrgn = qt_hrgn_from_qregion(sysRgn); SelectClipRgn(dc, hrgn); @@ -956,15 +955,16 @@ bool QWindowsXPStylePrivate::drawBackgroundDirectly(HDC dc, XPThemeData &themeDa engine). */ bool QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(XPThemeData &themeData, - int additionalDevicePixelRatio) + qreal additionalDevicePixelRatio) { QPainter *painter = themeData.painter; - QRect rect = scaleRect(themeData.rect, additionalDevicePixelRatio); + QRectF rectF = scaleRect(QRectF(themeData.rect), additionalDevicePixelRatio); if ((themeData.rotate + 90) % 180 == 0) { // Catch 90,270,etc.. degree flips. - rect = QRect(0, 0, rect.height(), rect.width()); + rectF = QRectF(0, 0, rectF.height(), rectF.width()); } - rect.moveTo(0,0); + rectF.moveTo(0, 0); + QRect rect = rectF.toRect(); int partId = themeData.partId; int stateId = themeData.stateId; int w = rect.width(); diff --git a/src/widgets/styles/qwindowsxpstyle_p_p.h b/src/widgets/styles/qwindowsxpstyle_p_p.h index 8ee4d1a641..2838ee93e0 100644 --- a/src/widgets/styles/qwindowsxpstyle_p_p.h +++ b/src/widgets/styles/qwindowsxpstyle_p_p.h @@ -394,8 +394,8 @@ public: void setTransparency(QWidget *widget, XPThemeData &themeData); bool drawBackground(XPThemeData &themeData); - bool drawBackgroundThruNativeBuffer(XPThemeData &themeData, int aditionalDevicePixelRatio); - bool drawBackgroundDirectly(HDC dc, XPThemeData &themeData, int aditionalDevicePixelRatio); + bool drawBackgroundThruNativeBuffer(XPThemeData &themeData, qreal aditionalDevicePixelRatio); + bool drawBackgroundDirectly(HDC dc, XPThemeData &themeData, qreal aditionalDevicePixelRatio); bool hasAlphaChannel(const QRect &rect); bool fixAlphaChannel(const QRect &rect); diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp index 5f7cfec5af..b8472e025e 100644 --- a/src/widgets/widgets/qmainwindow.cpp +++ b/src/widgets/widgets/qmainwindow.cpp @@ -670,8 +670,10 @@ QWidget *QMainWindow::takeCentralWidget() { Q_D(QMainWindow); QWidget *oldcentralwidget = d->layout->centralWidget(); - oldcentralwidget->setParent(0); - d->layout->setCentralWidget(0); + if (oldcentralwidget) { + oldcentralwidget->setParent(0); + d->layout->setCentralWidget(0); + } return oldcentralwidget; } |