Commit 1dd6575d authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

Compute valid opaque region at surface commit time

This allows us to simplify rendering code in the compositor.
parent a1d61bb6
......@@ -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
......
......@@ -107,6 +107,7 @@ public:
QSize implicitSurfaceSize;
QSize surfaceSize;
QRegion inputRegion;
QRegion opaqueRegion;
ClientBuffer *bufferRef = nullptr;
bool mapped = false;
bool hasCacheState = false;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment