backends/drm: Fix buffer centering with active hardware transform

Prior to beb6cca65d, the drm backend used
to specify QRect(0, 0, modeSize.width(), modeSize.height()) CRTC rect,
so we didn't have to care about buffer transforms, but now that we
compute the CRTC rect from the buffer size, we have to take the buffer
transform into account.

It fixes squashed output contents when the output is rotated 90 or 270
degrees and it uses hardware transforms.
master
Vlad Zahorodnii 2 years ago
parent 88563cbc8e
commit fb1a6ecd8d

@ -207,6 +207,15 @@ DrmPipeline::Error DrmPipeline::commitPipelinesAtomic(const QVector<DrmPipeline
}
}
static QSize orientateSize(const QSize &size, DrmPlane::Transformations transforms)
{
if (transforms & (DrmPlane::Transformation::Rotate90 | DrmPlane::Transformation::Rotate270)) {
return size.transposed();
} else {
return size;
}
}
static QRect centerBuffer(const QSize &bufferSize, const QSize &modeSize)
{
const double widthScale = bufferSize.width() / double(modeSize.width());
@ -231,7 +240,7 @@ void DrmPipeline::prepareAtomicPresentation()
m_pending.crtc->setPending(DrmCrtc::PropertyIndex::VrrEnabled, m_pending.syncMode == RenderLoopPrivate::SyncMode::Adaptive || m_pending.syncMode == RenderLoopPrivate::SyncMode::AdaptiveAsync);
m_pending.crtc->setPending(DrmCrtc::PropertyIndex::Gamma_LUT, m_pending.gamma ? m_pending.gamma->blobId() : 0);
const auto fb = m_pending.layer->currentBuffer().get();
m_pending.crtc->primaryPlane()->set(QPoint(0, 0), fb->buffer()->size(), centerBuffer(fb->buffer()->size(), m_pending.mode->size()));
m_pending.crtc->primaryPlane()->set(QPoint(0, 0), fb->buffer()->size(), centerBuffer(orientateSize(fb->buffer()->size(), m_pending.bufferOrientation), m_pending.mode->size()));
m_pending.crtc->primaryPlane()->setBuffer(fb);
if (m_pending.crtc->cursorPlane()) {

Loading…
Cancel
Save