Fix VNC format conversion

Pass the right from depth to the conversion function, and
set the right format before creating the compositor image
for RGB16 support.

Fixes: QTBUG-85621
Change-Id: I76f46a3c2d8f1d2b040b790035dbdb0a960ff1a7
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
(cherry picked from commit 47c6b5b91e0d1271075d98ded5aa7a25296b5ee3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Allan Sandfeld Jensen 2021-01-12 14:27:38 +01:00 committed by Qt Cherry-pick Bot
parent e15d63baa3
commit 3b1cb25eb0
4 changed files with 9 additions and 8 deletions

View File

@ -514,8 +514,9 @@ void QRfbRawEncoder::write()
// convert pixels
char *b = buffer.data();
const int bstep = rect.w * bytesPerPixel;
const int depth = screenImage.depth();
for (int i = 0; i < rect.h; ++i) {
client->convertPixels(b, (const char*)screendata, rect.w);
client->convertPixels(b, (const char*)screendata, rect.w, depth);
screendata += linestep;
b += bstep;
}
@ -568,9 +569,10 @@ void QVncClientCursor::write(QVncClient *client) const
Q_ASSERT(cursor.hasAlphaChannel());
const QImage img = cursor.convertToFormat(client->server()->screen()->format());
const int n = client->clientBytesPerPixel() * img.width();
const int depth = img.depth();
char *buffer = new char[n];
for (int i = 0; i < img.height(); ++i) {
client->convertPixels(buffer, (const char*)img.scanLine(i), img.width());
client->convertPixels(buffer, (const char*)img.scanLine(i), img.width(), depth);
socket->write(buffer, n);
}
delete[] buffer;

View File

@ -97,10 +97,8 @@ void QVncClient::setDirty(const QRegion &region)
}
}
void QVncClient::convertPixels(char *dst, const char *src, int count) const
void QVncClient::convertPixels(char *dst, const char *src, int count, int screendepth) const
{
const int screendepth = m_server->screen()->depth();
// cutoffs
#if Q_BYTE_ORDER == Q_BIG_ENDIAN
if (!m_swapBytes)

View File

@ -77,7 +77,7 @@ public:
return m_pixelFormat.bitsPerPixel / 8;
}
void convertPixels(char *dst, const char *src, int count) const;
void convertPixels(char *dst, const char *src, int count, int depth) const;
inline bool doPixelConversion() const { return m_needConversion; }
signals:

View File

@ -86,14 +86,13 @@ bool QVncScreen::initialize()
}
}
QFbScreen::initializeCompositor();
switch (depth()) {
case 32:
dirty = new QVncDirtyMapOptimized<quint32>(this);
break;
case 16:
dirty = new QVncDirtyMapOptimized<quint16>(this);
mFormat = QImage::Format_RGB16;
break;
case 8:
dirty = new QVncDirtyMapOptimized<quint8>(this);
@ -105,6 +104,8 @@ bool QVncScreen::initialize()
return false;
}
QFbScreen::initializeCompositor();
setPowerState(PowerStateOff);
return true;