PDA

View Full Version : Fix for high CPU in tiger example of reference impl



erikhansen
11-22-2009, 02:42 AM
Hi,

I'm just starting to play with OpenVG and ran the tiger example of the reference implementation on Win32. I noticed CPU load remains high even after rendering is complete. The reason is Windows keeps sending WM_PAINT messages because as far as it is concerned the drawing area is still "dirty". All that is needed is a ValidateRect() call to stop the flood of WM_PAINT messages.

Change:


case WM_PAINT:
{
RECT rect;
InvalidateRect(hWnd, NULL, 0);
GetClientRect(hWnd, &rect);
render(rect.right - rect.left, rect.bottom - rect.top);
return 0;
}


To


case WM_PAINT:
{
if (GetUpdateRect(hWnd, NULL, FALSE))
{
RECT rect;
GetClientRect(hWnd, &rect);
render(rect.right - rect.left, rect.bottom - rect.top);
ValidateRect(hWnd, &rect);
}
return 0;
}


Please let me know if there is a better place to post fixes.

Cheers,
Erik