Fix rounding issue in DrawTile() and remove a bogus assertion. Bug 194791, Author=paper@animecity.nu, r=smontagu, sr=roc+moz

This commit is contained in:
smontagu%netscape.com 2003-05-29 23:29:37 +00:00
Родитель 5cf6b5c420
Коммит 62b4d0e97f
5 изменённых файлов: 30 добавлений и 22 удалений

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

@ -812,8 +812,16 @@ public:
/* [noscript] void drawScaledImage (in imgIContainer aImage, [const] in nsRect aSrcRect, [const] in nsRect aDestRect); */
NS_IMETHOD DrawScaledImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsRect * aDestRect) = 0;
/* [noscript] void drawTile (in imgIContainer aImage, in nscoord aXOffset, in nscoord aYOffset, [const] in nsRect aTargetRect); */
NS_IMETHOD DrawTile(imgIContainer *aImage, nscoord aXOffset, nscoord aYOffset, const nsRect * aTargetRect) = 0;
/*
* Tiles an image over an area
* @param aImage Image to tile
* @param aXImageStart x location where the origin (0,0) of the image starts
* @param aYImageStart y location where the origin (0,0) of the image starts
* @param aTargetRect area to draw to
*/
NS_IMETHOD DrawTile(imgIContainer *aImage,
nscoord aXImageStart, nscoord aYImageStart,
const nsRect * aTargetRect) = 0;
};

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

@ -880,16 +880,25 @@ NS_IMETHODIMP nsRenderingContextImpl::DrawScaledImage(imgIContainer *aImage, con
dr.x, dr.y, dr.width, dr.height);
}
/* [noscript] void drawTile (in imgIContainer aImage, in nscoord aXOffset, in nscoord aYOffset, [const] in nsRect aTargetRect); */
NS_IMETHODIMP nsRenderingContextImpl::DrawTile(imgIContainer *aImage, nscoord aXOffset, nscoord aYOffset, const nsRect * aTargetRect)
/* [noscript] void drawTile (in imgIContainer aImage, in nscoord aXImageStart, in nscoord aYImageStart, [const] in nsRect aTargetRect); */
NS_IMETHODIMP
nsRenderingContextImpl::DrawTile(imgIContainer *aImage,
nscoord aXImageStart, nscoord aYImageStart,
const nsRect * aTargetRect)
{
nsRect dr(*aTargetRect);
nsRect so(0, 0, aXOffset, aYOffset);
mTranMatrix->TransformCoord(&dr.x, &dr.y, &dr.width, &dr.height);
mTranMatrix->TransformCoord(&aXImageStart, &aYImageStart);
// i want one of these...
mTranMatrix->TransformCoord(&so.x, &so.y, &so.width, &so.height);
nscoord width, height;
aImage->GetWidth(&width);
aImage->GetHeight(&height);
if (width == 0 || height == 0)
return PR_FALSE;
nscoord xOffset = (dr.x - aXImageStart) % width;
nscoord yOffset = (dr.y - aYImageStart) % height;
nsCOMPtr<gfxIImageFrame> iframe;
aImage->GetCurrentFrame(getter_AddRefs(iframe));
@ -902,7 +911,7 @@ NS_IMETHODIMP nsRenderingContextImpl::DrawTile(imgIContainer *aImage, nscoord aX
GetDrawingSurface((void**)&surface);
if (!surface) return NS_ERROR_FAILURE;
return img->DrawTile(*this, surface, so.width, so.height, dr);
return img->DrawTile(*this, surface, xOffset, yOffset, dr);
}
NS_IMETHODIMP

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

@ -735,9 +735,6 @@ NS_IMETHODIMP nsImageWin::DrawTile(nsIRenderingContext &aContext,
PRInt32 aSXOffset, PRInt32 aSYOffset,
const nsRect &aDestRect)
{
NS_ASSERTION(aSXOffset < mBHead->biWidth && aSYOffset < mBHead->biHeight,
"Offset(s) are bigger than image. Caller to DrawTile needs to do more thinking!");
if (mDecodedX2 < mDecodedX1 || mDecodedY2 < mDecodedY1)
return NS_OK;

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

@ -3375,11 +3375,8 @@ nsCSSRendering::PaintBackgroundWithSC(nsIPresContext* aPresContext,
nsRect tileRect(x0, y0, (x1 - x0), (y1 - y0));
nsRect drawRect;
if (drawRect.IntersectRect(tileRect, dirtyRect)) {
PRInt32 xOffset = drawRect.x - x0,
yOffset = drawRect.y - y0;
aRenderingContext.DrawTile(image, xOffset, yOffset, &drawRect);
}
if (drawRect.IntersectRect(tileRect, dirtyRect))
aRenderingContext.DrawTile(image, x0, y0, &drawRect);
#if (!defined(XP_UNIX) && !defined(XP_BEOS)) || defined(XP_MACOSX)
// Restore clipping

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

@ -3375,11 +3375,8 @@ nsCSSRendering::PaintBackgroundWithSC(nsIPresContext* aPresContext,
nsRect tileRect(x0, y0, (x1 - x0), (y1 - y0));
nsRect drawRect;
if (drawRect.IntersectRect(tileRect, dirtyRect)) {
PRInt32 xOffset = drawRect.x - x0,
yOffset = drawRect.y - y0;
aRenderingContext.DrawTile(image, xOffset, yOffset, &drawRect);
}
if (drawRect.IntersectRect(tileRect, dirtyRect))
aRenderingContext.DrawTile(image, x0, y0, &drawRect);
#if (!defined(XP_UNIX) && !defined(XP_BEOS)) || defined(XP_MACOSX)
// Restore clipping