Bug 98041 - xlib port of image tiling assertion fixes. Checking in for Roland.Mainz@informatik.med.uni-giessen.de. r=timeless, sr=jst.

This commit is contained in:
bryner%netscape.com 2001-09-15 21:20:24 +00:00
Родитель 494d5c0bec
Коммит ac97d0fb62
4 изменённых файлов: 5 добавлений и 166 удалений

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

@ -1362,124 +1362,6 @@ void nsImageXlib::TilePixmap(Pixmap src, Pixmap dest, PRInt32 aSXOffset,
XFreeGC(mDisplay, gc);
}
NS_IMETHODIMP nsImageXlib::DrawTile(nsIRenderingContext &aContext,
nsDrawingSurface aSurface,
nsRect &aSrcRect,
nsRect &aTileRect)
{
if (mPendingUpdate)
UpdateCachedImage();
if ((mAlphaDepth == 1) && mIsSpacer)
return NS_OK;
nsIDrawingSurfaceXlib *drawing = NS_STATIC_CAST(nsIDrawingSurfaceXlib *, aSurface);
PRBool partial = PR_FALSE;
PRInt32
validX = 0,
validY = 0,
validWidth = mWidth,
validHeight = mHeight;
// limit the image rectangle to the size of the image data which
// has been validated.
if (mDecodedY2 < mHeight) {
validHeight = mDecodedY2 - mDecodedY1;
partial = PR_TRUE;
}
if (mDecodedX2 < mWidth) {
validWidth = mDecodedX2 - mDecodedX1;
partial = PR_TRUE;
}
if (mDecodedY1 > 0) {
validHeight -= mDecodedY1;
validY = mDecodedY1;
partial = PR_TRUE;
}
if (mDecodedX1 > 0) {
validWidth -= mDecodedX1;
validX = mDecodedX1;
partial = PR_TRUE;
}
XlibRgbHandle *drawingXHandle;
drawing->GetXlibRgbHandle(drawingXHandle);
if (partial ||
(xxlib_rgb_get_depth(drawingXHandle) == 8) ||
((mAlphaDepth == 8) && mAlphaValid)) {
PRInt32 aY0 = aTileRect.y,
aX0 = aTileRect.x,
aY1 = aTileRect.y + aTileRect.height,
aX1 = aTileRect.x + aTileRect.width;
for (PRInt32 y = aY0; y < aY1; y+=aSrcRect.height)
for (PRInt32 x = aX0; x < aX1; x+=aSrcRect.width)
Draw(aContext,aSurface,x,y,
PR_MIN(aSrcRect.width, aX1-x),
PR_MIN(aSrcRect.height, aY1-y));
return NS_OK;
}
/* draw the tile offscreen */
CreateOffscreenPixmap(mWidth, mHeight);
if (mAlphaDepth == 1) {
Pixmap tileImg;
Pixmap tileMask;
CreateAlphaBitmap(validWidth, validHeight);
nsRect tmpRect(0,0,aTileRect.width, aTileRect.height);
tileImg = XCreatePixmap(mDisplay, mImagePixmap,
aTileRect.width, aTileRect.height,
mDepth);
TilePixmap(mImagePixmap, tileImg, 0, 0, tmpRect, tmpRect, PR_FALSE);
// tile alpha mask
tileMask = XCreatePixmap(mDisplay, mAlphaPixmap,
aTileRect.width, aTileRect.height, mAlphaDepth);
TilePixmap(mAlphaPixmap, tileMask, 0, 0, tmpRect, tmpRect, PR_FALSE);
GC fgc;
XGCValues values;
unsigned long valuesMask;
memset(&values, 0, sizeof(XGCValues));
values.clip_mask = tileMask;
values.clip_x_origin = aTileRect.x;
values.clip_y_origin = aTileRect.y;
valuesMask = GCClipXOrigin | GCClipYOrigin | GCClipMask;
Drawable drawable; drawing->GetDrawable(drawable);
fgc = XCreateGC(mDisplay, drawable, valuesMask, &values);
// and copy it back
XCopyArea(mDisplay, tileImg, drawable,
fgc, 0,0,
aTileRect.width, aTileRect.height,
aTileRect.x, aTileRect.y);
XFreePixmap(mDisplay, tileImg);
XFreePixmap(mDisplay, tileMask);
XFreeGC(mDisplay, fgc);
} else {
// In the non-alpha case, xlib can tile for us
nsRect clipRect;
PRBool isValid;
aContext.GetClipRect(clipRect, isValid);
Drawable drawable; drawing->GetDrawable(drawable);
TilePixmap(mImagePixmap, drawable, aTileRect.x, aTileRect.y, aTileRect, clipRect, PR_TRUE);
}
return NS_OK;
}
NS_IMETHODIMP nsImageXlib::DrawTile(nsIRenderingContext &aContext,
nsDrawingSurface aSurface,
PRInt32 aSXOffset, PRInt32 aSYOffset,
@ -1492,8 +1374,6 @@ NS_IMETHODIMP nsImageXlib::DrawTile(nsIRenderingContext &aContext,
return NS_OK;
if (aTileRect.width <= 0 || aTileRect.height <= 0) {
NS_ASSERTION(aTileRect.width > 0 && aTileRect.height > 0,
"You can't draw an image with a 0 width or height!");
return NS_OK;
}
@ -1527,7 +1407,11 @@ NS_IMETHODIMP nsImageXlib::DrawTile(nsIRenderingContext &aContext,
validX = mDecodedX1;
partial = PR_TRUE;
}
if (validWidth == 0 || validHeight == 0) {
return NS_OK;
}
if (partial || ((mAlphaDepth == 8) && mAlphaValid)) {
PRInt32 aY0 = aTileRect.y - aSYOffset,
aX0 = aTileRect.x - aSXOffset,

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

@ -71,11 +71,6 @@ public:
NS_IMETHOD DrawToImage(nsIImage* aDstImage, nscoord aDX, nscoord aDY,
nscoord aDWidth, nscoord aDHeight);
NS_IMETHOD DrawTile(nsIRenderingContext &aContext,
nsDrawingSurface aSurface,
nsRect &aSrcRect,
nsRect &aTileRect);
NS_IMETHOD DrawTile(nsIRenderingContext &aContext,
nsDrawingSurface aSurface,
PRInt32 aSXOffset, PRInt32 aSYOffset,

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

@ -1724,40 +1724,8 @@ NS_IMETHODIMP nsRenderingContextXp::DrawScaledImage(imgIContainer *aImage, const
dr.x, dr.y,
dr.width, dr.height);
}
// this method of DrawTile is not implemented in nsRenderingContextImpl
NS_IMETHODIMP
nsRenderingContextXp::DrawTile(nsIImage *aImage,
nscoord aSrcXOffset, nscoord aSrcYOffset,
const nsRect &aTileRect)
{
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::DrawTile()\n"));
NS_NOTREACHED("nsRenderingContextXlib::DrawTile() not yet implemented");
return NS_OK;
}
#endif /* USE_XPRINT */
NS_IMETHODIMP
nsRenderingContextXlib::DrawTile(nsIImage *aImage,
nscoord aSrcXOffset, nscoord aSrcYOffset,
const nsRect &aTileRect)
{
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::DrawTile()\n"));
nsRect tileRect(aTileRect);
nsRect srcRect(0, 0, aSrcXOffset, aSrcYOffset);
mTranMatrix->TransformCoord(&srcRect.x, &srcRect.y, &srcRect.width,
&srcRect.height);
mTranMatrix->TransformCoord(&tileRect.x, &tileRect.y,
&tileRect.width, &tileRect.height);
if((tileRect.width > 0) && (tileRect.height > 0))
((nsImageXlib*)aImage)->DrawTile(*this, mRenderingSurface, srcRect.width, srcRect.height, tileRect);
return NS_OK;
}
#ifdef USE_XPRINT
NS_IMETHODIMP
nsRenderingContextXp::CopyOffScreenBits(nsDrawingSurface aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY,

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

@ -179,13 +179,6 @@ class nsRenderingContextXlib : public nsRenderingContextImpl
NS_IMETHOD DrawImage(nsIImage *aImage, const nsRect& aRect);
NS_IMETHOD DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect);
#if 0
// in nsRenderingContextImpl
NS_IMETHOD DrawTile(nsIImage *aImage,nscoord aX0,nscoord aY0,nscoord aX1,nscoord aY1,
nscoord aWidth,nscoord aHeight);
#endif
NS_IMETHOD DrawTile(nsIImage *aImage,nscoord aX, nscoord aY, const nsRect&);
NS_IMETHOD CopyOffScreenBits(nsDrawingSurface aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY,
const nsRect &aDestBounds, PRUint32 aCopyFlags);
NS_IMETHOD RetrieveCurrentNativeGraphicData(PRUint32 * ngd);
@ -296,7 +289,6 @@ class nsRenderingContextXp : public nsRenderingContextXlib
NS_IMETHOD DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect);
NS_IMETHOD DrawImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsPoint * aDestPoint);
NS_IMETHOD DrawScaledImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsRect * aDestRect);
NS_IMETHOD DrawTile(nsIImage *aImage,nscoord aX, nscoord aY, const nsRect&);
NS_IMETHOD CopyOffScreenBits(nsDrawingSurface aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY,
const nsRect &aDestBounds, PRUint32 aCopyFlags);