Qt 4.8
Public Functions | Properties | List of all members
QRfbRawEncoder Class Reference

#include <qscreenvnc_p.h>

Inheritance diagram for QRfbRawEncoder:
QRfbEncoder QRfbEncoder

Public Functions

 QRfbRawEncoder (QVNCServer *s)
 
 QRfbRawEncoder (QVNCServer *s)
 
void write ()
 
void write ()
 
- Public Functions inherited from QRfbEncoder
 QRfbEncoder (QVNCServer *s)
 
 QRfbEncoder (QVNCServer *s)
 
virtual ~QRfbEncoder ()
 
virtual ~QRfbEncoder ()
 

Properties

QByteArray buffer
 

Additional Inherited Members

- Protected Variables inherited from QRfbEncoder
QVNCServerserver
 

Detailed Description

Definition at line 278 of file qscreenvnc_p.h.

Constructors and Destructors

◆ QRfbRawEncoder() [1/2]

QRfbRawEncoder::QRfbRawEncoder ( QVNCServer s)
inline

Definition at line 281 of file qscreenvnc_p.h.

281 : QRfbEncoder(s) {}
QRfbEncoder(QVNCServer *s)
Definition: qscreenvnc_p.h:269

◆ QRfbRawEncoder() [2/2]

QRfbRawEncoder::QRfbRawEncoder ( QVNCServer s)
inline

Definition at line 287 of file qvncserver.h.

287 : QRfbEncoder(s) {}
QRfbEncoder(QVNCServer *s)
Definition: qscreenvnc_p.h:269

Functions

◆ write() [1/2]

void QRfbRawEncoder::write ( )
virtual

Implements QRfbEncoder.

Definition at line 1898 of file qscreenvnc_qws.cpp.

Referenced by QVNCDirtyMap::QVNCDirtyMap().

1899 {
1900  QWSDisplay::grab(false);
1901 
1903  QTcpSocket *socket = server->clientSocket();
1904 
1905  const int bytesPerPixel = server->clientBytesPerPixel();
1906 
1907  // create a region from the dirty rects and send the region's merged rects.
1908  QRegion rgn;
1909  if (map) {
1910  for (int y = 0; y < map->mapHeight; ++y) {
1911  for (int x = 0; x < map->mapWidth; ++x) {
1912  if (!map->dirty(x, y))
1913  continue;
1914  rgn += QRect(x * MAP_TILE_SIZE, y * MAP_TILE_SIZE,
1915  MAP_TILE_SIZE, MAP_TILE_SIZE);
1916  map->setClean(x, y);
1917  }
1918  }
1919 
1920  rgn &= QRect(0, 0, server->screen()->deviceWidth(),
1921  server->screen()->deviceHeight());
1922  }
1923  const QVector<QRect> rects = rgn.rects();
1924 
1925  {
1926  const char tmp[2] = { 0, 0 }; // msg type, padding
1927  socket->write(tmp, sizeof(tmp));
1928  }
1929 
1930  {
1931  const quint16 count = htons(rects.size());
1932  socket->write((char *)&count, sizeof(count));
1933  }
1934 
1935  if (rects.size() <= 0) {
1937  return;
1938  }
1939 
1940  const QImage screenImage = server->screenImage();
1941 
1942  for (int i = 0; i < rects.size(); ++i) {
1943  const QRect tileRect = rects.at(i);
1944  const QRfbRect rect(tileRect.x(), tileRect.y(),
1945  tileRect.width(), tileRect.height());
1946  rect.write(socket);
1947 
1948  const quint32 encoding = htonl(0); // raw encoding
1949  socket->write((char *)&encoding, sizeof(encoding));
1950 
1951  int linestep = screenImage.bytesPerLine();
1952  const uchar *screendata = screenImage.scanLine(rect.y)
1953  + rect.x * screenImage.depth() / 8;
1954 
1955 #ifndef QT_NO_QWS_CURSOR
1956  // hardware cursors must be blended with the screen memory
1957  const bool doBlendCursor = qt_screencursor
1958  && !server->hasClientCursor()
1960  QImage tileImage;
1961  if (doBlendCursor) {
1962  const QRect cursorRect = qt_screencursor->boundingRect()
1963  .translated(-server->screen()->offset());
1964  if (tileRect.intersects(cursorRect)) {
1965  tileImage = screenImage.copy(tileRect);
1966  blendCursor(tileImage,
1967  tileRect.translated(server->screen()->offset()));
1968  screendata = tileImage.bits();
1969  linestep = tileImage.bytesPerLine();
1970  }
1971  }
1972 #endif // QT_NO_QWS_CURSOR
1973 
1974  if (server->doPixelConversion()) {
1975  const int bufferSize = rect.w * rect.h * bytesPerPixel;
1976  if (bufferSize > buffer.size())
1977  buffer.resize(bufferSize);
1978 
1979  // convert pixels
1980  char *b = buffer.data();
1981  const int bstep = rect.w * bytesPerPixel;
1982  for (int i = 0; i < rect.h; ++i) {
1983  server->convertPixels(b, (const char*)screendata, rect.w);
1984  screendata += linestep;
1985  b += bstep;
1986  }
1987  socket->write(buffer.constData(), bufferSize);
1988  } else {
1989  for (int i = 0; i < rect.h; ++i) {
1990  socket->write((const char*)screendata, rect.w * bytesPerPixel);
1991  screendata += linestep;
1992  }
1993  }
1994  if (socket->state() == QAbstractSocket::UnconnectedState)
1995  break;
1996  }
1997  socket->flush();
1998 
2000 }
void convertPixels(char *dst, const char *src, int count) const
QImage copy(const QRect &rect=QRect()) const
Returns a sub-area of the image as a new image.
Definition: qimage.cpp:1410
bool dirty(int x, int y) const
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
bool flush()
This function writes as much as possible from the internal write buffer to the underlying network soc...
bool hasClientCursor() const
Definition: qscreenvnc_p.h:467
static int bytesPerPixel(QImage::Format format)
QRect translated(int dx, int dy) const
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis...
Definition: qrect.h:328
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int deviceWidth() const
Returns the physical width of the framebuffer device in pixels.
Definition: qscreen_qws.h:233
int bytesPerLine() const
Returns the number of bytes per image scanline.
Definition: qimage.cpp:1812
#define MAP_TILE_SIZE
Definition: qscreenvnc_p.h:100
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
bool doPixelConversion() const
Definition: qscreenvnc_p.h:465
QVNCScreen * screen() const
Definition: qscreenvnc_p.h:461
unsigned char uchar
Definition: qglobal.h:994
bool isAccelerated() const
Returns true if the cursor is accelerated; otherwise false.
Definition: qscreen_qws.h:153
QVNCServer * server
Definition: qscreenvnc_p.h:275
unsigned short quint16
Definition: qglobal.h:936
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
The QTcpSocket class provides a TCP socket.
Definition: qtcpsocket.h:56
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
int depth() const
Returns the depth of the image.
Definition: qimage.cpp:1620
static void grab()
QByteArray buffer
Definition: qscreenvnc_p.h:286
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
void write(QTcpSocket *s) const
uchar * bits()
Returns a pointer to the first pixel data.
Definition: qimage.cpp:1946
QTcpSocket * clientSocket() const
Definition: qscreenvnc_p.h:463
int deviceHeight() const
Returns the full height of the framebuffer device in pixels.
Definition: qscreen_qws.h:234
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
QVNCDirtyMap * dirtyMap() const
Definition: qscreenvnc_p.h:462
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
QRect boundingRect() const
Returns the cursor&#39;s bounding rectangle.
Definition: qscreen_qws.h:150
QVector< QRect > rects() const
Returns an array of non-overlapping rectangles that make up the region.
Definition: qregion.cpp:4412
void resize(int size)
Sets the size of the byte array to size bytes.
unsigned int quint32
Definition: qglobal.h:938
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402
static void blendCursor(QImage &image, const QRect &imageRect)
QImage screenImage() const
bool intersects(const QRect &r) const
Returns true if this rectangle intersects with the given rectangle (i.
Definition: qrect.cpp:1429
Q_GUI_EXPORT QScreenCursor * qt_screencursor
Definition: qscreen_qws.cpp:67
static void ungrab()
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
Definition: qiodevice.cpp:1342
void setClean(int x, int y)
uchar * scanLine(int)
Returns a pointer to the pixel data at the scanline with index i.
Definition: qimage.cpp:1886
SocketState state() const
Returns the state of the socket.
QPoint offset() const
Returns the logical offset of the screen, i.
int clientBytesPerPixel() const
Definition: qscreenvnc_p.h:457

◆ write() [2/2]

void QRfbRawEncoder::write ( )
virtual

Implements QRfbEncoder.

Properties

◆ buffer

QByteArray QRfbRawEncoder::buffer
private

Definition at line 286 of file qscreenvnc_p.h.


The documentation for this class was generated from the following files: