Commit fe2951da authored by Phil Krylov's avatar Phil Krylov Committed by Alexandre Julliard

Cache background color brush instead of recreating it at each screen

update.
parent 2d62ba55
......@@ -821,6 +821,7 @@ ME_TextEditor *ME_MakeEditor(HWND hWnd) {
ed->nUDArrowX = -1;
ed->nSequence = 0;
ed->rgbBackColor = -1;
ed->hbrBackground = GetSysColorBrush(COLOR_WINDOW);
ed->bCaretAtEnd = FALSE;
ed->nEventMask = 0;
ed->nModifyStep = 0;
......@@ -926,7 +927,8 @@ void ME_DestroyEditor(ME_TextEditor *editor)
if (editor->pFontCache[i].hFont)
DeleteObject(editor->pFontCache[i].hFont);
}
DeleteObject(editor->hbrBackground);
FREE_OBJ(editor);
}
......@@ -1265,10 +1267,18 @@ LRESULT WINAPI RichEditANSIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP
case EM_SETBKGNDCOLOR:
{
LRESULT lColor = ME_GetBackColor(editor);
if (editor->rgbBackColor != -1)
DeleteObject(editor->hbrBackground);
if (wParam)
{
editor->rgbBackColor = -1;
editor->hbrBackground = GetSysColorBrush(COLOR_WINDOW);
}
else
{
editor->rgbBackColor = lParam;
editor->hbrBackground = CreateSolidBrush(editor->rgbBackColor);
}
if (editor->bRedraw)
{
InvalidateRect(hWnd, NULL, TRUE);
......@@ -1792,12 +1802,9 @@ LRESULT WINAPI RichEditANSIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP
{
HDC hDC = (HDC)wParam;
RECT rc;
COLORREF rgbBG = ME_GetBackColor(editor);
if (GetUpdateRect(hWnd,&rc,TRUE))
{
HBRUSH hbr = CreateSolidBrush(rgbBG);
FillRect(hDC, &rc, hbr);
DeleteObject(hbr);
FillRect(hDC, &rc, editor->hbrBackground);
}
}
return 1;
......
......@@ -270,6 +270,7 @@ typedef struct tagME_TextEditor
int nSequence;
int nOldSelFrom, nOldSelTo;
COLORREF rgbBackColor;
HBRUSH hbrBackground;
BOOL bCaretAtEnd;
int nEventMask;
int nModifyStep;
......
......@@ -78,14 +78,11 @@ void ME_PaintContent(ME_TextEditor *editor, HDC hDC, BOOL bOnlyNew, RECT *rcUpda
}
if (ye>ys) {
HBRUSH hbr;
hbr = CreateSolidBrush(ME_GetBackColor(c.editor));
rc.left = xs;
rc.top = ys;
rc.right = xe;
rc.bottom = ye;
FillRect(hDC, &rc, hbr);
DeleteObject(hbr);
FillRect(hDC, &rc, c.editor->hbrBackground);
}
if (ys == c.pt.y) /* don't overwrite the top bar */
ys++;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment