Compute valid opaque region at surface commit time

This allows us to simplify rendering code in the compositor.
This commit is contained in:
Vlad Zahorodnii 2022-03-29 16:27:17 +03:00
parent a1d61bb6e8
commit 1dd6575d76
2 changed files with 14 additions and 3 deletions

View file

@ -581,17 +581,27 @@ void SurfaceInterfacePrivate::applyState(SurfaceState *next)
} else {
surfaceSize = implicitSurfaceSize;
}
const QRect surfaceRect(QPoint(0, 0), surfaceSize);
inputRegion = current.input & surfaceRect;
if (!current.buffer->hasAlphaChannel()) {
opaqueRegion = surfaceRect;
} else {
opaqueRegion = current.opaque & surfaceRect;
}
} else {
surfaceSize = QSize();
implicitSurfaceSize = QSize();
bufferSize = QSize();
inputRegion = QRegion();
opaqueRegion = QRegion();
}
surfaceToBufferMatrix = buildSurfaceToBufferMatrix();
bufferToSurfaceMatrix = surfaceToBufferMatrix.inverted();
inputRegion = current.input & QRect(QPoint(0, 0), surfaceSize);
if (opaqueRegionChanged) {
Q_EMIT q->opaqueChanged(current.opaque);
Q_EMIT q->opaqueChanged(opaqueRegion);
}
if (oldInputRegion != inputRegion) {
Q_EMIT q->inputChanged(inputRegion);
@ -715,7 +725,7 @@ QRegion SurfaceInterface::damage() const
QRegion SurfaceInterface::opaque() const
{
return d->current.opaque;
return d->opaqueRegion;
}
QRegion SurfaceInterface::input() const

View file

@ -107,6 +107,7 @@ public:
QSize implicitSurfaceSize;
QSize surfaceSize;
QRegion inputRegion;
QRegion opaqueRegion;
ClientBuffer *bufferRef = nullptr;
bool mapped = false;
bool hasCacheState = false;