Bug 542280 - use GetUpdateRgn() on Windows mobile, r=blassey

This commit is contained in:
Brian Crowder 2010-01-28 20:02:12 -08:00
Родитель cc720f03d5
Коммит aca201ec7f
3 изменённых файлов: 18 добавлений и 43 удалений

Просмотреть файл

@ -404,11 +404,6 @@ nsWindow::nsWindow() : nsBaseWidget()
mBrush = ::CreateSolidBrush(NSRGB_2_COLOREF(mBackground)); mBrush = ::CreateSolidBrush(NSRGB_2_COLOREF(mBackground));
mForeground = ::GetSysColor(COLOR_WINDOWTEXT); mForeground = ::GetSysColor(COLOR_WINDOWTEXT);
#ifdef WINCE_WINDOWS_MOBILE
mInvalidatedRegion = do_CreateInstance(kRegionCID);
mInvalidatedRegion->Init();
#endif
#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_WIN7 #if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_WIN7
mTaskbarPreview = nsnull; mTaskbarPreview = nsnull;
mHasTaskbarIconBeenCreated = PR_FALSE; mHasTaskbarIconBeenCreated = PR_FALSE;
@ -2097,12 +2092,7 @@ NS_METHOD nsWindow::Invalidate(PRBool aIsSynchronous)
nsCAutoString("noname"), nsCAutoString("noname"),
(PRInt32) mWnd); (PRInt32) mWnd);
#endif // WIDGET_DEBUG_OUTPUT #endif // WIDGET_DEBUG_OUTPUT
#ifdef WINCE_WINDOWS_MOBILE
// We need to keep track of our own invalidated region for Windows CE
RECT r;
GetClientRect(mWnd, &r);
AddRECTToRegion(r, mInvalidatedRegion);
#endif
VERIFY(::InvalidateRect(mWnd, NULL, FALSE)); VERIFY(::InvalidateRect(mWnd, NULL, FALSE));
if (aIsSynchronous) { if (aIsSynchronous) {
@ -2133,10 +2123,6 @@ NS_METHOD nsWindow::Invalidate(const nsIntRect & aRect, PRBool aIsSynchronous)
rect.right = aRect.x + aRect.width; rect.right = aRect.x + aRect.width;
rect.bottom = aRect.y + aRect.height; rect.bottom = aRect.y + aRect.height;
#ifdef WINCE_WINDOWS_MOBILE
// We need to keep track of our own invalidated region for Windows CE
AddRECTToRegion(rect, mInvalidatedRegion);
#endif
VERIFY(::InvalidateRect(mWnd, &rect, FALSE)); VERIFY(::InvalidateRect(mWnd, &rect, FALSE));
if (aIsSynchronous) { if (aIsSynchronous) {
@ -6199,11 +6185,6 @@ HBRUSH nsWindow::OnControlColor()
// Can be overriden. Controls auto-erase of background. // Can be overriden. Controls auto-erase of background.
PRBool nsWindow::AutoErase(HDC dc) PRBool nsWindow::AutoErase(HDC dc)
{ {
#ifdef WINCE_WINDOWS_MOBILE
RECT wrect;
GetClipBox(dc, &wrect);
AddRECTToRegion(wrect, mInvalidatedRegion);
#endif
return PR_FALSE; return PR_FALSE;
} }

Просмотреть файл

@ -429,9 +429,6 @@ protected:
nsPopupType mPopupType; nsPopupType mPopupType;
PRPackedBool mDisplayPanFeedback; PRPackedBool mDisplayPanFeedback;
WindowHook mWindowHook; WindowHook mWindowHook;
#ifdef WINCE_WINDOWS_MOBILE
nsCOMPtr<nsIRegion> mInvalidatedRegion;
#endif
static PRUint32 sInstanceCount; static PRUint32 sInstanceCount;
static TriStateBool sCanQuit; static TriStateBool sCanQuit;
static nsWindow* sCurrentWindow; static nsWindow* sCurrentWindow;

Просмотреть файл

@ -283,13 +283,16 @@ nsCOMPtr<nsIRegion> nsWindow::GetRegionToPaint(PRBool aForceFullRepaint,
} }
#else #else
# ifdef WINCE_WINDOWS_MOBILE # ifdef WINCE_WINDOWS_MOBILE
if (!mInvalidatedRegion->IsEmpty()) { paintRgn = ::CreateRectRgn(0, 0, 0, 0);
// XXX: we may not recieve invalidates when an OS dialog obsures out window if (paintRgn != NULL) {
// and dismisses, so mInvalidatedRegion may not be complete int result = GetUpdateRgn(mWnd, paintRgn, FALSE);
paintRgnWin = mInvalidatedRegion.forget(); if (result == 1) {
mInvalidatedRegion = do_CreateInstance(kRegionCID); POINT pt = {0,0};
mInvalidatedRegion->Init(); ::MapWindowPoints(NULL, mWnd, &pt, 1);
return paintRgnWin; ::OffsetRgn(paintRgn, pt.x, pt.y);
}
paintRgnWin = nsWindowGfx::ConvertHRGNToRegion(paintRgn);
::DeleteObject(paintRgn);
} }
# endif # endif
paintRgn = ::CreateRectRgn(ps.rcPaint.left, ps.rcPaint.top, paintRgn = ::CreateRectRgn(ps.rcPaint.left, ps.rcPaint.top,
@ -1044,23 +1047,17 @@ PRBool nsWindow::OnPaintImageDDraw16()
r.bottom = rects->mRects[i].height + rects->mRects[i].y; r.bottom = rects->mRects[i].height + rects->mRects[i].y;
RECT renderRect = r; RECT renderRect = r;
SetLastError(0); // See http://msdn.microsoft.com/en-us/library/dd145046%28VS.85%29.aspx SetLastError(0); // See http://msdn.microsoft.com/en-us/library/dd145046%28VS.85%29.aspx
if (MapWindowPoints(mWnd, 0, (LPPOINT)&renderRect, 2) || 0 == (hr = GetLastError())) MapWindowPoints(mWnd, 0, (LPPOINT)&renderRect, 2);
hr = glpDDPrimary->Blt(&renderRect, glpDDSecondary, &r, 0, NULL); hr = glpDDPrimary->Blt(&renderRect, glpDDSecondary, &r, 0, NULL);
#ifdef WINCE_WINDOWS_MOBILE if (FAILED(hr)) {
if (FAILED(hr)) NS_ERROR("this blt should never fail!");
// add this rect back to the invalidated region so we'll attempt paint it next time around printf("#### %s blt failed: %08lx", __FUNCTION__, hr);
mInvalidatedRegion->Union(rects->mRects[i].x, rects->mRects[i].y, }
rects->mRects[i].width, rects->mRects[i].height);
#endif
} }
result = PR_TRUE; result = PR_TRUE;
cleanup: cleanup:
#ifdef WINCE_WINDOWS_MOBILE NS_ASSERTION(result == PR_TRUE, "fatal drawing error");
// re-invalidate the region if we failed.
if (!result)
mInvalidatedRegion->Union(*paintRgnWin.get());
#endif
::EndPaint(mWnd, &ps); ::EndPaint(mWnd, &ps);
mPaintDC = nsnull; mPaintDC = nsnull;
mPainting = PR_FALSE; mPainting = PR_FALSE;