use NS_TO_X to convert the pixel to gdkrgb type. this may not be what we want

to do here though.
This commit is contained in:
pavlov%pavlov.net 1998-11-14 19:39:04 +00:00
Родитель 973c0a528c
Коммит d76a646548
4 изменённых файлов: 23 добавлений и 10 удалений

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

@ -30,9 +30,6 @@
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID);
#define RESERVED_SIZE 0
#define COLOR_CUBE_SIZE 216
#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)
@ -77,6 +74,8 @@ NS_IMPL_RELEASE(nsDeviceContextGTK)
NS_IMETHODIMP nsDeviceContextGTK::Init(nsNativeWidget aNativeWidget)
{
GdkVisual *vis;
for (PRInt32 cnt = 0; cnt < 256; cnt++)
mGammaTable[cnt] = cnt;
@ -88,6 +87,19 @@ NS_IMETHODIMP nsDeviceContextGTK::Init(nsNativeWidget aNativeWidget)
(float)NSIntPointsToTwips(72));
mPixelsToTwips = 1.0f / mTwipsToPixels;
vis = gdk_rgb_get_visual();
mRedMask = vis->red_mask;
mGreenMask = vis->green_mask;
mBlueMask = vis->blue_mask;
mRedBits = vis->bits_per_rgb;
mGreenBits = vis->bits_per_rgb;
mBlueBits = vis->bits_per_rgb;
mRedOffset = vis->red_shift;
mGreenOffset = vis->green_shift;
mBlueOffset = vis->blue_shift;
mDepth = vis->depth;
return NS_OK;
}
@ -122,8 +134,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);
// ::gdk_rgb_init ();
// aPixel = ::gdk_rgb_xpixel_from_rgb ((guint32)aColor);
aPixel = ::gdk_rgb_xpixel_from_rgb ((PRUint32)NS_TO_X(aColor));
return NS_OK;
}

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

@ -47,7 +47,7 @@ public:
//already one in the device context. the drawing surface is then cached
//in the device context for re-use.
NS_IMETHOD GetDrawingSurface(nsIRenderingContext &aContext, nsDrawingSurface &aSurface);
NS_IMETHOD GetDrawingSurface(nsIRenderingContext &aContext, nsDrawingSurface &aSurface);
NS_IMETHOD ConvertPixel(nscolor aColor, PRUint32 & aPixel);
NS_IMETHOD CheckFontExistence(const nsString& aFontName);

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

@ -83,7 +83,7 @@ NS_IMETHODIMP nsFontMetricsGTK::Init(const nsFont& aFont, nsIDeviceContext* aCon
dpi = 100;
#ifdef NOISY_FONTS
fprintf(stderr, "looking for font %s (%d)", wildstring, aFont.size / 20);
g_print("looking for font %s (%d)", wildstring, aFont.size / 20);
#endif
//font properties we care about:
@ -154,7 +154,7 @@ NS_IMETHODIMP nsFontMetricsGTK::Init(const nsFont& aFont, nsIDeviceContext* aCon
mFontHandle = ::gdk_font_load(nametouse);
#ifdef NOISY_FONTS
fprintf(stderr, " is: %s\n", nametouse);
g_print(" is: %s\n", nametouse);
#endif
::XFreeFontInfo(fnames, fonts, numnames);
@ -164,7 +164,7 @@ NS_IMETHODIMP nsFontMetricsGTK::Init(const nsFont& aFont, nsIDeviceContext* aCon
//ack. we're in real trouble, go for fixed...
#ifdef NOISY_FONTS
fprintf(stderr, " is: %s\n", "fixed (final fallback)");
g_print(" is: %s\n", "fixed (final fallback)");
#endif
mFontHandle = ::gdk_font_load("fixed");

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

@ -131,7 +131,7 @@ NS_IMETHODIMP nsRenderingContextGTK::Init(nsIDeviceContext* aContext,
mContext = aContext;
NS_IF_ADDREF(mContext);
::gdk_rgb_init();
// ::gdk_rgb_init();
mRenderingSurface = new nsDrawingSurfaceGTK();