Qt 4.8
Classes | Public Functions | Private Functions | Properties | List of all members
QRfbDualColorHextile< SRC > Class Template Reference

#include <qscreenvnc_p.h>

Classes

struct  Rect
 

Public Functions

 QRfbDualColorHextile (QRfbHextileEncoder< SRC > *e)
 
 QRfbDualColorHextile (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

int height (int r) const
 
int height (int r) const
 
int lastx () const
 
int lastx () const
 
int lasty () const
 
int lasty () const
 
void next ()
 
void next ()
 
int rectx (int r) const
 
int rectx (int r) const
 
int recty (int r) const
 
int recty (int r) const
 
void setHeight (int r, int height)
 
void setHeight (int height)
 
void setHeight (int r, int height)
 
void setHeight (int height)
 
void setWidth (int r, int width)
 
void setWidth (int r, int width)
 
void setWidth (int width)
 
void setWidth (int width)
 
void setX (int r, int x)
 
void setX (int r, int x)
 
void setX (int x)
 
void setX (int x)
 
void setY (int r, int y)
 
void setY (int r, int y)
 
void setY (int y)
 
void setY (int y)
 
int width (int r) const
 
int width (int r) const
 

Properties

QRfbHextileEncoder< SRC > * encoder
 
quint8 numRects
 
struct QRfbDualColorHextile::Rect rects [8 *16]
 

Detailed Description

template<class SRC>
class QRfbDualColorHextile< SRC >

Definition at line 304 of file qscreenvnc_p.h.

Constructors and Destructors

◆ QRfbDualColorHextile() [1/2]

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

Definition at line 307 of file qscreenvnc_p.h.

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

◆ QRfbDualColorHextile() [2/2]

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

Definition at line 313 of file qvncserver.h.

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

Functions

◆ height() [1/2]

template<class SRC>
int QRfbDualColorHextile< SRC >::height ( int  r) const
inlineprivate

Definition at line 326 of file qscreenvnc_p.h.

326 { return (rects[r].wh & 0x0f) + 1; }
struct QRfbDualColorHextile::Rect rects[8 *16]

◆ height() [2/2]

template<class SRC>
int QRfbDualColorHextile< SRC >::height ( int  r) const
inlineprivate

Definition at line 332 of file qvncserver.h.

332 { return (rects[r].wh & 0x0f) + 1; }
struct QRfbDualColorHextile::Rect rects[8 *16]

◆ lastx() [1/2]

template<class SRC>
int QRfbDualColorHextile< SRC >::lastx ( ) const
inlineprivate

Definition at line 321 of file qscreenvnc_p.h.

321 { return rectx(numRects); }
int rectx(int r) const
Definition: qscreenvnc_p.h:323

◆ lastx() [2/2]

template<class SRC>
int QRfbDualColorHextile< SRC >::lastx ( ) const
inlineprivate

Definition at line 327 of file qvncserver.h.

327 { return rectx(numRects); }
int rectx(int r) const
Definition: qscreenvnc_p.h:323

◆ lasty() [1/2]

template<class SRC>
int QRfbDualColorHextile< SRC >::lasty ( ) const
inlineprivate

Definition at line 322 of file qscreenvnc_p.h.

322 { return recty(numRects); }
int recty(int r) const
Definition: qscreenvnc_p.h:324

◆ lasty() [2/2]

template<class SRC>
int QRfbDualColorHextile< SRC >::lasty ( ) const
inlineprivate

Definition at line 328 of file qvncserver.h.

328 { return recty(numRects); }
int recty(int r) const
Definition: qscreenvnc_p.h:324

◆ next() [1/2]

template<class SRC >
void QRfbDualColorHextile< SRC >::next ( )
private

Definition at line 1277 of file qscreenvnc_qws.cpp.

Referenced by buttonChange().

1278 {
1279  for (int r = numRects - 1; r >= 0; --r) {
1280  if (recty(r) == lasty())
1281  continue;
1282  if (recty(r) < lasty() - 1) // only search previous scanline
1283  break;
1284  if (rectx(r) == lastx() && width(r) == width(numRects)) {
1285  ++rects[r].wh;
1286  return;
1287  }
1288  }
1289  ++numRects;
1290 }
int width(int r) const
Definition: qscreenvnc_p.h:325
struct QRfbDualColorHextile::Rect rects[8 *16]
int rectx(int r) const
Definition: qscreenvnc_p.h:323
int recty(int r) const
Definition: qscreenvnc_p.h:324

◆ next() [2/2]

template<class SRC>
void QRfbDualColorHextile< SRC >::next ( )
private

◆ read() [1/2]

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

Definition at line 1150 of file qscreenvnc_qws.cpp.

Referenced by buttonChange().

1152 {
1153  const SRC *ptr = reinterpret_cast<const SRC*>(data);
1154  const int linestep = (stride / sizeof(SRC)) - width;
1155 
1156  SRC c1;
1157  SRC c2 = 0;
1158  int n1 = 0;
1159  int n2 = 0;
1160  int x = 0;
1161  int y = 0;
1162 
1163  c1 = *ptr;
1164 
1165  // find second color
1166  while (y < height) {
1167  while (x < width) {
1168  if (*ptr == c1) {
1169  ++n1;
1170  } else {
1171  c2 = *ptr;
1172  goto found_second_color;
1173  }
1174  ++ptr;
1175  ++x;
1176  }
1177  x = 0;
1178  ptr += linestep;
1179  ++y;
1180  }
1181 
1182 found_second_color:
1183  // finish counting
1184  while (y < height) {
1185  while (x < width) {
1186  if (*ptr == c1) {
1187  ++n1;
1188  } else if (*ptr == c2) {
1189  ++n2;
1190  } else {
1191  return false;
1192  }
1193  ++ptr;
1194  ++x;
1195  }
1196  x = 0;
1197  ptr += linestep;
1198  ++y;
1199  }
1200 
1201  if (n2 > n1) {
1202  const quint32 tmpC = c1;
1203  c1 = c2;
1204  c2 = tmpC;
1205  }
1206 
1207  encoder->newBg |= (c1 != encoder->bg);
1208  encoder->newFg |= (c2 != encoder->fg);
1209 
1210  encoder->bg = c1;
1211  encoder->fg = c2;
1212 
1213  // create map
1214  bool inRect = false;
1215  numRects = 0;
1216  ptr = reinterpret_cast<const SRC*>(data);
1217  for (y = 0; y < height; ++y) {
1218  for (x = 0; x < width; ++x) {
1219  if (inRect && *ptr == encoder->bg) {
1220  // rect finished
1221  setWidth(x - lastx());
1222  next();
1223  inRect = false;
1224  } else if (!inRect && *ptr == encoder->fg) {
1225  // rect start
1226  setX(x);
1227  setY(y);
1228  setHeight(1);
1229  inRect = true;
1230  }
1231  ++ptr;
1232  }
1233  if (inRect) {
1234  // finish rect
1235  setWidth(width - lastx());
1236  next();
1237  inRect = false;
1238  }
1239  ptr += linestep;
1240  }
1241 
1242  return true;
1243 }
int width(int r) const
Definition: qscreenvnc_p.h:325
void setHeight(int r, int height)
Definition: qscreenvnc_p.h:337
int height(int r) const
Definition: qscreenvnc_p.h:326
void setWidth(int r, int width)
Definition: qscreenvnc_p.h:334
static const char * data(const QByteArray &arr)
void setX(int r, int x)
Definition: qscreenvnc_p.h:328
const T * ptr(const T &t)
unsigned int quint32
Definition: qglobal.h:938
void setY(int r, int y)
Definition: qscreenvnc_p.h:331
QRfbHextileEncoder< SRC > * encoder
Definition: qscreenvnc_p.h:318

◆ read() [2/2]

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

◆ rectx() [1/2]

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

Definition at line 323 of file qscreenvnc_p.h.

323 { return rects[r].xy >> 4; }
struct QRfbDualColorHextile::Rect rects[8 *16]

◆ rectx() [2/2]

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

Definition at line 329 of file qvncserver.h.

329 { return rects[r].xy >> 4; }
struct QRfbDualColorHextile::Rect rects[8 *16]

◆ recty() [1/2]

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

Definition at line 324 of file qscreenvnc_p.h.

324 { return rects[r].xy & 0x0f; }
struct QRfbDualColorHextile::Rect rects[8 *16]

◆ recty() [2/2]

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

Definition at line 330 of file qvncserver.h.

330 { return rects[r].xy & 0x0f; }
struct QRfbDualColorHextile::Rect rects[8 *16]

◆ setHeight() [1/4]

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

Definition at line 337 of file qscreenvnc_p.h.

337  {
338  rects[r].wh = (rects[r].wh & 0xf0) | (height - 1);
339  }
int height(int r) const
Definition: qscreenvnc_p.h:326
struct QRfbDualColorHextile::Rect rects[8 *16]

◆ setHeight() [2/4]

template<class SRC>
void QRfbDualColorHextile< SRC >::setHeight ( int  height)
inlineprivate

Definition at line 342 of file qscreenvnc_p.h.

Referenced by QRfbDualColorHextile< SRC >::setHeight().

void setHeight(int r, int height)
Definition: qscreenvnc_p.h:337
int height(int r) const
Definition: qscreenvnc_p.h:326

◆ setHeight() [3/4]

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

Definition at line 343 of file qvncserver.h.

343  {
344  rects[r].wh = (rects[r].wh & 0xf0) | (height - 1);
345  }
int height(int r) const
Definition: qscreenvnc_p.h:326
struct QRfbDualColorHextile::Rect rects[8 *16]

◆ setHeight() [4/4]

template<class SRC>
void QRfbDualColorHextile< SRC >::setHeight ( int  height)
inlineprivate

Definition at line 348 of file qvncserver.h.

Referenced by QRfbDualColorHextile< SRC >::setHeight().

void setHeight(int r, int height)
Definition: qscreenvnc_p.h:337
int height(int r) const
Definition: qscreenvnc_p.h:326

◆ setWidth() [1/4]

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

Definition at line 334 of file qscreenvnc_p.h.

334  {
335  rects[r].wh = ((width - 1) << 4) | (rects[r].wh & 0x0f);
336  }
int width(int r) const
Definition: qscreenvnc_p.h:325
struct QRfbDualColorHextile::Rect rects[8 *16]

◆ setWidth() [2/4]

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

Definition at line 340 of file qvncserver.h.

340  {
341  rects[r].wh = ((width - 1) << 4) | (rects[r].wh & 0x0f);
342  }
int width(int r) const
Definition: qscreenvnc_p.h:325
struct QRfbDualColorHextile::Rect rects[8 *16]

◆ setWidth() [3/4]

template<class SRC>
void QRfbDualColorHextile< SRC >::setWidth ( int  width)
inlineprivate

Definition at line 341 of file qscreenvnc_p.h.

Referenced by QRfbDualColorHextile< SRC >::setWidth().

341 { setWidth(numRects, width); }
int width(int r) const
Definition: qscreenvnc_p.h:325
void setWidth(int r, int width)
Definition: qscreenvnc_p.h:334

◆ setWidth() [4/4]

template<class SRC>
void QRfbDualColorHextile< SRC >::setWidth ( int  width)
inlineprivate

Definition at line 347 of file qvncserver.h.

Referenced by QRfbDualColorHextile< SRC >::setWidth().

347 { setWidth(numRects, width); }
int width(int r) const
Definition: qscreenvnc_p.h:325
void setWidth(int r, int width)
Definition: qscreenvnc_p.h:334

◆ setX() [1/4]

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

Definition at line 328 of file qscreenvnc_p.h.

328  {
329  rects[r].xy = (x << 4) | (rects[r].xy & 0x0f);
330  }
struct QRfbDualColorHextile::Rect rects[8 *16]

◆ setX() [2/4]

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

Definition at line 334 of file qvncserver.h.

334  {
335  rects[r].xy = (x << 4) | (rects[r].xy & 0x0f);
336  }
struct QRfbDualColorHextile::Rect rects[8 *16]

◆ setX() [3/4]

template<class SRC>
void QRfbDualColorHextile< SRC >::setX ( int  x)
inlineprivate

Definition at line 343 of file qscreenvnc_p.h.

Referenced by QRfbDualColorHextile< SRC >::setX().

343 { setX(numRects, x); }
void setX(int r, int x)
Definition: qscreenvnc_p.h:328

◆ setX() [4/4]

template<class SRC>
void QRfbDualColorHextile< SRC >::setX ( int  x)
inlineprivate

Definition at line 349 of file qvncserver.h.

Referenced by QRfbDualColorHextile< SRC >::setX().

349 { setX(numRects, x); }
void setX(int r, int x)
Definition: qscreenvnc_p.h:328

◆ setY() [1/4]

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

Definition at line 331 of file qscreenvnc_p.h.

331  {
332  rects[r].xy = (rects[r].xy & 0xf0) | y;
333  }
struct QRfbDualColorHextile::Rect rects[8 *16]

◆ setY() [2/4]

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

Definition at line 337 of file qvncserver.h.

337  {
338  rects[r].xy = (rects[r].xy & 0xf0) | y;
339  }
struct QRfbDualColorHextile::Rect rects[8 *16]

◆ setY() [3/4]

template<class SRC>
void QRfbDualColorHextile< SRC >::setY ( int  y)
inlineprivate

Definition at line 344 of file qscreenvnc_p.h.

Referenced by QRfbDualColorHextile< SRC >::setY().

344 { setY(numRects, y); }
void setY(int r, int y)
Definition: qscreenvnc_p.h:331

◆ setY() [4/4]

template<class SRC>
void QRfbDualColorHextile< SRC >::setY ( int  y)
inlineprivate

Definition at line 350 of file qvncserver.h.

Referenced by QRfbDualColorHextile< SRC >::setY().

350 { setY(numRects, y); }
void setY(int r, int y)
Definition: qscreenvnc_p.h:331

◆ width() [1/2]

template<class SRC>
int QRfbDualColorHextile< SRC >::width ( int  r) const
inlineprivate

Definition at line 325 of file qscreenvnc_p.h.

325 { return (rects[r].wh >> 4) + 1; }
struct QRfbDualColorHextile::Rect rects[8 *16]

◆ width() [2/2]

template<class SRC>
int QRfbDualColorHextile< SRC >::width ( int  r) const
inlineprivate

Definition at line 331 of file qvncserver.h.

331 { return (rects[r].wh >> 4) + 1; }
struct QRfbDualColorHextile::Rect rects[8 *16]

◆ write() [1/2]

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

Definition at line 1246 of file qscreenvnc_qws.cpp.

Referenced by buttonChange().

1247 {
1248  const int bpp = encoder->server->clientBytesPerPixel();
1249  const int padding = 3;
1250  QVarLengthArray<char> buffer(padding + 2 * bpp + sizeof(char) + sizeof(numRects));
1251  char &subenc = buffer[padding];
1252  int n = padding + sizeof(subenc);
1253 
1254  subenc = 0x8; // AnySubrects
1255 
1256  if (encoder->newBg) {
1257  subenc |= 0x2; // Background
1258  encoder->server->convertPixels(buffer.data() + n, (char*)&encoder->bg, 1);
1259  n += bpp;
1260 // encoder->newBg = false;
1261  }
1262 
1263  if (encoder->newFg) {
1264  subenc |= 0x4; // Foreground
1265  encoder->server->convertPixels(buffer.data() + n, (char*)&encoder->fg, 1);
1266  n += bpp;
1267 // encoder->newFg = false;
1268  }
1269  buffer[n] = numRects;
1270  n += sizeof(numRects);
1271 
1272  socket->write(buffer.data() + padding, n - padding);
1273  socket->write((char*)rects, numRects * sizeof(Rect));
1274 }
struct QRfbDualColorHextile::Rect rects[8 *16]
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
Definition: qiodevice.cpp:1342
QRfbHextileEncoder< SRC > * encoder
Definition: qscreenvnc_p.h:318

◆ write() [2/2]

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

Properties

◆ encoder

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

Definition at line 318 of file qscreenvnc_p.h.

◆ numRects

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

Definition at line 317 of file qscreenvnc_p.h.

◆ rects

template<class SRC>
struct QRfbDualColorHextile::Rect QRfbDualColorHextile< SRC >::rects
private

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