mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 216682 - Eliminate DrawToImage p=Alfred Kayser <alfredkayser@nl.ibm.com> r=tor, sr=pavlov, a=pavlov
This commit is contained in:
parent
f84d6685a6
commit
1e536127c0
@ -57,7 +57,7 @@ native nsRectRef(nsIntRect &);
|
||||
* @author Stuart Parmenter <pavlov@netscape.com>
|
||||
* @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.
|
||||
|
@ -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
|
||||
|
@ -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<nsIImage> img(do_GetInterface(aDst));
|
||||
return mImage->DrawToImage(img, aDX, aDY, aDWidth, aDHeight);
|
||||
}
|
||||
|
||||
|
||||
/* attribute long timeout; */
|
||||
NS_IMETHODIMP gfxImageFrame::GetTimeout(PRInt32 *aTimeout)
|
||||
{
|
||||
|
@ -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<nsThebesImage*>(aDstImage);
|
||||
|
||||
nsRefPtr<gfxContext> 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()
|
||||
{
|
||||
|
@ -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,
|
||||
|
@ -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<nsIInterfaceRequestor> ireq(do_QueryInterface(aDstFrame));
|
||||
if (!ireq)
|
||||
return PR_FALSE;
|
||||
nsCOMPtr<nsIImage> img(do_GetInterface(ireq));
|
||||
nsCOMPtr<nsIImage> 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<nsIImage> srcImg(do_GetInterface(aSrc));
|
||||
nsRefPtr<gfxASurface> srcSurf;
|
||||
srcImg->GetSurface(getter_AddRefs(srcSurf));
|
||||
|
||||
nsCOMPtr<nsIImage> dstImg(do_GetInterface(aDst));
|
||||
nsRefPtr<gfxASurface> 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)
|
||||
{
|
||||
|
@ -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 <gfxIImageFrame>s of the PNG
|
||||
|
Loading…
Reference in New Issue
Block a user