mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Cache visual and depth information in drawing surface since it is not available
when the surface is an offscreen PixMap
This commit is contained in:
parent
3bfaaa037a
commit
ddb4ebba46
@ -33,6 +33,8 @@ typedef struct nsDrawingSurfaceUnix {
|
||||
Display *display ;
|
||||
Drawable drawable ;
|
||||
GC gc ;
|
||||
Visual * visual ;
|
||||
PRUint32 depth ;
|
||||
};
|
||||
|
||||
class nsDeviceContextUnix : public nsIDeviceContext
|
||||
|
@ -224,7 +224,6 @@ nsresult nsImageUnix::Optimize(nsDrawingSurface aDrawingSurface)
|
||||
|
||||
void nsImageUnix::CreateImage(nsDrawingSurface aSurface)
|
||||
{
|
||||
XWindowAttributes wa;
|
||||
PRUint32 wdepth;
|
||||
Visual * visual ;
|
||||
PRUint32 format ;
|
||||
@ -232,23 +231,15 @@ void nsImageUnix::CreateImage(nsDrawingSurface aSurface)
|
||||
//char * data = (char *) PR_Malloc(sizeof(char) * mWidth * mHeight * mDepth);
|
||||
|
||||
if(mImageBits) {
|
||||
::XGetWindowAttributes(unixdrawing->display,
|
||||
unixdrawing->drawable,
|
||||
&wa);
|
||||
|
||||
/* XXX What if mDepth != wDepth */
|
||||
wdepth = wa.depth;
|
||||
visual = wa.visual;
|
||||
|
||||
/* Need to support monochrome too */
|
||||
if (visual->c_class == TrueColor || visual->c_class == DirectColor)
|
||||
if (unixdrawing->visual->c_class == TrueColor || unixdrawing->visual->c_class == DirectColor)
|
||||
format = ZPixmap;
|
||||
else
|
||||
format = XYPixmap;
|
||||
|
||||
mImage = ::XCreateImage(unixdrawing->display,
|
||||
visual,
|
||||
wdepth,
|
||||
unixdrawing->visual,
|
||||
unixdrawing->depth,
|
||||
format,
|
||||
0,
|
||||
(char *)mImageBits,
|
||||
|
@ -132,6 +132,7 @@ NS_IMPL_RELEASE(nsRenderingContextUnix)
|
||||
nsresult nsRenderingContextUnix :: Init(nsIDeviceContext* aContext,
|
||||
nsIWidget *aWindow)
|
||||
{
|
||||
|
||||
if (nsnull == aWindow->GetNativeData(NS_NATIVE_WINDOW))
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
@ -144,6 +145,15 @@ nsresult nsRenderingContextUnix :: Init(nsIDeviceContext* aContext,
|
||||
mRenderingSurface->drawable = (Drawable)aWindow->GetNativeData(NS_NATIVE_WINDOW);
|
||||
mRenderingSurface->gc = (GC)aWindow->GetNativeData(NS_NATIVE_GRAPHIC);
|
||||
|
||||
XWindowAttributes wa;
|
||||
|
||||
::XGetWindowAttributes(mRenderingSurface->display,
|
||||
mRenderingSurface->drawable,
|
||||
&wa);
|
||||
|
||||
mRenderingSurface->visual = wa.visual;
|
||||
mRenderingSurface->depth = wa.depth;
|
||||
|
||||
mFrontBuffer = mRenderingSurface;
|
||||
|
||||
((nsDeviceContextUnix *)aContext)->SetDrawingSurface(mRenderingSurface);
|
||||
@ -482,6 +492,8 @@ nsDrawingSurface nsRenderingContextUnix :: CreateDrawingSurface(nsRect *aBounds)
|
||||
surface->drawable = p ;
|
||||
surface->display = mRenderingSurface->display;
|
||||
surface->gc = mRenderingSurface->gc;
|
||||
surface->visual = mRenderingSurface->visual;
|
||||
surface->depth = mRenderingSurface->depth;
|
||||
|
||||
return ((nsDrawingSurface)surface);
|
||||
}
|
||||
@ -494,8 +506,8 @@ void nsRenderingContextUnix :: DestroyDrawingSurface(nsDrawingSurface aDS)
|
||||
::XFreePixmap(surface->display, surface->drawable);
|
||||
|
||||
//XXX greg, this seems bad. MMP
|
||||
//if (mRenderingSurface == surface)
|
||||
//mRenderingSurface = nsnull;
|
||||
if (mRenderingSurface == surface)
|
||||
mRenderingSurface = nsnull;
|
||||
|
||||
delete aDS;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user