mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-01 22:55:23 +00:00
convert BGR colors to RGB for tables and such. We now draw images, text, etc
correctly, and we don't crash (at least not usually). Images are not converted from BGR to RGB yet, but they will be shortly.
This commit is contained in:
parent
aadaf47fc1
commit
551a9f0ab8
@ -30,11 +30,7 @@
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID);
|
||||
|
||||
#define NS_TO_X_RED(a) (((NS_GET_R(a) >> (8 - mRedBits)) << mRedOffset) & mRedMask)
|
||||
#define NS_TO_X_GREEN(a) (((NS_GET_G(a) >> (8 - mGreenBits)) << mGreenOffset) & mGreenMask)
|
||||
#define NS_TO_X_BLUE(a) (((NS_GET_B(a) >> (8 - mBlueBits)) << mBlueOffset) & mBlueMask)
|
||||
|
||||
#define NS_TO_X(a) (NS_TO_X_RED(a) | NS_TO_X_GREEN(a) | NS_TO_X_BLUE(a))
|
||||
typedef unsigned char BYTE;
|
||||
|
||||
nsDeviceContextGTK :: nsDeviceContextGTK()
|
||||
{
|
||||
@ -134,9 +130,9 @@ NS_IMETHODIMP nsDeviceContextGTK::GetDrawingSurface(nsIRenderingContext &aContex
|
||||
NS_IMETHODIMP nsDeviceContextGTK::ConvertPixel(nscolor aColor,
|
||||
PRUint32 & aPixel)
|
||||
{
|
||||
// ::gdk_rgb_init ();
|
||||
// aPixel = ::gdk_rgb_xpixel_from_rgb ((guint32)aColor);
|
||||
aPixel = ::gdk_rgb_xpixel_from_rgb ((PRUint32)NS_TO_X(aColor));
|
||||
aPixel = ::gdk_rgb_xpixel_from_rgb ((aColor & 0xff) << 16 |
|
||||
(aColor & 0xff00) |
|
||||
((aColor >> 16) & 0xff));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -120,7 +120,6 @@ void nsImageGTK :: ImageUpdated(nsIDeviceContext *aContext, PRUint8 aFlags, nsRe
|
||||
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
// Draw the bitmap, this method has a source and destination coordinates
|
||||
|
@ -26,6 +26,8 @@ typedef unsigned char BYTE;
|
||||
|
||||
#define RGB(r,g,b) ((unsigned long) (((BYTE) (r) | ((unsigned long) ((BYTE) (g)) <<8)) | (((unsigned long)(BYTE)(b)) << 16)))
|
||||
|
||||
#define NS_TO_GDK_RGB(ns) (ns & 0xff) << 16 | (ns & 0xff00) | ((ns >> 16) & 0xff)
|
||||
|
||||
#define NSRECT_TO_GDKRECT(ns,gdk) \
|
||||
PR_BEGIN_MACRO \
|
||||
gdk.x = ns.x; \
|
||||
@ -385,9 +387,10 @@ NS_IMETHODIMP nsRenderingContextGTK::GetClipRegion(nsIRegion **aRegion)
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextGTK::SetColor(nscolor aColor)
|
||||
{
|
||||
::gdk_rgb_gc_set_foreground(mRenderingSurface->gc, (guint32)aColor);
|
||||
mCurrentColor = aColor;
|
||||
|
||||
::gdk_rgb_gc_set_foreground(mRenderingSurface->gc, NS_TO_GDK_RGB(aColor));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -462,14 +465,20 @@ NS_IMETHODIMP nsRenderingContextGTK::CreateDrawingSurface(nsRect *aBounds,
|
||||
PRUint32 aSurfFlags,
|
||||
nsDrawingSurface &aSurface)
|
||||
{
|
||||
GdkPixmap *pixmap;
|
||||
|
||||
gint attributes_mask;
|
||||
|
||||
if (nsnull == mRenderingSurface) {
|
||||
aSurface = nsnull;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
pixmap = ::gdk_pixmap_new(mRenderingSurface->drawable, aBounds->width, aBounds->height, -1);
|
||||
nsDrawingSurfaceGTK * surface = new nsDrawingSurfaceGTK();
|
||||
|
||||
nsDrawingSurfaceGTK * surface = new nsDrawingSurfaceGTK();
|
||||
|
||||
surface->drawable = mRenderingSurface->drawable;
|
||||
// surface->drawable = mRenderingSurface->drawable;
|
||||
surface->drawable = pixmap;
|
||||
surface->gc = mRenderingSurface->gc;
|
||||
|
||||
aSurface = (nsDrawingSurface)surface;
|
||||
@ -916,9 +925,9 @@ nsRenderingContextGTK::CopyOffScreenBits(nsDrawingSurface aSrcSurf,
|
||||
//XXX flags are unused. that would seem to mean that there is
|
||||
//inefficiency somewhere... MMP
|
||||
|
||||
::gdk_draw_pixmap(((nsDrawingSurfaceGTK *)aSrcSurf)->drawable,
|
||||
::gdk_draw_pixmap(destsurf->drawable,
|
||||
((nsDrawingSurfaceGTK *)aSrcSurf)->gc,
|
||||
destsurf->drawable,
|
||||
((nsDrawingSurfaceGTK *)aSrcSurf)->drawable,
|
||||
x, y,
|
||||
drect.x, drect.y,
|
||||
drect.width, drect.height);
|
||||
|
Loading…
Reference in New Issue
Block a user