summaryrefslogtreecommitdiffstats
path: root/src/compositor/compositor_api/qwaylandsurface.cpp
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2022-02-11 09:11:00 +0100
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2022-02-17 07:53:46 +0100
commit00323844defd67b0edc76db1c56ba32433a232bf (patch)
treeb7470038435703fdf9dc3f8e44df78b4d24ea169 /src/compositor/compositor_api/qwaylandsurface.cpp
parent824ac51444e7df1420e9d35b94fd3efd204f9cc9 (diff)
Use opaque render list when client content is opaque
If the client says it's fully opaque through the set_opaque_region request, we can disable blending for the item and potentially improve performance a little bit. [ChangeLog][QtWaylandCompositor] The compositor now respects the opaque region set by the client and no longer applies blending or overdraw for fully opaque windows. Fixes: QTBUG-100373 Change-Id: Iaa68fbf1f086d926c9c1867d981a63810f4ca855 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'src/compositor/compositor_api/qwaylandsurface.cpp')
-rw-r--r--src/compositor/compositor_api/qwaylandsurface.cpp34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/compositor/compositor_api/qwaylandsurface.cpp b/src/compositor/compositor_api/qwaylandsurface.cpp
index b07a93e91..4523080b2 100644
--- a/src/compositor/compositor_api/qwaylandsurface.cpp
+++ b/src/compositor/compositor_api/qwaylandsurface.cpp
@@ -257,6 +257,7 @@ void QWaylandSurfacePrivate::surface_commit(Resource *)
QSize surfaceSize = bufferSize / bufferScale;
sourceGeometry = !pending.sourceGeometry.isValid() ? QRect(QPoint(), surfaceSize) : pending.sourceGeometry;
destinationSize = pending.destinationSize.isEmpty() ? sourceGeometry.size().toSize() : pending.destinationSize;
+ QRect destinationRect(QPoint(), destinationSize);
if (!pending.damageInBufferCoordinates || pending.bufferScale == 1) {
// pending.damage is already in surface coordinates
damage = pending.damage.intersected(QRect(QPoint(), destinationSize));
@@ -272,13 +273,19 @@ void QWaylandSurfacePrivate::surface_commit(Resource *)
};
damage = {};
for (const QRect &r : pending.damage) {
- damage |= xform(r, bufferScale).intersected(QRect{{}, destinationSize});
+ damage |= xform(r, bufferScale).intersected(destinationRect);
}
}
hasContent = bufferRef.hasContent();
frameCallbacks << pendingFrameCallbacks;
- inputRegion = pending.inputRegion.intersected(QRect(QPoint(), destinationSize));
- opaqueRegion = pending.opaqueRegion.intersected(QRect(QPoint(), destinationSize));
+ inputRegion = pending.inputRegion.intersected(destinationRect);
+ opaqueRegion = pending.opaqueRegion.intersected(destinationRect);
+ bool becameOpaque = opaqueRegion.boundingRect().contains(destinationRect);
+ if (becameOpaque != isOpaque) {
+ isOpaque = becameOpaque;
+ emit q->isOpaqueChanged();
+ }
+
QPoint offsetForNextFrame = pending.offset;
if (viewport)
@@ -857,6 +864,27 @@ bool QWaylandSurface::inhibitsIdle() const
return !d->idleInhibitors.isEmpty();
}
+/*!
+ * \qmlproperty bool QtWaylandCompositor::WaylandSurface::isOpaque
+ * \since 6.4
+ *
+ * This property holds whether the surface is fully opaque, as reported by the
+ * client through the set_opaque_region request.
+ */
+
+/*!
+ * \property bool QWaylandSurface::isOpaque
+ * \since 6.4
+ *
+ * This property holds whether the surface is fully opaque, as reported by the
+ * client through the set_opaque_region request.
+ */
+bool QWaylandSurface::isOpaque() const
+{
+ Q_D(const QWaylandSurface);
+ return d->isOpaque;
+}
+
#if QT_CONFIG(im)
QWaylandInputMethodControl *QWaylandSurface::inputMethodControl() const
{