This commit is contained in:
spider 1998-05-20 23:17:49 +00:00
Родитель 171ccffcab
Коммит 39cfef3a83
6 изменённых файлов: 118 добавлений и 32 удалений

Просмотреть файл

@ -28,11 +28,14 @@ nsDeviceContextUnix :: nsDeviceContextUnix()
NS_INIT_REFCNT();
mFontCache = nsnull;
mSurface = nsnull;
}
nsDeviceContextUnix :: ~nsDeviceContextUnix()
{
NS_IF_RELEASE(mFontCache);
if (mSurface) delete mSurface;
}
NS_IMPL_QUERY_INTERFACE(nsDeviceContextUnix, kDeviceContextIID)
@ -85,15 +88,22 @@ float nsDeviceContextUnix :: GetScrollBarHeight() const
nsIRenderingContext * nsDeviceContextUnix :: CreateRenderingContext(nsIView *aView)
{
nsIRenderingContext *pContext = nsnull;
nsIWidget *win = aView->GetWidget();
nsresult rv;
mSurface = new nsDrawingSurfaceUnix();
mSurface->display = XtDisplay((Widget)win->GetNativeData(NS_NATIVE_WIDGET));
mSurface->drawable = (Drawable)win->GetNativeData(NS_NATIVE_WINDOW);
mSurface->gc = (GC)win->GetNativeData(NS_NATIVE_GRAPHIC);
static NS_DEFINE_IID(kRCCID, NS_RENDERING_CONTEXT_CID);
static NS_DEFINE_IID(kRCIID, NS_IRENDERING_CONTEXT_IID);
rv = NSRepository::CreateInstance(kRCCID, nsnull, kRCIID, (void **)&pContext);
if (NS_OK == rv)
InitRenderingContext(pContext, mWidget);
InitRenderingContext(pContext, win);
return pContext;
}
@ -101,7 +111,6 @@ nsIRenderingContext * nsDeviceContextUnix :: CreateRenderingContext(nsIView *aVi
void nsDeviceContextUnix :: InitRenderingContext(nsIRenderingContext *aContext, nsIWidget *aWin)
{
aContext->Init(this, aWin);
mWidget = aWin;
}
nsIFontCache* nsDeviceContextUnix::GetFontCache()
@ -150,3 +159,32 @@ nsDrawingSurface nsDeviceContextUnix :: GetDrawingSurface(nsIRenderingContext &a
{
return ( aContext.CreateDrawingSurface(nsnull));
}
float nsDeviceContextUnix :: GetGamma(void)
{
return mGammaValue;
}
void nsDeviceContextUnix :: SetGamma(float aGamma)
{
if (aGamma != mGammaValue)
{
//we don't need to-recorrect existing images for this case
//so pass in 1.0 for the current gamma regardless of what it
//really happens to be. existing images will get a one time
//re-correction when they're rendered the next time. MMP
mGammaValue = aGamma;
}
}
PRUint8 * nsDeviceContextUnix :: GetGammaTable(void)
{
//XXX we really need to ref count this somehow. MMP
return nsnull;
}

Просмотреть файл

@ -26,6 +26,15 @@
#include "nsIView.h"
#include "nsIRenderingContext.h"
#include "Xm/Xm.h"
/* nsDrawingSurface is actually the following struct */
typedef struct nsDrawingSurfaceUnix {
Display *display ;
Drawable drawable ;
GC gc ;
};
class nsDeviceContextUnix : public nsIDeviceContext
{
public:
@ -60,12 +69,20 @@ public:
virtual nsDrawingSurface GetDrawingSurface(nsIRenderingContext &aContext);
//functions for handling gamma correction of output device
virtual float GetGamma(void);
virtual void SetGamma(float aGamma);
//XXX the return from this really needs to be ref counted somehow. MMP
virtual PRUint8 * GetGammaTable(void);
protected:
~nsDeviceContextUnix();
nsresult CreateFontCache();
nsIFontCache *mFontCache;
nsIWidget *mWidget;
float mGammaValue;
nsDrawingSurfaceUnix * mSurface ;
};

Просмотреть файл

@ -46,10 +46,11 @@ nsresult nsImageUnix :: Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth,nsM
//------------------------------------------------------------
// set up the pallete to the passed in color array, RGB only in this array
void nsImageUnix :: ImageUpdated(PRUint8 aFlags, nsRect *aUpdateRect)
void nsImageUnix :: ImageUpdated(nsIDeviceContext *aContext, PRUint8 aFlags, nsRect *aUpdateRect)
{
}
//------------------------------------------------------------
// Draw the bitmap, this method has a source and destination coordinates
@ -70,7 +71,7 @@ PRBool nsImageUnix :: Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurf
//------------------------------------------------------------
void nsImageUnix::CompositeImage(nsIImage *aTheImage, nsPoint *aULLocation)
void nsImageUnix::CompositeImage(nsIImage *aTheImage, nsPoint *aULLocation,nsBlendQuality aBlendQuality)
{
}

Просмотреть файл

@ -40,7 +40,7 @@ public:
virtual PRBool Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight);
virtual nsColorMap* GetColorMap() {return nsnull;}
virtual void ImageUpdated(PRUint8 aFlags, nsRect *aUpdateRect);
virtual void ImageUpdated(nsIDeviceContext *aContext, PRUint8 aFlags, nsRect *aUpdateRect);
virtual nsresult Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth, nsMaskRequirements aMaskRequirements);
virtual PRBool IsOptimized() { return PR_FALSE; }
virtual nsresult Optimize(nsDrawingSurface aSurface);
@ -50,7 +50,7 @@ public:
virtual PRInt32 GetAlphaXLoc() {return 0;}
virtual PRInt32 GetAlphaYLoc() {return 0;}
virtual PRInt32 GetAlphaLineStride(){ return 0; }
virtual void CompositeImage(nsIImage *aTheImage,nsPoint *aULLocation);
virtual void CompositeImage(nsIImage *aTheImage,nsPoint *aULLocation,nsBlendQuality aQuality);
virtual nsIImage* DuplicateImage();
@ -75,8 +75,16 @@ public:
PRBool SetAlphaMask(nsIImage *aTheMask);
virtual void SetAlphaLevel(PRInt32 aAlphaLevel) {mAlphaLevel=aAlphaLevel;}
virtual PRInt32 GetAlphaLevel() {return(mAlphaLevel);}
void MoveAlphaMask(PRInt32 aX, PRInt32 aY){}
private:
PRInt16 mAlphaLevel; // an alpha level every pixel uses
};
#endif

Просмотреть файл

@ -52,9 +52,12 @@ nsresult nsRenderingContextUnix :: Init(nsIDeviceContext* aContext,
mContext = aContext;
NS_IF_ADDREF(mContext);
mGC = (GC)aWindow->GetNativeData(NS_NATIVE_GRAPHIC);
mDrawable = (Drawable) aWindow->GetNativeData(NS_NATIVE_WIDGET);
mSurface = new nsDrawingSurfaceUnix();
mSurface->display = XtDisplay((Widget)aWindow->GetNativeData(NS_NATIVE_WIDGET));
mSurface->drawable = (Drawable)aWindow->GetNativeData(NS_NATIVE_WINDOW);
mSurface->gc = (GC)aWindow->GetNativeData(NS_NATIVE_GRAPHIC);
#if 0
mFontCache = mContext->GetFontCache();
#endif
@ -68,7 +71,8 @@ nsresult nsRenderingContextUnix :: Init(nsIDeviceContext* aContext,
mContext = aContext;
NS_IF_ADDREF(mContext);
mGC = (GC)aSurface;
mSurface = (nsDrawingSurfaceUnix *) aSurface;
}
nsresult nsRenderingContextUnix :: SelectOffScreenDrawingSurface(nsDrawingSurface aSurface)
@ -102,10 +106,14 @@ void nsRenderingContextUnix :: SetClipRect(const nsRect& aRect, PRBool aIntersec
{
}
const nsRect& nsRenderingContextUnix :: GetClipRect()
PRBool nsRenderingContextUnix :: GetClipRect(nsRect &aRect)
{
nsRect r(0,0,0,0);
return r;
return PR_TRUE;
}
void nsRenderingContextUnix :: SetClipRegion(const nsIRegion& aRegion, PRBool aIntersect)
{
//XXX wow, needs to do something.
}
void nsRenderingContextUnix :: SetColor(nscolor aColor)
@ -117,8 +125,8 @@ void nsRenderingContextUnix :: SetColor(nscolor aColor)
values.foreground = mCurrentColor;
values.background = mCurrentColor;
XChangeGC(XtDisplay((Widget)mDrawable),
mGC,
XChangeGC(mSurface->display,
mSurface->gc,
GCForeground | GCBackground,
&values);
}
@ -130,11 +138,11 @@ nscolor nsRenderingContextUnix :: GetColor() const
void nsRenderingContextUnix :: SetFont(const nsFont& aFont)
{
Font id = ::XLoadFont(XtDisplay((Widget)mDrawable), "fixed");
Font id = ::XLoadFont(mSurface->display, "fixed");
XFontStruct * fs = ::XQueryFont(XtDisplay((Widget)mDrawable), id);
XFontStruct * fs = ::XQueryFont(mSurface->display, id);
::XSetFont(XtDisplay((Widget)mDrawable), mGC, id);
::XSetFont(mSurface->display, mSurface->gc, id);
#if 0
@ -197,9 +205,9 @@ void nsRenderingContextUnix :: FillRect(const nsRect& aRect)
void nsRenderingContextUnix :: FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
{
::XFillRectangle(XtDisplay((Widget)mDrawable),
XtWindow((Widget)mDrawable),
mGC,
::XFillRectangle(mSurface->display,
mSurface->drawable,
mSurface->gc,
aX, aY,
aWidth, aHeight);
}
@ -258,11 +266,11 @@ void nsRenderingContextUnix :: DrawString(const char *aString, PRUint32 aLength,
nscoord aWidth)
{
// XXX Hack
::XLoadFont(XtDisplay((Widget)mDrawable), "fixed");
::XLoadFont(mSurface->display, "fixed");
::XDrawString(XtDisplay((Widget)mDrawable),
XtWindow((Widget)mDrawable),
mGC,
::XDrawString(mSurface->display,
mSurface->drawable,
mSurface->gc,
aX, aY, aString, aWidth);
}
@ -274,8 +282,20 @@ void nsRenderingContextUnix :: DrawString(const PRUnichar *aString, PRUint32 aLe
void nsRenderingContextUnix :: DrawString(const nsString& aString,
nscoord aX, nscoord aY, nscoord aWidth)
{
// XXX Leak - How to Print UniChar
DrawString(aString.ToNewCString(), aString.Length(), aX, aY, aWidth);
// XXX Leak - How to Print UniChar
if (aString.Length() > 0) {
char * buf ;
buf = (char *) malloc(sizeof(char) * (aString.Length()+1));
buf[aString.Length()] = '\0';
aString.ToCString(buf, aString.Length());
DrawString(buf, aString.Length(), aX, aY, aWidth);
free(buf);
}
}
void nsRenderingContextUnix :: DrawImage(nsIImage *aImage, nscoord aX, nscoord aY)

Просмотреть файл

@ -37,6 +37,8 @@
#include "Xm/Xm.h"
#include "nsDeviceContextUnix.h"
class nsRenderingContextUnix : public nsIRenderingContext
{
public:
@ -66,7 +68,9 @@ public:
virtual PRBool IsVisibleRect(const nsRect& aRect);
virtual void SetClipRect(const nsRect& aRect, PRBool aIntersect);
virtual const nsRect& GetClipRect();
virtual PRBool GetClipRect(nsRect &aRect);
virtual void SetClipRegion(const nsIRegion& aRegion, PRBool aIntersect);
virtual void SetColor(nscolor aColor);
virtual nscolor GetColor() const;
@ -125,13 +129,11 @@ public:
protected:
nscolor mCurrentColor ;
GC mGC;
Drawable mDrawable;
nsDrawingSurfaceUnix * mSurface;
nsIDeviceContext *mContext;
nsIFontMetrics *mFontMetrics;
nsIFontMetrics *mFontMetrics;
nsIFontCache *mFontCache;
};
#endif /* nsRenderingContextUnix_h___ */