Bug 150881 - rendering artifacts painting scaled alpha composited

images on gtk+ and win32.  r=pavlov, sr=bryner, a=asa
This commit is contained in:
tor%cs.brown.edu 2003-11-23 15:23:52 +00:00
Родитель 0b1339f7cf
Коммит cb0625606f
9 изменённых файлов: 274 добавлений и 181 удалений

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

@ -108,7 +108,7 @@ CPPSRCS += \
$(NULL)
endif
ifneq (,$(filter gtk gtk2 xlib beos,$(MOZ_WIDGET_TOOLKIT)))
ifneq (,$(filter gtk gtk2 xlib beos windows,$(MOZ_WIDGET_TOOLKIT)))
CPPSRCS += imgScaler.cpp
endif

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

@ -475,8 +475,9 @@ NS_IMETHODIMP nsImageBeOS::DrawToImage(nsIImage *aDstImage, nscoord aDX, nscoord
scaledImage = (PRUint8 *)nsMemory::Alloc(3 * aDWidth * aDHeight);
if (!scaledImage) return NS_ERROR_OUT_OF_MEMORY;
RectStretch(0, 0, mWidth - 1, mHeight - 1, 0, 0, aDWidth - 1, aDHeight - 1,
mImageBits, mRowBytes, scaledImage, 3 * aDWidth, 24);
RectStretch(mWidth, mHeight, aDWidth, aDHeight,
0, 0, aDWidth-1, aDHeight-1,
mImageBits, mRowBytes, scaledImage, 3 * aDWidth, 24);
if (mAlphaDepth) {
if (mAlphaDepth == 1) {
@ -492,8 +493,9 @@ NS_IMETHODIMP nsImageBeOS::DrawToImage(nsIImage *aDstImage, nscoord aDX, nscoord
return NS_ERROR_OUT_OF_MEMORY;
}
RectStretch(0, 0, mWidth - 1, mHeight - 1, 0, 0, aDWidth - 1, aDHeight - 1,
mAlphaBits, mAlphaRowBytes, scaledAlpha, alphaStride, mAlphaDepth);
RectStretch(mWidth, mHeight, aDWidth, aDHeight,
aDWidth-1, aDHeight-1,
mAlphaBits, mAlphaRowBytes, scaledAlpha, alphaStride, mAlphaDepth);
}
rgbPtr = scaledImage;
rgbStride = 3 * aDWidth;

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

@ -465,8 +465,8 @@ XlibRectStretch(PRInt32 srcWidth, PRInt32 srcHeight,
xd2 = dstWidth-1;
yd2 = dstHeight-1;
// fprintf(stderr, "%p (%ld %ld)-(%ld %ld) (%ld %ld)-(%ld %ld)\n",
// aDstImage, xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2);
// fprintf(stderr, "XRS %p (%ld %ld)-(%ld %ld) (%ld %ld)-(%ld %ld)\n",
// (void *)aDstImage, xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2);
startColumn = aDX-dstOrigX;
startRow = aDY-dstOrigY;
@ -733,7 +733,8 @@ nsImageGTK::Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface,
if (!scaledRGB)
return NS_ERROR_OUT_OF_MEMORY;
RectStretch(0, 0, mWidth-1, mHeight-1,
RectStretch(mWidth, mHeight,
dstWidth, dstHeight,
0, 0, dstWidth-1, dstHeight-1,
mImageBits, mRowBytes, scaledRGB, 3*dstWidth, 24);
@ -801,7 +802,8 @@ nsImageGTK::Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface,
if (gdk_rgb_get_visual()->depth <= 8) {
PRUint8 *scaledRGB = (PRUint8 *)nsMemory::Alloc(3*dstWidth*dstHeight);
RectStretch(0, 0, mWidth-1, mHeight-1,
RectStretch(mWidth, mHeight,
dstWidth, dstHeight,
0, 0, dstWidth-1, dstHeight-1,
mImageBits, mRowBytes, scaledRGB, 3*dstWidth, 24);
@ -1245,10 +1247,10 @@ nsImageGTK::DrawComposited(nsIRenderingContext &aContext,
readWidth = aDWidth;
readHeight = aDHeight;
// 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, "dstOrigX=%d dstOrigY=%d, dstWidth=%u dstHeight=%u\n", dstOrigX, dstOrigY, dstWidth, dstHeight);
// fprintf(stderr, "srcWidth=%u srcHeight=%u\n", srcWidth, srcHeight);
// 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,
@ -1283,11 +1285,15 @@ nsImageGTK::DrawComposited(nsIRenderingContext &aContext,
nsMemory::Free(scaledAlpha);
return;
}
RectStretch(x1, y1, x2-1, y2-1,
0, 0, readWidth-1, readHeight-1,
RectStretch(srcWidth, srcHeight,
dstWidth, dstHeight,
destX, destY,
destX+aDWidth-1, destY+aDHeight-1,
mImageBits, mRowBytes, scaledImage, 3*readWidth, 24);
RectStretch(x1, y1, x2-1, y2-1,
0, 0, readWidth-1, readHeight-1,
RectStretch(srcWidth, srcHeight,
dstWidth, dstHeight,
destX, destY,
destX+aDWidth-1, destY+aDHeight-1,
mAlphaBits, mAlphaRowBytes, scaledAlpha, readWidth, 8);
imageOrigin = scaledImage;
imageStride = 3*readWidth;

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

@ -35,23 +35,26 @@ Fast Bitmap Stretching
Tomas Mšller
*/
#define sign(x) ((x)>0 ? 1:-1)
static void
Stretch24(unsigned x1, unsigned x2, unsigned y1, unsigned y2,
unsigned yr, unsigned yw,
unsigned aStartRow, unsigned aStartColumn, unsigned aEndColumn,
unsigned char *aSrcImage, unsigned aSrcStride,
unsigned char *aDstImage, unsigned aDstStride);
void RectStretch(long xs1,long ys1,long xs2,long ys2,
long xd1,long yd1,long xd2,long yd2,
unsigned char *aSrcImage, unsigned aSrcStride,
unsigned char *aDstImage, unsigned aDstStride,
unsigned aDepth);
static void
Stretch8(unsigned x1, unsigned x2, unsigned y1, unsigned y2,
unsigned yr, unsigned yw,
unsigned aStartRow, unsigned aStartColumn, unsigned aEndColumn,
unsigned char *aSrcImage, unsigned aSrcStride,
unsigned char *aDstImage, unsigned aDstStride);
static void Stretch24(long x1,long x2,long y1,long y2,long yr,long yw,
unsigned char *aSrcImage, unsigned aSrcStride,
unsigned char *aDstImage, unsigned aDstStride);
static void Stretch8(long x1,long x2,long y1,long y2,long yr,long yw,
unsigned char *aSrcImage, unsigned aSrcStride,
unsigned char *aDstImage, unsigned aDstStride);
static void Stretch1(long x1,long x2,long y1,long y2,long yr,long yw,
unsigned char *aSrcImage, unsigned aSrcStride,
unsigned char *aDstImage, unsigned aDstStride);
static void
Stretch1(unsigned x1, unsigned x2, unsigned y1, unsigned y2,
unsigned yr, unsigned yw,
unsigned aStartRow, unsigned aStartColumn, unsigned aEndColumn,
unsigned char *aSrcImage, unsigned aSrcStride,
unsigned char *aDstImage, unsigned aDstStride);
/**********************************************************
RectStretch enlarges or diminishes a source rectangle of a bitmap to
@ -63,58 +66,78 @@ static void Stretch1(long x1,long x2,long y1,long y2,long yr,long yw,
then stretching that bitmap in y-direction.
Entry:
xs1,ys1 - first point of source rectangle
xs2,ys2 - second point of source rectangle
xd1,yd1 - first point of destination rectangle
xd2,yd2 - second point of destination rectangle
aSrcWidth, aSrcHeight - size of entire original image
aDstWidth, aDstHeight - size of entire scaled image
aStartColumn, aStartRow - upper corner of desired area (inclusive)
aEndColumn, aEndRow - bottom corner of desired area (inclusive)
unsigned char *aSrcImage, aSrcStride - start of original image data
unsigned char *aDstStride, aDstStride - start of desired area image data
unsigned aDepth - bit depth of image (24, 8, or 1)
**********************************************************/
void
RectStretch(long xs1,long ys1,long xs2,long ys2,
long xd1,long yd1,long xd2,long yd2,
NS_GFX_(void)
RectStretch(unsigned aSrcWidth, unsigned aSrcHeight,
unsigned aDstWidth, unsigned aDstHeight,
unsigned aStartColumn, unsigned aStartRow,
unsigned aEndColumn, unsigned aEndRow,
unsigned char *aSrcImage, unsigned aSrcStride,
unsigned char *aDstImage, unsigned aDstStride,
unsigned aDepth)
{
long dx,dy,e,d,dx2;
short sx,sy;
void (*Stretch)(long x1,long x2,long y1,long y2,long yr,long yw,
unsigned char *aSrcImage, unsigned aSrcStride,
unsigned char *aDstImage, unsigned aDstStride);
int e;
unsigned dx, dy;
void (*Stretch)(unsigned x1, unsigned x2, unsigned y1, unsigned y2,
unsigned yr, unsigned yw,
unsigned aStartRow, unsigned aStartColumn,
unsigned aEndColumn,
unsigned char *aSrcImage, unsigned aSrcStride,
unsigned char *aDstImage, unsigned aDstStride);
// fprintf(stderr, "(%ld %ld)-(%ld %ld) (%ld %ld)-(%ld %ld) %d %d %d\n",
// xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2,
// aSrcStride, aDstStride, aDepth);
unsigned xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2;
switch (aDepth) {
case 24:
Stretch = Stretch24;
break;
case 8:
Stretch = Stretch8;
break;
case 1:
Stretch = Stretch1;
break;
default:
return;
}
dx = abs((int)(yd2-yd1));
dy = abs((int)(ys2-ys1));
sx = sign(yd2-yd1);
sy = sign(ys2-ys1);
e = dy-dx;
dx2 = dx;
dy += 1;
if (!dx2) dx2=1;
for (d=0; d<=dx; d++) {
Stretch(xd1,xd2,xs1,xs2,ys1,yd1,aSrcImage,aSrcStride,aDstImage,aDstStride);
while (e>=0) {
ys1 += sy;
e -= dx2;
xs1 = ys1 = xd1 = yd1 = 0;
xs2 = aSrcWidth - 1;
ys2 = aSrcHeight - 1;
xd2 = aDstWidth - 1;
yd2 = aDstHeight - 1;
// fprintf(stderr, "RS (%d %d)-(%d %d) (%d %d)-(%d %d) %d %d %d\n",
// xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2,
// aSrcStride, aDstStride, aDepth);
switch (aDepth) {
case 24:
Stretch = Stretch24;
break;
case 8:
Stretch = Stretch8;
break;
case 1:
Stretch = Stretch1;
break;
default:
return;
}
dx = yd2 - yd1;
dy = ys2 - ys1;
e = dy - dx;
dy += 1;
if (!dx)
dx = 1;
for (yd1 = 0; yd1 <= aEndRow; yd1++) {
if (yd1 >= aStartRow)
Stretch(xd1, xd2, xs1, xs2, ys1, yd1,
aStartRow, aStartColumn, aEndColumn,
aSrcImage, aSrcStride, aDstImage, aDstStride);
while (e >= 0) {
ys1++;
e -= dx;
}
e += dy;
}
yd1 += sx;
e += dy;
}
}
/**********************************************************
@ -128,88 +151,98 @@ RectStretch(long xs1,long ys1,long xs2,long ys2,
yw - y-coordinate of destination line
**********************************************************/
static void
Stretch24(long x1,long x2,long y1,long y2,long yr,long yw,
Stretch24(unsigned x1, unsigned x2, unsigned y1, unsigned y2,
unsigned yr, unsigned yw,
unsigned aStartRow, unsigned aStartColumn, unsigned aEndColumn,
unsigned char *aSrcImage, unsigned aSrcStride,
unsigned char *aDstImage, unsigned aDstStride)
{
long dx,dy,e,d,dx2;
short sx,sy;
unsigned char *src, *dst;
dx = abs((int)(x2-x1));
dy = abs((int)(y2-y1));
sx = 3*sign(x2-x1);
sy = 3*sign(y2-y1);
e = dy-dx;
dx2 = dx;
dy += 1;
src=aSrcImage+yr*aSrcStride+3*y1;
dst=aDstImage+yw*aDstStride+3*x1;
if (!dx2) dx2=1;
for (d=0; d<=dx; d++) {
dst[0] = src[0];
dst[1] = src[1];
dst[2] = src[2];
while (e>=0) {
src += sy;
e -= dx2;
int e;
unsigned dx, dy, d;
unsigned char *src, *dst;
dx = x2 - x1;
dy = y2 - y1;
e = dy - dx;
dy += 1;
src = aSrcImage + yr * aSrcStride + 3 * y1;
dst = aDstImage + (yw - aStartRow) * aDstStride;
if (!dx)
dx = 1;
for (d = 0; d <= aEndColumn; d++) {
if (d >= aStartColumn) {
*dst++ = src[0];
*dst++ = src[1];
*dst++ = src[2];
}
while (e >= 0) {
src += 3;
e -= dx;
}
e += dy;
}
dst += sx;
e += dy;
}
}
static void
Stretch8(long x1,long x2,long y1,long y2,long yr,long yw,
unsigned char *aSrcImage, unsigned aSrcStride,
unsigned char *aDstImage, unsigned aDstStride)
{
long dx,dy,e,d,dx2;
short sx,sy;
unsigned char *src, *dst;
dx = abs((int)(x2-x1));
dy = abs((int)(y2-y1));
sx = sign(x2-x1);
sy = sign(y2-y1);
e = dy-dx;
dx2 = dx;
dy += 1;
src=aSrcImage+yr*aSrcStride+y1;
dst=aDstImage+yw*aDstStride+x1;
if (!dx2) dx2=1;
for (d=0; d<=dx; d++) {
*dst = *src;
while (e>=0) {
src += sy;
e -= dx2;
}
dst += sx;
e += dy;
}
}
static void
Stretch1(long x1,long x2,long y1,long y2,long yr,long yw,
Stretch8(unsigned x1, unsigned x2, unsigned y1, unsigned y2,
unsigned yr, unsigned yw,
unsigned aStartRow, unsigned aStartColumn, unsigned aEndColumn,
unsigned char *aSrcImage, unsigned aSrcStride,
unsigned char *aDstImage, unsigned aDstStride)
{
long dx,dy,e,d,dx2;
short sx,sy;
dx = abs((int)(x2-x1));
dy = abs((int)(y2-y1));
sx = sign(x2-x1);
sy = sign(y2-y1);
e = dy-dx;
dx2 = dx;
dy += 1;
if (!dx2) dx2=1;
for (d=0; d<=dx; d++) {
if (*(aSrcImage+yr*aSrcStride+(y1>>3)) & 1<<(7-y1&0x7))
*(aDstImage+yw*aDstStride+(x1>>3)) |= 1<<(7-x1&0x7);
while (e>=0) {
y1 += sy;
e -= dx2;
int e;
unsigned dx, dy, d;
unsigned char *src, *dst;
dx = x2 - x1;
dy = y2 - y1;
e = dy - dx;
dy += 1;
src = aSrcImage + yr * aSrcStride + y1;
dst = aDstImage + (yw - aStartRow) * aDstStride;
if (!dx)
dx = 1;
for (d = 0; d <= aEndColumn; d++) {
if (d >= aStartColumn) {
*dst = *src;
dst++;
}
while (e >= 0) {
src++;
e -= dx;
}
e += dy;
}
}
static void
Stretch1(unsigned x1, unsigned x2, unsigned y1, unsigned y2,
unsigned yr, unsigned yw,
unsigned aStartRow, unsigned aStartColumn, unsigned aEndColumn,
unsigned char *aSrcImage, unsigned aSrcStride,
unsigned char *aDstImage, unsigned aDstStride)
{
int e;
unsigned dx, dy, d;
dx = x2 - x1;
dy = y2 - y1;
e = dy - dx;
dy += 1;
if (!dx)
dx = 1;
for (d = 0; d <= aEndColumn; d++) {
if ((d >= aStartColumn) &&
(*(aSrcImage + yr * aSrcStride + (y1 >> 3)) & 1 << (7 - y1 & 0x7)))
*(aDstImage +
(yw - aStartRow) * aDstStride +
((x1 - aStartColumn) >> 3))
|= 1 << (7 - x1 & 0x7);
while (e >= 0) {
y1++;
e -= dx;
}
x1++;
e += dy;
}
x1 += sx;
e += dy;
}
}

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

@ -20,8 +20,13 @@
* Tim Rowley <tor@cs.brown.edu>
*/
void RectStretch(long xs1,long ys1,long xs2,long ys2,
long xd1,long yd1,long xd2,long yd2,
unsigned char *aSrcImage, unsigned aSrcStride,
unsigned char *aDstImage, unsigned aDstStride,
unsigned aDepth);
#include "nsComObsolete.h"
NS_GFX_(void)
RectStretch(unsigned aSrcWidth, unsigned aSrcHeight,
unsigned aDstWidth, unsigned aDstHeight,
unsigned aStartColumn, unsigned aStartRow,
unsigned aEndColumn, unsigned aEndRowe,
unsigned char *aSrcImage, unsigned aSrcStride,
unsigned char *aDstImage, unsigned aDstStride,
unsigned aDepth);

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

@ -41,6 +41,7 @@
#include "nsImageWin.h"
#include "nsRenderingContextWin.h"
#include "nsDeviceContextWin.h"
#include "imgScaler.h"
static nsresult BuildDIB(LPBITMAPINFOHEADER *aBHead, PRInt32 aWidth,
PRInt32 aHeight, PRInt32 aDepth, PRInt8 *aNumBitPix);
@ -636,14 +637,16 @@ nsImageWin::Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface,
* This is a helper routine to do the blending for the DrawComposited method
* @update 1/04/02 dwc
*/
void nsImageWin::DrawComposited24(unsigned char *aBits, int aX, int aY, int aWidth, int aHeight)
void nsImageWin::DrawComposited24(unsigned char *aBits,
PRUint8 *aImageRGB, PRUint32 aStrideRGB,
PRUint8 *aImageAlpha, PRUint32 aStrideAlpha,
int aWidth, int aHeight)
{
PRInt32 targetRowBytes = ((aWidth * 3) + 3) & ~3;
for (int y = 0; y < aHeight; y++) {
unsigned char *targetRow = aBits + y * targetRowBytes;
unsigned char *imageRow = mImageBits + (y + aY) * mRowBytes + 3 * aX;
unsigned char *alphaRow = mAlphaBits + (y + aY) * mARowBytes + aX;
unsigned char *imageRow = aImageRGB + y * aStrideRGB;
unsigned char *alphaRow = aImageAlpha + y * aStrideAlpha;
for (int x = 0; x < aWidth;
x++, targetRow += 3, imageRow += 3, alphaRow++) {
@ -660,14 +663,15 @@ void nsImageWin::DrawComposited24(unsigned char *aBits, int aX, int aY, int aWid
* Blend the image into a 24 bit buffer.. using an 8 bit alpha mask
* @update 1/04/02 dwc
*/
nsresult nsImageWin::DrawComposited(HDC TheHDC, int aDX, int aDY, int aDWidth, int aDHeight,
int aSX, int aSY, int aSWidth, int aSHeight)
nsresult nsImageWin::DrawComposited(HDC TheHDC, int aDX, int aDY,
int aDWidth, int aDHeight,
int aSX, int aSY, int aSWidth, int aSHeight)
{
HDC memDC = ::CreateCompatibleDC(TheHDC);
if (!memDC)
return NS_ERROR_OUT_OF_MEMORY;
unsigned char *screenBits;
ALPHA24BITMAPINFO bmi(aSWidth, aSHeight);
ALPHA24BITMAPINFO bmi(aDWidth, aDHeight);
HBITMAP tmpBitmap = ::CreateDIBSection(memDC, (LPBITMAPINFO)&bmi, DIB_RGB_COLORS,
(LPVOID *)&screenBits, NULL, 0);
if (!tmpBitmap) {
@ -682,10 +686,9 @@ nsresult nsImageWin::DrawComposited(HDC TheHDC, int aDX, int aDY, int aDWidth, i
return NS_ERROR_OUT_OF_MEMORY;
}
/* Copy from the HDC */
BOOL retval = ::StretchBlt(memDC, 0, 0, aSWidth, aSHeight,
TheHDC, aDX, aDY, aDWidth, aDHeight, SRCCOPY);
BOOL retval = ::BitBlt(memDC, 0, 0, aDWidth, aDHeight,
TheHDC, aDX, aDY, SRCCOPY);
if (!retval) {
/* select the old object again... */
::SelectObject(memDC, oldBitmap);
@ -694,13 +697,53 @@ nsresult nsImageWin::DrawComposited(HDC TheHDC, int aDX, int aDY, int aDWidth, i
return NS_ERROR_FAILURE;
}
/* Do composite */
DrawComposited24(screenBits, aSX, aSY, aSWidth, aSHeight);
PRUint8 *imageRGB, *imageAlpha;
PRUint32 strideRGB, strideAlpha;
/* Both scaled and unscaled images come through this code - save
work if not scaling */
if ((aSWidth != aDWidth) || (aSHeight != aDHeight)) {
/* Scale our image to match */
imageRGB = (PRUint8 *)nsMemory::Alloc(3*aDWidth*aDHeight);
imageAlpha = (PRUint8 *)nsMemory::Alloc(aDWidth*aDHeight);
if (!imageRGB || !imageAlpha) {
if (imageRGB)
nsMemory::Free(imageRGB);
if (imageAlpha)
nsMemory::Free(imageAlpha);
::SelectObject(memDC, oldBitmap);
::DeleteObject(tmpBitmap);
::DeleteDC(memDC);
return NS_ERROR_FAILURE;
}
strideRGB = 3 * aDWidth;
strideAlpha = aDWidth;
RectStretch(aSWidth, aSHeight, aDWidth, aDHeight, 0, 0, aDWidth-1, aDHeight-1,
mImageBits, mRowBytes, imageRGB, strideRGB, 24);
RectStretch(aSWidth, aSHeight, aDWidth, aDHeight, 0, 0, aDWidth-1, aDHeight-1,
mAlphaBits, mARowBytes, imageAlpha, strideAlpha, 8);
} else {
imageRGB = mImageBits + aSY * mRowBytes + aSX * 3;
imageAlpha = mAlphaBits + aSY * mARowBytes + aSX;
strideRGB = mRowBytes;
strideAlpha = mARowBytes;
}
/* Do composite */
DrawComposited24(screenBits, imageRGB, strideRGB, imageAlpha, strideAlpha,
aDWidth, aDHeight);
if ((aSWidth != aDWidth) || (aSHeight != aDHeight)) {
/* Free scaled images */
nsMemory::Free(imageRGB);
nsMemory::Free(imageAlpha);
}
/* Copy back to the HDC */
retval = ::StretchBlt(TheHDC, aDX, aDY, aDWidth, aDHeight,
memDC, 0, 0, aSWidth, aSHeight, SRCCOPY);
retval = ::BitBlt(TheHDC, aDX, aDY, aDWidth, aDHeight,
memDC, 0, 0, SRCCOPY);
if (!retval) {
::SelectObject(memDC, oldBitmap);
::DeleteObject(tmpBitmap);

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

@ -171,7 +171,10 @@ private:
*/
void CreateDDB(nsDrawingSurface aSurface);
void DrawComposited24(unsigned char *aBits, int aX, int aY, int aWidth, int aHeight);
void DrawComposited24(unsigned char *aBits,
PRUint8 *aImageRGB, PRUint32 aStrideRGB,
PRUint8 *aImageAlpha, PRUint32 aStrideAlpha,
int aWidth, int aHeight);
nsresult DrawComposited(HDC TheHDC, int aDX, int aDY, int aDWidth, int aDHeight,
int aSX, int aSY, int aSWidth, int aSHeight);
static PRBool CanAlphaBlend(void);

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

@ -471,9 +471,9 @@ nsImageXlib::DrawScaled(nsIRenderingContext &aContext,
// creation fails for some reason. thus no easy-out "return"
if (scaledAlpha) {
memset(scaledAlpha, 0, aDHeight*scaledRowBytes);
RectStretch(aSX, aSY, aSX+aSWidth-1, aSY+aSHeight-1,
0, 0, aDWidth-1, aDHeight-1,
mAlphaBits, mAlphaRowBytes, scaledAlpha, scaledRowBytes, 1);
RectStretch(mWidth, mHeight, origDWidth, origDHeight,
aDX + aDWidth - 1, aDY + aDHeight - 1,
mAlphaBits, mAlphaRowBytes, scaledAlpha, scaledRowBytes, 1);
pixmap = XCreatePixmap(mDisplay, DefaultRootWindow(mDisplay),
aDWidth, aDHeight, 1);
@ -533,8 +533,8 @@ nsImageXlib::DrawScaled(nsIRenderingContext &aContext,
PRUint8 *scaledRGB = (PRUint8 *)nsMemory::Alloc(3*aDWidth*aDHeight);
if (scaledRGB && gc) {
RectStretch(aSX, aSY, aSX+aSWidth-1, aSY+aSHeight-1,
0, 0, aDWidth-1, aDHeight-1,
RectStretch(mWidth, mHeight, origDWidth, origDHeight,
aDX + aDWidth - 1, aDY + aDHeight - 1,
mImageBits, mRowBytes, scaledRGB, 3*aDWidth, 24);
Drawable drawable; drawing->GetDrawable(drawable);
@ -1046,11 +1046,11 @@ nsImageXlib::DrawComposited(nsIRenderingContext &aContext,
nsMemory::Free(scaledAlpha);
return;
}
RectStretch(x1, y1, x2-1, y2-1,
0, 0, readWidth-1, readHeight-1,
RectStretch(aSWidth, aSHeight, aDWidth, aDHeight,
0, 0, aDWidth-1, aDHeight-1,
mImageBits, mRowBytes, scaledImage, 3*readWidth, 24);
RectStretch(x1, y1, x2-1, y2-1,
0, 0, readWidth-1, readHeight-1,
0, 0, aDWidth-1, aDHeight-1,
mAlphaBits, mAlphaRowBytes, scaledAlpha, readWidth, 8);
imageOrigin = scaledImage;
imageStride = 3*readWidth;
@ -1536,7 +1536,7 @@ NS_IMETHODIMP nsImageXlib::DrawToImage(nsIImage* aDstImage,
if (!scaledImage)
return NS_ERROR_OUT_OF_MEMORY;
RectStretch(0, 0, mWidth-1, mHeight-1, 0, 0, aDWidth-1, aDHeight-1,
RectStretch(mWidth, mHeight, aDWidth, aDHeight, aDWidth-1, aDHeight-1,
mImageBits, mRowBytes, scaledImage, 3*aDWidth, 24);
if (mAlphaDepth) {
@ -1551,7 +1551,7 @@ NS_IMETHODIMP nsImageXlib::DrawToImage(nsIImage* aDstImage,
return NS_ERROR_OUT_OF_MEMORY;
}
RectStretch(0, 0, mWidth-1, mHeight-1, 0, 0, aDWidth-1, aDHeight-1,
RectStretch(mWidth, mHeight, aDWidth, aDHeight, aDWidth-1, aDHeight-1,
mAlphaBits, mAlphaRowBytes, scaledAlpha, alphaStride,
mAlphaDepth);
}

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

@ -1166,8 +1166,9 @@ nsXPrintContext::DrawImageBitsScaled(xGC *xgc, nsIImage *aImage,
return NS_ERROR_FAILURE;
}
RectStretch(aSX, aSY, aSX+aSWidth-1, aSY+aSHeight-1,
0, 0, (aDWidth-1), (aDHeight-1),
RectStretch(aSWidth, aSHeight,
aDWidth, aDHeight,
0, 0, aDWidth-1, aDHeight-1,
srcimg_data, srcimg_bytes_per_line,
dstimg_data, dstimg_bytes_per_line,
imageDepth);