зеркало из https://github.com/mozilla/gecko-dev.git
bug 37779. patch mostly from tor@cs.brown.edu. r=me, saari. r=blizzard for gtk gfx changes. r=rods for the nsImageFrame changes. sr=waterson. needed to land new imagelib.
This commit is contained in:
Родитель
736d75d3bb
Коммит
bf637c0135
|
@ -1234,6 +1234,9 @@ NS_IMETHODIMP nsRenderingContextBeOS::DrawImage(nsIImage *aImage,
|
|||
sr = aSRect;
|
||||
mTranMatrix->TransformCoord(&sr.x, &sr.y,
|
||||
&sr.width, &sr.height);
|
||||
sr.x = aSRect.x;
|
||||
sr.y = aSRect.y;
|
||||
mTranMatrix->TransformNoXLateCoord(&sr.x, &sr.y);
|
||||
|
||||
dr = aDRect;
|
||||
mTranMatrix->TransformCoord(&dr.x, &dr.y,
|
||||
|
|
|
@ -357,14 +357,63 @@ nsImageGTK::Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface,
|
|||
aDX, aDY, aDWidth, aDHeight);
|
||||
#endif
|
||||
|
||||
if (aSX < mDecodedX1) {
|
||||
aSWidth -= mDecodedX1 - aSX;
|
||||
aDX += mDecodedX1 - aSX;
|
||||
aSX += mDecodedX1 - aSX;
|
||||
}
|
||||
if (aSX + aSWidth > mDecodedX2) {
|
||||
aSWidth -= aSX + aSWidth - mDecodedX2;
|
||||
}
|
||||
if (aSY < mDecodedY1) {
|
||||
aSHeight -= mDecodedY1 - aSY;
|
||||
aDY += mDecodedY1 - aSY;
|
||||
aSY += mDecodedY1 - aSY;
|
||||
}
|
||||
if (aSY + aSHeight > mDecodedY2) {
|
||||
aSHeight -= (aSY + aSHeight) - mDecodedY2;
|
||||
}
|
||||
|
||||
if ((mAlphaDepth==8) && mAlphaValid) {
|
||||
DrawComposited(aContext, aSurface, aSX, aSY, aDX, aDY, aSWidth, aSHeight);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsDrawingSurfaceGTK *drawing = (nsDrawingSurfaceGTK*)aSurface;
|
||||
|
||||
gdk_draw_rgb_image (drawing->GetDrawable(),
|
||||
((nsRenderingContextGTK&)aContext).GetGC(),
|
||||
aDX, aDY, aDWidth, aDHeight,
|
||||
GDK_RGB_DITHER_MAX,
|
||||
mImageBits + mRowBytes * aSY + 3 * aDX,
|
||||
mRowBytes);
|
||||
if (mAlphaDepth == 1)
|
||||
CreateAlphaBitmap(mWidth, mHeight);
|
||||
|
||||
GdkGC *copyGC;
|
||||
if (mAlphaPixmap) {
|
||||
if (mGC) {
|
||||
copyGC = gdk_gc_ref(mGC);
|
||||
} else {
|
||||
mGC = gdk_gc_new(drawing->GetDrawable());
|
||||
GdkGC *gc = ((nsRenderingContextGTK&)aContext).GetGC();
|
||||
gdk_gc_copy(mGC, gc);
|
||||
gdk_gc_unref(gc); // unref the one we got
|
||||
copyGC = gdk_gc_ref(mGC);
|
||||
}
|
||||
|
||||
SetupGCForAlpha(copyGC, aDX-aSX, aDY-aSY);
|
||||
} else {
|
||||
// don't make a copy... we promise not to change it
|
||||
copyGC = ((nsRenderingContextGTK&)aContext).GetGC();
|
||||
}
|
||||
|
||||
gdk_window_copy_area(drawing->GetDrawable(), // dest window
|
||||
copyGC, // gc
|
||||
aDX, // xdest
|
||||
aDY, // ydest
|
||||
mImagePixmap, // source window
|
||||
aSX, // xsrc
|
||||
aSY, // ysrc
|
||||
aSWidth, // width
|
||||
aSHeight); // height
|
||||
|
||||
gdk_gc_unref(copyGC);
|
||||
mFlags = 0;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -696,7 +745,8 @@ nsImageGTK::DrawCompositedGeneral(PRBool isLSB, PRBool flipBytes,
|
|||
void
|
||||
nsImageGTK::DrawComposited(nsIRenderingContext &aContext,
|
||||
nsDrawingSurface aSurface,
|
||||
PRInt32 aX, PRInt32 aY,
|
||||
PRInt32 aSX, PRInt32 aSY,
|
||||
PRInt32 aDX, PRInt32 aDY,
|
||||
PRInt32 aWidth, PRInt32 aHeight)
|
||||
{
|
||||
if ((aWidth==0) || (aHeight==0))
|
||||
|
@ -715,23 +765,23 @@ nsImageGTK::DrawComposited(nsIRenderingContext &aContext,
|
|||
int readX, readY;
|
||||
unsigned readWidth, readHeight, destX, destY;
|
||||
|
||||
if ((aY>=(int)surfaceHeight) || (aX>=(int)surfaceWidth) ||
|
||||
(aY+aHeight<=0) || (aX+aWidth<=0)) {
|
||||
if ((aDY>=(int)surfaceHeight) || (aDX>=(int)surfaceWidth) ||
|
||||
(aDY+aHeight<=0) || (aDX+aWidth<=0)) {
|
||||
// This should never happen if the layout engine is sane,
|
||||
// as it means we're trying to draw an image which is outside
|
||||
// the drawing surface. Bulletproof gfx for now...
|
||||
return;
|
||||
}
|
||||
|
||||
if (aX<0) {
|
||||
readX = 0; readWidth = aWidth+aX; destX = -aX;
|
||||
if (aDX<0) {
|
||||
readX = 0; readWidth = aWidth+aDX; destX = aSX-aDX;
|
||||
} else {
|
||||
readX = aX; readWidth = aWidth; destX = 0;
|
||||
readX = aDX; readWidth = aWidth; destX = aSX;
|
||||
}
|
||||
if (aY<0) {
|
||||
readY = 0; readHeight = aHeight+aY; destY = -aY;
|
||||
if (aDY<0) {
|
||||
readY = 0; readHeight = aHeight+aDY; destY = aSY-aDY;
|
||||
} else {
|
||||
readY = aY; readHeight = aHeight; destY = 0;
|
||||
readY = aDY; readHeight = aHeight; destY = aSY;
|
||||
}
|
||||
|
||||
if (readX+readWidth > surfaceWidth)
|
||||
|
@ -739,11 +789,13 @@ nsImageGTK::DrawComposited(nsIRenderingContext &aContext,
|
|||
if (readY+readHeight > surfaceHeight)
|
||||
readHeight = surfaceHeight-readY;
|
||||
|
||||
if ((readHeight <= 0) || (readWidth <= 0))
|
||||
return;
|
||||
|
||||
// fprintf(stderr, "aX=%d aY=%d, aWidth=%u aHeight=%u\n", aX, aY, aWidth, aHeight);
|
||||
// fprintf(stderr, "surfaceWidth=%u surfaceHeight=%u\n", surfaceWidth, surfaceHeight);
|
||||
// fprintf(stderr, "readX=%u readY=%u readWidth=%u readHeight=%u destX=%u destY=%u\n\n",
|
||||
// readX, readY, readWidth, readHeight, destX, destY);
|
||||
// fprintf(stderr, "aX=%d aY=%d, aWidth=%u aHeight=%u\n", aX, aY, aWidth, aHeight);
|
||||
// fprintf(stderr, "surfaceWidth=%u surfaceHeight=%u\n", surfaceWidth, surfaceHeight);
|
||||
// fprintf(stderr, "readX=%u readY=%u readWidth=%u readHeight=%u destX=%u destY=%u\n\n",
|
||||
// readX, readY, readWidth, readHeight, destX, destY);
|
||||
|
||||
XImage *ximage = XGetImage(dpy, drawable,
|
||||
readX, readY, readWidth, readHeight,
|
||||
|
@ -795,6 +847,7 @@ nsImageGTK::DrawComposited(nsIRenderingContext &aContext,
|
|||
|
||||
XDestroyImage(ximage);
|
||||
delete [] readData;
|
||||
mFlags = 0;
|
||||
}
|
||||
|
||||
void nsImageGTK::CreateAlphaBitmap(PRInt32 aWidth, PRInt32 aHeight)
|
||||
|
@ -921,7 +974,7 @@ nsImageGTK::Draw(nsIRenderingContext &aContext,
|
|||
g_return_val_if_fail ((aSurface != nsnull), NS_ERROR_FAILURE);
|
||||
|
||||
if ((mAlphaDepth==8) && mAlphaValid) {
|
||||
DrawComposited(aContext, aSurface, aX, aY, aWidth, aHeight);
|
||||
DrawComposited(aContext, aSurface, 0, 0, aX, aY, aWidth, aHeight);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1014,11 +1067,11 @@ nsImageGTK::Draw(nsIRenderingContext &aContext,
|
|||
// copy our offscreen pixmap onto the window.
|
||||
gdk_window_copy_area(drawing->GetDrawable(), // dest window
|
||||
copyGC, // gc
|
||||
validX+aX, // xsrc
|
||||
validY+aY, // ysrc
|
||||
validX+aX, // xdest
|
||||
validY+aY, // ydest
|
||||
mImagePixmap, // source window
|
||||
validX, // xdest
|
||||
validY, // ydest
|
||||
validX, // xsrc
|
||||
validY, // ysrc
|
||||
validWidth, // width
|
||||
validHeight); // height
|
||||
#ifdef CHEAP_PERFORMANCE_MEASURMENT
|
||||
|
|
|
@ -147,7 +147,8 @@ private:
|
|||
XImage *ximage, unsigned char *readData);
|
||||
inline void DrawComposited(nsIRenderingContext &aContext,
|
||||
nsDrawingSurface aSurface,
|
||||
PRInt32 aX, PRInt32 aY,
|
||||
PRInt32 aSX, PRInt32 aSY,
|
||||
PRInt32 aDX, PRInt32 aDY,
|
||||
PRInt32 aWidth, PRInt32 aHeight);
|
||||
|
||||
inline void TilePixmap(GdkPixmap *src, GdkPixmap *dest, PRInt32 aSXOffset, PRInt32 aSYOffset,
|
||||
|
|
|
@ -1617,6 +1617,8 @@ NS_IMETHODIMP nsRenderingContextGTK::DrawImage(nsIImage *aImage,
|
|||
sr = aSRect;
|
||||
mTranMatrix->TransformCoord(&sr.x, &sr.y,
|
||||
&sr.width, &sr.height);
|
||||
sr.x -= mTranMatrix->GetXTranslationCoord();
|
||||
sr.y -= mTranMatrix->GetYTranslationCoord();
|
||||
|
||||
dr = aDRect;
|
||||
mTranMatrix->TransformCoord(&dr.x, &dr.y,
|
||||
|
|
|
@ -1390,6 +1390,8 @@ NS_IMETHODIMP nsRenderingContextMac::DrawImage(nsIImage *aImage, const nsRect& a
|
|||
nsRect sr = aSRect;
|
||||
nsRect dr = aDRect;
|
||||
mGS->mTMatrix.TransformCoord(&sr.x,&sr.y,&sr.width,&sr.height);
|
||||
sr.x -= mTranMatrix->GetXTranslationCoord();
|
||||
sr.y -= mTranMatrix->GetYTranslationCoord();
|
||||
mGS->mTMatrix.TransformCoord(&dr.x,&dr.y,&dr.width,&dr.height);
|
||||
|
||||
return aImage->Draw(*this, mCurrentSurface, sr.x, sr.y, sr.width, sr.height,
|
||||
|
|
|
@ -1415,6 +1415,9 @@ NS_IMETHODIMP nsRenderingContextMotif :: DrawImage(nsIImage *aImage, const nsRec
|
|||
|
||||
sr = aSRect;
|
||||
mTMatrix ->TransformCoord(&sr.x,&sr.y,&sr.width,&sr.height);
|
||||
sr.x = aSRect.x;
|
||||
sr.y a aSRect.y;
|
||||
mTranMatrix->TransformNoXLateCoord(&sr.x, &sr.y);
|
||||
|
||||
dr = aDRect;
|
||||
mTMatrix->TransformCoord(&dr.x,&dr.y,&dr.width,&dr.height);
|
||||
|
|
|
@ -1675,6 +1675,9 @@ nsresult nsRenderingContextOS2::DrawImage( nsIImage *aImage, const nsRect& aSRec
|
|||
|
||||
sr = aSRect;
|
||||
mTMatrix.TransformCoord( &sr.x, &sr.y, &sr.width, &sr.height);
|
||||
sr.x = aSRect.x;
|
||||
sr.y = aSRect.y;
|
||||
mTranMatrix->TransformNoXLateCoord(&sr.x, &sr.y);
|
||||
|
||||
dr = aDRect;
|
||||
mTMatrix.TransformCoord( &dr.x, &dr.y, &dr.width, &dr.height);
|
||||
|
|
|
@ -1056,6 +1056,9 @@ NS_IMETHODIMP nsRenderingContextPh::DrawImage( nsIImage *aImage, const nsRect& a
|
|||
|
||||
sr = aSRect;
|
||||
mTMatrix->TransformCoord(&sr.x, &sr.y, &sr.width, &sr.height);
|
||||
sr.x = aSRect.x;
|
||||
sr.y = aSRect.y;
|
||||
mTranMatrix->TransformNoXLateCoord(&sr.x, &sr.y);
|
||||
dr = aDRect;
|
||||
mTMatrix->TransformCoord(&dr.x, &dr.y, &dr.width, &dr.height);
|
||||
|
||||
|
|
|
@ -1215,6 +1215,9 @@ nsRect sr,dr;
|
|||
|
||||
sr = aSRect;
|
||||
mTMatrix->TransformCoord(&sr.x, &sr.y, &sr.width, &sr.height);
|
||||
sr.x = aSRect.x;
|
||||
sr.y = aSRect.y;
|
||||
mTranMatrix->TransformNoXLateCoord(&sr.x, &sr.y);
|
||||
|
||||
dr = aDRect;
|
||||
mTMatrix->TransformCoord(&dr.x, &dr.y, &dr.width, &dr.height);
|
||||
|
|
|
@ -1303,6 +1303,9 @@ NS_IMETHODIMP nsRenderingContextQT::DrawImage(nsIImage *aImage,
|
|||
|
||||
sr = aSRect;
|
||||
mTranMatrix ->TransformCoord(&sr.x,&sr.y,&sr.width,&sr.height);
|
||||
sr.x = aSRect.x;
|
||||
sr.y = aSRect.y;
|
||||
mTranMatrix->TransformNoXLateCoord(&sr.x, &sr.y);
|
||||
|
||||
dr = aDRect;
|
||||
mTranMatrix->TransformCoord(&dr.x,&dr.y,&dr.width,&dr.height);
|
||||
|
|
|
@ -428,21 +428,42 @@ nsImageWin :: Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface,
|
|||
{
|
||||
|
||||
HDC TheHDC;
|
||||
PRInt32 canRaster,srcHeight,srcy;
|
||||
PRInt32 canRaster,srcy;
|
||||
HBITMAP oldBits;
|
||||
DWORD rop;
|
||||
PRInt32 origSHeight = aSHeight, origDHeight = aDHeight;
|
||||
PRInt32 origSWidth = aSWidth, origDWidth = aDWidth;
|
||||
|
||||
if (mBHead == nsnull)
|
||||
if (mBHead == nsnull || aSWidth < 0 || aDWidth < 0 || aSHeight < 0 || aDHeight < 0)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (0 == aSWidth || 0 == aDWidth || 0 == aSHeight || 0 == aDHeight)
|
||||
return NS_OK;
|
||||
|
||||
// limit the size of the blit to the amount of the image read in
|
||||
srcHeight = mBHead->biHeight;
|
||||
srcy = 0;
|
||||
if((mDecodedY2 < srcHeight)) {
|
||||
aDHeight = PRInt32 (float(mDecodedY2/float(srcHeight))*aDHeight);
|
||||
srcHeight = mDecodedY2;
|
||||
srcy = (mBHead->biHeight-mDecodedY2);
|
||||
if (aSX + aSWidth > mDecodedX2) {
|
||||
aDWidth -= ((aSX + aSWidth - mDecodedX2)*origDWidth)/origSWidth;
|
||||
aSWidth = mDecodedX2 - mDecodedX1;
|
||||
}
|
||||
if (aSX < mDecodedX1) {
|
||||
aDX += ((mDecodedX1 - aSX)*origDWidth)/origSWidth;
|
||||
aSX = mDecodedX1;
|
||||
}
|
||||
|
||||
if (aSY + aSHeight > mDecodedY2) {
|
||||
aDHeight -= ((aSY + aSHeight - mDecodedY2)*origDHeight)/origSHeight;
|
||||
aSHeight = mDecodedY2 - mDecodedY1;
|
||||
}
|
||||
if (aSY < mDecodedY1) {
|
||||
aDY += ((mDecodedY1 - aSY)*origDHeight)/origSHeight;
|
||||
aSY = mDecodedY1;
|
||||
}
|
||||
|
||||
if (aDWidth <= 0 || aDHeight <= 0)
|
||||
return NS_OK;
|
||||
|
||||
// Translate to bottom-up coordinates for the source bitmap
|
||||
srcy = mBHead->biHeight - (aSY + aSHeight);
|
||||
|
||||
// if DC is not for a printer, and the image can be optimized,
|
||||
((nsDrawingSurfaceWin *)aSurface)->GetDC(&TheHDC);
|
||||
|
@ -462,23 +483,20 @@ DWORD rop;
|
|||
if( 1==mAlphaDepth){
|
||||
MONOBITMAPINFO bmi(mAlphaWidth, mAlphaHeight);
|
||||
|
||||
::StretchDIBits(TheHDC, aDX, aDY, aDWidth, aDHeight,aSX, aSY,aSWidth, aSHeight, mAlphaBits,
|
||||
::StretchDIBits(TheHDC, aDX, aDY, aDWidth, aDHeight,aSX, srcy,aSWidth, aSHeight, mAlphaBits,
|
||||
(LPBITMAPINFO)&bmi, DIB_RGB_COLORS, SRCAND);
|
||||
rop = SRCPAINT;
|
||||
}
|
||||
else if( 8==mAlphaDepth){
|
||||
ALPHA8BITMAPINFO bmi(mAlphaWidth, mAlphaHeight);
|
||||
|
||||
::StretchDIBits(TheHDC, aDX, aDY, aDWidth, aDHeight,aSX, aSY, aSWidth, aSHeight, mAlphaBits,
|
||||
(LPBITMAPINFO)&bmi, DIB_RGB_COLORS, SRCAND);
|
||||
rop = SRCPAINT;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
::StretchDIBits(TheHDC, aDX, aDY, aDWidth, aDHeight,aSX, srcy, aSWidth, srcHeight, mImageBits,
|
||||
(LPBITMAPINFO)mBHead, 256 == mNumPaletteColors ? DIB_PAL_COLORS :
|
||||
if (8==mAlphaDepth) {
|
||||
DrawComposited(TheHDC, aDX, aDY, aDWidth, aDHeight,
|
||||
aSX, srcy, aSWidth, aSHeight);
|
||||
} else {
|
||||
::StretchDIBits(TheHDC, aDX, aDY, aDWidth, aDHeight,aSX, srcy, aSWidth, aSHeight, mImageBits,
|
||||
(LPBITMAPINFO)mBHead, 256 == mNumPaletteColors ? DIB_PAL_COLORS :
|
||||
DIB_RGB_COLORS, rop);
|
||||
}
|
||||
|
||||
}else{
|
||||
nsIDeviceContext *dx;
|
||||
|
@ -497,7 +515,7 @@ DWORD rop;
|
|||
if( 1==mAlphaDepth){
|
||||
MONOBITMAPINFO bmi(mAlphaWidth, mAlphaHeight);
|
||||
|
||||
::StretchDIBits(TheHDC, aDX, aDY, aDWidth, aDHeight,aSX, aSY, aSWidth, aSHeight, mAlphaBits,
|
||||
::StretchDIBits(TheHDC, aDX, aDY, aDWidth, aDHeight,aSX, srcy, aSWidth, aSHeight, mAlphaBits,
|
||||
(LPBITMAPINFO)&bmi, DIB_RGB_COLORS, SRCAND);
|
||||
rop = SRCPAINT;
|
||||
//rop = SRCCOPY;
|
||||
|
@ -517,9 +535,9 @@ DWORD rop;
|
|||
blendFunction.BlendFlags = 0;
|
||||
blendFunction.SourceConstantAlpha = 255;
|
||||
blendFunction.AlphaFormat = 1 /*AC_SRC_ALPHA*/;
|
||||
gAlphaBlend(TheHDC, aDX, aDY, aDWidth, aDHeight, srcDC, aSX, srcy, aSWidth, srcHeight, blendFunction);
|
||||
gAlphaBlend(TheHDC, aDX, aDY, aDWidth, aDHeight, srcDC, aSX, srcy, aSWidth, aSHeight, blendFunction);
|
||||
} else {
|
||||
::StretchBlt(TheHDC, aDX, aDY, aDWidth, aDHeight, srcDC, aSX, srcy,aSWidth, srcHeight, rop);
|
||||
::StretchBlt(TheHDC, aDX, aDY, aDWidth, aDHeight, srcDC, aSX, aSY,aSWidth, aSHeight, rop);
|
||||
}
|
||||
}else{
|
||||
PrintDDB(aSurface,aDX,aDY,aDWidth,aDHeight,rop);
|
||||
|
@ -534,9 +552,9 @@ DWORD rop;
|
|||
blendFunction.BlendFlags = 0;
|
||||
blendFunction.SourceConstantAlpha = 255;
|
||||
blendFunction.AlphaFormat = 1 /*AC_SRC_ALPHA*/;
|
||||
gAlphaBlend(TheHDC, aDX, aDY, aDWidth, aDHeight, srcDC, aSX, srcy, aSWidth, srcHeight, blendFunction);
|
||||
gAlphaBlend(TheHDC, aDX, aDY, aDWidth, aDHeight, srcDC, aSX, srcy, aSWidth, aSHeight, blendFunction);
|
||||
} else {
|
||||
::StretchBlt(TheHDC,aDX,aDY,aDWidth,aDHeight,srcDC,aSX,srcy,aSWidth,srcHeight,rop);
|
||||
::StretchBlt(TheHDC,aDX,aDY,aDWidth,aDHeight,srcDC,aSX,aSY,aSWidth,aSHeight,rop);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -606,129 +624,7 @@ void nsImageWin::DrawComposited(HDC TheHDC, int aDX, int aDY, int aDWidth, int a
|
|||
NS_IMETHODIMP nsImageWin :: Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface,
|
||||
PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
|
||||
{
|
||||
HDC TheHDC;
|
||||
PRInt32 canRaster,srcHeight,srcy;
|
||||
HBITMAP oldBits;
|
||||
DWORD rop;
|
||||
|
||||
if (mBHead == nsnull)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// limit the size of the blit to the amount of the image read in
|
||||
srcHeight = mBHead->biHeight;
|
||||
srcy = 0;
|
||||
if((mDecodedY2 < srcHeight)) {
|
||||
aHeight = PRInt32 (float(mDecodedY2/float(srcHeight))*aHeight);
|
||||
srcHeight = mDecodedY2;
|
||||
srcy = (mBHead->biHeight-mDecodedY2);
|
||||
}
|
||||
|
||||
// if DC is not for a printer, and the image can be optimized,
|
||||
((nsDrawingSurfaceWin *)aSurface)->GetDC(&TheHDC);
|
||||
|
||||
// find out if the surface is a printer.
|
||||
((nsDrawingSurfaceWin *)aSurface)->GetTECHNOLOGY(&canRaster);
|
||||
if(canRaster != DT_RASPRINTER){
|
||||
if ((PR_TRUE==mCanOptimize) && (nsnull == mHBitmap))
|
||||
CreateDDB(aSurface);
|
||||
}
|
||||
|
||||
if (nsnull != TheHDC){
|
||||
if (!IsOptimized() || nsnull==mHBitmap){
|
||||
rop = SRCCOPY;
|
||||
|
||||
if (nsnull != mAlphaBits){
|
||||
if( 1==mAlphaDepth){
|
||||
MONOBITMAPINFO bmi(mAlphaWidth, mAlphaHeight);
|
||||
|
||||
::StretchDIBits(TheHDC, aX, aY, aWidth, aHeight,0, 0,
|
||||
mAlphaWidth, mAlphaHeight, mAlphaBits,
|
||||
(LPBITMAPINFO)&bmi, DIB_RGB_COLORS, SRCAND);
|
||||
rop = SRCPAINT;
|
||||
}
|
||||
}
|
||||
|
||||
if (8 == mAlphaDepth) {
|
||||
DrawComposited(TheHDC, aX, aY, aWidth, aHeight,
|
||||
0, srcy, mBHead->biWidth, srcHeight);
|
||||
} else {
|
||||
::StretchDIBits(TheHDC, aX, aY, aWidth, aHeight,
|
||||
0, srcy, mBHead->biWidth, srcHeight, mImageBits,
|
||||
(LPBITMAPINFO)mBHead, 256 == mNumPaletteColors ? DIB_PAL_COLORS :
|
||||
DIB_RGB_COLORS, rop);
|
||||
}
|
||||
|
||||
}else{
|
||||
nsIDeviceContext *dx;
|
||||
aContext.GetDeviceContext(dx);
|
||||
nsDrawingSurface ds;
|
||||
dx->GetDrawingSurface(aContext, ds);
|
||||
nsDrawingSurfaceWin *srcDS = (nsDrawingSurfaceWin *)ds;
|
||||
HDC srcDC;
|
||||
|
||||
if (nsnull != srcDS){
|
||||
srcDS->GetDC(&srcDC);
|
||||
|
||||
rop = SRCCOPY;
|
||||
|
||||
if (nsnull != mAlphaBits){
|
||||
if( 1==mAlphaDepth){
|
||||
MONOBITMAPINFO bmi(mAlphaWidth, mAlphaHeight);
|
||||
|
||||
::StretchDIBits(TheHDC,aX,aY,aWidth,aHeight,0,0,mAlphaWidth, mAlphaHeight, mAlphaBits,
|
||||
(LPBITMAPINFO)&bmi,DIB_RGB_COLORS,SRCAND);
|
||||
rop = SRCPAINT;
|
||||
}
|
||||
}
|
||||
// if this is for a printer.. we have to convert it back to a DIB
|
||||
if(canRaster == DT_RASPRINTER){
|
||||
if(!(GetDeviceCaps(TheHDC,RASTERCAPS) &(RC_BITBLT | RC_STRETCHBLT))) {
|
||||
// we have an error with the printer not supporting a raster device
|
||||
} else {
|
||||
// if we did not convert to a DDB already
|
||||
if (nsnull == mHBitmap) {
|
||||
oldBits = (HBITMAP)::SelectObject(srcDC, mHBitmap);
|
||||
if (8 == mAlphaDepth) {
|
||||
BLENDFUNCTION blendFunction;
|
||||
blendFunction.BlendOp = AC_SRC_OVER;
|
||||
blendFunction.BlendFlags = 0;
|
||||
blendFunction.SourceConstantAlpha = 255;
|
||||
blendFunction.AlphaFormat = 1 /*AC_SRC_ALPHA*/;
|
||||
gAlphaBlend(TheHDC, aX, aY, aWidth, aHeight, srcDC, 0, srcy,
|
||||
mBHead->biWidth, srcHeight, blendFunction);
|
||||
} else {
|
||||
::StretchBlt(TheHDC, aX, aY, aWidth, aHeight, srcDC, 0, srcy,
|
||||
mBHead->biWidth, srcHeight, rop);
|
||||
}
|
||||
}else{
|
||||
PrintDDB(aSurface,aX,aY,aWidth,aHeight,rop);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// we are going to the device that created this DDB
|
||||
oldBits = (HBITMAP)::SelectObject(srcDC, mHBitmap);
|
||||
if (8 == mAlphaDepth) {
|
||||
BLENDFUNCTION blendFunction;
|
||||
blendFunction.BlendOp = AC_SRC_OVER;
|
||||
blendFunction.BlendFlags = 0;
|
||||
blendFunction.SourceConstantAlpha = 255;
|
||||
blendFunction.AlphaFormat = 1 /*AC_SRC_ALPHA*/;
|
||||
gAlphaBlend(TheHDC, aX, aY, aWidth, aHeight, srcDC, 0, srcy, mBHead->biWidth, srcHeight, blendFunction);
|
||||
} else {
|
||||
::StretchBlt(TheHDC,aX,aY,aWidth,aHeight,srcDC,0,srcy,mBHead->biWidth,srcHeight,rop);
|
||||
}
|
||||
}
|
||||
|
||||
::SelectObject(srcDC, oldBits);
|
||||
srcDS->ReleaseDC();
|
||||
}
|
||||
NS_RELEASE(dx);
|
||||
}
|
||||
|
||||
((nsDrawingSurfaceWin *)aSurface)->ReleaseDC();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return Draw(aContext, aSurface, 0, 0, mNaturalWidth, mNaturalHeight, aX, aY, aWidth, aHeight);
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
|
|
|
@ -2790,6 +2790,9 @@ NS_IMETHODIMP nsRenderingContextWin :: DrawImage(nsIImage *aImage, const nsRect&
|
|||
|
||||
sr = aSRect;
|
||||
mTranMatrix->TransformCoord(&sr.x, &sr.y, &sr.width, &sr.height);
|
||||
sr.x = aSRect.x;
|
||||
sr.y = aSRect.y;
|
||||
mTranMatrix->TransformNoXLateCoord(&sr.x, &sr.y);
|
||||
|
||||
dr = aDRect;
|
||||
mTranMatrix->TransformCoord(&dr.x, &dr.y, &dr.width, &dr.height);
|
||||
|
|
|
@ -1403,6 +1403,9 @@ nsRenderingContextXlib::DrawImage(nsIImage *aImage, const nsRect& aSRect, const
|
|||
sr = aSRect;
|
||||
mTMatrix->TransformCoord(&sr.x, &sr.y,
|
||||
&sr.width, &sr.height);
|
||||
sr.x = aSRect.x;
|
||||
sr.y = aSRect.y;
|
||||
mTranMatrix->TransformNoXLateCoord(&sr.x, &sr.y);
|
||||
|
||||
dr = aDRect;
|
||||
mTMatrix->TransformCoord(&dr.x, &dr.y,
|
||||
|
|
|
@ -1401,6 +1401,9 @@ nsRenderingContextXP :: DrawImage(nsIImage *aImage, const nsRect& aSRect, const
|
|||
|
||||
sr = aSRect;
|
||||
mTMatrix->TransformCoord(&sr.x, &sr.y, &sr.width, &sr.height);
|
||||
sr.x = aSRect.x;
|
||||
sr.y = aSRect.y;
|
||||
mTranMatrix->TransformNoXLateCoord(&sr.x, &sr.y);
|
||||
|
||||
dr = aDRect;
|
||||
mTMatrix->TransformCoord(&dr.x, &dr.y, &dr.width, &dr.height);
|
||||
|
|
|
@ -1001,21 +1001,8 @@ nsImageFrame::Paint(nsIPresContext* aPresContext,
|
|||
inner.SizeTo(mComputedSize);
|
||||
} else if (lowImgCon) {
|
||||
}
|
||||
#else
|
||||
if (mImageLoader.GetLoadImageFailed()) {
|
||||
float p2t;
|
||||
aPresContext->GetScaledPixelsToTwips(&p2t);
|
||||
if (image) {
|
||||
inner.width = NSIntPixelsToTwips(image->GetWidth(), p2t);
|
||||
inner.height = NSIntPixelsToTwips(image->GetHeight(), p2t);
|
||||
} else if (lowImage) {
|
||||
inner.width = NSIntPixelsToTwips(lowImage->GetWidth(), p2t);
|
||||
inner.height = NSIntPixelsToTwips(lowImage->GetHeight(), p2t);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef USE_IMG2
|
||||
if (imgCon) {
|
||||
nsPoint p(inner.x, inner.y);
|
||||
if (mIntrinsicSize == mComputedSize) {
|
||||
|
@ -1038,13 +1025,39 @@ nsImageFrame::Paint(nsIPresContext* aPresContext,
|
|||
}
|
||||
}
|
||||
#else
|
||||
if (image && imgSrcLinesLoaded > 0) {
|
||||
aRenderingContext.DrawImage(image, inner);
|
||||
} else if (lowImage && lowSrcLinesLoaded > 0) {
|
||||
aRenderingContext.DrawImage(lowImage, inner);
|
||||
/*
|
||||
* aDirtyRect is the dirty rect, which we want to use to minimize
|
||||
* painting, but it's in terms of the frame and not the image, so
|
||||
* we need to use the intersection of the dirty rect and the inner
|
||||
* image rect.
|
||||
*/
|
||||
if (inner.IntersectRect(inner, aDirtyRect)) {
|
||||
if (mImageLoader.GetLoadImageFailed()) {
|
||||
float p2t;
|
||||
aPresContext->GetScaledPixelsToTwips(&p2t);
|
||||
if (image != nsnull) {
|
||||
inner.width = NSIntPixelsToTwips(image->GetWidth(), p2t);
|
||||
inner.height = NSIntPixelsToTwips(image->GetHeight(), p2t);
|
||||
} else if (lowImage != nsnull) {
|
||||
inner.width = NSIntPixelsToTwips(lowImage->GetWidth(), p2t);
|
||||
inner.height = NSIntPixelsToTwips(lowImage->GetHeight(), p2t);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* We need to adjust the image source rect to match
|
||||
* the image's coordinates: we slide to the right and down.
|
||||
*/
|
||||
nsRect innerSource(inner);
|
||||
innerSource.x -= mBorderPadding.left;
|
||||
innerSource.y -= mBorderPadding.top;
|
||||
|
||||
if (image != nsnull && imgSrcLinesLoaded > 0) {
|
||||
aRenderingContext.DrawImage(image, innerSource, inner);
|
||||
} else if (lowImage != nsnull && lowSrcLinesLoaded > 0) {
|
||||
aRenderingContext.DrawImage(lowImage, innerSource, inner);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
nsImageMap* map = GetImageMap(aPresContext);
|
||||
|
|
|
@ -1001,21 +1001,8 @@ nsImageFrame::Paint(nsIPresContext* aPresContext,
|
|||
inner.SizeTo(mComputedSize);
|
||||
} else if (lowImgCon) {
|
||||
}
|
||||
#else
|
||||
if (mImageLoader.GetLoadImageFailed()) {
|
||||
float p2t;
|
||||
aPresContext->GetScaledPixelsToTwips(&p2t);
|
||||
if (image) {
|
||||
inner.width = NSIntPixelsToTwips(image->GetWidth(), p2t);
|
||||
inner.height = NSIntPixelsToTwips(image->GetHeight(), p2t);
|
||||
} else if (lowImage) {
|
||||
inner.width = NSIntPixelsToTwips(lowImage->GetWidth(), p2t);
|
||||
inner.height = NSIntPixelsToTwips(lowImage->GetHeight(), p2t);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef USE_IMG2
|
||||
if (imgCon) {
|
||||
nsPoint p(inner.x, inner.y);
|
||||
if (mIntrinsicSize == mComputedSize) {
|
||||
|
@ -1038,13 +1025,39 @@ nsImageFrame::Paint(nsIPresContext* aPresContext,
|
|||
}
|
||||
}
|
||||
#else
|
||||
if (image && imgSrcLinesLoaded > 0) {
|
||||
aRenderingContext.DrawImage(image, inner);
|
||||
} else if (lowImage && lowSrcLinesLoaded > 0) {
|
||||
aRenderingContext.DrawImage(lowImage, inner);
|
||||
/*
|
||||
* aDirtyRect is the dirty rect, which we want to use to minimize
|
||||
* painting, but it's in terms of the frame and not the image, so
|
||||
* we need to use the intersection of the dirty rect and the inner
|
||||
* image rect.
|
||||
*/
|
||||
if (inner.IntersectRect(inner, aDirtyRect)) {
|
||||
if (mImageLoader.GetLoadImageFailed()) {
|
||||
float p2t;
|
||||
aPresContext->GetScaledPixelsToTwips(&p2t);
|
||||
if (image != nsnull) {
|
||||
inner.width = NSIntPixelsToTwips(image->GetWidth(), p2t);
|
||||
inner.height = NSIntPixelsToTwips(image->GetHeight(), p2t);
|
||||
} else if (lowImage != nsnull) {
|
||||
inner.width = NSIntPixelsToTwips(lowImage->GetWidth(), p2t);
|
||||
inner.height = NSIntPixelsToTwips(lowImage->GetHeight(), p2t);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* We need to adjust the image source rect to match
|
||||
* the image's coordinates: we slide to the right and down.
|
||||
*/
|
||||
nsRect innerSource(inner);
|
||||
innerSource.x -= mBorderPadding.left;
|
||||
innerSource.y -= mBorderPadding.top;
|
||||
|
||||
if (image != nsnull && imgSrcLinesLoaded > 0) {
|
||||
aRenderingContext.DrawImage(image, innerSource, inner);
|
||||
} else if (lowImage != nsnull && lowSrcLinesLoaded > 0) {
|
||||
aRenderingContext.DrawImage(lowImage, innerSource, inner);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
nsImageMap* map = GetImageMap(aPresContext);
|
||||
|
|
Загрузка…
Ссылка в новой задаче