Hello,
Please see below a function that processes WM_PAINT message. Being run
under Wine this function updates the client area (50x120 chars) about
50-100 times slower than under Windows XP. Could anyone please explain
me what might be wrong and how to fix that?
Thank you,
Andrew Makhorin
/***********************************************************************
* update_panel_area - update client area of panel window
*
* This routine updates the client area of the window associated with
* the specified panel. (It is called when the panel window procedure
* receives the message WM_PAINT.) */
void update_panel_area(PANELX *px)
{ PAINTSTRUCT ps;
HFONT old_hfont;
HPEN old_hpen, hpen;
int row, col, row1, row2, col1, col2;
xassert(px != NULL);
/* if the update region is empty, do nothing */
if (!GetUpdateRect(px->window, NULL, FALSE))
goto done;
/* start updating */
BeginPaint(px->window, &ps);
old_hfont = SelectObject(ps.hdc, px->hfont);
hpen = CreatePen(PS_SOLID, 0, 0x000000);
old_hpen = SelectObject(ps.hdc, hpen);
/* given the update region, determine which rows and columns of
the display area should be updated (note that the update
region reported by BeginPaint does not include right-most and
bottom-most pixels, so we subtract 1 in order not to update
an extra row and column out of the update region) */
row1 = 1 + ps.rcPaint.top / px->fy;
row2 = 1 + (ps.rcPaint.bottom - 1) / px->fy;
col1 = 1 + ps.rcPaint.left / px->fx;
col2 = 1 + (ps.rcPaint.right - 1) / px->fx;
/* updating is performed according to information in the buffer
array of the panel display area (see rpsed.h) */
for (row = row1; row <= row2; row++)
{ for (col = col1; col <= col2; col++)
{ FMTCHAR c;
int x, y;
char buf[1];
/* get formatted character at position (row,col) */
if (1 <= row && row <= px->p->nrows+1 &&
1 <= col && col <= px->p->ncols+1)
c = px->p->c[row][col];
else
c = px->p->std_char[FMT_SPACE];
/* paint this character */
x = (col - 1) * px->fx;
y = (row - 1) * px->fy;
SetTextColor(ps.hdc, palette->value[c.f]);
SetBkColor(ps.hdc, palette->value[c.b]);
SetBkMode(ps.hdc, OPAQUE);
buf[0] = c.c;
TextOut(ps.hdc, x, y, buf, 1);
/* paint the underline, if specified */
if (c.a & FMT_UNDERLINE)
{ SetBkMode(ps.hdc, TRANSPARENT);
TextOut(ps.hdc, x, y, "_", 1);
}
/* paint the vertical bar, if specified */
if (c.a & FMT_MARGIN)
{ MoveToEx(ps.hdc, x, y, NULL);
LineTo(ps.hdc, x, y + px->fy);
}
}
}
/* finish updating */
SelectObject(ps.hdc, old_hfont);
SelectObject(ps.hdc, old_hpen);
DeleteObject(hpen);
EndPaint(px->window, &ps);
done: return;
}