From d51c3a6fa18e09991f2be77896135510b15947ce Mon Sep 17 00:00:00 2001 From: "pavlov%netscape.com" Date: Sat, 10 Mar 2001 03:39:13 +0000 Subject: [PATCH] gfx to new branch git-svn-id: svn://10.0.0.236/branches/IMGLIB2_20010309_BRANCH@89214 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/gfx/public/nsIRenderingContext.h | 22 +++ mozilla/gfx/public/nsRenderingContextImpl.h | 9 +- mozilla/gfx/src/gtk/nsRenderingContextGTK.cpp | 63 ++++++++ mozilla/gfx/src/gtk/nsRenderingContextGTK.h | 7 + mozilla/gfx/src/mac/nsRenderingContextMac.cpp | 149 ++++++++++++++++++ mozilla/gfx/src/mac/nsRenderingContextMac.h | 7 + mozilla/gfx/src/nsRenderingContextImpl.cpp | 30 +++- .../gfx/src/shared/nsRenderingContextImpl.cpp | 30 +++- .../gfx/src/windows/nsRenderingContextWin.cpp | 71 +++++++++ .../gfx/src/windows/nsRenderingContextWin.h | 7 + 10 files changed, 390 insertions(+), 5 deletions(-) diff --git a/mozilla/gfx/public/nsIRenderingContext.h b/mozilla/gfx/public/nsIRenderingContext.h index 6766b172746..b8751af61d1 100644 --- a/mozilla/gfx/public/nsIRenderingContext.h +++ b/mozilla/gfx/public/nsIRenderingContext.h @@ -44,6 +44,13 @@ struct nsRect; struct nsBoundingMetrics; #endif + +#ifdef USE_IMG2 +/* gfx2 */ +#include "gfxtypes.h" +class imgIContainer; +#endif + //cliprect/region combination methods typedef enum @@ -756,6 +763,21 @@ public: nsBoundingMetrics& aBoundingMetrics, PRInt32* aFontID = nsnull) = 0; #endif + + +#ifdef USE_IMG2 + /* [noscript] void drawImage (in imgIContainer aImage, [const] in nsRect aSrcRect, [const] in nsPoint aDestPoint); */ + NS_IMETHOD DrawImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsPoint * aDestPoint) = 0; + + /* [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; + + /* [noscript] void drawScaledTile (in imgIContainer aImage, in nscoord aXOffset, in nscoord aYOffset, in nscoord aTileWidth, in nscoord aTileHeight, [const] in nsRect aTargetRect); */ + NS_IMETHOD DrawScaledTile(imgIContainer *aImage, nscoord aXOffset, nscoord aYOffset, nscoord aTileWidth, nscoord aTileHeight, const nsRect * aTargetRect) = 0; +#endif }; //modifiers for text rendering diff --git a/mozilla/gfx/public/nsRenderingContextImpl.h b/mozilla/gfx/public/nsRenderingContextImpl.h index 7fe06e36ff2..2985e9e13b7 100644 --- a/mozilla/gfx/public/nsRenderingContextImpl.h +++ b/mozilla/gfx/public/nsRenderingContextImpl.h @@ -79,7 +79,6 @@ public: */ NS_IMETHOD RasterPolygon(const nsPoint aPoints[], PRInt32 aNumPoints); - /** --------------------------------------------------- * See documentation in nsIRenderingContext.h * @update 05/01/00 dwc @@ -92,6 +91,14 @@ public: */ NS_IMETHOD FillStdPolygon(const nsPoint aPoints[], PRInt32 aNumPoints) { return NS_OK; } +#ifdef USE_IMG2 + 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(imgIContainer *aImage, nscoord aXOffset, nscoord aYOffset, const nsRect * aTargetRect); + NS_IMETHOD DrawScaledTile(imgIContainer *aImage, nscoord aXOffset, nscoord aYOffset, nscoord aTileWidth, nscoord aTileHeight, const nsRect * aTargetRect); +#endif + + protected: virtual ~nsRenderingContextImpl(); diff --git a/mozilla/gfx/src/gtk/nsRenderingContextGTK.cpp b/mozilla/gfx/src/gtk/nsRenderingContextGTK.cpp index 1ba8b55823e..fbacc16bd49 100644 --- a/mozilla/gfx/src/gtk/nsRenderingContextGTK.cpp +++ b/mozilla/gfx/src/gtk/nsRenderingContextGTK.cpp @@ -1986,3 +1986,66 @@ nsRenderingContextGTK::my_gdk_draw_text (GdkDrawable *drawable, else g_error("undefined font type\n"); } + + +#ifdef USE_IMG2 + +#include "gfxIImageContainer.h" +#include "nsPIImageContainerGtk.h" + +/* [noscript] void drawImage (in gfxIImageContainer aImage, [const] in nsRect aSrcRect, [const] in nsPoint aDestPoint); */ +NS_IMETHODIMP nsRenderingContextGTK::DrawImage(gfxIImageContainer *aImage, const nsRect * aSrcRect, const nsPoint * aDestPoint) +{ + nsPoint pt; + nsRect sr; + + pt = *aDestPoint; + mTranMatrix->TransformCoord(&pt.x, &pt.y); + + sr = *aSrcRect; + mTranMatrix->TransformCoord(&sr.x, &sr.y, &sr.width, &sr.height); + + sr.x = aSrcRect->x; + sr.y = aSrcRect->y; + mTranMatrix->TransformNoXLateCoord(&sr.x, &sr.y); + + nsCOMPtr cx(do_QueryInterface(aImage)); + if (!cx) return NS_ERROR_FAILURE; + + return cx->DrawImage(mSurface->GetDrawable(), NS_CONST_CAST(const GdkGC *, mGC), &sr, &pt); +} + +/* [noscript] void drawScaledImage (in gfxIImageContainer aImage, [const] in nsRect aSrcRect, [const] in nsRect aDestRect); */ +NS_IMETHODIMP nsRenderingContextGTK::DrawScaledImage(gfxIImageContainer *aImage, const nsRect * aSrcRect, const nsRect * aDestRect) +{ + nsRect dr; + nsRect sr; + + dr = *aDestRect; + mTranMatrix->TransformCoord(&dr.x, &dr.y, &dr.width, &dr.height); + + sr = *aSrcRect; + mTranMatrix->TransformCoord(&sr.x, &sr.y, &sr.width, &sr.height); + + sr.x = aSrcRect->x; + sr.y = aSrcRect->y; + mTranMatrix->TransformNoXLateCoord(&sr.x, &sr.y); + + nsCOMPtr cg(do_QueryInterface(aImage)); + if (!cg) return NS_ERROR_FAILURE; + + return cg->DrawScaledImage(mSurface->GetDrawable(), NS_CONST_CAST(const GdkGC *, mGC), &sr, &dr); +} + +/* [noscript] void drawTile (in gfxIImageContainer aImage, in nscoord aXOffset, in nscoord aYOffset, [const] in nsRect aTargetRect); */ +NS_IMETHODIMP nsRenderingContextGTK::DrawTile(gfxIImageContainer *aImage, nscoord aXOffset, nscoord aYOffset, const nsRect * aTargetRect) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* [noscript] void drawScaledTile (in gfxIImageContainer aImage, in nscoord aXOffset, in nscoord aYOffset, in nscoord aTileWidth, in nscoord aTileHeight, [const] in nsRect aTargetRect); */ +NS_IMETHODIMP nsRenderingContextGTK::DrawScaledTile(gfxIImageContainer *aImage, nscoord aXOffset, nscoord aYOffset, nscoord aTileWidth, nscoord aTileHeight, const nsRect * aTargetRect) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} +#endif \ No newline at end of file diff --git a/mozilla/gfx/src/gtk/nsRenderingContextGTK.h b/mozilla/gfx/src/gtk/nsRenderingContextGTK.h index c9ada06dc00..917dcb27aaf 100644 --- a/mozilla/gfx/src/gtk/nsRenderingContextGTK.h +++ b/mozilla/gfx/src/gtk/nsRenderingContextGTK.h @@ -173,6 +173,13 @@ public: const nsRect &aDestBounds, PRUint32 aCopyFlags); NS_IMETHOD RetrieveCurrentNativeGraphicData(PRUint32 * ngd); +#ifdef USE_IMG2 + NS_IMETHOD DrawImage(gfxIImageContainer *aImage, const nsRect * aSrcRect, const nsPoint * aDestPoint); + NS_IMETHOD DrawScaledImage(gfxIImageContainer *aImage, const nsRect * aSrcRect, const nsRect * aDestRect); + NS_IMETHOD DrawTile(gfxIImageContainer *aImage, nscoord aXOffset, nscoord aYOffset, const nsRect * aTargetRect); + NS_IMETHOD DrawScaledTile(gfxIImageContainer *aImage, nscoord aXOffset, nscoord aYOffset, nscoord aTileWidth, nscoord aTileHeight, const nsRect * aTargetRect); +#endif + #ifdef MOZ_MATHML /** * Returns metrics (in app units) of an 8-bit character string diff --git a/mozilla/gfx/src/mac/nsRenderingContextMac.cpp b/mozilla/gfx/src/mac/nsRenderingContextMac.cpp index db02cf64932..18ab503f3a0 100644 --- a/mozilla/gfx/src/mac/nsRenderingContextMac.cpp +++ b/mozilla/gfx/src/mac/nsRenderingContextMac.cpp @@ -23,6 +23,7 @@ #include "nsRenderingContextMac.h" +#include "nsImageMac.h" #include "nsDeviceContextMac.h" #include "nsFontMetricsMac.h" #include "nsIRegion.h" @@ -1482,3 +1483,151 @@ nsRenderingContextMac::GetBoundingMetrics(const PRUnichar* aString, } #endif /* MOZ_MATHML */ + + +#ifdef USE_IMG2 + +#include "gfxIImageContainer.h" +#include "nsIImageFrame.h" + +/* [noscript] void drawImage (in gfxIImageContainer aImage, [const] in nsRect aSrcRect, [const] in nsPoint aDestPoint); */ +NS_IMETHODIMP nsRenderingContextMac::DrawImage(gfxIImageContainer *aImage, const nsRect * aSrcRect, const nsPoint * aDestPoint) +{ + + // XXX there are some rounding problems in this code (or in the image frame) + + nsresult rv; + + nsCOMPtr img; + rv = aImage->GetCurrentFrame(getter_AddRefs(img)); + + if (NS_FAILED(rv)) + return rv; + + + // XXX this is ugly. + nsPoint pt; + nsRect sr; + + pt = *aDestPoint; + mTranMatrix->TransformCoord(&pt.x, &pt.y); + + sr = *aSrcRect; + mTranMatrix->TransformCoord(&sr.x, &sr.y, &sr.width, &sr.height); + + sr.x = aSrcRect->x; + sr.y = aSrcRect->y; + mTranMatrix->TransformNoXLateCoord(&sr.x, &sr.y); + + PRUint32 len; + PRUint8 *bits; + rv = img->GetImageData(&bits, &len); + if (NS_FAILED(rv)) + return rv; + + PRUint32 bpr; + img->GetImageBytesPerRow(&bpr); + + PRInt32 height; + img->GetHeight(&height); + + PRInt32 width; + img->GetWidth(&width); + +// void* oldThing = ::SelectObject(mDC, memBM); + +// mBHead->biHeight = -mBHead->biHeight; + + /*::StretchDIBits(mDC, PRInt32(pt.x + sr.x), PRInt32(pt.y + sr.y), width, height, + GFXCoordToIntFloor(sr.x), 0, width, height, + bits + (GFXCoordToIntFloor(sr.y) * bpr), + (LPBITMAPINFO)mBHead, DIB_RGB_COLORS, SRCAND); + */ + + + PixMap imagePixmap; + Handle imageBitsHandle = nsnull; + PixMap maskPixmap; // the alpha level pixel map + Handle maskBitsHandle = nsnull; // handle for the mask bits + nsImageMac::CreatePixMap(width, height, 24, nsnull, imagePixmap, imageBitsHandle); + // lock and set up bits handles + StHandleLocker imageBitsLocker(imageBitsHandle); + StHandleLocker maskBitsLocker(maskBitsHandle); // ok with nil handle + + imagePixmap.baseAddr = (char*) bits; + if (maskBitsHandle) + maskPixmap.baseAddr = *maskBitsHandle; + + imagePixmap.rowBytes = bpr | 0x8000; + + // make sure the current port is correct. where else does this need to be done? + StPortSetter setter(mPort); + + // set the right colors for CopyBits + RGBColor foreColor; + Boolean changedForeColor = false; + ::GetForeColor(&foreColor); + if ((foreColor.red != 0x0000) || (foreColor.green != 0x0000) || (foreColor.blue != 0x0000)) { + RGBColor rgbBlack = {0x0000,0x0000,0x0000}; + ::RGBForeColor(&rgbBlack); + changedForeColor = true; + } + + RGBColor backColor; + Boolean changedBackColor = false; + ::GetBackColor(&backColor); + if ((backColor.red != 0xFFFF) || (backColor.green != 0xFFFF) || (backColor.blue != 0xFFFF)) { + RGBColor rgbWhite = {0xFFFF,0xFFFF,0xFFFF}; + ::RGBBackColor(&rgbWhite); + changedBackColor = true; + } + + Rect macSrcRect; + Rect macDstRect; + ::SetRect(&macSrcRect, 0, 0, width, height); + ::SetRect(&macDstRect, pt.x, pt.y, pt.x + width, pt.y + height); + + //PixMapHandle destPixels = GetGWorldPixMap(mPort); + + // copy the bits now + ::CopyBits( +#if TARGET_CARBON + ::GetPortBitMapForCopyBits(srcPort), + ::GetPortBitMapForCopyBits(mPort), +#else + (BitMap*)&imagePixmap, + &mPort->portBits, +#endif + &macSrcRect, + &macDstRect, + srcCopy, + 0L); + + // restore colors and surface + if (changedForeColor) + ::RGBForeColor(&foreColor); + if (changedBackColor) + ::RGBBackColor(&backColor); + + return NS_OK; +} + +/* [noscript] void drawScaledImage (in gfxIImageContainer aImage, [const] in nsRect2 aSrcRect, [const] in nsRect2 aDestRect); */ +NS_IMETHODIMP nsRenderingContextMac::DrawScaledImage(gfxIImageContainer *aImage, const nsRect * aSrcRect, const nsRect * aDestRect) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* [noscript] void drawTile (in gfxIImageContainer aImage, in nscoord aXOffset, in nscoord aYOffset, [const] in nsRect2 aTargetRect); */ +NS_IMETHODIMP nsRenderingContextMac::DrawTile(gfxIImageContainer *aImage, nscoord aXOffset, nscoord aYOffset, const nsRect * aTargetRect) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* [noscript] void drawScaledTile (in gfxIImageContainer aImage, in nscoord aXOffset, in nscoord aYOffset, in nscoord aTileWidth, in nscoord aTileHeight, [const] in nsRect2 aTargetRect); */ +NS_IMETHODIMP nsRenderingContextMac::DrawScaledTile(gfxIImageContainer *aImage, nscoord aXOffset, nscoord aYOffset, nscoord aTileWidth, nscoord aTileHeight, const nsRect * aTargetRect) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +#endif \ No newline at end of file diff --git a/mozilla/gfx/src/mac/nsRenderingContextMac.h b/mozilla/gfx/src/mac/nsRenderingContextMac.h index a68c755af74..a9634620f96 100644 --- a/mozilla/gfx/src/mac/nsRenderingContextMac.h +++ b/mozilla/gfx/src/mac/nsRenderingContextMac.h @@ -151,6 +151,13 @@ public: PRInt32* aFontID); #endif /* MOZ_MATHML */ +#ifdef USE_IMG2 + NS_IMETHOD DrawImage(gfxIImageContainer *aImage, const nsRect * aSrcRect, const nsPoint * aDestPoint); + NS_IMETHOD DrawScaledImage(gfxIImageContainer *aImage, const nsRect * aSrcRect, const nsRect * aDestRect); + NS_IMETHOD DrawTile(gfxIImageContainer *aImage, nscoord aXOffset, nscoord aYOffset, const nsRect * aTargetRect); + NS_IMETHOD DrawScaledTile(gfxIImageContainer *aImage, nscoord aXOffset, nscoord aYOffset, nscoord aTileWidth, nscoord aTileHeight, const nsRect * aTargetRect); +#endif + //locals NS_IMETHOD SetPortTextState(); nsresult Init(nsIDeviceContext* aContext, GrafPtr aPort); diff --git a/mozilla/gfx/src/nsRenderingContextImpl.cpp b/mozilla/gfx/src/nsRenderingContextImpl.cpp index 65e3f7c4a45..8ef7d78f9ac 100644 --- a/mozilla/gfx/src/nsRenderingContextImpl.cpp +++ b/mozilla/gfx/src/nsRenderingContextImpl.cpp @@ -115,7 +115,7 @@ nsTransform2D *theTransform; // copy the initial image to our buffer, this takes twips and converts to pixels.. // which is what the image is in - this->DrawImage(aImage,0,0,aWidth,aHeight); + NS_STATIC_CAST(nsIRenderingContext*, this)->DrawImage(aImage,0,0,aWidth,aHeight); // duplicate the image in the upperleft corner to fill up the nsDrawingSurface srcRect.SetRect(0,0,aWidth,aHeight); @@ -143,7 +143,7 @@ nsTransform2D *theTransform; // slow blitting, one tile at a time.... ( will create a mask and fall into code below -next task-) for(y=aY0;yDrawImage(aImage,x,y,aWidth,aHeight); + NS_STATIC_CAST(nsIRenderingContext*, this)->DrawImage(aImage,x,y,aWidth,aHeight); } } } @@ -663,3 +663,29 @@ float avx,avy,av1x,av1y; return result; } + +#ifdef USE_IMG2 +/* [noscript] void drawImage (in imgIContainer aImage, [const] in nsRect aSrcRect, [const] in nsPoint aDestPoint); */ +NS_IMETHODIMP nsRenderingContextImpl::DrawImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsPoint * aDestPoint) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* [noscript] void drawScaledImage (in imgIContainer aImage, [const] in nsRect aSrcRect, [const] in nsRect aDestRect); */ +NS_IMETHODIMP nsRenderingContextImpl::DrawScaledImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsRect * aDestRect) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* [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) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* [noscript] void drawScaledTile (in imgIContainer aImage, in nscoord aXOffset, in nscoord aYOffset, in nscoord aTileWidth, in nscoord aTileHeight, [const] in nsRect aTargetRect); */ +NS_IMETHODIMP nsRenderingContextImpl::DrawScaledTile(imgIContainer *aImage, nscoord aXOffset, nscoord aYOffset, nscoord aTileWidth, nscoord aTileHeight, const nsRect * aTargetRect) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} +#endif \ No newline at end of file diff --git a/mozilla/gfx/src/shared/nsRenderingContextImpl.cpp b/mozilla/gfx/src/shared/nsRenderingContextImpl.cpp index 65e3f7c4a45..8ef7d78f9ac 100644 --- a/mozilla/gfx/src/shared/nsRenderingContextImpl.cpp +++ b/mozilla/gfx/src/shared/nsRenderingContextImpl.cpp @@ -115,7 +115,7 @@ nsTransform2D *theTransform; // copy the initial image to our buffer, this takes twips and converts to pixels.. // which is what the image is in - this->DrawImage(aImage,0,0,aWidth,aHeight); + NS_STATIC_CAST(nsIRenderingContext*, this)->DrawImage(aImage,0,0,aWidth,aHeight); // duplicate the image in the upperleft corner to fill up the nsDrawingSurface srcRect.SetRect(0,0,aWidth,aHeight); @@ -143,7 +143,7 @@ nsTransform2D *theTransform; // slow blitting, one tile at a time.... ( will create a mask and fall into code below -next task-) for(y=aY0;yDrawImage(aImage,x,y,aWidth,aHeight); + NS_STATIC_CAST(nsIRenderingContext*, this)->DrawImage(aImage,x,y,aWidth,aHeight); } } } @@ -663,3 +663,29 @@ float avx,avy,av1x,av1y; return result; } + +#ifdef USE_IMG2 +/* [noscript] void drawImage (in imgIContainer aImage, [const] in nsRect aSrcRect, [const] in nsPoint aDestPoint); */ +NS_IMETHODIMP nsRenderingContextImpl::DrawImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsPoint * aDestPoint) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* [noscript] void drawScaledImage (in imgIContainer aImage, [const] in nsRect aSrcRect, [const] in nsRect aDestRect); */ +NS_IMETHODIMP nsRenderingContextImpl::DrawScaledImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsRect * aDestRect) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* [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) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* [noscript] void drawScaledTile (in imgIContainer aImage, in nscoord aXOffset, in nscoord aYOffset, in nscoord aTileWidth, in nscoord aTileHeight, [const] in nsRect aTargetRect); */ +NS_IMETHODIMP nsRenderingContextImpl::DrawScaledTile(imgIContainer *aImage, nscoord aXOffset, nscoord aYOffset, nscoord aTileWidth, nscoord aTileHeight, const nsRect * aTargetRect) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} +#endif \ No newline at end of file diff --git a/mozilla/gfx/src/windows/nsRenderingContextWin.cpp b/mozilla/gfx/src/windows/nsRenderingContextWin.cpp index 4c62c71c738..79915694b67 100644 --- a/mozilla/gfx/src/windows/nsRenderingContextWin.cpp +++ b/mozilla/gfx/src/windows/nsRenderingContextWin.cpp @@ -3785,3 +3785,74 @@ nsRenderingContextWin::ConditionRect(nsRect& aSrcRect, RECT& aDestRect) +#ifdef USE_IMG2 + +#include "imgIContainer.h" +#include "gfxIImageFrame.h" +#include "nsIInterfaceRequestor.h" + +/* [noscript] void drawImage (in imgIContainer aImage, [const] in nsRect aSrcRect, [const] in nsPoint aDestPoint); */ +NS_IMETHODIMP nsRenderingContextWin::DrawImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsPoint * aDestPoint) +{ + nsPoint pt; + nsRect sr; + + pt = *aDestPoint; + mTranMatrix->TransformCoord(&pt.x, &pt.y); + + sr = *aSrcRect; + mTranMatrix->TransformCoord(&sr.x, &sr.y, &sr.width, &sr.height); + + sr.x = aSrcRect->x; + sr.y = aSrcRect->y; + mTranMatrix->TransformNoXLateCoord(&sr.x, &sr.y); + + nsCOMPtr iframe; + aImage->GetCurrentFrame(getter_AddRefs(iframe)); + if (!iframe) return NS_ERROR_FAILURE; + + nsCOMPtr img(do_GetInterface(iframe)); + if (!img) return NS_ERROR_FAILURE; + + return img->Draw(*this, mSurface, pt.x, pt.y, sr.width, sr.height); +} + +/* [noscript] void drawScaledImage (in imgIContainer aImage, [const] in nsRect aSrcRect, [const] in nsRect aDestRect); */ +NS_IMETHODIMP nsRenderingContextWin::DrawScaledImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsRect * aDestRect) +{ + nsRect dr; + nsRect sr; + + dr = *aDestRect; + mTranMatrix->TransformCoord(&dr.x, &dr.y, &dr.width, &dr.height); + + sr = *aSrcRect; + mTranMatrix->TransformCoord(&sr.x, &sr.y, &sr.width, &sr.height); + + sr.x = aSrcRect->x; + sr.y = aSrcRect->y; + mTranMatrix->TransformNoXLateCoord(&sr.x, &sr.y); + + nsCOMPtr iframe; + aImage->GetCurrentFrame(getter_AddRefs(iframe)); + if (!iframe) return NS_ERROR_FAILURE; + + nsCOMPtr img(do_GetInterface(iframe)); + if (!img) return NS_ERROR_FAILURE; + + return img->Draw(*this, mSurface, sr.x, sr.y, sr.width, sr.height, 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 nsRenderingContextWin::DrawTile(imgIContainer *aImage, nscoord aXOffset, nscoord aYOffset, const nsRect * aTargetRect) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* [noscript] void drawScaledTile (in imgIContainer aImage, in nscoord aXOffset, in nscoord aYOffset, in nscoord aTileWidth, in nscoord aTileHeight, [const] in nsRect aTargetRect); */ +NS_IMETHODIMP nsRenderingContextWin::DrawScaledTile(imgIContainer *aImage, nscoord aXOffset, nscoord aYOffset, nscoord aTileWidth, nscoord aTileHeight, const nsRect * aTargetRect) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +#endif \ No newline at end of file diff --git a/mozilla/gfx/src/windows/nsRenderingContextWin.h b/mozilla/gfx/src/windows/nsRenderingContextWin.h index 36a555fc1ac..fca7a13f7c9 100644 --- a/mozilla/gfx/src/windows/nsRenderingContextWin.h +++ b/mozilla/gfx/src/windows/nsRenderingContextWin.h @@ -199,6 +199,13 @@ public: PRInt32* aFontID); #endif +#ifdef USE_IMG2 + 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(imgIContainer *aImage, nscoord aXOffset, nscoord aYOffset, const nsRect * aTargetRect); + NS_IMETHOD DrawScaledTile(imgIContainer *aImage, nscoord aXOffset, nscoord aYOffset, nscoord aTileWidth, nscoord aTileHeight, const nsRect * aTargetRect); +#endif + protected: void SetupFontAndColor(void);