painting fixes...

This commit is contained in:
michaelp 1998-06-19 02:46:25 +00:00
parent ad0536d14d
commit ec3f238ac8
4 changed files with 85 additions and 11 deletions

View File

@ -94,15 +94,22 @@ nsEventStatus PR_CALLBACK HandleEvent(nsGUIEvent *aEvent)
//see if the paint region is greater than .75 the area of our root view.
//if so, enable double buffered painting.
view->GetBounds(vrect);
// view->GetBounds(vrect);
PRBool db = PR_FALSE;
// PRBool db = PR_FALSE;
if ((((float)trect.width * trect.height) / ((float)vrect.width * vrect.height)) > 0.75f)
db = PR_TRUE;
// if ((((float)trect.width * trect.height) / ((float)vrect.width * vrect.height)) > 0.75f)
// db = PR_TRUE;
vm->Refresh(view, ((nsPaintEvent *)aEvent)->renderingContext, &trect,
((db == PR_TRUE) ? NS_VMREFRESH_DOUBLE_BUFFER : 0) | NS_VMREFRESH_SCREEN_RECT);
vm->UpdateView(view, trect,
// ((db == PR_TRUE) ? NS_VMREFRESH_DOUBLE_BUFFER : 0) |
NS_VMREFRESH_SCREEN_RECT);
// NS_VMREFRESH_IMMEDIATE);
vm->Composite();
//printf("damage repair...\n");
// vm->Refresh(view, ((nsPaintEvent *)aEvent)->renderingContext, &trect,
// ((db == PR_TRUE) ? NS_VMREFRESH_DOUBLE_BUFFER : 0) | NS_VMREFRESH_SCREEN_RECT);
NS_RELEASE(dx);
NS_RELEASE(px);

View File

@ -43,6 +43,7 @@ static void vm_timer_callback(nsITimer *aTimer, void *aClosure)
vm->mFrameRate = 0;
vm->SetFrameRate(fr);
//printf("timer composite...\n");
vm->Composite();
}
@ -217,6 +218,7 @@ void nsViewManager :: SetWindowDimensions(nscoord width, nscoord height)
if (nsnull != mRootView)
mRootView->SetDimensions(width, height);
//printf("new dims: %4.2f %4.2f...\n", width / 20.0f, height / 20.0f);
// Inform the presentation shell that we've been resized
if (nsnull != presShell)
{
@ -284,6 +286,7 @@ void nsViewManager :: Refresh(nsIView *aView, nsIRenderingContext *aContext, nsI
nscoord xoff, yoff;
float scale;
//printf("refreshing region...\n");
//force double buffering because of non-opaque views?
if (mTransCnt > 0)
@ -353,6 +356,9 @@ void nsViewManager :: Refresh(nsIView *aView, nsIRenderingContext *aContext, nsR
//force double buffering because of non-opaque views?
//printf("refreshing rect... ");
//stdout << *rect;
//printf("\n");
if (mTransCnt > 0)
aUpdateFlags |= NS_VMREFRESH_DOUBLE_BUFFER;
@ -468,6 +474,9 @@ void nsViewManager :: UpdateView(nsIView *aView, const nsRect &aRect, PRUint32 a
nsIView *par = aView;
nscoord x, y;
if ((aRect.width == 0) || (aRect.height == 0))
return;
if (gsDebug)
{
printf("ViewManager::UpdateView: %x, rect ", aView);
@ -475,7 +484,16 @@ void nsViewManager :: UpdateView(nsIView *aView, const nsRect &aRect, PRUint32 a
printf("\n");
}
if (nsnull != aView)
if (aUpdateFlags & NS_VMREFRESH_SCREEN_RECT)
{
nscoord xoff, yoff;
GetWindowOffsets(&xoff, &yoff);
trect.x += xoff;
trect.y += yoff;
}
else if (nsnull != aView)
{
do
{
@ -489,6 +507,9 @@ void nsViewManager :: UpdateView(nsIView *aView, const nsRect &aRect, PRUint32 a
while (par = par->GetParent());
}
//printf("updating... ");
//stdout << trect;
//printf("\n");
#ifdef USE_DIRTY_RECT
if (mDirtyRect.IsEmpty())

View File

@ -369,6 +369,7 @@ nsWindow::nsWindow(nsISupports *aOuter) : nsObject(aOuter)
mDeferredPositioner = NULL;
mLastPoint.x = 0;
mLastPoint.y = 0;
mWidth = mHeight = 0;
}
@ -1486,7 +1487,42 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
// the window origin in screen coordinates...
RECT r;
::GetClientRect(mWnd, &r);
nsRect rect(wp->x, wp->y, PRInt32(r.right - r.left), PRInt32(r.bottom - r.top));
PRInt32 newWidth, newHeight;
newWidth = PRInt32(r.right - r.left);
newHeight = PRInt32(r.bottom - r.top);
nsRect rect(wp->x, wp->y, newWidth, newHeight);
if (newWidth > mWidth)
{
RECT drect;
//getting wider
drect.left = wp->x + mWidth;
drect.top = wp->y;
drect.right = drect.left + (newWidth - mWidth);
drect.bottom = drect.top + newHeight;
// ::InvalidateRect(mWnd, &drect, FALSE);
::RedrawWindow(mWnd, &drect, NULL,
RDW_INVALIDATE | RDW_NOERASE | RDW_NOINTERNALPAINT | RDW_ERASENOW | RDW_ALLCHILDREN);
}
if (newHeight > mHeight)
{
RECT drect;
//getting taller
drect.left = wp->x;
drect.top = wp->y + mHeight;
drect.right = drect.left + newWidth;
drect.bottom = drect.top + (newHeight - mHeight);
// ::InvalidateRect(mWnd, &drect, FALSE);
::RedrawWindow(mWnd, &drect, NULL,
RDW_INVALIDATE | RDW_NOERASE | RDW_NOINTERNALPAINT | RDW_ERASENOW | RDW_ALLCHILDREN);
}
mWidth = newWidth;
mHeight = newHeight;
///nsRect rect(wp->x, wp->y, wp->cx, wp->cy);
result = OnResize(rect);
}
@ -1550,7 +1586,7 @@ LPCTSTR nsWindow::WindowClass()
if (!nsWindow::sIsRegistered) {
WNDCLASS wc;
// wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
// wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
wc.style = CS_DBLCLKS;
wc.lpfnWndProc = ::DefWindowProc;
wc.cbClsExtra = 0;
@ -1682,7 +1718,6 @@ PRBool nsWindow::OnPaint()
HDC hDC = ::BeginPaint(mWnd, &ps);
if (ps.rcPaint.left || ps.rcPaint.right || ps.rcPaint.top || ps.rcPaint.bottom) {
// call the event callback
if (mEventCallback) {
nsPaintEvent event;
@ -1695,21 +1730,29 @@ PRBool nsWindow::OnPaint()
ps.rcPaint.bottom - ps.rcPaint.top);
event.rect = &rect;
::EndPaint(mWnd, &ps);
static NS_DEFINE_IID(kRenderingContextCID, NS_RENDERING_CONTEXT_CID);
static NS_DEFINE_IID(kRenderingContextIID, NS_IRENDERING_CONTEXT_IID);
if (NS_OK == NSRepository::CreateInstance(kRenderingContextCID, nsnull, kRenderingContextIID, (void **)&event.renderingContext))
{
hDC = ::GetDC(mWnd);
event.renderingContext->Init(mContext, (nsDrawingSurface)hDC);
result = DispatchEvent(&event);
NS_RELEASE(event.renderingContext);
::ReleaseDC(mWnd, hDC);
}
else
result = PR_FALSE;
}
else
::EndPaint(mWnd, &ps);
}
else
::EndPaint(mWnd, &ps);
::EndPaint(mWnd, &ps);
// ::EndPaint(mWnd, &ps);
return result;
}

View File

@ -187,6 +187,9 @@ protected:
PRBool mIsAltDown;
PRBool mIsDestroying;
PRInt32 mWidth;
PRInt32 mHeight;
// keep the list of children
class Enumerator : public nsIEnumerator {
nsIWidget **mChildrens;