зеркало из https://github.com/mozilla/gecko-dev.git
Implimented nsImageGTK. Fixed some compling problems in the other files due
to headers needed in nsImageGTK
This commit is contained in:
Родитель
9ef6528746
Коммит
733e8c1795
|
@ -16,10 +16,11 @@
|
|||
* Reserved.
|
||||
*/
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
|
||||
#include "xp_core.h"
|
||||
#include "nsFontMetricsGTK.h"
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
|
||||
static NS_DEFINE_IID(kIFontMetricsIID, NS_IFONT_METRICS_IID);
|
||||
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
* Reserved.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsISupports.h"
|
||||
|
@ -24,7 +26,7 @@
|
|||
#include "nsRenderingContextGTK.h"
|
||||
#include "nsImageGTK.h"
|
||||
#include "nsDeviceContextGTK.h"
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kCFontMetrics, NS_FONT_METRICS_CID);
|
||||
static NS_DEFINE_IID(kCRenderingContext, NS_RENDERING_CONTEXT_CID);
|
||||
|
|
|
@ -16,9 +16,14 @@
|
|||
* Reserved.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "nsImageGTK.h"
|
||||
#include "nsRenderingContextGTK.h"
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "nspr.h"
|
||||
|
||||
#define IsFlagSet(a,b) (a & b)
|
||||
|
||||
static NS_DEFINE_IID(kIImageIID, NS_IIMAGE_IID);
|
||||
|
||||
|
@ -27,12 +32,45 @@ static NS_DEFINE_IID(kIImageIID, NS_IIMAGE_IID);
|
|||
nsImageGTK :: nsImageGTK()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mImage = nsnull ;
|
||||
mImageBits = nsnull;
|
||||
mConvertedBits = nsnull;
|
||||
mBitsForCreate = nsnull;
|
||||
mWidth = 0;
|
||||
mHeight = 0;
|
||||
mDepth = 0;
|
||||
mOriginalDepth = 0;
|
||||
mColorMap = nsnull;
|
||||
mAlphaBits = nsnull;
|
||||
mStaticImage = PR_FALSE;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
nsImageGTK :: ~nsImageGTK()
|
||||
{
|
||||
if (nsnull != mImage) {
|
||||
gdk_image_destroy(mImage);
|
||||
mImage = nsnull;
|
||||
}
|
||||
|
||||
if(nsnull != mConvertedBits) {
|
||||
delete[] (PRUint8*)mConvertedBits;
|
||||
mConvertedBits = nsnull;
|
||||
}
|
||||
|
||||
if(nsnull != mImageBits) {
|
||||
delete[] (PRUint8*)mImageBits;
|
||||
mImageBits = nsnull;
|
||||
}
|
||||
|
||||
if(nsnull!= mColorMap)
|
||||
delete mColorMap;
|
||||
|
||||
if (nsnull != mAlphaBits) {
|
||||
delete mAlphaBits;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsImageGTK, kIImageIID);
|
||||
|
@ -41,36 +79,163 @@ NS_IMPL_ISUPPORTS(nsImageGTK, kIImageIID);
|
|||
|
||||
nsresult nsImageGTK :: Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth,nsMaskRequirements aMaskRequirements)
|
||||
{
|
||||
if(nsnull != mImageBits)
|
||||
delete[] (PRUint8*)mImageBits;
|
||||
|
||||
if(nsnull != mColorMap)
|
||||
delete[] mColorMap;
|
||||
|
||||
if (nsnull != mImage) {
|
||||
gdk_image_destroy(mImage);
|
||||
mImage = nsnull;
|
||||
}
|
||||
mWidth = aWidth;
|
||||
mHeight = aHeight;
|
||||
mDepth = aDepth;
|
||||
mOriginalDepth = aDepth;
|
||||
mOriginalRowBytes = CalcBytesSpan(aWidth);
|
||||
mConverted = PR_FALSE;
|
||||
|
||||
ComputePaletteSize(aDepth);
|
||||
|
||||
// create the memory for the image
|
||||
ComputMetrics();
|
||||
|
||||
mImageBits = (PRUint8*) new PRUint8[mSizeImage];
|
||||
mAlphaBits = (PRUint8*) new PRUint8[mSizeImage];
|
||||
|
||||
mColorMap = new nsColorMap;
|
||||
|
||||
if (mColorMap != nsnull) {
|
||||
mColorMap->NumColors = mNumPalleteColors;
|
||||
mColorMap->Index = new PRUint8[3 * mNumPalleteColors];
|
||||
memset(mColorMap->Index, 0, sizeof(PRUint8) * (3 * mNumPalleteColors));
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
void nsImageGTK::ComputMetrics()
|
||||
{
|
||||
|
||||
mRowBytes = CalcBytesSpan(mWidth);
|
||||
mSizeImage = mRowBytes * mHeight;
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
// figure out how big our palette needs to be
|
||||
void nsImageGTK :: ComputePaletteSize(PRIntn nBitCount)
|
||||
{
|
||||
switch (nBitCount)
|
||||
{
|
||||
case 8:
|
||||
mNumPalleteColors = 256;
|
||||
mNumBytesPixel = 1;
|
||||
break;
|
||||
case 16:
|
||||
mNumPalleteColors = 0;
|
||||
mNumBytesPixel = 2;
|
||||
break;
|
||||
case 24:
|
||||
mNumPalleteColors = 0;
|
||||
mNumBytesPixel = 3;
|
||||
break;
|
||||
default:
|
||||
mNumPalleteColors = -1;
|
||||
mNumBytesPixel = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
PRInt32 nsImageGTK :: CalcBytesSpan(PRUint32 aWidth)
|
||||
{
|
||||
PRInt32 spanbytes;
|
||||
|
||||
spanbytes = (aWidth * mDepth) >> 5;
|
||||
|
||||
if (((PRUint32)aWidth * mDepth) & 0x1F)
|
||||
spanbytes++;
|
||||
spanbytes <<= 2;
|
||||
return(spanbytes);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
// set up the pallete to the passed in color array, RGB only in this array
|
||||
void nsImageGTK :: ImageUpdated(nsIDeviceContext *aContext, PRUint8 aFlags, nsRect *aUpdateRect)
|
||||
{
|
||||
|
||||
if (nsnull == mImage)
|
||||
return;
|
||||
|
||||
if (IsFlagSet(nsImageUpdateFlags_kBitsChanged, aFlags)){
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
// Draw the bitmap, this method has a source and destination coordinates
|
||||
NS_IMETHODIMP nsImageGTK :: Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface,
|
||||
PRInt32 aSX, PRInt32 aSY,
|
||||
PRInt32 aSWidth, PRInt32 aSHeight,
|
||||
PRInt32 aDX, PRInt32 aDY,
|
||||
PRInt32 aDWidth, PRInt32 aDHeight)
|
||||
NS_IMETHODIMP nsImageGTK :: Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface,
|
||||
PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
|
||||
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight)
|
||||
{
|
||||
nsDrawingSurfaceGTK *drawing = (nsDrawingSurfaceGTK*)aSurface;
|
||||
|
||||
if ((PR_FALSE==mStaticImage) || (nsnull == mImage)) {
|
||||
BuildImage(aSurface);
|
||||
}
|
||||
|
||||
if (nsnull == mImage)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
||||
gdk_draw_image(drawing->drawable, drawing->gc, mImage,
|
||||
aSX, aSY,
|
||||
aDX, aDY,
|
||||
aDWidth, aDHeight);
|
||||
/*
|
||||
XPutImage(drawing->display,drawing->drawable,drawing->gc,mImage,
|
||||
aSX,aSY,aDX,aDY,aDWidth,aDHeight);
|
||||
*/
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
// Draw the bitmap, this draw just has destination coordinates
|
||||
NS_IMETHODIMP nsImageGTK :: Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface,
|
||||
PRInt32 aX, PRInt32 aY,
|
||||
PRInt32 aWidth, PRInt32 aHeight)
|
||||
NS_IMETHODIMP nsImageGTK :: Draw(nsIRenderingContext &aContext,
|
||||
nsDrawingSurface aSurface,
|
||||
PRInt32 aX, PRInt32 aY,
|
||||
PRInt32 aWidth, PRInt32 aHeight)
|
||||
{
|
||||
nsDrawingSurfaceGTK *drawing = (nsDrawingSurfaceGTK*) aSurface;
|
||||
|
||||
BuildImage(aSurface);
|
||||
|
||||
// Build Image each time if it's not static.
|
||||
if ((PR_FALSE==mStaticImage) || (nsnull == mImage)) {
|
||||
BuildImage(aSurface);
|
||||
}
|
||||
|
||||
if (nsnull == mImage)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
gdk_draw_image(drawing->drawable, drawing->gc, mImage,
|
||||
0, 0,
|
||||
aX, aY,
|
||||
aWidth, aHeight);
|
||||
/*
|
||||
XPutImage(drawing->display,drawing->drawable,drawing->gc,mImage,
|
||||
0,0,aX,aY,aWidth,aHeight);
|
||||
*/
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -78,7 +243,6 @@ NS_IMETHODIMP nsImageGTK :: Draw(nsIRenderingContext &aContext, nsDrawingSurface
|
|||
|
||||
void nsImageGTK::CompositeImage(nsIImage *aTheImage, nsPoint *aULLocation,nsBlendQuality aBlendQuality)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
@ -86,15 +250,201 @@ void nsImageGTK::CompositeImage(nsIImage *aTheImage, nsPoint *aULLocation,nsBlen
|
|||
// lets build an alpha mask from this image
|
||||
PRBool nsImageGTK::SetAlphaMask(nsIImage *aTheMask)
|
||||
{
|
||||
PRInt32 num;
|
||||
PRUint8 *srcbits;
|
||||
|
||||
if (aTheMask &&
|
||||
(((nsImageGTK*)aTheMask)->mNumBytesPixel == 1)) {
|
||||
mLocation.x = 0;
|
||||
mLocation.y = 0;
|
||||
mAlphaDepth = 8;
|
||||
mAlphaWidth = aTheMask->GetWidth();
|
||||
mAlphaHeight = aTheMask->GetWidth();
|
||||
num = mAlphaWidth*mAlphaHeight;
|
||||
mARowBytes = aTheMask->GetLineStride();
|
||||
mAlphaBits = new unsigned char[mARowBytes * mAlphaHeight];
|
||||
|
||||
srcbits = aTheMask->GetBits();
|
||||
memcpy(mAlphaBits,srcbits,num);
|
||||
|
||||
return(PR_TRUE);
|
||||
}
|
||||
|
||||
return(PR_FALSE);
|
||||
}
|
||||
|
||||
nsresult nsImageGTK::Optimize(nsIDeviceContext* aContext)
|
||||
|
||||
void nsImageGTK::AllocConvertedBits(PRUint32 aSize)
|
||||
{
|
||||
if (nsnull == mConvertedBits)
|
||||
mConvertedBits = (PRUint8*) new PRUint8[aSize];
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
void nsImageGTK::ConvertImage(nsDrawingSurface aDrawingSurface)
|
||||
{
|
||||
nsDrawingSurfaceGTK *drawing =(nsDrawingSurfaceGTK*) aDrawingSurface;
|
||||
PRUint8 *tempbuffer,*cursrc,*curdest;
|
||||
PRInt32 x,y;
|
||||
PRUint16 red,green,blue,*cur16;
|
||||
|
||||
mBitsForCreate = mImageBits;
|
||||
|
||||
#if 0
|
||||
if((drawing->depth==24) && (mOriginalDepth==8))
|
||||
{
|
||||
// convert this nsImage to a 24 bit image
|
||||
mDepth = 24;
|
||||
ComputePaletteSize(mDepth);
|
||||
ComputMetrics();
|
||||
AllocConvertedBits(mSizeImage);
|
||||
tempbuffer = mConvertedBits;
|
||||
mBitsForCreate = mConvertedBits;
|
||||
|
||||
for(y=0;y<mHeight;y++)
|
||||
{
|
||||
cursrc = mImageBits+(y*mOriginalRowBytes);
|
||||
curdest =tempbuffer+(y*mRowBytes);
|
||||
for(x=0;x<mOriginalRowBytes;x++)
|
||||
{
|
||||
*curdest = mColorMap->Index[(3*(*cursrc))+2]; // red
|
||||
curdest++;
|
||||
*curdest = mColorMap->Index[(3*(*cursrc))+1]; // green
|
||||
curdest++;
|
||||
*curdest = mColorMap->Index[(3*(*cursrc))]; // blue
|
||||
curdest++;
|
||||
cursrc++;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
if(mColorMap)
|
||||
delete mColorMap;
|
||||
|
||||
// after we are finished converting the image, build a new color map
|
||||
mColorMap = new nsColorMap;
|
||||
|
||||
if (mColorMap != nsnull)
|
||||
{
|
||||
mColorMap->NumColors = mNumPalleteColors;
|
||||
mColorMap->Index = new PRUint8[3 * mNumPalleteColors];
|
||||
memset(mColorMap->Index, 0, sizeof(PRUint8) * (3 * mNumPalleteColors));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// convert the 8 bit image to 16 bit
|
||||
if((drawing->depth==16) && (mOriginalDepth==8))
|
||||
{
|
||||
mDepth = 16;
|
||||
ComputePaletteSize(mDepth);
|
||||
ComputMetrics();
|
||||
AllocConvertedBits(mSizeImage);
|
||||
tempbuffer = mConvertedBits;
|
||||
mBitsForCreate = mConvertedBits;
|
||||
|
||||
for(y=0;y<mHeight;y++)
|
||||
{
|
||||
cursrc = mImageBits+(y*mOriginalRowBytes);
|
||||
cur16 = (PRUint16*) (tempbuffer+(y*mRowBytes));
|
||||
|
||||
for(x=0;x<mOriginalRowBytes;x++)
|
||||
{
|
||||
blue = mColorMap->Index[(3*(*cursrc))+2]; // red
|
||||
green = mColorMap->Index[(3*(*cursrc))+1]; // green
|
||||
red = mColorMap->Index[(3*(*cursrc))]; // blue
|
||||
cursrc++;
|
||||
*cur16 = ((red&0xf8)<<8)|((green&0xfc)<<3)| ((blue&0xf8)>>3);
|
||||
cur16++;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (mColorMap != nsnull)
|
||||
{
|
||||
mColorMap->NumColors = mNumPalleteColors;
|
||||
mColorMap->Index = new PRUint8[3 * mNumPalleteColors];
|
||||
memset(mColorMap->Index, 0, sizeof(PRUint8) * (3 * mNumPalleteColors));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
nsresult nsImageGTK::BuildImage(nsDrawingSurface aDrawingSurface)
|
||||
{
|
||||
if (nsnull != mImage) {
|
||||
// XDestroyImage(mImage);
|
||||
gdk_image_destroy(mImage);
|
||||
mImage = nsnull;
|
||||
}
|
||||
|
||||
ConvertImage(aDrawingSurface);
|
||||
CreateImage(aDrawingSurface);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIImage* nsImageGTK::DuplicateImage()
|
||||
//------------------------------------------------------------
|
||||
|
||||
nsresult nsImageGTK::Optimize(nsIDeviceContext* aContext)
|
||||
{
|
||||
return NULL;
|
||||
mStaticImage = PR_TRUE;
|
||||
#if 0
|
||||
BuildImage(aDrawingSurface);
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
void nsImageGTK::CreateImage(nsDrawingSurface aSurface)
|
||||
{
|
||||
PRUint32 wdepth;
|
||||
GdkVisual * visual ;
|
||||
PRUint32 format ;
|
||||
nsDrawingSurfaceGTK *drawing =(nsDrawingSurfaceGTK*) aSurface;
|
||||
|
||||
if(mImageBits) {
|
||||
format = ZPixmap;
|
||||
|
||||
#if 0
|
||||
/* Need to support monochrome too */
|
||||
if (drawing->visual->c_class == TrueColor ||
|
||||
drawing->visual->c_class == DirectColor) {
|
||||
format = ZPixmap;
|
||||
}
|
||||
else {
|
||||
printf("Format XYPixmap\n");
|
||||
format = XYPixmap;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* printf("Width %d Height %d Visual Depth %d Image Depth %d\n",
|
||||
mWidth, mHeight,
|
||||
drawing->depth, mDepth); */
|
||||
|
||||
// FIXME we should be storing the visual somewhere
|
||||
mImage = gdk_image_new(GDK_IMAGE_NORMAL,
|
||||
gdk_visual_get_best(),
|
||||
mWidth,
|
||||
mHeight);
|
||||
/*
|
||||
mImage = ::XCreateImage(drawing->display,
|
||||
drawing->visual,
|
||||
drawing->depth,
|
||||
format,
|
||||
0,
|
||||
(char *)mBitsForCreate,
|
||||
(unsigned int)mWidth,
|
||||
(unsigned int)mHeight,
|
||||
32,mRowBytes);
|
||||
mImage->byte_order = ImageByteOrder(drawing->display);
|
||||
mImage->bits_per_pixel = drawing->depth;
|
||||
mImage->bitmap_bit_order = BitmapBitOrder(drawing->display);
|
||||
mImage->bitmap_unit = 32;
|
||||
*/
|
||||
}
|
||||
return ;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,11 @@
|
|||
|
||||
#include "nsIImage.h"
|
||||
|
||||
#include "X11/Xlib.h"
|
||||
#include "X11/Xutil.h"
|
||||
|
||||
#undef Bool
|
||||
|
||||
class nsImageGTK : public nsIImage
|
||||
{
|
||||
public:
|
||||
|
@ -32,35 +37,31 @@ public:
|
|||
/**
|
||||
@see nsIImage.h
|
||||
*/
|
||||
virtual PRInt32 GetHeight() { return 0; }
|
||||
virtual PRInt32 GetWidth() { return 0; }
|
||||
virtual PRUint8* GetBits() { return nsnull; }
|
||||
virtual void* GetBitInfo() { return nsnull; }
|
||||
virtual PRInt32 GetLineStride() {return 0; }
|
||||
NS_IMETHOD Draw(nsIRenderingContext &aContext,
|
||||
nsDrawingSurface aSurface,
|
||||
PRInt32 aX, PRInt32 aY,
|
||||
PRInt32 aWidth, PRInt32 aHeight);
|
||||
NS_IMETHOD 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 PRInt32 GetHeight() { return mHeight; }
|
||||
virtual PRInt32 GetWidth() { return mWidth; }
|
||||
virtual PRUint8* GetBits() { return mImageBits; }
|
||||
virtual void* GetBitInfo() { return nsnull; }
|
||||
virtual PRInt32 GetLineStride() {return mRowBytes; }
|
||||
NS_IMETHOD Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
|
||||
NS_IMETHOD 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 mColorMap;}
|
||||
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 PRBool IsOptimized() { return (mImage!=nsnull); }
|
||||
|
||||
virtual nsresult BuildImage(nsDrawingSurface aDrawingSurface);
|
||||
virtual nsresult Optimize(nsIDeviceContext* aContext);
|
||||
virtual PRUint8* GetAlphaBits() { return nsnull; }
|
||||
virtual PRUint8* GetAlphaBits() { return mAlphaBits; }
|
||||
virtual PRInt32 GetAlphaWidth() { return 0;}
|
||||
virtual PRInt32 GetAlphaHeight() {return 0;}
|
||||
virtual PRInt32 GetAlphaXLoc() {return 0;}
|
||||
virtual PRInt32 GetAlphaYLoc() {return 0;}
|
||||
virtual PRInt32 GetAlphaLineStride(){ return 0; }
|
||||
virtual void CompositeImage(nsIImage *aTheImage,nsPoint *aULLocation,nsBlendQuality aQuality);
|
||||
|
||||
virtual nsIImage* DuplicateImage();
|
||||
virtual void CompositeImage(nsIImage *aTheImage,nsPoint *aULLocation,nsBlendQuality aQuality);
|
||||
virtual nsIImage* DuplicateImage() {return(nsnull);}
|
||||
|
||||
void AllocConvertedBits(PRUint32 aSize);
|
||||
|
||||
/**
|
||||
* Return the image size of the Device Independent Bitmap(DIB).
|
||||
|
@ -80,17 +81,48 @@ public:
|
|||
* @return the number of bytes in this span
|
||||
*/
|
||||
PRInt32 CalcBytesSpan(PRUint32 aWidth);
|
||||
|
||||
PRBool SetAlphaMask(nsIImage *aTheMask);
|
||||
|
||||
virtual void SetAlphaLevel(PRInt32 aAlphaLevel) {mAlphaLevel=aAlphaLevel;}
|
||||
|
||||
virtual PRInt32 GetAlphaLevel() {return(mAlphaLevel);}
|
||||
|
||||
void MoveAlphaMask(PRInt32 aX, PRInt32 aY){}
|
||||
virtual void SetAlphaLevel(PRInt32 /* aAlphaLevel */) {}
|
||||
virtual PRInt32 GetAlphaLevel() {return(0);}
|
||||
virtual void MoveAlphaMask(PRInt32 /* aX */, PRInt32 /* aY */) {}
|
||||
|
||||
private:
|
||||
PRInt16 mAlphaLevel; // an alpha level every pixel uses
|
||||
void CreateImage(nsDrawingSurface aSurface);
|
||||
void ConvertImage(nsDrawingSurface aSurface);
|
||||
|
||||
/**
|
||||
* Calculate the amount of memory needed for the initialization of the image
|
||||
*/
|
||||
void ComputMetrics();
|
||||
void ComputePaletteSize(PRIntn nBitCount);
|
||||
|
||||
|
||||
private:
|
||||
PRBool mStaticImage;
|
||||
PRInt32 mWidth;
|
||||
PRInt32 mHeight;
|
||||
PRInt32 mDepth; // bits per pixel
|
||||
PRInt32 mOriginalDepth; // bits per pixel
|
||||
PRInt32 mRowBytes;
|
||||
PRInt32 mOriginalRowBytes;
|
||||
GdkPixmap *mThePixMap;
|
||||
PRUint8 *mImageBits;
|
||||
PRUint8 *mConvertedBits;
|
||||
PRBool mConverted;
|
||||
PRUint8 *mBitsForCreate;
|
||||
PRInt32 mSizeImage;
|
||||
GdkImage *mImage ;
|
||||
nsColorMap *mColorMap;
|
||||
PRInt16 mNumPalleteColors;
|
||||
PRInt8 mNumBytesPixel;
|
||||
|
||||
// alpha layer members
|
||||
PRUint8 *mAlphaBits;
|
||||
PRInt8 mAlphaDepth; // alpha layer depth
|
||||
PRInt16 mARowBytes;
|
||||
PRInt16 mAlphaWidth; // alpha layer width
|
||||
PRInt16 mAlphaHeight; // alpha layer height
|
||||
nsPoint mLocation; // alpha mask location
|
||||
|
||||
|
||||
};
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
* Reserved.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "nsRenderingContextGTK.h"
|
||||
#include <math.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
typedef unsigned char BYTE;
|
||||
|
||||
|
@ -261,7 +261,7 @@ NS_IMETHODIMP nsRenderingContextGTK::CreateDrawingSurface(nsRect *aBounds,
|
|||
PRUint32 aSurfFlags,
|
||||
nsDrawingSurface &aSurface)
|
||||
{
|
||||
#if 0
|
||||
|
||||
GdkPixmap *pixmap = gdk_pixmap_new(mRenderingSurface->drawable, aBounds->width,
|
||||
aBounds->height, -1);
|
||||
|
||||
|
@ -270,8 +270,8 @@ NS_IMETHODIMP nsRenderingContextGTK::CreateDrawingSurface(nsRect *aBounds,
|
|||
surface->drawable = pixmap ;
|
||||
surface->gc = mRenderingSurface->gc;
|
||||
|
||||
return ((nsDrawingSurface)surface);
|
||||
#endif
|
||||
// return ((nsDrawingSurface)surface);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче