-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClientConnectionRRE.cpp
More file actions
executable file
·70 lines (59 loc) · 2.37 KB
/
Copy pathClientConnectionRRE.cpp
File metadata and controls
executable file
·70 lines (59 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// RRE (Rising Rectangle Encoding)
//
// The bits of the ClientConnection object to do with RRE.
#include "stdhdrs.h"
#include "vncviewer.h"
#include "ClientConnection.h"
void ClientConnection::ReadRRERect(rfbFramebufferUpdateRectHeader *pfburh)
{
// An RRE rect is always followed by a background color
// For speed's sake we read them together into a buffer.
char tmpbuf[sz_rfbRREHeader+4]; // biggest pixel is 4 bytes long
rfbRREHeader *prreh = (rfbRREHeader *) tmpbuf;
CARD8 *pcolor = (CARD8 *) tmpbuf + sz_rfbRREHeader;
ReadExact(tmpbuf, sz_rfbRREHeader + m_minPixelBytes);
prreh->nSubrects = Swap32IfLE(prreh->nSubrects);
SETUP_COLOR_SHORTCUTS;
COLORREF color;
switch (m_myFormat.bitsPerPixel) {
case 8:
color = COLOR_FROM_PIXEL8_ADDRESS(pcolor); break;
case 16:
color = COLOR_FROM_PIXEL16_ADDRESS(pcolor); break;
case 24:
color = COLOR_FROM_PIXEL24_ADDRESS(pcolor); break;
case 32:
color = COLOR_FROM_PIXEL32_ADDRESS(pcolor); break;
}
// Draw the background of the rectangle
FillSolidRect(pfburh->r.x, pfburh->r.y, pfburh->r.w, pfburh->r.h, color);
if (prreh->nSubrects == 0) return;
// Draw the sub-rectangles
rfbRectangle rect, *pRect;
// The size of an RRE subrect including color info
int subRectSize = m_minPixelBytes + sz_rfbRectangle;
// Read subrects into the buffer
CheckBufferSize(subRectSize * prreh->nSubrects);
ReadExact(m_netbuf, subRectSize * prreh->nSubrects);
BYTE *p = (BYTE *) m_netbuf;
for (CARD32 i = 0; i < prreh->nSubrects; i++) {
pRect = (rfbRectangle *) (p + m_minPixelBytes);
switch (m_myFormat.bitsPerPixel) {
case 8:
color = COLOR_FROM_PIXEL8_ADDRESS(p); break;
case 16:
color = COLOR_FROM_PIXEL16_ADDRESS(p); break;
case 24:
color = COLOR_FROM_PIXEL24_ADDRESS(p); break;
case 32:
color = COLOR_FROM_PIXEL32_ADDRESS(p); break;
};
// color = COLOR_FROM_PIXEL8_ADDRESS(netbuf);
rect.x = (CARD16) (Swap16IfLE(pRect->x) + pfburh->r.x);
rect.y = (CARD16) (Swap16IfLE(pRect->y) + pfburh->r.y);
rect.w = Swap16IfLE(pRect->w);
rect.h = Swap16IfLE(pRect->h);
FillSolidRect(rect.x, rect.y, rect.w, rect.h, color);
p+=subRectSize;
}
}