Qt 4.8
Public Functions | Private Functions | Properties | Static Private Attributes | List of all members
QRfbMultiColorHextile< SRC > Class Template Reference

#include <qscreenvnc_p.h>

Public Functions

 QRfbMultiColorHextile (QRfbHextileEncoder< SRC > *e)
 
 QRfbMultiColorHextile (QRfbHextileEncoder< SRC > *e)
 
bool read (const uchar *data, int width, int height, int stride)
 
bool read (const uchar *data, int width, int height, int stride)
 
void write (QTcpSocket *socket) const
 
void write (QTcpSocket *socket) const
 

Private Functions

bool beginRect ()
 
bool beginRect ()
 
void endRect ()
 
void endRect ()
 
quint8rect (int r)
 
const quint8rect (int r) const
 
quint8rect (int r)
 
const quint8rect (int r) const
 
int rectx (int r) const
 
int rectx (int r) const
 
int recty (int r) const
 
int recty (int r) const
 
void setColor (SRC color)
 
void setColor (SRC color)
 
void setHeight (int r, int height)
 
void setHeight (int r, int height)
 
void setWidth (int r, int width)
 
void setWidth (int r, int width)
 
void setX (int r, int x)
 
void setX (int r, int x)
 
void setY (int r, int y)
 
void setY (int r, int y)
 

Properties

quint8 bpp
 
QRfbHextileEncoder< SRC > * encoder
 
quint8 numRects
 
QVarLengthArray< quint8, maxRectsSizerects
 

Static Private Attributes

static const int maxRectsSize = 16 * 16
 

Detailed Description

template<class SRC>
class QRfbMultiColorHextile< SRC >

Definition at line 349 of file qscreenvnc_p.h.

Constructors and Destructors

◆ QRfbMultiColorHextile() [1/2]

template<class SRC>
QRfbMultiColorHextile< SRC >::QRfbMultiColorHextile ( QRfbHextileEncoder< SRC > *  e)
inline

Definition at line 352 of file qscreenvnc_p.h.

352 : encoder(e) {}
QRfbHextileEncoder< SRC > * encoder
Definition: qscreenvnc_p.h:397

◆ QRfbMultiColorHextile() [2/2]

template<class SRC>
QRfbMultiColorHextile< SRC >::QRfbMultiColorHextile ( QRfbHextileEncoder< SRC > *  e)
inline

Definition at line 358 of file qvncserver.h.

358 : encoder(e) {}
QRfbHextileEncoder< SRC > * encoder
Definition: qscreenvnc_p.h:397

Functions

◆ beginRect() [1/2]

template<class SRC >
bool QRfbMultiColorHextile< SRC >::beginRect ( )
inlineprivate

Definition at line 1300 of file qscreenvnc_qws.cpp.

Referenced by buttonChange().

1301 {
1302  if ((rects.size() + bpp + 2) > maxRectsSize)
1303  return false;
1304  rects.resize(rects.size() + bpp + 2);
1305  return true;
1306 }
void resize(int size)
QVarLengthArray< quint8, maxRectsSize > rects
Definition: qscreenvnc_p.h:393
static const int maxRectsSize
Definition: qscreenvnc_p.h:392
int size() const

◆ beginRect() [2/2]

template<class SRC>
bool QRfbMultiColorHextile< SRC >::beginRect ( )
private

◆ endRect() [1/2]

template<class SRC >
void QRfbMultiColorHextile< SRC >::endRect ( )
inlineprivate

Definition at line 1309 of file qscreenvnc_qws.cpp.

Referenced by buttonChange().

1310 {
1311  setHeight(numRects, 1);
1312  ++numRects;
1313 }
void setHeight(int r, int height)
Definition: qscreenvnc_p.h:384

◆ endRect() [2/2]

template<class SRC>
void QRfbMultiColorHextile< SRC >::endRect ( )
private

◆ read() [1/2]

template<class SRC >
bool QRfbMultiColorHextile< SRC >::read ( const uchar data,
int  width,
int  height,
int  stride 
)

Definition at line 1316 of file qscreenvnc_qws.cpp.

Referenced by buttonChange().

1318 {
1319  const SRC *ptr = reinterpret_cast<const SRC*>(data);
1320  const int linestep = (stride / sizeof(SRC)) - width;
1321 
1322  bpp = encoder->server->clientBytesPerPixel();
1323 
1324  if (encoder->newBg)
1325  encoder->bg = ptr[0];
1326 
1327  const SRC bg = encoder->bg;
1328  SRC color = bg;
1329  bool inRect = false;
1330 
1331  numRects = 0;
1332  rects.clear();
1333 
1334  for (int y = 0; y < height; ++y) {
1335  for (int x = 0; x < width; ++x) {
1336  if (inRect && *ptr != color) { // end rect
1338  endRect();
1339  inRect = false;
1340  }
1341 
1342  if (!inRect && *ptr != bg) { // begin rect
1343  if (!beginRect())
1344  return false;
1345  inRect = true;
1346  color = *ptr;
1347  setColor(color);
1348  setX(numRects, x);
1349  setY(numRects, y);
1350  }
1351  ++ptr;
1352  }
1353  if (inRect) { // end rect
1354  setWidth(numRects, width - rectx(numRects));
1355  endRect();
1356  inRect = false;
1357  }
1358  ptr += linestep;
1359  }
1360 
1361  return true;
1362 }
void setWidth(int r, int width)
Definition: qscreenvnc_p.h:380
int rectx(int r) const
Definition: qscreenvnc_p.h:372
void setX(int r, int x)
Definition: qscreenvnc_p.h:363
static const char * data(const QByteArray &arr)
const T * ptr(const T &t)
QRfbHextileEncoder< SRC > * encoder
Definition: qscreenvnc_p.h:397
QVarLengthArray< quint8, maxRectsSize > rects
Definition: qscreenvnc_p.h:393
void setY(int r, int y)
Definition: qscreenvnc_p.h:367
void setColor(SRC color)

◆ read() [2/2]

template<class SRC>
bool QRfbMultiColorHextile< SRC >::read ( const uchar data,
int  width,
int  height,
int  stride 
)

◆ rect() [1/4]

template<class SRC>
quint8* QRfbMultiColorHextile< SRC >::rect ( int  r)
inlineprivate

Definition at line 357 of file qscreenvnc_p.h.

357  {
358  return rects.data() + r * (bpp + 2);
359  }
QVarLengthArray< quint8, maxRectsSize > rects
Definition: qscreenvnc_p.h:393

◆ rect() [2/4]

template<class SRC>
const quint8* QRfbMultiColorHextile< SRC >::rect ( int  r) const
inlineprivate

Definition at line 360 of file qscreenvnc_p.h.

360  {
361  return rects.constData() + r * (bpp + 2);
362  }
const T * constData() const
QVarLengthArray< quint8, maxRectsSize > rects
Definition: qscreenvnc_p.h:393

◆ rect() [3/4]

template<class SRC>
quint8* QRfbMultiColorHextile< SRC >::rect ( int  r)
inlineprivate

Definition at line 363 of file qvncserver.h.

363  {
364  return rects.data() + r * (bpp + 2);
365  }
QVarLengthArray< quint8, maxRectsSize > rects
Definition: qscreenvnc_p.h:393

◆ rect() [4/4]

template<class SRC>
const quint8* QRfbMultiColorHextile< SRC >::rect ( int  r) const
inlineprivate

Definition at line 366 of file qvncserver.h.

366  {
367  return rects.constData() + r * (bpp + 2);
368  }
const T * constData() const
QVarLengthArray< quint8, maxRectsSize > rects
Definition: qscreenvnc_p.h:393

◆ rectx() [1/2]

template<class SRC>
int QRfbMultiColorHextile< SRC >::rectx ( int  r) const
inlineprivate

Definition at line 372 of file qscreenvnc_p.h.

372  {
373  const quint8 *ptr = rect(r) + bpp;
374  return *ptr >> 4;
375  }
quint8 * rect(int r)
Definition: qscreenvnc_p.h:357
unsigned char quint8
Definition: qglobal.h:934
const T * ptr(const T &t)

◆ rectx() [2/2]

template<class SRC>
int QRfbMultiColorHextile< SRC >::rectx ( int  r) const
inlineprivate

Definition at line 378 of file qvncserver.h.

378  {
379  const quint8 *ptr = rect(r) + bpp;
380  return *ptr >> 4;
381  }
quint8 * rect(int r)
Definition: qscreenvnc_p.h:357
unsigned char quint8
Definition: qglobal.h:934
const T * ptr(const T &t)

◆ recty() [1/2]

template<class SRC>
int QRfbMultiColorHextile< SRC >::recty ( int  r) const
inlineprivate

Definition at line 376 of file qscreenvnc_p.h.

376  {
377  const quint8 *ptr = rect(r) + bpp;
378  return *ptr & 0x0f;
379  }
quint8 * rect(int r)
Definition: qscreenvnc_p.h:357
unsigned char quint8
Definition: qglobal.h:934
const T * ptr(const T &t)

◆ recty() [2/2]

template<class SRC>
int QRfbMultiColorHextile< SRC >::recty ( int  r) const
inlineprivate

Definition at line 382 of file qvncserver.h.

382  {
383  const quint8 *ptr = rect(r) + bpp;
384  return *ptr & 0x0f;
385  }
quint8 * rect(int r)
Definition: qscreenvnc_p.h:357
unsigned char quint8
Definition: qglobal.h:934
const T * ptr(const T &t)

◆ setColor() [1/2]

template<class SRC >
void QRfbMultiColorHextile< SRC >::setColor ( SRC  color)
inlineprivate

Definition at line 1293 of file qscreenvnc_qws.cpp.

Referenced by buttonChange().

1294 {
1295  encoder->server->convertPixels(reinterpret_cast<char*>(rect(numRects)),
1296  (const char*)&color, 1);
1297 }
quint8 * rect(int r)
Definition: qscreenvnc_p.h:357
QRfbHextileEncoder< SRC > * encoder
Definition: qscreenvnc_p.h:397

◆ setColor() [2/2]

template<class SRC>
void QRfbMultiColorHextile< SRC >::setColor ( SRC  color)
private

◆ setHeight() [1/2]

template<class SRC>
void QRfbMultiColorHextile< SRC >::setHeight ( int  r,
int  height 
)
inlineprivate

Definition at line 384 of file qscreenvnc_p.h.

384  {
385  quint8 *ptr = rect(r) + bpp + 1;
386  *ptr = (*ptr & 0xf0) | (height - 1);
387  }
quint8 * rect(int r)
Definition: qscreenvnc_p.h:357
unsigned char quint8
Definition: qglobal.h:934
const T * ptr(const T &t)

◆ setHeight() [2/2]

template<class SRC>
void QRfbMultiColorHextile< SRC >::setHeight ( int  r,
int  height 
)
inlineprivate

Definition at line 390 of file qvncserver.h.

390  {
391  quint8 *ptr = rect(r) + bpp + 1;
392  *ptr = (*ptr & 0xf0) | (height - 1);
393  }
quint8 * rect(int r)
Definition: qscreenvnc_p.h:357
unsigned char quint8
Definition: qglobal.h:934
const T * ptr(const T &t)

◆ setWidth() [1/2]

template<class SRC>
void QRfbMultiColorHextile< SRC >::setWidth ( int  r,
int  width 
)
inlineprivate

Definition at line 380 of file qscreenvnc_p.h.

380  {
381  quint8 *ptr = rect(r) + bpp + 1;
382  *ptr = ((width - 1) << 4) | (*ptr & 0x0f);
383  }
quint8 * rect(int r)
Definition: qscreenvnc_p.h:357
unsigned char quint8
Definition: qglobal.h:934
const T * ptr(const T &t)

◆ setWidth() [2/2]

template<class SRC>
void QRfbMultiColorHextile< SRC >::setWidth ( int  r,
int  width 
)
inlineprivate

Definition at line 386 of file qvncserver.h.

386  {
387  quint8 *ptr = rect(r) + bpp + 1;
388  *ptr = ((width - 1) << 4) | (*ptr & 0x0f);
389  }
quint8 * rect(int r)
Definition: qscreenvnc_p.h:357
unsigned char quint8
Definition: qglobal.h:934
const T * ptr(const T &t)

◆ setX() [1/2]

template<class SRC>
void QRfbMultiColorHextile< SRC >::setX ( int  r,
int  x 
)
inlineprivate

Definition at line 363 of file qscreenvnc_p.h.

363  {
364  quint8 *ptr = rect(r) + bpp;
365  *ptr = (x << 4) | (*ptr & 0x0f);
366  }
quint8 * rect(int r)
Definition: qscreenvnc_p.h:357
unsigned char quint8
Definition: qglobal.h:934
const T * ptr(const T &t)

◆ setX() [2/2]

template<class SRC>
void QRfbMultiColorHextile< SRC >::setX ( int  r,
int  x 
)
inlineprivate

Definition at line 369 of file qvncserver.h.

369  {
370  quint8 *ptr = rect(r) + bpp;
371  *ptr = (x << 4) | (*ptr & 0x0f);
372  }
quint8 * rect(int r)
Definition: qscreenvnc_p.h:357
unsigned char quint8
Definition: qglobal.h:934
const T * ptr(const T &t)

◆ setY() [1/2]

template<class SRC>
void QRfbMultiColorHextile< SRC >::setY ( int  r,
int  y 
)
inlineprivate

Definition at line 367 of file qscreenvnc_p.h.

367  {
368  quint8 *ptr = rect(r) + bpp;
369  *ptr = (*ptr & 0xf0) | y;
370  }
quint8 * rect(int r)
Definition: qscreenvnc_p.h:357
unsigned char quint8
Definition: qglobal.h:934
const T * ptr(const T &t)

◆ setY() [2/2]

template<class SRC>
void QRfbMultiColorHextile< SRC >::setY ( int  r,
int  y 
)
inlineprivate

Definition at line 373 of file qvncserver.h.

373  {
374  quint8 *ptr = rect(r) + bpp;
375  *ptr = (*ptr & 0xf0) | y;
376  }
quint8 * rect(int r)
Definition: qscreenvnc_p.h:357
unsigned char quint8
Definition: qglobal.h:934
const T * ptr(const T &t)

◆ write() [1/2]

template<class SRC >
void QRfbMultiColorHextile< SRC >::write ( QTcpSocket socket) const

Definition at line 1365 of file qscreenvnc_qws.cpp.

Referenced by buttonChange().

1366 {
1367  const int padding = 3;
1368  QVarLengthArray<quint8> buffer(bpp + padding + sizeof(quint8) + sizeof(numRects));
1369 
1370  quint8 &subenc = buffer[padding];
1371  int n = padding + sizeof(quint8);
1372 
1373  subenc = 8 | 16; // AnySubrects | SubrectsColoured
1374 
1375  if (encoder->newBg) {
1376  subenc |= 0x2; // Background
1377  encoder->server->convertPixels(reinterpret_cast<char*>(buffer.data() + n),
1378  reinterpret_cast<const char*>(&encoder->bg),
1379  1);
1380  n += bpp;
1381 // encoder->newBg = false;
1382  }
1383 
1384  buffer[n] = numRects;
1385  n += sizeof(numRects);
1386 
1387  socket->write(reinterpret_cast<const char*>(buffer.data() + padding),
1388  n - padding);
1389  socket->write(reinterpret_cast<const char*>(rects.constData()),
1390  rects.size());
1391 }
const T * constData() const
unsigned char quint8
Definition: qglobal.h:934
QRfbHextileEncoder< SRC > * encoder
Definition: qscreenvnc_p.h:397
QVarLengthArray< quint8, maxRectsSize > rects
Definition: qscreenvnc_p.h:393
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
Definition: qiodevice.cpp:1342
int size() const

◆ write() [2/2]

template<class SRC>
void QRfbMultiColorHextile< SRC >::write ( QTcpSocket socket) const

Properties

◆ bpp

template<class SRC>
quint8 QRfbMultiColorHextile< SRC >::bpp
private

Definition at line 395 of file qscreenvnc_p.h.

◆ encoder

template<class SRC>
QRfbHextileEncoder< SRC > * QRfbMultiColorHextile< SRC >::encoder
private

Definition at line 397 of file qscreenvnc_p.h.

◆ maxRectsSize

template<class SRC>
static const int QRfbMultiColorHextile< SRC >::maxRectsSize = 16 * 16
staticprivate

Definition at line 392 of file qscreenvnc_p.h.

◆ numRects

template<class SRC>
quint8 QRfbMultiColorHextile< SRC >::numRects
private

Definition at line 396 of file qscreenvnc_p.h.

◆ rects

template<class SRC>
QVarLengthArray< quint8, maxRectsSize > QRfbMultiColorHextile< SRC >::rects
private

Definition at line 393 of file qscreenvnc_p.h.


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