diff --git a/mozilla/gfx/idl/gfxIImageFrame.idl b/mozilla/gfx/idl/gfxIImageFrame.idl index 357ffef4c34..90815205ec4 100644 --- a/mozilla/gfx/idl/gfxIImageFrame.idl +++ b/mozilla/gfx/idl/gfxIImageFrame.idl @@ -57,7 +57,7 @@ native nsRectRef(nsIntRect &); * @author Stuart Parmenter * @version 0.1 */ -[scriptable, uuid(f6d00ee7-defc-4101-b2dc-e72cf4c37c3c)] +[scriptable, uuid(2502c898-73bd-4da5-8fae-21cf7a492f64)] interface gfxIImageFrame : nsISupports { /** @@ -188,15 +188,6 @@ interface gfxIImageFrame : nsISupports /* GIF Specific methods. These should be in a different class or interface. */ - /** - * Blit this frame into another frame. Used for GIF animation compositing - */ - void drawTo(in gfxIImageFrame aDst, - in PRInt32 aDX, - in PRInt32 aDY, - in PRInt32 aDWidth, - in PRInt32 aDHeight); - /** * Represents the number of milliseconds until the next frame should be displayed. * @note -1 means that this frame should be displayed forever. diff --git a/mozilla/gfx/public/nsIImage.h b/mozilla/gfx/public/nsIImage.h index f1f142ade65..edde6fdb89d 100644 --- a/mozilla/gfx/public/nsIImage.h +++ b/mozilla/gfx/public/nsIImage.h @@ -204,18 +204,6 @@ public: const gfxRect &aSourceRect, const gfxRect &aDestRect) = 0; - /** - * BitBlit the entire (no cropping) nsIImage to another nsImage, the source and dest can be scaled - * @update - saari 03/08/01 - * @param aDstImage the nsImage to blit to - * @param aDX The destination horizontal location - * @param aDY The destination vertical location - * @param aDWidth The destination width of the pixelmap - * @param aDHeight The destination height of the pixelmap - * @return if TRUE, no errors - */ - NS_IMETHOD DrawToImage(nsIImage* aDstImage, PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight) = 0; - /** * Get the alpha depth for the image mask * @update - lordpixel 2001/05/16 diff --git a/mozilla/gfx/src/shared/gfxImageFrame.cpp b/mozilla/gfx/src/shared/gfxImageFrame.cpp index 5c2fd569298..53d72d1fbd4 100644 --- a/mozilla/gfx/src/shared/gfxImageFrame.cpp +++ b/mozilla/gfx/src/shared/gfxImageFrame.cpp @@ -446,21 +446,6 @@ NS_IMETHODIMP gfxImageFrame::UnlockAlphaData() return mImage->UnlockImagePixels(PR_TRUE); } - - - - -/* void drawTo */ -NS_IMETHODIMP gfxImageFrame::DrawTo(gfxIImageFrame* aDst, PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight) -{ - if (!mInitialized) - return NS_ERROR_NOT_INITIALIZED; - - nsCOMPtr img(do_GetInterface(aDst)); - return mImage->DrawToImage(img, aDX, aDY, aDWidth, aDHeight); -} - - /* attribute long timeout; */ NS_IMETHODIMP gfxImageFrame::GetTimeout(PRInt32 *aTimeout) { diff --git a/mozilla/gfx/src/thebes/nsThebesImage.cpp b/mozilla/gfx/src/thebes/nsThebesImage.cpp index 8ec3fec62f1..164ff80ddf6 100644 --- a/mozilla/gfx/src/thebes/nsThebesImage.cpp +++ b/mozilla/gfx/src/thebes/nsThebesImage.cpp @@ -562,28 +562,6 @@ nsThebesImage::ThebesDrawTile(gfxContext *thebesContext, return NS_OK; } -/* This is only used by the GIF decoder, via gfxImageFrame::DrawTo */ -NS_IMETHODIMP -nsThebesImage::DrawToImage(nsIImage* aDstImage, PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight) -{ - nsThebesImage *dstThebesImage = static_cast(aDstImage); - - nsRefPtr dst = new gfxContext(dstThebesImage->ThebesSurface()); - - dst->NewPath(); - // We don't use PixelSnappedRectangleAndSetPattern because if - // these coords aren't already pixel aligned, we've lost - // before we've even begun. - dst->Translate(gfxPoint(aDX, aDY)); - dst->Rectangle(gfxRect(0, 0, aDWidth, aDHeight), PR_TRUE); - dst->Scale(double(aDWidth)/mWidth, double(aDHeight)/mHeight); - - dst->SetSource(ThebesSurface()); - dst->Paint(); - - return NS_OK; -} - PRBool nsThebesImage::ShouldUseImageSurfaces() { diff --git a/mozilla/gfx/src/thebes/nsThebesImage.h b/mozilla/gfx/src/thebes/nsThebesImage.h index 0ff8103d3bf..ceba3fc273e 100644 --- a/mozilla/gfx/src/thebes/nsThebesImage.h +++ b/mozilla/gfx/src/thebes/nsThebesImage.h @@ -75,8 +75,6 @@ public: NS_IMETHOD Draw(nsIRenderingContext &aContext, const gfxRect &aSourceRect, const gfxRect &aDestRect); - NS_IMETHOD DrawToImage(nsIImage* aDstImage, - PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight); nsresult ThebesDrawTile(gfxContext *thebesContext, nsIDeviceContext* dx, diff --git a/mozilla/modules/libpr0n/src/imgContainer.cpp b/mozilla/modules/libpr0n/src/imgContainer.cpp index 776c4ee6920..5a90d3a2f9f 100644 --- a/mozilla/modules/libpr0n/src/imgContainer.cpp +++ b/mozilla/modules/libpr0n/src/imgContainer.cpp @@ -663,8 +663,7 @@ nsresult imgContainer::DoComposite(gfxIImageFrame** aFrameToUse, CopyFrameImage(aPrevFrame, mAnim->compositingFrame); } else { ClearFrame(mAnim->compositingFrame); - aPrevFrame->DrawTo(mAnim->compositingFrame, prevFrameRect.x, prevFrameRect.y, - prevFrameRect.width, prevFrameRect.height); + DrawFrameTo(aPrevFrame, mAnim->compositingFrame, prevFrameRect); needToBlankComposite = PR_FALSE; } } @@ -721,8 +720,7 @@ nsresult imgContainer::DoComposite(gfxIImageFrame** aFrameToUse, } // blit next frame into it's correct spot - aNextFrame->DrawTo(mAnim->compositingFrame, nextFrameRect.x, nextFrameRect.y, - nextFrameRect.width, nextFrameRect.height); + DrawFrameTo(aNextFrame, mAnim->compositingFrame, nextFrameRect); // Set timeout of CompositeFrame to timeout of frame we just composed // Bug 177948 PRInt32 timeout; @@ -795,7 +793,7 @@ void imgContainer::ClearFrame(gfxIImageFrame *aFrame, nsIntRect &aRect) // Whether we succeed or fail will not cause a crash, and there's not much // we can do about a failure, so there we don't return a nsresult PRBool imgContainer::CopyFrameImage(gfxIImageFrame *aSrcFrame, - gfxIImageFrame *aDstFrame) + gfxIImageFrame *aDstFrame) { PRUint8* aDataSrc; PRUint8* aDataDest; @@ -819,10 +817,7 @@ PRBool imgContainer::CopyFrameImage(gfxIImageFrame *aSrcFrame, aDstFrame->UnlockImageData(); // Tell the image that it's data has been updated - nsCOMPtr ireq(do_QueryInterface(aDstFrame)); - if (!ireq) - return PR_FALSE; - nsCOMPtr img(do_GetInterface(ireq)); + nsCOMPtr img(do_GetInterface(aDstFrame)); if (!img) return PR_FALSE; nsIntRect r; @@ -832,6 +827,41 @@ PRBool imgContainer::CopyFrameImage(gfxIImageFrame *aSrcFrame, return PR_TRUE; } +//****************************************************************************** +nsresult imgContainer::DrawFrameTo(gfxIImageFrame *aSrc, + gfxIImageFrame *aDst, + nsIntRect& aDstRect) +{ + if (!aSrc || !aDst) + return NS_ERROR_NOT_INITIALIZED; + + nsCOMPtr srcImg(do_GetInterface(aSrc)); + nsRefPtr srcSurf; + srcImg->GetSurface(getter_AddRefs(srcSurf)); + + nsCOMPtr dstImg(do_GetInterface(aDst)); + nsRefPtr dstSurf; + dstImg->GetSurface(getter_AddRefs(dstSurf)); + + gfxContext dst(dstSurf); + dst.NewPath(); + // We don't use PixelSnappedRectangleAndSetPattern because if + // these coords aren't already pixel aligned, we've lost + // before we've even begun. + dst.Translate(gfxPoint(aDstRect.x, aDstRect.y)); + dst.Rectangle(gfxRect(0, 0, aDstRect.width, aDstRect.height), PR_TRUE); + + nsIntRect srcRect; + aSrc->GetRect(srcRect); + dst.Scale(double(aDstRect.width) / srcRect.width, + double(aDstRect.height) / srcRect.height); + dst.SetSource(srcSurf); + dst.Paint(); + + return NS_OK; +} + + /********* Methods to implement lazy allocation of nsIProperties object *************/ NS_IMETHODIMP imgContainer::Get(const char *prop, const nsIID & iid, void * *result) { diff --git a/mozilla/modules/libpr0n/src/imgContainer.h b/mozilla/modules/libpr0n/src/imgContainer.h index 3db7034b11c..dfd159a5fd3 100644 --- a/mozilla/modules/libpr0n/src/imgContainer.h +++ b/mozilla/modules/libpr0n/src/imgContainer.h @@ -271,6 +271,17 @@ private: static PRBool CopyFrameImage(gfxIImageFrame *aSrcFrame, gfxIImageFrame *aDstFrame); + /** Draws one gfxIImageFrame's image to into another, + * at the position specified by aRect + * + * @param aSrcFrame Frame providing the source image + * @param aDstFrame Frame where the image is drawn into + * @param aRect The position and size to draw the image + */ + static nsresult DrawFrameTo(gfxIImageFrame *aSrcFrame, + gfxIImageFrame *aDstFrame, + nsIntRect& aRect); + nsIntSize mSize; //! All the s of the PNG