Second attempt to fix bug 137295; gaps appearing in images on Mac OS X. Changed to not pass in the clipRgn when we're drawing to another image (e.g. animated GIFs), or another non-window destination where we don't want to clip. r=pink, sr=beard.

This commit is contained in:
sfraser%netscape.com 2002-04-19 23:07:56 +00:00
Родитель 5f29c565cc
Коммит 8f9d48ef0b
2 изменённых файлов: 18 добавлений и 13 удалений

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

@ -370,7 +370,7 @@ NS_IMETHODIMP nsImageMac::Draw(nsIRenderingContext &aContext, nsDrawingSurface a
CopyBitsWithMask((BitMap*)(&mImagePixmap),
mMaskBitsHandle ? (BitMap*)(&mMaskPixmap) : nsnull, mAlphaDepth,
(BitMap*)(*destPixels),
srcRect, maskRect, dstRect);
srcRect, maskRect, dstRect, PR_TRUE);
}
return NS_OK;
@ -428,7 +428,7 @@ NS_IMETHODIMP nsImageMac :: DrawToImage(nsIImage* aDstImage, PRInt32 aDX, PRInt3
CopyBitsWithMask((BitMap*)(&mImagePixmap),
mMaskBitsHandle ? (BitMap*)(&mMaskPixmap) : nsnull, mAlphaDepth,
(BitMap*)(destPixels), srcRect, maskRect, dstRect);
(BitMap*)(destPixels), srcRect, maskRect, dstRect, PR_FALSE);
aDstImage->UnlockImagePixels(PR_FALSE);
aDstImage->UnlockImagePixels(PR_TRUE);
@ -822,15 +822,20 @@ OSErr nsImageMac::AllocateGWorld(PRInt16 depth, CTabHandle colorTable, const Rec
}
void nsImageMac::CopyBitsWithMask(const BitMap* srcBits, const BitMap* maskBits, PRInt16 maskDepth, const BitMap* destBits,
const Rect& srcRect, const Rect& maskRect, const Rect& destRect)
const Rect& srcRect, const Rect& maskRect, const Rect& destRect, PRBool inDrawingToPort)
{
if (maskBits)
{
// we need to pass in the clip region, even if it doesn't intersect the image, to avoid a bug
// on Mac OS X that causes bad image drawing (see bug 137295).
StRegionFromPool clipRegion;
::GetClip(clipRegion);
::CopyDeepMask(srcBits, maskBits, destBits, &srcRect, &maskRect, &destRect, srcCopy, clipRegion);
if (inDrawingToPort)
{
// we need to pass in the clip region, even if it doesn't intersect the image, to avoid a bug
// on Mac OS X that causes bad image drawing (see bug 137295).
::GetClip(clipRegion);
}
::CopyDeepMask(srcBits, maskBits, destBits, &srcRect, &maskRect, &destRect, srcCopy, inDrawingToPort ? clipRegion : nsnull);
}
else
{
@ -889,7 +894,7 @@ nsImageMac :: ConvertToPICT ( PicHandle* outPicture )
// copy from the destination into our temp GWorld, to get the background
CopyBitsWithMask((BitMap*)(&mImagePixmap),
mMaskBitsHandle ? (BitMap*)(&mMaskPixmap) : nsnull, mAlphaDepth,
(BitMap*)(*tempPixMap), picFrame, maskFrame, picFrame);
(BitMap*)(*tempPixMap), picFrame, maskFrame, picFrame, PR_FALSE);
// now copy into the picture
GWorldPtr currPort;
@ -993,7 +998,7 @@ nsImageMac::ConvertToIcon( const nsRect& aSrcRegion,
}
//returns null if there size specified isn't a valid size for an icon
OSType iconType = MakeIconType(aIconSize, aIconDepth, false);
OSType iconType = MakeIconType(aIconSize, aIconDepth, PR_FALSE);
if (iconType == nil) {
return NS_ERROR_INVALID_ARG;
}
@ -1080,7 +1085,7 @@ nsImageMac::ConvertAlphaToIconMask( const nsRect& aSrcRegion,
*aOutIconType = nsnull;
//returns null if there size specified isn't a valid size for an icon
OSType iconType = MakeIconType(aMaskSize, aMaskDepth, true);
OSType iconType = MakeIconType(aMaskSize, aMaskDepth, PR_TRUE);
if (iconType == nil) {
return NS_ERROR_INVALID_ARG;
}
@ -1608,7 +1613,7 @@ nsresult nsImageMac::DrawTileQuickly(nsIRenderingContext &aContext,
// CopyBits will do the truncation for us at the edges
CopyBitsWithMask((BitMap*)(&mImagePixmap),
mMaskBitsHandle ? (BitMap*)(&mMaskPixmap) : nsnull, mAlphaDepth,
(BitMap*)(*destPixels), imageRect, imageRect, imageDestRect);
(BitMap*)(*destPixels), imageRect, imageRect, imageDestRect, PR_TRUE);
}
}
@ -1791,7 +1796,7 @@ nsresult nsImageMac::DrawTileQuickly(nsIRenderingContext &aContext,
// finally, copy to the destination
CopyBitsWithMask((BitMap*)(*tilingPixels),
maskingPixels ? (BitMap*)(*maskingPixels) : nsnull, mAlphaDepth,
(BitMap*)(*destPixels), tileRect, tileRect, tileDestRect);
(BitMap*)(*destPixels), tileRect, tileRect, tileDestRect, PR_TRUE);
} // scope for locks

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

@ -181,7 +181,7 @@ protected:
Handle *aMask);
static void CopyBitsWithMask(const BitMap* srcBits, const BitMap* maskBits, PRInt16 maskDepth, const BitMap* destBits,
const Rect& srcRect, const Rect& maskRect, const Rect& destRect);
const Rect& srcRect, const Rect& maskRect, const Rect& destRect, PRBool inDrawingToPort);
static PRBool RenderingToPrinter(nsIRenderingContext &aContext);