[SceneQPainter] Render per DrmOutput in DrmQPainterBackend

For each DrmOutput a set of buffers is created and presented. The
renderig is still in one go and not synced to the individual screens.

Dynamic changes are not yet supported.
This commit is contained in:
Martin Gräßlin 2015-04-17 11:18:58 +02:00
parent 9133c0f9d5
commit 5c79f777a4
2 changed files with 46 additions and 14 deletions

View file

@ -356,24 +356,38 @@ DrmQPainterBackend::DrmQPainterBackend(DrmBackend *backend)
, QPainterBackend()
, m_backend(backend)
{
m_buffer[0] = m_backend->createBuffer(m_backend->size());
m_buffer[0]->map();
m_buffer[1] = m_backend->createBuffer(m_backend->size());
m_buffer[1]->map();
m_buffer[0]->image()->fill(Qt::black);
m_buffer[1]->image()->fill(Qt::black);
const auto outputs = m_backend->outputs();
for (auto output: outputs) {
Output o;
auto initBuffer = [&o, output, this] (int index) {
o.buffer[index] = m_backend->createBuffer(output->size());
o.buffer[index]->map();
o.buffer[index]->image()->fill(Qt::black);
};
initBuffer(0);
initBuffer(1);
o.output = output;
m_outputs << o;
}
}
DrmQPainterBackend::~DrmQPainterBackend()
{
delete m_buffer[0];
delete m_buffer[1];
for (auto it = m_outputs.begin(); it != m_outputs.end(); ++it) {
delete (*it).buffer[0];
delete (*it).buffer[1];
}
}
QImage *DrmQPainterBackend::buffer()
{
return m_buffer[m_bufferIndex]->image();
return bufferForScreen(0);
}
QImage *DrmQPainterBackend::bufferForScreen(int screenId)
{
const Output &o = m_outputs.at(screenId);
return o.buffer[o.index]->image();
}
bool DrmQPainterBackend::needsFullRepaint() const
@ -383,7 +397,9 @@ bool DrmQPainterBackend::needsFullRepaint() const
void DrmQPainterBackend::prepareRenderingFrame()
{
m_bufferIndex = (m_bufferIndex + 1) % 2;
for (auto it = m_outputs.begin(); it != m_outputs.end(); ++it) {
(*it).index = ((*it).index + 1) % 2;
}
}
void DrmQPainterBackend::present(int mask, const QRegion &damage)
@ -393,13 +409,22 @@ void DrmQPainterBackend::present(int mask, const QRegion &damage)
if (!VirtualTerminal::self()->isActive()) {
return;
}
m_backend->present(m_buffer[m_bufferIndex]);
for (auto it = m_outputs.begin(); it != m_outputs.end(); ++it) {
const Output &o = *it;
m_backend->present(o.buffer[o.index], o.output);
}
}
bool DrmQPainterBackend::usesOverlayWindow() const
{
return false;
}
bool DrmQPainterBackend::perScreenRendering() const
{
return true;
}
#endif
#endif

View file

@ -46,6 +46,7 @@ class WaylandBackend;
}
class DrmBackend;
class DrmBuffer;
class DrmOutput;
class FramebufferBackend;
class X11WindowedBackend;
@ -198,15 +199,21 @@ public:
virtual ~DrmQPainterBackend();
QImage *buffer() override;
QImage *bufferForScreen(int screenId);
bool needsFullRepaint() const override;
bool usesOverlayWindow() const override;
void prepareRenderingFrame() override;
void present(int mask, const QRegion &damage) override;
bool perScreenRendering() const override;
private:
struct Output {
DrmBuffer *buffer[2];
DrmOutput *output;
int index = 0;
};
QVector<Output> m_outputs;
DrmBackend *m_backend;
DrmBuffer *m_buffer[2];
int m_bufferIndex = 0;
};
#endif