зеркало из https://github.com/mozilla/pjs.git
work in progress for new compositor. not currently enabled, so it won't
affect anyone else. killed Paint() method of scrolling view since it no longer does anything useful. made view manager destructor protected to eliminate gcc warnings.
This commit is contained in:
Родитель
8f7c758700
Коммит
e9df6a8f2c
|
@ -462,6 +462,11 @@ private:
|
|||
//while in the front to back pass
|
||||
#define NS_VIEW_FLAG_FRONT_TO_BACK 0x0040
|
||||
|
||||
//temporary hack so that michael can work on the new
|
||||
//compositor and make checkins without busting the rest
|
||||
//of the world.
|
||||
#define NS_VIEW_FLAG_JUST_PAINT 0x0080
|
||||
|
||||
//Flag to determine whether the view will check if events can be handled
|
||||
//by its children or just handle the events itself
|
||||
#define NS_VIEW_FLAG_DONT_CHECK_CHILDREN 0x0001
|
||||
|
|
|
@ -467,6 +467,7 @@ NS_IMETHODIMP nsScrollingView :: SetPosition(nscoord aX, nscoord aY)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
#if 0
|
||||
NS_IMETHODIMP nsScrollingView :: Paint(nsIRenderingContext& rc, const nsRect& rect,
|
||||
PRUint32 aPaintFlags, PRBool &aResult)
|
||||
{
|
||||
|
@ -494,6 +495,7 @@ NS_IMETHODIMP nsScrollingView :: Paint(nsIRenderingContext& rc, const nsRect& re
|
|||
aResult = clipres;
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
void nsScrollingView :: HandleScrollEvent(nsGUIEvent *aEvent, PRUint32 aEventFlags)
|
||||
{
|
||||
|
|
|
@ -39,8 +39,8 @@ public:
|
|||
NS_IMETHOD SetDimensions(nscoord width, nscoord height, PRBool aPaint = PR_TRUE);
|
||||
NS_IMETHOD SetPosition(nscoord aX, nscoord aY);
|
||||
NS_IMETHOD HandleEvent(nsGUIEvent *aEvent, PRUint32 aEventFlags, nsEventStatus &aStatus);
|
||||
NS_IMETHOD Paint(nsIRenderingContext& rc, const nsRect& rect,
|
||||
PRUint32 aPaintFlags, PRBool &aResult);
|
||||
// NS_IMETHOD Paint(nsIRenderingContext& rc, const nsRect& rect,
|
||||
// PRUint32 aPaintFlags, PRBool &aResult);
|
||||
NS_IMETHOD SetWidget(nsIWidget *aWidget);
|
||||
|
||||
//nsIScrollableView interface
|
||||
|
|
|
@ -255,6 +255,37 @@ NS_IMETHODIMP nsView :: GetViewManager(nsIViewManager *&aViewMgr)
|
|||
|
||||
NS_IMETHODIMP nsView :: Paint(nsIRenderingContext& rc, const nsRect& rect,
|
||||
PRUint32 aPaintFlags, PRBool &aResult)
|
||||
{
|
||||
if (aPaintFlags & NS_VIEW_FLAG_JUST_PAINT)
|
||||
{
|
||||
//new compositor
|
||||
|
||||
if (nsnull != mClientData)
|
||||
{
|
||||
nsIViewObserver *obs;
|
||||
|
||||
if (NS_OK == mViewManager->GetViewObserver(obs))
|
||||
{
|
||||
if ((mClip.mLeft != mClip.mRight) && (mClip.mTop != mClip.mBottom))
|
||||
{
|
||||
nsRect crect, brect;
|
||||
|
||||
GetBounds(brect);
|
||||
|
||||
crect.x = mClip.mLeft + brect.x;
|
||||
crect.y = mClip.mTop + brect.y;
|
||||
crect.width = mClip.mRight - mClip.mLeft;
|
||||
crect.height = mClip.mBottom - mClip.mTop;
|
||||
|
||||
rc.SetClipRect(crect, nsClipCombine_kIntersect, aResult);
|
||||
}
|
||||
|
||||
obs->Paint((nsIView *)this, rc, rect);
|
||||
NS_RELEASE(obs);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nsIView *pRoot;
|
||||
PRBool clipres = PR_FALSE;
|
||||
|
@ -713,6 +744,8 @@ NS_IMETHODIMP nsView :: Paint(nsIRenderingContext& rc, const nsRect& rect,
|
|||
}
|
||||
|
||||
aResult = clipres;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ static const PRBool gsDebug = PR_FALSE;
|
|||
#define UPDATE_QUANTUM 1000 / 40
|
||||
|
||||
//#define NO_DOUBLE_BUFFER
|
||||
//#define NEW_COMPOSITOR
|
||||
|
||||
static void vm_timer_callback(nsITimer *aTimer, void *aClosure)
|
||||
{
|
||||
|
@ -107,6 +108,22 @@ nsViewManager :: ~nsViewManager()
|
|||
|
||||
mObserver = nsnull;
|
||||
mContext = nsnull;
|
||||
|
||||
if (nsnull != mFlatViews)
|
||||
{
|
||||
PRInt32 cnt = mFlatViews->Count(), idx;
|
||||
|
||||
for (idx = 1; idx < cnt; idx += 2)
|
||||
{
|
||||
nsRect *rect = (nsRect *)mFlatViews->ElementAt(idx);
|
||||
|
||||
if (nsnull != rect)
|
||||
delete rect;
|
||||
}
|
||||
|
||||
delete mFlatViews;
|
||||
mFlatViews = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMPL_QUERY_INTERFACE(nsViewManager, knsViewManagerIID)
|
||||
|
@ -320,11 +337,14 @@ void nsViewManager :: Refresh(nsIView *aView, nsIRenderingContext *aContext, nsI
|
|||
|
||||
localcx->SetClipRect(trect, nsClipCombine_kIntersect, result);
|
||||
|
||||
// Paint the view. The clipping rect was set above set don't clip again.
|
||||
aView->Paint(*localcx, trect, NS_VIEW_FLAG_CLIP_SET, result);
|
||||
RenderViews(aView, *localcx, trect, result);
|
||||
|
||||
if (aUpdateFlags & NS_VMREFRESH_DOUBLE_BUFFER)
|
||||
#ifdef NEW_COMPOSITOR
|
||||
localcx->CopyOffScreenBits(ds, wrect.x, wrect.y, wrect, 0);
|
||||
#else
|
||||
localcx->CopyOffScreenBits(ds, wrect.x, wrect.y, wrect, NS_COPYBITS_USE_SOURCE_CLIP_REGION);
|
||||
#endif
|
||||
|
||||
if (localcx != aContext)
|
||||
NS_RELEASE(localcx);
|
||||
|
@ -399,11 +419,14 @@ void nsViewManager :: Refresh(nsIView *aView, nsIRenderingContext *aContext, con
|
|||
|
||||
localcx->SetClipRect(trect, nsClipCombine_kReplace, result);
|
||||
|
||||
// Paint the view. The clipping rect was set above set don't clip again.
|
||||
aView->Paint(*localcx, trect, NS_VIEW_FLAG_CLIP_SET, result);
|
||||
RenderViews(aView, *localcx, trect, result);
|
||||
|
||||
if (aUpdateFlags & NS_VMREFRESH_DOUBLE_BUFFER)
|
||||
#ifdef NEW_COMPOSITOR
|
||||
localcx->CopyOffScreenBits(ds, wrect.x, wrect.y, wrect, 0);
|
||||
#else
|
||||
localcx->CopyOffScreenBits(ds, wrect.x, wrect.y, wrect, NS_COPYBITS_USE_SOURCE_CLIP_REGION);
|
||||
#endif
|
||||
|
||||
if (localcx != aContext)
|
||||
NS_RELEASE(localcx);
|
||||
|
@ -429,6 +452,95 @@ void nsViewManager :: Refresh(nsIView *aView, nsIRenderingContext *aContext, con
|
|||
mPainting = PR_FALSE;
|
||||
}
|
||||
|
||||
void nsViewManager :: RenderViews(nsIView *aRootView, nsIRenderingContext& aRC, const nsRect& aRect, PRBool &aResult)
|
||||
{
|
||||
#ifdef NEW_COMPOSITOR
|
||||
|
||||
PRInt32 flatlen = 0, cnt;
|
||||
|
||||
if (nsnull != aRootView)
|
||||
FlattenViewTree(aRootView, &flatlen);
|
||||
|
||||
#if 0
|
||||
printf("flatlen %d\n", flatlen);
|
||||
|
||||
for (cnt = 0; cnt < flatlen; cnt += 2)
|
||||
{
|
||||
nsRect *rect;
|
||||
printf("view: %x\n", mFlatViews->ElementAt(cnt));
|
||||
|
||||
rect = (nsRect *)mFlatViews->ElementAt(cnt + 1);
|
||||
|
||||
if (nsnull != rect)
|
||||
printf("rect: %d, %d, %d, %d\n", rect->x, rect->y, rect->width, rect->height);
|
||||
else
|
||||
printf("rect: null\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
for (cnt = 0; cnt < flatlen; cnt += 2)
|
||||
{
|
||||
nsIView *curview = (nsIView *)mFlatViews->ElementAt(cnt);
|
||||
nsRect *currect = (nsRect *)mFlatViews->ElementAt(cnt + 1);
|
||||
|
||||
if ((nsnull != curview) && (nsnull != currect))
|
||||
{
|
||||
nsIWidget *widget;
|
||||
PRBool hasWidget = PR_FALSE;
|
||||
|
||||
curview->GetWidget(widget);
|
||||
|
||||
if (nsnull != widget)
|
||||
{
|
||||
void *nativewidget;
|
||||
|
||||
nativewidget = widget->GetNativeData(NS_NATIVE_WIDGET);
|
||||
|
||||
NS_RELEASE(widget);
|
||||
|
||||
if (nsnull != nativewidget)
|
||||
hasWidget = PR_TRUE;
|
||||
}
|
||||
|
||||
if ((PR_FALSE == hasWidget) || ((PR_TRUE == hasWidget) && (cnt == (flatlen - 2))))
|
||||
{
|
||||
nsRect lrect, drect, grect;
|
||||
|
||||
grect = *currect;
|
||||
curview->GetBounds(lrect);
|
||||
|
||||
aRC.PushState();
|
||||
|
||||
aRC.Translate(grect.x, grect.y);
|
||||
|
||||
drect.IntersectRect(aRect, grect);
|
||||
|
||||
drect.x -= grect.x;
|
||||
drect.y -= grect.y;
|
||||
|
||||
curview->Paint(aRC, drect, NS_VIEW_FLAG_JUST_PAINT, aResult);
|
||||
|
||||
aRC.PopState(aResult);
|
||||
|
||||
if (aResult == PR_FALSE)
|
||||
aRC.SetClipRect(grect, nsClipCombine_kSubtract, aResult);
|
||||
}
|
||||
else
|
||||
aRC.SetClipRect(*currect, nsClipCombine_kSubtract, aResult);
|
||||
|
||||
if (aResult == PR_TRUE)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// Paint the view. The clipping rect was set above set don't clip again.
|
||||
aRootView->Paint(aRC, aRect, NS_VIEW_FLAG_CLIP_SET, aResult);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
void nsViewManager :: UpdateDirtyViews(nsIView *aView, nsRect *aParentRect) const
|
||||
{
|
||||
nsRect pardamage;
|
||||
|
@ -990,7 +1102,9 @@ NS_IMETHODIMP nsViewManager :: InsertChild(nsIView *parent, nsIView *child, PRIn
|
|||
|
||||
//and mark this area as dirty if the view is visible...
|
||||
nsViewVisibility visibility;
|
||||
|
||||
child->GetVisibility(visibility);
|
||||
|
||||
if (nsViewVisibility_kHide != visibility)
|
||||
UpdateView(child, nsnull, NS_VMREFRESH_NO_SYNC);
|
||||
}
|
||||
|
@ -1008,6 +1122,7 @@ NS_IMETHODIMP nsViewManager :: RemoveChild(nsIView *parent, nsIView *child)
|
|||
UpdateView(child, nsnull, NS_VMREFRESH_NO_SYNC);
|
||||
parent->RemoveChild(child);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1542,3 +1657,92 @@ NS_IMETHODIMP nsViewManager :: Display(nsIView* aView)
|
|||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsViewManager :: FlattenViewTree(nsIView *aView, PRInt32 *aIndex, nsIView *aTopView, nsVoidArray *aArray, nscoord aX, nscoord aY)
|
||||
{
|
||||
PRInt32 numkids, cnt;
|
||||
|
||||
NS_ASSERTION(!(nsnull == aView), "no view");
|
||||
NS_ASSERTION(!(nsnull == aIndex), "no index");
|
||||
|
||||
if (nsnull == aArray)
|
||||
{
|
||||
if (nsnull == mFlatViews)
|
||||
mFlatViews = new nsVoidArray(8);
|
||||
|
||||
aArray = mFlatViews;
|
||||
|
||||
if (nsnull == aArray)
|
||||
return;
|
||||
}
|
||||
|
||||
if (nsnull == aTopView)
|
||||
aTopView = aView;
|
||||
|
||||
nsRect lrect;
|
||||
|
||||
aView->GetBounds(lrect);
|
||||
|
||||
if (aView == aTopView)
|
||||
{
|
||||
lrect.x = 0;
|
||||
lrect.y = 0;
|
||||
}
|
||||
|
||||
lrect.x += aX;
|
||||
lrect.y += aY;
|
||||
|
||||
aView->GetChildCount(numkids);
|
||||
|
||||
if (numkids > 0)
|
||||
{
|
||||
nsIWidget *widget;
|
||||
PRBool hasWidget = PR_FALSE;
|
||||
|
||||
aView->GetWidget(widget);
|
||||
|
||||
if (nsnull != widget)
|
||||
{
|
||||
void *nativewidget;
|
||||
|
||||
nativewidget = widget->GetNativeData(NS_NATIVE_WIDGET);
|
||||
|
||||
NS_RELEASE(widget);
|
||||
|
||||
if (nsnull != nativewidget)
|
||||
hasWidget = PR_TRUE;
|
||||
}
|
||||
|
||||
if ((PR_FALSE == hasWidget) || ((PR_TRUE == hasWidget) && (aView == aTopView)))
|
||||
{
|
||||
for (cnt = 0; cnt < numkids; cnt++)
|
||||
{
|
||||
nsIView *child;
|
||||
|
||||
aView->GetChild(cnt, child);
|
||||
FlattenViewTree(child, aIndex, aTopView, aArray, lrect.x, lrect.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
aArray->ReplaceElementAt(aView, (*aIndex)++);
|
||||
|
||||
nsRect *grect = (nsRect *)aArray->ElementAt(*aIndex);
|
||||
|
||||
if (nsnull == grect)
|
||||
{
|
||||
grect = new nsRect(lrect.x, lrect.y, lrect.width, lrect.height);
|
||||
|
||||
if (nsnull == grect)
|
||||
{
|
||||
(*aIndex)--;
|
||||
return;
|
||||
}
|
||||
|
||||
aArray->ReplaceElementAt(grect, *aIndex);
|
||||
}
|
||||
else
|
||||
*grect = lrect;
|
||||
|
||||
(*aIndex)++;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "nsIWidget.h"
|
||||
#include "nsITimer.h"
|
||||
#include "prtime.h"
|
||||
#include "nsVoidArray.h"
|
||||
|
||||
class nsViewManager : public nsIViewManager
|
||||
{
|
||||
|
@ -112,8 +113,10 @@ public:
|
|||
|
||||
NS_IMETHOD Display(nsIView *aView);
|
||||
|
||||
private:
|
||||
protected:
|
||||
virtual ~nsViewManager();
|
||||
|
||||
private:
|
||||
nsIRenderingContext *CreateRenderingContext(nsIView &aView);
|
||||
void AddRectToDirtyRegion(nsIView* aView, const nsRect &aRect) const;
|
||||
void UpdateDirtyViews(nsIView *aView, nsRect *aParentRect) const;
|
||||
|
@ -123,6 +126,12 @@ private:
|
|||
nsIRegion *region, PRUint32 aUpdateFlags);
|
||||
void Refresh(nsIView* aView, nsIRenderingContext *aContext,
|
||||
const nsRect *rect, PRUint32 aUpdateFlags);
|
||||
void FlattenViewTree(nsIView *aView, PRInt32 *aIndex,
|
||||
nsIView *aTopView = nsnull, nsVoidArray *aArray = nsnull,
|
||||
nscoord aX = 0, nscoord aY = 0);
|
||||
void RenderViews(nsIView *aRootView, nsIRenderingContext& aRC, const nsRect& aRect,
|
||||
PRBool &aResult);
|
||||
|
||||
|
||||
nsIDeviceContext *mContext;
|
||||
nsIViewObserver *mObserver;
|
||||
|
@ -134,6 +143,7 @@ private:
|
|||
nsIView *mMouseGrabber;
|
||||
nsIView *mKeyGrabber;
|
||||
PRInt32 mUpdateCnt;
|
||||
nsVoidArray *mFlatViews;
|
||||
|
||||
static PRUint32 mVMCount; //number of viewmanagers
|
||||
static nsDrawingSurface mDrawingSurface; //single drawing surface
|
||||
|
|
Загрузка…
Ссылка в новой задаче