зеркало из https://github.com/mozilla/gecko-dev.git
added support for handling transparent views to viewmanager. added
transparency query to nsIFrame.
This commit is contained in:
Родитель
7dcd8c536d
Коммит
9f71c8886e
|
@ -547,6 +547,12 @@ public:
|
|||
NS_IMETHOD GetNextSibling(nsIFrame*& aNextSibling) const = 0;
|
||||
NS_IMETHOD SetNextSibling(nsIFrame* aNextSibling) = 0;
|
||||
|
||||
/**
|
||||
* Does this frame have content that is considered "transparent"?
|
||||
* This is binary transparency as opposed to translucency. MMP
|
||||
*/
|
||||
NS_IMETHOD IsTransparent(PRBool& aTransparent) const = 0;
|
||||
|
||||
// Debugging
|
||||
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const= 0;
|
||||
NS_IMETHOD ListTag(FILE* out = stdout) const = 0;
|
||||
|
|
|
@ -1329,6 +1329,14 @@ NS_METHOD nsFrame::SetNextSibling(nsIFrame* aNextSibling)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// Transparency query
|
||||
NS_METHOD nsFrame::IsTransparent(PRBool& aTransparent) const
|
||||
{
|
||||
//XXX this needs to be overridden in just about every leaf class? MMP
|
||||
aTransparent = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Debugging
|
||||
NS_METHOD nsFrame::List(FILE* out, PRInt32 aIndent) const
|
||||
{
|
||||
|
|
|
@ -210,6 +210,9 @@ public:
|
|||
NS_IMETHOD GetNextSibling(nsIFrame*& aNextSibling) const;
|
||||
NS_IMETHOD SetNextSibling(nsIFrame* aNextSibling);
|
||||
|
||||
// Transparency query
|
||||
NS_IMETHOD IsTransparent(PRBool& aTransparent) const;
|
||||
|
||||
// Invalidate part of the frame by asking the view manager to repaint.
|
||||
// aDamageRect is in the frame's local coordinate space
|
||||
void Invalidate(const nsRect& aDamageRect) const;
|
||||
|
|
|
@ -547,6 +547,12 @@ public:
|
|||
NS_IMETHOD GetNextSibling(nsIFrame*& aNextSibling) const = 0;
|
||||
NS_IMETHOD SetNextSibling(nsIFrame* aNextSibling) = 0;
|
||||
|
||||
/**
|
||||
* Does this frame have content that is considered "transparent"?
|
||||
* This is binary transparency as opposed to translucency. MMP
|
||||
*/
|
||||
NS_IMETHOD IsTransparent(PRBool& aTransparent) const = 0;
|
||||
|
||||
// Debugging
|
||||
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const= 0;
|
||||
NS_IMETHOD ListTag(FILE* out = stdout) const = 0;
|
||||
|
|
|
@ -340,6 +340,13 @@ public:
|
|||
*/
|
||||
virtual PRBool HasTransparency() = 0;
|
||||
|
||||
/**
|
||||
* Used set the transparency status of the content in a view. see
|
||||
* HasTransparency().
|
||||
* @param aTransparent PR_TRUE if there are transparent areas, PR_FALSE otherwise.
|
||||
*/
|
||||
virtual void SetContentTransparency(PRBool aTransparent) = 0;
|
||||
|
||||
/**
|
||||
* Set the view's link to the nsIFrame part of the universe.
|
||||
* @param aFrame frame to associate with view. nsnull to disassociate
|
||||
|
|
|
@ -333,6 +333,21 @@ public:
|
|||
*/
|
||||
virtual PRBool GetViewClipAbsolute(nsIView *aView, nsRect *rect) = 0;
|
||||
|
||||
/**
|
||||
* Used set the transparency status of the content in a view. see
|
||||
* nsIView.HasTransparency().
|
||||
* @param aTransparent PR_TRUE if there are transparent areas, PR_FALSE otherwise.
|
||||
*/
|
||||
virtual void SetViewContentTransparency(nsIView *aView, PRBool aTransparent) = 0;
|
||||
|
||||
/**
|
||||
* Note: This didn't exist in 4.0. Called to set the opacity of a view.
|
||||
* A value of 0.0 means completely transparent. A value of 1.0 means
|
||||
* completely opaque.
|
||||
* @param opacity new opacity value
|
||||
*/
|
||||
virtual void SetViewOpacity(nsIView *aView, float aOpacity) = 0;
|
||||
|
||||
/**
|
||||
* Get the presentation context associated with this manager
|
||||
* @result presentation context
|
||||
|
|
|
@ -146,12 +146,12 @@ nsView :: nsView()
|
|||
{
|
||||
mVis = nsViewVisibility_kShow;
|
||||
mXForm = nsnull;
|
||||
mDying = PR_FALSE;
|
||||
mVFlags = ~ALL_VIEW_FLAGS;
|
||||
}
|
||||
|
||||
nsView :: ~nsView()
|
||||
{
|
||||
mDying = PR_TRUE;
|
||||
mVFlags |= VIEW_FLAG_DYING;
|
||||
|
||||
if (GetChildCount() > 0)
|
||||
{
|
||||
|
@ -254,7 +254,7 @@ nsrefcnt nsView::Release()
|
|||
{
|
||||
mRefCnt--;
|
||||
|
||||
if (mDying == PR_FALSE)
|
||||
if (!(mVFlags & VIEW_FLAG_DYING))
|
||||
{
|
||||
if ((mRefCnt == 1) && (nsnull != mViewManager))
|
||||
{
|
||||
|
@ -853,7 +853,15 @@ float nsView :: GetOpacity()
|
|||
|
||||
PRBool nsView :: HasTransparency()
|
||||
{
|
||||
return PR_FALSE;
|
||||
return (mVFlags & VIEW_FLAG_TRANSPARENT) ? PR_TRUE : PR_FALSE;
|
||||
}
|
||||
|
||||
void nsView :: SetContentTransparency(PRBool aTransparent)
|
||||
{
|
||||
if (aTransparent == PR_TRUE)
|
||||
mVFlags |= VIEW_FLAG_TRANSPARENT;
|
||||
else
|
||||
mVFlags &= ~VIEW_FLAG_TRANSPARENT;
|
||||
}
|
||||
|
||||
// Frames have a pointer to the view, so don't AddRef the frame.
|
||||
|
|
|
@ -86,6 +86,7 @@ public:
|
|||
virtual void SetOpacity(float opacity);
|
||||
virtual float GetOpacity();
|
||||
virtual PRBool HasTransparency();
|
||||
virtual void SetContentTransparency(PRBool aTransparent);
|
||||
virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
|
||||
virtual void SetFrame(nsIFrame *aFrame);
|
||||
virtual nsIFrame * GetFrame();
|
||||
|
@ -120,7 +121,12 @@ protected:
|
|||
nsViewClip mClip;
|
||||
nsTransform2D *mXForm;
|
||||
float mOpacity;
|
||||
PRBool mDying;
|
||||
PRInt32 mVFlags;
|
||||
};
|
||||
|
||||
#define VIEW_FLAG_DYING 0x0001
|
||||
#define VIEW_FLAG_TRANSPARENT 0x0002
|
||||
|
||||
#define ALL_VIEW_FLAGS (VIEW_FLAG_DYING | VIEW_FLAG_TRANSPARENT)
|
||||
|
||||
#endif
|
||||
|
|
|
@ -132,6 +132,7 @@ nsresult nsViewManager::Init(nsIPresContext* aPresContext)
|
|||
mDrawingSurface = nsnull;
|
||||
mTimer = nsnull;
|
||||
mFrameRate = 0;
|
||||
mTransCnt = 0;
|
||||
|
||||
rv = SetFrameRate(UPDATE_QUANTUM);
|
||||
|
||||
|
@ -161,6 +162,7 @@ nsIView * nsViewManager :: GetRootView()
|
|||
|
||||
void nsViewManager :: SetRootView(nsIView *aView)
|
||||
{
|
||||
UpdateTransCnt(mRootView, aView);
|
||||
NS_IF_RELEASE(mRootView);
|
||||
mRootView = aView;
|
||||
NS_IF_ADDREF(mRootView);
|
||||
|
@ -283,6 +285,11 @@ void nsViewManager :: Refresh(nsIView *aView, nsIRenderingContext *aContext, nsI
|
|||
nscoord xoff, yoff;
|
||||
float scale;
|
||||
|
||||
//force double buffering because of non-opaque views?
|
||||
|
||||
if (mTransCnt > 0)
|
||||
aUpdateFlags |= NS_VMREFRESH_DOUBLE_BUFFER;
|
||||
|
||||
if (nsnull == aContext)
|
||||
{
|
||||
localcx = CreateRenderingContext(*aView);
|
||||
|
@ -347,6 +354,11 @@ void nsViewManager :: Refresh(nsIView *aView, nsIRenderingContext *aContext, nsR
|
|||
nsIRenderingContext *localcx = nsnull;
|
||||
nscoord xoff, yoff;
|
||||
|
||||
//force double buffering because of non-opaque views?
|
||||
|
||||
if (mTransCnt > 0)
|
||||
aUpdateFlags |= NS_VMREFRESH_DOUBLE_BUFFER;
|
||||
|
||||
if (nsnull == aContext)
|
||||
{
|
||||
localcx = CreateRenderingContext(*aView);
|
||||
|
@ -574,6 +586,8 @@ void nsViewManager :: InsertChild(nsIView *parent, nsIView *child, nsIView *sibl
|
|||
parent->InsertChild(child, sibling);
|
||||
}
|
||||
|
||||
UpdateTransCnt(nsnull, child);
|
||||
|
||||
//and mark this area as dirty if the view is visible...
|
||||
|
||||
if (child->GetVisibility() != nsViewVisibility_kHide)
|
||||
|
@ -612,6 +626,8 @@ void nsViewManager :: InsertChild(nsIView *parent, nsIView *child, PRInt32 zinde
|
|||
child->SetZIndex(zindex);
|
||||
parent->InsertChild(child, prev);
|
||||
|
||||
UpdateTransCnt(nsnull, child);
|
||||
|
||||
//and mark this area as dirty if the view is visible...
|
||||
|
||||
if (child->GetVisibility() != nsViewVisibility_kHide)
|
||||
|
@ -626,6 +642,7 @@ void nsViewManager :: RemoveChild(nsIView *parent, nsIView *child)
|
|||
|
||||
if ((nsnull != parent) && (nsnull != child))
|
||||
{
|
||||
UpdateTransCnt(child, nsnull);
|
||||
UpdateView(child, nsnull, NS_VMREFRESH_NO_SYNC);
|
||||
parent->RemoveChild(child);
|
||||
}
|
||||
|
@ -754,6 +771,59 @@ PRBool nsViewManager :: GetViewClipAbsolute(nsIView *aView, nsRect *rect)
|
|||
return PR_TRUE;
|
||||
}
|
||||
|
||||
void nsViewManager :: SetViewContentTransparency(nsIView *aView, PRBool aTransparent)
|
||||
{
|
||||
if (aTransparent != aView->HasTransparency())
|
||||
{
|
||||
if (aTransparent == PR_FALSE)
|
||||
{
|
||||
//going opaque
|
||||
mTransCnt--;
|
||||
}
|
||||
else
|
||||
{
|
||||
//going transparent
|
||||
mTransCnt++;
|
||||
}
|
||||
|
||||
aView->SetContentTransparency(aTransparent);
|
||||
}
|
||||
}
|
||||
|
||||
void nsViewManager :: SetViewOpacity(nsIView *aView, float aOpacity)
|
||||
{
|
||||
PRBool newopaque, oldopaque;
|
||||
float oldopacity;
|
||||
|
||||
if ((aOpacity == 1.0f) || (aOpacity == 0.0f))
|
||||
newopaque = PR_TRUE;
|
||||
else
|
||||
newopaque = PR_FALSE;
|
||||
|
||||
oldopacity = aView->GetOpacity();
|
||||
|
||||
if ((oldopacity == 1.0f) || (oldopacity == 0.0f))
|
||||
oldopaque = PR_TRUE;
|
||||
else
|
||||
oldopaque = PR_FALSE;
|
||||
|
||||
if (newopaque != oldopaque)
|
||||
{
|
||||
if (newopaque == PR_FALSE)
|
||||
{
|
||||
//going transparent
|
||||
mTransCnt++;
|
||||
}
|
||||
else
|
||||
{
|
||||
//going opaque
|
||||
mTransCnt--;
|
||||
}
|
||||
}
|
||||
|
||||
aView->SetOpacity(aOpacity);
|
||||
}
|
||||
|
||||
nsIPresContext * nsViewManager :: GetPresContext()
|
||||
{
|
||||
NS_IF_ADDREF(mContext);
|
||||
|
@ -862,3 +932,14 @@ void nsViewManager :: AddRectToDirtyRegion(nsRect &aRect)
|
|||
trect *= mContext->GetTwipsToPixels();
|
||||
mDirtyRegion->Union(trect.x, trect.y, trect.width, trect.height);
|
||||
}
|
||||
|
||||
void nsViewManager :: UpdateTransCnt(nsIView *oldview, nsIView *newview)
|
||||
{
|
||||
if ((nsnull != oldview) && (oldview->HasTransparency() ||
|
||||
(oldview->GetOpacity() != 1.0f)))
|
||||
mTransCnt--;
|
||||
|
||||
if ((nsnull != newview) && (newview->HasTransparency() ||
|
||||
(newview->GetOpacity() != 1.0f)))
|
||||
mTransCnt++;
|
||||
}
|
||||
|
|
|
@ -41,126 +41,72 @@ public:
|
|||
|
||||
virtual nsresult Init(nsIPresContext* aPresContext);
|
||||
|
||||
// Get the window for which the manager is responsible.
|
||||
virtual void SetRootWindow(nsIWidget *aRootWindow);
|
||||
virtual nsIWidget *GetRootWindow();
|
||||
|
||||
// Get and set the root of the layer tree.
|
||||
virtual nsIView *GetRootView();
|
||||
virtual void SetRootView(nsIView *aView);
|
||||
|
||||
// Get and set the current framerate i.e. the rate at which timed
|
||||
// refreshes occur. A framerate of 0 indicates that timed refreshes
|
||||
// should not occur.
|
||||
virtual PRUint32 GetFrameRate();
|
||||
virtual nsresult SetFrameRate(PRUint32 frameRate);
|
||||
|
||||
// Get and set the dimensions of the root window. The latter should
|
||||
// be called if the root window is resized.. The dimensions are in
|
||||
// twips
|
||||
virtual void GetWindowDimensions(nscoord *width, nscoord *height);
|
||||
virtual void SetWindowDimensions(nscoord width, nscoord height);
|
||||
|
||||
// Get and set the position of the root window relative to the
|
||||
// composited area. The latter should be called if the root window
|
||||
// is scrolled.
|
||||
virtual void GetWindowOffsets(nscoord *xoffset, nscoord *yoffset);
|
||||
virtual void SetWindowOffsets(nscoord xoffset, nscoord yoffset);
|
||||
|
||||
virtual void ResetScrolling(void);
|
||||
|
||||
// Called to refresh an area of the root window. The coordinates of
|
||||
// the region or rectangle passed in should be in the window's
|
||||
// coordinate space. Often called in response to a paint/redraw event
|
||||
// from the native windowing system.
|
||||
virtual void Refresh(nsIView *aView, nsIRenderingContext *aContext,
|
||||
nsIRegion *region, PRUint32 aUpdateFlags);
|
||||
virtual void Refresh(nsIView* aView, nsIRenderingContext *aContext,
|
||||
nsRect *rect, PRUint32 aUpdateFlags);
|
||||
|
||||
// Called to force a redrawing of any dirty areas.
|
||||
virtual void Composite();
|
||||
|
||||
// Called to inform the layer manager that some portion of a layer
|
||||
// is dirty and needs to be redrawn. The region or rect passed in
|
||||
// should be in the layer's coordinate space.
|
||||
virtual void UpdateView(nsIView *aView, nsIRegion *aRegion,
|
||||
PRUint32 aUpdateFlags);
|
||||
virtual void UpdateView(nsIView *aView, const nsRect &aRect, PRUint32 aUpdateFlags);
|
||||
|
||||
// Called to dispatch an event to the appropriate layer. Often called
|
||||
// as a result of receiving a mouse or keyboard event from the native
|
||||
// event system.
|
||||
virtual PRBool DispatchEvent(nsIEvent *event);
|
||||
|
||||
// Used to grab/capture all events of the type (mouse or keyboard) for
|
||||
// a specific layer, irrespective of the cursor position at which the
|
||||
// event occurred.
|
||||
virtual PRBool GrabMouseEvents(nsIView *aView);
|
||||
virtual PRBool GrabKeyEvents(nsIView *aView);
|
||||
|
||||
// Get the current layer, if any, that's capturing a specific type of
|
||||
// event.
|
||||
virtual nsIView* GetMouseEventGrabber();
|
||||
virtual nsIView* GetKeyEventGrabber();
|
||||
|
||||
// Given a parent layer, insert another layer as its child. If above
|
||||
// is PR_TRUE, the layer is inserted above (in z-order) the sibling. If
|
||||
// it is nsfalse, the layer is inserted below.
|
||||
// The layer manager generates the appopriate dirty regions.
|
||||
virtual void InsertChild(nsIView *parent, nsIView *child, nsIView *sibling,
|
||||
PRBool above);
|
||||
|
||||
// Given a parent layer, insert another layer as its child. The zindex
|
||||
// indicates where the child should be inserted relative to other
|
||||
// children of the parent.
|
||||
// The layer manager generates the appopriate dirty regions.
|
||||
virtual void InsertChild(nsIView *parent, nsIView *child,
|
||||
PRInt32 zindex);
|
||||
|
||||
// Remove a specific child of a layer.
|
||||
// The layer manager generates the appopriate dirty regions.
|
||||
virtual void RemoveChild(nsIView *parent, nsIView *child);
|
||||
|
||||
// Move a layer's position by the specified amount.
|
||||
// The layer manager generates the appopriate dirty regions.
|
||||
virtual void MoveViewBy(nsIView *aView, nscoord x, nscoord y);
|
||||
|
||||
// Move a layer to the specified position, provided in parent coordinates.
|
||||
// The layer manager generates the appopriate dirty regions.
|
||||
virtual void MoveViewTo(nsIView *aView, nscoord x, nscoord y);
|
||||
|
||||
// Resize a layer to the specified width and height.
|
||||
// The layer manager generates the appopriate dirty regions.
|
||||
virtual void ResizeView(nsIView *aView, nscoord width, nscoord height);
|
||||
|
||||
// Set the clip of a layer.
|
||||
// The layer manager generates the appopriate dirty regions.
|
||||
virtual void SetViewClip(nsIView *aView, nsRect *rect);
|
||||
|
||||
// Set the visibility of a layer.
|
||||
// The layer manager generates the appopriate dirty regions.
|
||||
virtual void SetViewVisibility(nsIView *aView, nsViewVisibility visible);
|
||||
|
||||
// Set the z-index of a layer. Positive z-indices mean that a layer
|
||||
// is above its parent in z-order. Negative z-indices mean that a
|
||||
// layer is below its parent.
|
||||
// The layer manager generates the appopriate dirty regions.
|
||||
virtual void SetViewZindex(nsIView *aView, PRInt32 zindex);
|
||||
|
||||
// Used to move a layer above or below another in z-order.
|
||||
// The layer manager generates the appopriate dirty regions.
|
||||
virtual void MoveViewAbove(nsIView *aView, nsIView *other);
|
||||
virtual void MoveViewBelow(nsIView *aView, nsIView *other);
|
||||
|
||||
// Returns whether a layer is actually shown (based on its visibility
|
||||
// and that of its ancestors).
|
||||
virtual PRBool IsViewShown(nsIView *aView);
|
||||
|
||||
// Returns the clipping area of layer in absolute coordinates.
|
||||
virtual PRBool GetViewClipAbsolute(nsIView *aView, nsRect *rect);
|
||||
|
||||
// Get the presentation context associated with this manager
|
||||
virtual void SetViewContentTransparency(nsIView *aView, PRBool aTransparent);
|
||||
virtual void SetViewOpacity(nsIView *aView, float aOpacity);
|
||||
|
||||
virtual nsIPresContext* GetPresContext();
|
||||
|
||||
virtual void ClearDirtyRegion();
|
||||
|
@ -171,6 +117,7 @@ private:
|
|||
~nsViewManager();
|
||||
nsIRenderingContext *CreateRenderingContext(nsIView &aView);
|
||||
void AddRectToDirtyRegion(nsRect &aRect);
|
||||
void UpdateTransCnt(nsIView *oldview, nsIView *newview);
|
||||
|
||||
nsIPresContext *mContext;
|
||||
nsIWidget *mRootWindow;
|
||||
|
@ -178,6 +125,7 @@ private:
|
|||
nsDrawingSurface mDrawingSurface;
|
||||
PRTime mLastRefresh;
|
||||
nsIRegion *mDirtyRegion;
|
||||
PRInt32 mTransCnt;
|
||||
|
||||
public:
|
||||
//these are public so that our timer callback can poke them.
|
||||
|
|
Загрузка…
Ссылка в новой задаче