Why don't we talk a little about existing bottlenecks/ possible tune-up idea?
I have just done with a viewer-side tuning as an example. Take a look
![Wink ;)](./images/smilies/_icon_wink.gif)
Whenever using the Tight encoding, CPU usage was sky high and was occasionaly causing choppy slow updates.
This replacement for the SETPIXELS_NOCONV macro in ClientConnection.h will perform DIB conversion + BitBlt instead of hitting every dots by SetPixelV.
That made my viewer with Tight encoding use less CPU and no longer stick still while frequent updates are made. Possiblly considerable to be faster too.
[syntax="c"]#define SETPIXELS_NOCONV(buffer, x, y, w, h) \
{ \
/*Convert RGB <-> BGR*/ \
unsigned char* rgbtable = buffer; \
unsigned char rgbtemp; \
for(int i = 0; i < w * h; i++) \
{ \
rgbtemp = rgbtable[i * 4]; \
rgbtable[i * 4] = rgbtable[i * 4 + 2]; \
rgbtable[i * 4 + 2] = rgbtemp; \
} \
/*BitBlit Buffer Data*/ \
LPBITMAPINFO lpBmpInfo = (LPBITMAPINFO)HeapAlloc(GetProcessHeap(), \
HEAP_ZERO_MEMORY, sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD)); \
lpBmpInfo->bmiHeader.biSize=sizeof(BITMAPINFOHEADER); \
lpBmpInfo->bmiHeader.biWidth=w; \
lpBmpInfo->bmiHeader.biHeight=-h; \
lpBmpInfo->bmiHeader.biPlanes=1; \
lpBmpInfo->bmiHeader.biBitCount=32; \
lpBmpInfo->bmiHeader.biCompression=BI_RGB; \
HDC hMemDC = CreateCompatibleDC(m_hBitmapDC); \
HBITMAP hBitmap = \
CreateDIBitmap(m_hBitmapDC, &lpBmpInfo->bmiHeader, CBM_INIT, \
(void*)buffer, lpBmpInfo, DIB_RGB_COLORS); \
SelectObject(hMemDC, hBitmap); \
HeapFree(GetProcessHeap(),0,lpBmpInfo); \
DeleteObject(hBitmap); \
BitBlt(m_hBitmapDC, x, y, w, h, hMemDC, 0, 0, SRCCOPY); \
DeleteDC(hMemDC); \
}[/syntax]
well, i want someone to review it anyway since i know my crappy C skill is totally unreliable
![Razz :P](./images/smilies/_icon_razz.gif)
(if you don't have a compiler environment, you could try my latest custom binary(#14) as shown below in the signature.)
any more speed-up idea?