diff options
Diffstat (limited to 'src/compositor/compositor_api')
5 files changed, 55 insertions, 2 deletions
diff --git a/src/compositor/compositor_api/qwaylandquickcompositor.cpp b/src/compositor/compositor_api/qwaylandquickcompositor.cpp index 8e8a903e3..426008a60 100644 --- a/src/compositor/compositor_api/qwaylandquickcompositor.cpp +++ b/src/compositor/compositor_api/qwaylandquickcompositor.cpp @@ -53,6 +53,7 @@ #include "qwaylandquickitem.h" #include "qwaylandoutput.h" #include <QtWaylandCompositor/private/qwaylandcompositor_p.h> +#include <QtWaylandCompositor/QWaylandViewporter> #include "qwaylandsurfacegrabber.h" QT_BEGIN_NAMESPACE @@ -60,8 +61,9 @@ QT_BEGIN_NAMESPACE class QWaylandQuickCompositorPrivate : public QWaylandCompositorPrivate { public: - QWaylandQuickCompositorPrivate(QWaylandCompositor *compositor) + explicit QWaylandQuickCompositorPrivate(QWaylandCompositor *compositor) : QWaylandCompositorPrivate(compositor) + , m_viewporter(new QWaylandViewporter(compositor)) { } protected: @@ -69,6 +71,8 @@ protected: { return new QWaylandQuickSurface(); } +private: + QScopedPointer<QWaylandViewporter> m_viewporter; }; QWaylandQuickCompositor::QWaylandQuickCompositor(QObject *parent) diff --git a/src/compositor/compositor_api/qwaylandquickitem.cpp b/src/compositor/compositor_api/qwaylandquickitem.cpp index bc8365982..f848a0169 100644 --- a/src/compositor/compositor_api/qwaylandquickitem.cpp +++ b/src/compositor/compositor_api/qwaylandquickitem.cpp @@ -1317,6 +1317,10 @@ QSGNode *QWaylandQuickItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeDat d->provider->setSmooth(smooth()); node->setRect(rect); + qreal scale = surface()->bufferScale(); + QRectF source = surface()->sourceGeometry(); + node->setSourceRect(QRectF(source.topLeft() * scale, source.size() * scale)); + return node; } else { Q_ASSERT(!d->provider); diff --git a/src/compositor/compositor_api/qwaylandsurface.cpp b/src/compositor/compositor_api/qwaylandsurface.cpp index 8ad2389b6..eef51283c 100644 --- a/src/compositor/compositor_api/qwaylandsurface.cpp +++ b/src/compositor/compositor_api/qwaylandsurface.cpp @@ -235,6 +235,7 @@ void QWaylandSurfacePrivate::surface_commit(Resource *) // Needed in order to know whether we want to emit signals later QSize oldBufferSize = bufferSize; + QRectF oldSourceGeometry = sourceGeometry; QSize oldDestinationSize = destinationSize; bool oldHasContent = hasContent; int oldBufferScale = bufferScale; @@ -244,7 +245,9 @@ void QWaylandSurfacePrivate::surface_commit(Resource *) bufferRef = pending.buffer; bufferScale = pending.bufferScale; bufferSize = bufferRef.size(); - destinationSize = pending.destinationSize.isEmpty() ? bufferSize / bufferScale : pending.destinationSize; + QSize surfaceSize = bufferSize / bufferScale; + sourceGeometry = !pending.sourceGeometry.isValid() ? QRect(QPoint(), surfaceSize) : pending.sourceGeometry; + destinationSize = pending.destinationSize.isEmpty() ? sourceGeometry.size().toSize() : pending.destinationSize; damage = pending.damage.intersected(QRect(QPoint(), destinationSize)); hasContent = bufferRef.hasContent(); frameCallbacks << pendingFrameCallbacks; @@ -252,6 +255,9 @@ void QWaylandSurfacePrivate::surface_commit(Resource *) opaqueRegion = pending.opaqueRegion.intersected(QRect(QPoint(), destinationSize)); QPoint offsetForNextFrame = pending.offset; + if (viewport) + viewport->checkCommittedState(); + // Clear per-commit state pending.buffer = QWaylandBufferRef(); pending.offset = QPoint(); @@ -284,6 +290,9 @@ void QWaylandSurfacePrivate::surface_commit(Resource *) if (oldDestinationSize != destinationSize) emit q->destinationSizeChanged(); + if (oldSourceGeometry != sourceGeometry) + emit q->sourceGeometryChanged(); + if (oldHasContent != hasContent) emit q->hasContentChanged(); @@ -471,6 +480,35 @@ bool QWaylandSurface::hasContent() const } /*! + * \qmlproperty rect QtWaylandCompositor::WaylandSurface::sourceGeometry + * + * This property describes the portion of the attached Wayland buffer that should + * be drawn on the screen. The coordinates are from the corner of the buffer and are + * scaled by \l bufferScale. + * + * \sa bufferScale + * \sa bufferSize + * \sa destinationSize + */ + +/*! + * \property QWaylandSurface::sourceGeometry + * + * This property describes the portion of the attached QWaylandBuffer that should + * be drawn on the screen. The coordinates are from the corner of the buffer and are + * scaled by \l bufferScale. + * + * \sa bufferScale + * \sa bufferSize + * \sa destinationSize + */ +QRectF QWaylandSurface::sourceGeometry() const +{ + Q_D(const QWaylandSurface); + return d->sourceGeometry; +} + +/*! * \qmlproperty size QtWaylandCompositor::WaylandSurface::destinationSize * * This property holds the size of this WaylandSurface in surface coordinates. diff --git a/src/compositor/compositor_api/qwaylandsurface.h b/src/compositor/compositor_api/qwaylandsurface.h index 13f09f33c..9bf842900 100644 --- a/src/compositor/compositor_api/qwaylandsurface.h +++ b/src/compositor/compositor_api/qwaylandsurface.h @@ -81,6 +81,7 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandSurface : public QWaylandObject Q_OBJECT Q_DECLARE_PRIVATE(QWaylandSurface) Q_PROPERTY(QWaylandClient *client READ client CONSTANT) + Q_PROPERTY(QRectF sourceGeometry READ sourceGeometry NOTIFY sourceGeometryChanged) Q_PROPERTY(QSize destinationSize READ destinationSize NOTIFY destinationSizeChanged) #if QT_DEPRECATED_SINCE(5, 13) Q_PROPERTY(QSize size READ size NOTIFY sizeChanged) // Qt 6: Remove @@ -113,6 +114,7 @@ public: bool hasContent() const; + QRectF sourceGeometry() const; QSize destinationSize() const; #if QT_DEPRECATED_SINCE(5, 13) QT_DEPRECATED QSize size() const; @@ -162,6 +164,7 @@ Q_SIGNALS: void damaged(const QRegion &rect); void parentChanged(QWaylandSurface *newParent, QWaylandSurface *oldParent); void childAdded(QWaylandSurface *child); + void sourceGeometryChanged(); void destinationSizeChanged(); #if QT_DEPRECATED_SINCE(5, 13) QT_DEPRECATED void sizeChanged(); diff --git a/src/compositor/compositor_api/qwaylandsurface_p.h b/src/compositor/compositor_api/qwaylandsurface_p.h index b34367801..85643623d 100644 --- a/src/compositor/compositor_api/qwaylandsurface_p.h +++ b/src/compositor/compositor_api/qwaylandsurface_p.h @@ -73,6 +73,7 @@ #include <wayland-util.h> #include <QtWaylandCompositor/private/qwayland-server-wayland.h> +#include <QtWaylandCompositor/private/qwaylandviewporter_p.h> QT_BEGIN_NAMESPACE @@ -144,6 +145,7 @@ public: //member variables QRegion damage; QWaylandBufferRef bufferRef; QWaylandSurfaceRole *role = nullptr; + QWaylandViewporterPrivate::Viewport *viewport = nullptr; struct { QWaylandBufferRef buffer; @@ -152,6 +154,7 @@ public: //member variables bool newlyAttached; QRegion inputRegion; int bufferScale; + QRectF sourceGeometry; QSize destinationSize; QRegion opaqueRegion; } pending; @@ -167,6 +170,7 @@ public: //member variables QRegion inputRegion; QRegion opaqueRegion; + QRectF sourceGeometry; QSize destinationSize; QSize bufferSize; int bufferScale = 1; |