Qt 4.8
Public Functions | Private Types | Properties | Friends | List of all members
QRfbHextileEncoder< SRC > Class Template Reference

#include <qscreenvnc_p.h>

Inheritance diagram for QRfbHextileEncoder< SRC >:
QRfbEncoder QRfbEncoder

Public Functions

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

Private Types

enum  SubEncoding {
  Raw = 1, BackgroundSpecified = 2, ForegroundSpecified = 4, AnySubrects = 8,
  SubrectsColoured = 16, Raw = 1, BackgroundSpecified = 2, ForegroundSpecified = 4,
  AnySubrects = 8, SubrectsColoured = 16
}
 
enum  SubEncoding {
  Raw = 1, BackgroundSpecified = 2, ForegroundSpecified = 4, AnySubrects = 8,
  SubrectsColoured = 16, Raw = 1, BackgroundSpecified = 2, ForegroundSpecified = 4,
  AnySubrects = 8, SubrectsColoured = 16
}
 

Properties

SRC bg
 
QByteArray buffer
 
QRfbDualColorHextile< SRC > dualColorHextile
 
SRC fg
 
QRfbMultiColorHextile< SRC > multiColorHextile
 
bool newBg
 
bool newFg
 
QRfbSingleColorHextile< SRC > singleColorHextile
 

Friends

class QRfbDualColorHextile< SRC >
 
class QRfbMultiColorHextile< SRC >
 
class QRfbSingleColorHextile< SRC >
 

Additional Inherited Members

- Protected Variables inherited from QRfbEncoder
QVNCServerserver
 

Detailed Description

template<class SRC>
class QRfbHextileEncoder< SRC >

Definition at line 289 of file qscreenvnc_p.h.

Enumerations

◆ SubEncoding [1/2]

template<class SRC>
enum QRfbHextileEncoder::SubEncoding
private
Enumerator
Raw 
BackgroundSpecified 
ForegroundSpecified 
AnySubrects 
SubrectsColoured 
Raw 
BackgroundSpecified 
ForegroundSpecified 
AnySubrects 
SubrectsColoured 

Definition at line 408 of file qscreenvnc_p.h.

◆ SubEncoding [2/2]

template<class SRC>
enum QRfbHextileEncoder::SubEncoding
private
Enumerator
Raw 
BackgroundSpecified 
ForegroundSpecified 
AnySubrects 
SubrectsColoured 
Raw 
BackgroundSpecified 
ForegroundSpecified 
AnySubrects 
SubrectsColoured 

Definition at line 414 of file qvncserver.h.

Constructors and Destructors

◆ QRfbHextileEncoder() [1/2]

template<class SRC >
QRfbHextileEncoder< SRC >::QRfbHextileEncoder ( QVNCServer s)

Definition at line 1773 of file qscreenvnc_qws.cpp.

Referenced by QVNCDirtyMap::QVNCDirtyMap().

1774  : QRfbEncoder(s),
1776 {
1777 }
QRfbEncoder(QVNCServer *s)
Definition: qscreenvnc_p.h:269
QRfbSingleColorHextile< SRC > singleColorHextile
Definition: qscreenvnc_p.h:417
QRfbMultiColorHextile< SRC > multiColorHextile
Definition: qscreenvnc_p.h:419
QRfbDualColorHextile< SRC > dualColorHextile
Definition: qscreenvnc_p.h:418

◆ QRfbHextileEncoder() [2/2]

template<class SRC>
QRfbHextileEncoder< SRC >::QRfbHextileEncoder ( QVNCServer s)

Functions

◆ write() [1/2]

template<class SRC >
void QRfbHextileEncoder< SRC >::write ( )
virtual

Implements QRfbEncoder.

Definition at line 1784 of file qscreenvnc_qws.cpp.

Referenced by QVNCDirtyMap::QVNCDirtyMap().

1785 {
1786  QWSDisplay::grab(true);
1787 
1789  QTcpSocket *socket = server->clientSocket();
1790 
1791  const quint32 encoding = htonl(5); // hextile encoding
1792  const int bytesPerPixel = server->clientBytesPerPixel();
1793 
1794  {
1795  const char tmp[2] = { 0, 0 }; // msg type, padding
1796  socket->write(tmp, sizeof(tmp));
1797  }
1798  {
1799  const quint16 count = htons(map->numDirty);
1800  socket->write((char *)&count, sizeof(count));
1801  }
1802 
1803  if (map->numDirty <= 0) {
1805  return;
1806  }
1807 
1808  newBg = true;
1809  newFg = true;
1810 
1811  const QImage screenImage = server->screenImage();
1812  QRfbRect rect(0, 0, MAP_TILE_SIZE, MAP_TILE_SIZE);
1813 
1814  for (int y = 0; y < map->mapHeight; ++y) {
1815  if (rect.y + MAP_TILE_SIZE > server->screen()->height())
1816  rect.h = server->screen()->height() - rect.y;
1817  rect.w = MAP_TILE_SIZE;
1818  for (int x = 0; x < map->mapWidth; ++x) {
1819  if (!map->dirty(x, y))
1820  continue;
1821  map->setClean(x, y);
1822 
1823  rect.x = x * MAP_TILE_SIZE;
1824  if (rect.x + MAP_TILE_SIZE > server->screen()->deviceWidth())
1825  rect.w = server->screen()->deviceWidth() - rect.x;
1826  rect.write(socket);
1827 
1828  socket->write((char *)&encoding, sizeof(encoding));
1829 
1830  const uchar *screendata = screenImage.scanLine(rect.y)
1831  + rect.x * screenImage.depth() / 8;
1832  int linestep = screenImage.bytesPerLine();
1833 
1834 #ifndef QT_NO_QWS_CURSOR
1835  // hardware cursors must be blended with the screen memory
1836  const bool doBlendCursor = qt_screencursor
1837  && !server->hasClientCursor()
1839  QImage tileImage;
1840  if (doBlendCursor) {
1841  const QRect tileRect(rect.x, rect.y, rect.w, rect.h);
1842  const QRect cursorRect = qt_screencursor->boundingRect()
1843  .translated(-server->screen()->offset());
1844  if (tileRect.intersects(cursorRect)) {
1845  tileImage = screenImage.copy(tileRect);
1846  blendCursor(tileImage,
1847  tileRect.translated(server->screen()->offset()));
1848  screendata = tileImage.bits();
1849  linestep = tileImage.bytesPerLine();
1850  }
1851  }
1852 #endif // QT_NO_QWS_CURSOR
1853 
1854  if (singleColorHextile.read(screendata, rect.w, rect.h, linestep)) {
1855  singleColorHextile.write(socket);
1856  } else if (dualColorHextile.read(screendata, rect.w, rect.h, linestep)) {
1857  dualColorHextile.write(socket);
1858  } else if (multiColorHextile.read(screendata, rect.w, rect.h, linestep)) {
1859  multiColorHextile.write(socket);
1860  } else if (server->doPixelConversion()) {
1861  const int bufferSize = rect.w * rect.h * bytesPerPixel + 1;
1862  const int padding = sizeof(quint32) - sizeof(char);
1863  buffer.resize(bufferSize + padding);
1864 
1865  buffer[padding] = 1; // Raw subencoding
1866 
1867  // convert pixels
1868  char *b = buffer.data() + padding + 1;
1869  const int bstep = rect.w * bytesPerPixel;
1870  for (int i = 0; i < rect.h; ++i) {
1871  server->convertPixels(b, (const char*)screendata, rect.w);
1872  screendata += linestep;
1873  b += bstep;
1874  }
1875  socket->write(buffer.constData() + padding, bufferSize);
1876  } else {
1877  quint8 subenc = 1; // Raw subencoding
1878  socket->write((char *)&subenc, 1);
1879 
1880  // send pixels
1881  for (int i = 0; i < rect.h; ++i) {
1882  socket->write((const char*)screendata,
1883  rect.w * bytesPerPixel);
1884  screendata += linestep;
1885  }
1886  }
1887  }
1888  if (socket->state() == QAbstractSocket::UnconnectedState)
1889  break;
1890  rect.y += MAP_TILE_SIZE;
1891  }
1892  socket->flush();
1893  Q_ASSERT(map->numDirty == 0);
1894 
1896 }
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
int height() const
Returns the logical height of the framebuffer in pixels.
Definition: qscreen_qws.h:228
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 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
unsigned char quint8
Definition: qglobal.h:934
bool doPixelConversion() const
Definition: qscreenvnc_p.h:465
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
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
int depth() const
Returns the depth of the image.
Definition: qimage.cpp:1620
static void grab()
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
uchar * bits()
Returns a pointer to the first pixel data.
Definition: qimage.cpp:1946
QTcpSocket * clientSocket() const
Definition: qscreenvnc_p.h:463
QVNCDirtyMap * dirtyMap() const
Definition: qscreenvnc_p.h:462
QRect boundingRect() const
Returns the cursor&#39;s bounding rectangle.
Definition: qscreen_qws.h:150
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
static void blendCursor(QImage &image, const QRect &imageRect)
QImage screenImage() const
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)
QRfbSingleColorHextile< SRC > singleColorHextile
Definition: qscreenvnc_p.h:417
QRfbMultiColorHextile< SRC > multiColorHextile
Definition: qscreenvnc_p.h:419
QRfbDualColorHextile< SRC > dualColorHextile
Definition: qscreenvnc_p.h:418
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]

template<class SRC>
void QRfbHextileEncoder< SRC >::write ( )
virtual

Implements QRfbEncoder.

Friends and Related Functions

◆ QRfbDualColorHextile< SRC >

template<class SRC>
friend class QRfbDualColorHextile< SRC >
friend

Definition at line 427 of file qscreenvnc_p.h.

◆ QRfbMultiColorHextile< SRC >

template<class SRC>
friend class QRfbMultiColorHextile< SRC >
friend

Definition at line 428 of file qscreenvnc_p.h.

◆ QRfbSingleColorHextile< SRC >

template<class SRC>
friend class QRfbSingleColorHextile< SRC >
friend

Definition at line 426 of file qscreenvnc_p.h.

Properties

◆ bg

template<class SRC>
SRC QRfbHextileEncoder< SRC >::bg
private

Definition at line 421 of file qscreenvnc_p.h.

◆ buffer

template<class SRC>
QByteArray QRfbHextileEncoder< SRC >::buffer
private

Definition at line 416 of file qscreenvnc_p.h.

Referenced by QRfbRawEncoder::write(), and QRfbHextileEncoder< SRC >::write().

◆ dualColorHextile

template<class SRC>
QRfbDualColorHextile< SRC > QRfbHextileEncoder< SRC >::dualColorHextile
private

Definition at line 418 of file qscreenvnc_p.h.

Referenced by QRfbHextileEncoder< SRC >::write().

◆ fg

template<class SRC>
SRC QRfbHextileEncoder< SRC >::fg
private

Definition at line 422 of file qscreenvnc_p.h.

◆ multiColorHextile

template<class SRC>
QRfbMultiColorHextile< SRC > QRfbHextileEncoder< SRC >::multiColorHextile
private

Definition at line 419 of file qscreenvnc_p.h.

Referenced by QRfbHextileEncoder< SRC >::write().

◆ newBg

template<class SRC>
bool QRfbHextileEncoder< SRC >::newBg
private

Definition at line 423 of file qscreenvnc_p.h.

Referenced by QRfbHextileEncoder< SRC >::write().

◆ newFg

template<class SRC>
bool QRfbHextileEncoder< SRC >::newFg
private

Definition at line 424 of file qscreenvnc_p.h.

Referenced by QRfbHextileEncoder< SRC >::write().

◆ singleColorHextile

template<class SRC>
QRfbSingleColorHextile< SRC > QRfbHextileEncoder< SRC >::singleColorHextile
private

Definition at line 417 of file qscreenvnc_p.h.

Referenced by QRfbHextileEncoder< SRC >::write().


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