added APIs to viewmanager to enable and disable all rendering.

made Refresh() APIs of viewmanager implementation private.
This commit is contained in:
michaelp%netscape.com 1998-07-24 21:05:50 +00:00
parent 146b35a4e0
commit 837d1a9ae0
11 changed files with 120 additions and 35 deletions

View File

@ -69,7 +69,7 @@ nsresult StringUnicharInputStream::Read(PRUnichar* aBuf,
{
if (mPos >= mLen) {
*aReadCount = 0;
return -1;
return (nsresult)-1;
}
const PRUnichar* us = mString->GetUnicode();
PRInt32 amount = mLen - mPos;

View File

@ -909,7 +909,7 @@ HTMLContentSink::CloseContainer(const nsIParserNode& aNode)
rootView->GetBounds(rect);
rect.x = 0;
rect.y = 0;
vm->Refresh(rootView, nsnull, &rect, NS_VMREFRESH_IMMEDIATE);
vm->UpdateView(rootView, rect, NS_VMREFRESH_IMMEDIATE);
NS_RELEASE(rootView);
}
NS_RELEASE(vm);

View File

@ -909,7 +909,7 @@ HTMLContentSink::CloseContainer(const nsIParserNode& aNode)
rootView->GetBounds(rect);
rect.x = 0;
rect.y = 0;
vm->Refresh(rootView, nsnull, &rect, NS_VMREFRESH_IMMEDIATE);
vm->UpdateView(rootView, rect, NS_VMREFRESH_IMMEDIATE);
NS_RELEASE(rootView);
}
NS_RELEASE(vm);

View File

@ -109,8 +109,19 @@ public:
* Scroll the view to the given x,y, update's the scrollbar's thumb
* positions and the view's offset. Clamps the values to be
* legal. Updates the display based on aUpdateFlags.
* @param aX left edge to scroll to
* @param aY top edge to scroll to
* @param aUpdateFlags passed onto nsIViewManager->UpdateView()
* @return error status
*/
NS_IMETHOD ScrollTo(nscoord aX, nscoord aY, PRUint32 aUpdateFlags) = 0;
/**
* Get the view that clips the contents of the scrolling view
* @param aClipView out param to hold view pointer
* @return error status
*/
NS_IMETHOD GetClipView(nsIView ** aClipView) = 0;
};
#endif

View File

@ -134,27 +134,6 @@ public:
*/
virtual void ResetScrolling(void) = 0;
/**
* Called to refresh an area of the root window. Often called in
* response to a paint/redraw event from the native windowing system.
* @param aContext rendering context to draw into
* @param region nsIRegion to be updated
* @param aUpdateFlags see bottom of nsIViewManager.h for description
*/
virtual void Refresh(nsIView *aView, nsIRenderingContext *aContext,
nsIRegion *region, PRUint32 aUpdateFlags) = 0;
/**
* Called to refresh an area of the root window. Often called in
* response to a paint/redraw event from the native windowing system.
* @param aView view to paint. should be root view
* @param aContext rendering context to draw into
* @param rect nsRect to be updated
* @param aUpdateFlags see bottom of nsIViewManager.h for description
*/
virtual void Refresh(nsIView* aView, nsIRenderingContext *aContext,
nsRect *rect, PRUint32 aUpdateFlags) = 0;
/**
* Called to force a redrawing of any dirty areas.
*/
@ -384,6 +363,19 @@ public:
* @param aShow if PR_TRUE, quality level will be displayed, else hidden
*/
virtual void SetQuality(nsContentQuality aQuality) = 0;
/**
* prevent the view manager from refreshing.
* @return error status
*/
NS_IMETHOD DisableRefresh(void) = 0;
/**
* allow the view manager to refresh. this may cause a synchronous
* paint to occur inside the call.
* @return error status
*/
NS_IMETHOD EnableRefresh(void) = 0;
};
//when the refresh happens, should it be double buffered?

View File

@ -312,6 +312,7 @@ nsScrollingView :: nsScrollingView()
mHScrollBarView = nsnull;
mCornerView = nsnull;
mScrollPref = nsScrollPreference_kAuto;
mClipView = nsnull;
}
nsScrollingView :: ~nsScrollingView()
@ -335,6 +336,12 @@ nsScrollingView :: ~nsScrollingView()
NS_RELEASE(mCornerView);
mCornerView = nsnull;
}
if (nsnull != mClipView)
{
NS_RELEASE(mClipView);
mClipView = nsnull;
}
}
nsresult nsScrollingView :: QueryInterface(const nsIID& aIID, void** aInstancePtr)
@ -404,6 +411,28 @@ nsresult nsScrollingView :: Init(nsIViewManager* aManager,
mViewManager->InsertChild(this, mCornerView, -1);
}
#if 0
// Create a view for clipping
mClipView = new ClipView();
if (nsnull != mClipView)
{
NS_ADDREF(mClipView);
nsRect trect;
trect.width = aBounds.XMost() - NS_TO_INT_ROUND(dx->GetScrollBarWidth());
trect.x = 0;
trect.height = aBounds.YMost() - NS_TO_INT_ROUND(dx->GetScrollBarHeight());
trect.y = 0;
rv = mClipView->Init(mViewManager, trect, this, nsnull, nsnull, nsnull, -1);
mViewManager->InsertChild(this, mCornerView, -1);
}
#endif
// Create a view for a vertical scrollbar
mVScrollBarView = new ScrollBarView(this);
@ -422,7 +451,7 @@ nsresult nsScrollingView :: Init(nsIViewManager* aManager,
rv = mVScrollBarView->Init(mViewManager, trect, this, &kCScrollbarIID, nsnull, nsnull, -2);
mViewManager->InsertChild(this, mVScrollBarView, -2);
mViewManager->InsertChild(this, mVScrollBarView, -3);
}
// Create a view for a horizontal scrollbar
@ -443,7 +472,7 @@ nsresult nsScrollingView :: Init(nsIViewManager* aManager,
rv = mHScrollBarView->Init(mViewManager, trect, this, &kCHScrollbarIID, nsnull, nsnull, -2);
mViewManager->InsertChild(this, mHScrollBarView, -2);
mViewManager->InsertChild(this, mHScrollBarView, -3);
}
NS_RELEASE(dx);
@ -1044,6 +1073,14 @@ nsScrollingView :: ScrollTo(nscoord aX, nscoord aY, PRUint32 aUpdateFlags)
return NS_OK;
}
NS_IMETHODIMP nsScrollingView :: GetClipView(nsIView ** aClipView)
{
NS_IF_ADDREF(mClipView);
*aClipView = mClipView;
return NS_OK;
}
void nsScrollingView :: AdjustChildWidgets(nsScrollingView *aScrolling, nsIView *aView, nscoord aDx, nscoord aDy, float scale)
{
PRInt32 numkids = aView->GetChildCount();

View File

@ -69,6 +69,7 @@ public:
virtual void SetScrollPreference(nsScrollPreference aPref);
virtual nsScrollPreference GetScrollPreference(void);
NS_IMETHOD ScrollTo(nscoord aX, nscoord aY, PRUint32 aUpdateFlags);
NS_IMETHOD GetClipView(nsIView ** aClipView);
//private
void ComputeScrollArea(nsIView *aView, nsRect &aRect, nscoord aOffX, nscoord aOffY);
@ -83,6 +84,7 @@ protected:
nsIView *mHScrollBarView;
nsIView *mCornerView;
nsScrollPreference mScrollPref;
nsIView *mClipView;
};
#endif

View File

@ -96,8 +96,9 @@ nsEventStatus PR_CALLBACK HandleEvent(nsGUIEvent *aEvent)
//printf("damage repair...\n");
vm->UpdateView(view, trect,
NS_VMREFRESH_SCREEN_RECT);
vm->Composite();
NS_VMREFRESH_SCREEN_RECT |
NS_VMREFRESH_IMMEDIATE |
NS_VMREFRESH_DOUBLE_BUFFER);
NS_RELEASE(dx);
NS_RELEASE(px);

View File

@ -137,6 +137,8 @@ nsresult nsViewManager::Init(nsIPresContext* aPresContext)
mLastRefresh = PR_Now();
mRefreshEnabled = PR_TRUE;
return rv;
}
@ -285,6 +287,9 @@ void nsViewManager :: Refresh(nsIView *aView, nsIRenderingContext *aContext, nsI
nscoord xoff, yoff;
float scale;
if (PR_FALSE == mRefreshEnabled)
return;
//printf("refreshing region...\n");
//force double buffering because of non-opaque views?
@ -353,6 +358,9 @@ void nsViewManager :: Refresh(nsIView *aView, nsIRenderingContext *aContext, nsR
nsIRenderingContext *localcx = nsnull;
nscoord xoff, yoff;
if (PR_FALSE == mRefreshEnabled)
return;
//force double buffering because of non-opaque views?
//printf("refreshing rect... ");
@ -1011,3 +1019,33 @@ void nsViewManager :: UpdateTransCnt(nsIView *oldview, nsIView *newview)
(newview->GetOpacity() != 1.0f)))
mTransCnt++;
}
NS_IMETHODIMP nsViewManager :: DisableRefresh(void)
{
mRefreshEnabled = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP nsViewManager :: EnableRefresh(void)
{
mRefreshEnabled = PR_TRUE;
if (mFrameRate > 0)
{
PRTime now = PR_Now();
PRTime conversion, ustoms;
PRInt32 deltams;
LL_I2L(ustoms, 1000);
LL_SUB(conversion, now, mLastRefresh);
LL_DIV(conversion, conversion, ustoms);
LL_L2I(deltams, conversion);
if (deltams > (1000 / (PRInt32)mFrameRate))
Composite();
}
return NS_OK;
}

View File

@ -58,11 +58,6 @@ public:
virtual void ResetScrolling(void);
virtual void Refresh(nsIView *aView, nsIRenderingContext *aContext,
nsIRegion *region, PRUint32 aUpdateFlags);
virtual void Refresh(nsIView* aView, nsIRenderingContext *aContext,
nsRect *rect, PRUint32 aUpdateFlags);
virtual void Composite();
virtual void UpdateView(nsIView *aView, nsIRegion *aRegion,
@ -117,12 +112,20 @@ public:
virtual PRBool GetShowQuality(void);
virtual void SetQuality(nsContentQuality aQuality);
NS_IMETHOD DisableRefresh(void);
NS_IMETHOD EnableRefresh(void);
private:
virtual ~nsViewManager();
nsIRenderingContext *CreateRenderingContext(nsIView &aView);
void AddRectToDirtyRegion(nsRect &aRect);
void UpdateTransCnt(nsIView *oldview, nsIView *newview);
void Refresh(nsIView *aView, nsIRenderingContext *aContext,
nsIRegion *region, PRUint32 aUpdateFlags);
void Refresh(nsIView* aView, nsIRenderingContext *aContext,
nsRect *rect, PRUint32 aUpdateFlags);
nsIPresContext *mContext;
nsIWidget *mRootWindow;
nsRect mDSBounds;
@ -130,13 +133,14 @@ private:
PRTime mLastRefresh;
nsIRegion *mDirtyRegion;
PRInt32 mTransCnt;
PRBool mRefreshEnabled;
public:
//these are public so that our timer callback can poke them.
nsITimer *mTimer;
nsRect mDirtyRect;
nsIView *mRootView;
PRUint32 mFrameRate;
PRUint32 mFrameRate;
};
#endif

View File

@ -69,7 +69,7 @@ nsresult StringUnicharInputStream::Read(PRUnichar* aBuf,
{
if (mPos >= mLen) {
*aReadCount = 0;
return -1;
return (nsresult)-1;
}
const PRUnichar* us = mString->GetUnicode();
PRInt32 amount = mLen - mPos;