void QXcbBackingStore::flush(QWindow *window, const QRegion ®ion, const QPoint &offset) { if (!m_image || m_image->size().isEmpty()) return; QSize imageSize = m_image->size(); QRegion clipped = region; clipped &= QRect(0, 0, window->width(), window->height()); clipped &= QRect(0, 0, imageSize.width(), imageSize.height()).translated(-offset); QRect bounds = clipped.boundingRect(); if (bounds.isNull()) return; Q_XCB_NOOP(connection()); QXcbWindow *platformWindow = static_cast<QXcbWindow *>(window->handle()); QVector<QRect> rects = clipped.rects(); for (int i = 0; i < rects.size(); ++i) m_image->put(platformWindow->xcb_window(), rects.at(i).topLeft(), rects.at(i).translated(offset)); Q_XCB_NOOP(connection()); if (m_syncingResize) { xcb_flush(xcb_connection()); connection()->sync(); m_syncingResize = false; platformWindow->updateSyncRequestCounter(); } }
void QXcbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) { QRect bounds = region.boundingRect(); if (size().isEmpty() || !geometry().contains(bounds)) return; Q_XCB_NOOP(connection()); QXcbWindow *window = static_cast<QXcbWindow *>(widget->window()->platformWindow()); extern QWidgetData* qt_widget_data(QWidget *); QPoint widgetOffset = qt_qwidget_data(widget)->wrect.topLeft(); QVector<QRect> rects = region.rects(); for (int i = 0; i < rects.size(); ++i) m_image->put(window->window(), rects.at(i).topLeft() - widgetOffset, rects.at(i).translated(offset)); Q_XCB_NOOP(connection()); if (m_syncingResize) { xcb_flush(xcb_connection()); connection()->sync(); m_syncingResize = false; window->updateSyncRequestCounter(); } }
void QXcbNativeBackingStore::flush(QWindow *window, const QRegion ®ion, const QPoint &offset) { if (m_pixmap.isNull()) return; QSize pixmapSize = m_pixmap.size(); QRegion clipped = region; clipped &= QRect(QPoint(), QHighDpi::toNativePixels(window->size(), window)); clipped &= QRect(0, 0, pixmapSize.width(), pixmapSize.height()).translated(-offset); QRect br = clipped.boundingRect(); if (br.isNull()) return; QXcbWindow *platformWindow = static_cast<QXcbWindow *>(window->handle()); if (!platformWindow) { qWarning("QXcbBackingStore::flush: QWindow has no platform window (QTBUG-32681)"); return; } Window wid = platformWindow->xcb_window(); Pixmap pid = qt_x11PixmapHandle(m_pixmap); QVector<XRectangle> clipRects = qt_region_to_xrectangles(clipped); #if QT_CONFIG(xrender) if (m_translucentBackground) { XWindowAttributes attrib; XGetWindowAttributes(display(), wid, &attrib); XRenderPictFormat *format = XRenderFindVisualFormat(display(), attrib.visual); Picture srcPic = qt_x11PictureHandle(m_pixmap); Picture dstPic = XRenderCreatePicture(display(), wid, format, 0, 0); XRenderSetPictureClipRectangles(display(), dstPic, 0, 0, clipRects.constData(), clipRects.size()); XRenderComposite(display(), PictOpSrc, srcPic, None, dstPic, br.x() + offset.x(), br.y() + offset.y(), 0, 0, br.x(), br.y(), br.width(), br.height()); XRenderFreePicture(display(), dstPic); } else #endif { GC gc = XCreateGC(display(), wid, 0, Q_NULLPTR); if (clipRects.size() != 1) XSetClipRectangles(display(), gc, 0, 0, clipRects.data(), clipRects.size(), YXBanded); XCopyArea(display(), pid, wid, gc, br.x() + offset.x(), br.y() + offset.y(), br.width(), br.height(), br.x(), br.y()); XFreeGC(display(), gc); } if (platformWindow->needsSync()) { platformWindow->updateSyncRequestCounter(); } else { XFlush(display()); } }