Commit e3335ee7 authored by Dimitrie O. Paun's avatar Dimitrie O. Paun Committed by Alexandre Julliard

Cleanup and simplify the painting code.

Fix a potential bug along the way.
parent 8b55b76d
...@@ -261,6 +261,10 @@ static BOOL ANIMATE_PaintFrame(ANIMATE_INFO* infoPtr, HDC hDC) ...@@ -261,6 +261,10 @@ static BOOL ANIMATE_PaintFrame(ANIMATE_INFO* infoPtr, HDC hDC)
if (!hDC || !infoPtr->inbih) if (!hDC || !infoPtr->inbih)
return TRUE; return TRUE;
if (GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & ACS_TRANSPARENT)
infoPtr->hbrushBG = (HBRUSH)SendMessageW(infoPtr->hwndNotify, WM_CTLCOLORSTATIC,
(WPARAM)hDC, (LPARAM)infoPtr->hwndSelf);
if (infoPtr->hic ) if (infoPtr->hic )
{ {
pBitmapData = infoPtr->outdata; pBitmapData = infoPtr->outdata;
...@@ -268,7 +272,8 @@ static BOOL ANIMATE_PaintFrame(ANIMATE_INFO* infoPtr, HDC hDC) ...@@ -268,7 +272,8 @@ static BOOL ANIMATE_PaintFrame(ANIMATE_INFO* infoPtr, HDC hDC)
nWidth = infoPtr->outbih->biWidth; nWidth = infoPtr->outbih->biWidth;
nHeight = infoPtr->outbih->biHeight; nHeight = infoPtr->outbih->biHeight;
} else }
else
{ {
pBitmapData = infoPtr->indata; pBitmapData = infoPtr->indata;
pBitmapInfo = (LPBITMAPINFO)infoPtr->inbih; pBitmapInfo = (LPBITMAPINFO)infoPtr->inbih;
...@@ -374,6 +379,22 @@ static BOOL ANIMATE_DrawFrame(ANIMATE_INFO *infoPtr) ...@@ -374,6 +379,22 @@ static BOOL ANIMATE_DrawFrame(ANIMATE_INFO *infoPtr)
return TRUE; return TRUE;
} }
static LRESULT ANIMATE_Paint(ANIMATE_INFO *infoPtr, HDC hdc)
{
PAINTSTRUCT ps;
HDC hDC = hdc;
if (!hdc) hDC = BeginPaint(infoPtr->hwndSelf, &ps);
EnterCriticalSection(&infoPtr->cs);
ANIMATE_PaintFrame(infoPtr, hDC);
LeaveCriticalSection(&infoPtr->cs);
if (!hdc) EndPaint(infoPtr->hwndSelf, &ps);
return 0;
}
static DWORD CALLBACK ANIMATE_AnimationThread(LPVOID ptr_) static DWORD CALLBACK ANIMATE_AnimationThread(LPVOID ptr_)
{ {
ANIMATE_INFO *infoPtr = (ANIMATE_INFO *)ptr_; ANIMATE_INFO *infoPtr = (ANIMATE_INFO *)ptr_;
...@@ -837,7 +858,7 @@ static BOOL ANIMATE_EraseBackground(ANIMATE_INFO *infoPtr, HDC hdc) ...@@ -837,7 +858,7 @@ static BOOL ANIMATE_EraseBackground(ANIMATE_INFO *infoPtr, HDC hdc)
return TRUE; return TRUE;
} }
static LRESULT WINAPI ANIMATE_Size(ANIMATE_INFO *infoPtr, INT flags, WORD width, WORD height) static LRESULT ANIMATE_Size(ANIMATE_INFO *infoPtr, INT flags, WORD width, WORD height)
{ {
if (GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & ACS_CENTER) if (GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & ACS_CENTER)
{ {
...@@ -882,50 +903,16 @@ static LRESULT WINAPI ANIMATE_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LP ...@@ -882,50 +903,16 @@ static LRESULT WINAPI ANIMATE_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LP
/* case WM_STYLECHANGED: FIXME shall we do something ?? */ /* case WM_STYLECHANGED: FIXME shall we do something ?? */
case WM_TIMER: case WM_TIMER:
if (GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & ACS_TRANSPARENT) return ANIMATE_DrawFrame(infoPtr);
{
infoPtr->hbrushBG = (HBRUSH)SendMessageW(infoPtr->hwndNotify,
WM_CTLCOLORSTATIC,
wParam, (LPARAM)infoPtr->hwndSelf);
}
return ANIMATE_DrawFrame(infoPtr);
case WM_PAINT: case WM_PAINT:
{ /* the animation isn't playing, or has not decompressed
/* the animation isn't playing, or has not decompressed * (and displayed) the first frame yet, do default painting
* (and displayed) the first frame yet, don't paint */
*/ if ((!infoPtr->uTimer && !infoPtr->hThread) || !infoPtr->hbmPrevFrame)
if ((!infoPtr->uTimer && !infoPtr->hThread) || return DefWindowProcW(hWnd, uMsg, wParam, lParam);
!infoPtr->hbmPrevFrame) else
{ return ANIMATE_Paint(infoPtr, (HDC)wParam);
/* default paint handling */
return DefWindowProcW(hWnd, uMsg, wParam, lParam);
}
if (GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & ACS_TRANSPARENT)
infoPtr->hbrushBG = (HBRUSH)SendMessageW(infoPtr->hwndNotify,
WM_CTLCOLORSTATIC,
wParam, (LPARAM)infoPtr->hwndSelf);
if (wParam)
{
EnterCriticalSection(&infoPtr->cs);
ANIMATE_PaintFrame(infoPtr, (HDC)wParam);
LeaveCriticalSection(&infoPtr->cs);
}
else
{
PAINTSTRUCT ps;
HDC hDC = BeginPaint(infoPtr->hwndSelf, &ps);
EnterCriticalSection(&infoPtr->cs);
ANIMATE_PaintFrame(infoPtr, hDC);
LeaveCriticalSection(&infoPtr->cs);
EndPaint(infoPtr->hwndSelf, &ps);
}
}
break;
case WM_SIZE: case WM_SIZE:
return ANIMATE_Size(infoPtr, (INT)wParam, LOWORD(lParam), HIWORD(lParam)); return ANIMATE_Size(infoPtr, (INT)wParam, LOWORD(lParam), HIWORD(lParam));
......
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