X11PaintEngine: Don't use system clip for non-system painting
When painting into a pixmap, we would apply the system clip, which is a rectangle that starts at the position of the current widget relative to the window. If the widget was not positioned at (0,0), we would therefore clip the top left part of the drawing when drawing into a pixmap, which is obviously not intentional. The solution is in accordance with how it is done in e.g. the OpenGL paint engine, where useSystemClip is set to true only if we are drawing to a widget. The system clip should otherwise be ignored, so we do that in the X11 paint engine as well. Task-number: QTBUG-70387 Change-Id: I9cad26019970280a8a452dc6f1015d229120cac5 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
parent
b0145f029c
commit
26462f9c4c
@ -192,6 +192,10 @@ bool QXcbNativeBackingStore::scroll(const QRegion &area, int dx, int dy)
|
||||
|
||||
void QXcbNativeBackingStore::beginPaint(const QRegion ®ion)
|
||||
{
|
||||
QX11PlatformPixmap *x11pm = qt_x11Pixmap(m_pixmap);
|
||||
if (x11pm)
|
||||
x11pm->setIsBackingStore(true);
|
||||
|
||||
#if QT_CONFIG(xrender)
|
||||
if (m_translucentBackground) {
|
||||
const QVector<XRectangle> xrects = qt_region_to_xrectangles(region);
|
||||
|
@ -200,6 +200,7 @@ public:
|
||||
uint has_pattern : 1;
|
||||
uint has_alpha_pen : 1;
|
||||
uint has_alpha_brush : 1;
|
||||
uint use_sysclip : 1;
|
||||
uint render_hints;
|
||||
|
||||
const QXcbX11Info *xinfo;
|
||||
@ -701,6 +702,9 @@ bool QX11PaintEngine::begin(QPaintDevice *pdev)
|
||||
d->xlibMaxLinePoints = 32762; // a safe number used to avoid, call to XMaxRequestSize(d->dpy) - 3;
|
||||
d->opacity = 1;
|
||||
|
||||
QX11PlatformPixmap *x11pm = paintDevice()->devType() == QInternal::Pixmap ? qt_x11Pixmap(*static_cast<QPixmap *>(paintDevice())) : nullptr;
|
||||
d->use_sysclip = paintDevice()->devType() == QInternal::Widget || (x11pm ? x11pm->isBackingStore() : false);
|
||||
|
||||
// Set up the polygon clipper. Note: This will only work in
|
||||
// polyline mode as long as we have a buffer zone, since a
|
||||
// polyline may be clipped into several non-connected polylines.
|
||||
@ -1472,7 +1476,7 @@ void QX11PaintEngine::updatePen(const QPen &pen)
|
||||
}
|
||||
|
||||
if (!d->has_clipping) { // if clipping is set the paintevent clip region is merged with the clip region
|
||||
QRegion sysClip = systemClip();
|
||||
QRegion sysClip = d->use_sysclip ? systemClip() : QRegion();
|
||||
if (!sysClip.isEmpty())
|
||||
x11SetClipRegion(d->dpy, d->gc, 0, d->picture, sysClip);
|
||||
else
|
||||
@ -1603,7 +1607,7 @@ void QX11PaintEngine::updateBrush(const QBrush &brush, const QPointF &origin)
|
||||
vals.fill_style = s;
|
||||
XChangeGC(d->dpy, d->gc_brush, mask, &vals);
|
||||
if (!d->has_clipping) {
|
||||
QRegion sysClip = systemClip();
|
||||
QRegion sysClip = d->use_sysclip ? systemClip() : QRegion();
|
||||
if (!sysClip.isEmpty())
|
||||
x11SetClipRegion(d->dpy, d->gc_brush, 0, d->picture, sysClip);
|
||||
else
|
||||
@ -2223,7 +2227,7 @@ void QX11PaintEngine::updateMatrix(const QTransform &mtx)
|
||||
void QX11PaintEngine::updateClipRegion_dev(const QRegion &clipRegion, Qt::ClipOperation op)
|
||||
{
|
||||
Q_D(QX11PaintEngine);
|
||||
QRegion sysClip = systemClip();
|
||||
QRegion sysClip = d->use_sysclip ? systemClip() : QRegion();
|
||||
if (op == Qt::NoClip) {
|
||||
d->has_clipping = false;
|
||||
d->crgn = sysClip;
|
||||
|
@ -1772,6 +1772,20 @@ XID QX11PlatformPixmap::createBitmapFromImage(const QImage &image)
|
||||
return hd;
|
||||
}
|
||||
|
||||
bool QX11PlatformPixmap::isBackingStore() const
|
||||
{
|
||||
return (flags & IsBackingStore);
|
||||
}
|
||||
|
||||
void QX11PlatformPixmap::setIsBackingStore(bool on)
|
||||
{
|
||||
if (on)
|
||||
flags |= IsBackingStore;
|
||||
else {
|
||||
flags &= ~IsBackingStore;
|
||||
}
|
||||
}
|
||||
|
||||
#if QT_CONFIG(xrender)
|
||||
void QX11PlatformPixmap::convertToARGB32(bool preserveContents)
|
||||
{
|
||||
|
@ -90,6 +90,8 @@ public:
|
||||
void convertToARGB32(bool preserveContents = true);
|
||||
#endif
|
||||
|
||||
bool isBackingStore() const;
|
||||
void setIsBackingStore(bool on);
|
||||
private:
|
||||
friend class QX11PaintEngine;
|
||||
friend const QXcbX11Info &qt_x11Info(const QPixmap &pixmap);
|
||||
@ -110,7 +112,8 @@ private:
|
||||
Uninitialized = 0x1,
|
||||
Readonly = 0x2,
|
||||
InvertedWhenBoundToTexture = 0x4,
|
||||
GlSurfaceCreatedWithAlpha = 0x8
|
||||
GlSurfaceCreatedWithAlpha = 0x8,
|
||||
IsBackingStore = 0x10
|
||||
};
|
||||
uint flags;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user