Bug 403181 backout

This commit is contained in:
roc+@cs.cmu.edu 2008-03-02 18:38:19 -08:00
parent ad8da38faa
commit 67c8b1e808
7 changed files with 17 additions and 63 deletions

View File

@ -71,10 +71,10 @@ typedef enum {
#define nsImageUpdateFlags_kBitsChanged 0x2
// IID for the nsIImage interface
// 79fc5cde-09d8-4134-935b-4dcb6d76d622
// fd31e1f2-bd46-47f1-b8b6-b94ce954f9ce
#define NS_IIMAGE_IID \
{ 0x79fc5cde, 0x09d8, 0x4134, \
{ 0x93, 0x5b, 0x4d, 0xcb, 0x6d, 0x76, 0xd6, 0x22 } }
{ 0xfd31e1f2, 0xbd46, 0x47f1, \
{ 0xb8, 0xb6, 0xb9, 0x4c, 0xe9, 0x54, 0xf9, 0xce } }
// Interface to Images
class nsIImage : public nsISupports
@ -189,14 +189,10 @@ public:
/**
* BitBlit the nsIImage to a device, the source and dest can be scaled
* @param aSourceRect source rectangle, in image pixels
* @param aSubimageRect the subimage that we're extracting the contents from.
* It must contain aSourceRect. Pixels outside this rectangle must not
* be sampled.
* @param aDestRect destination rectangle, in device pixels
*/
NS_IMETHOD Draw(nsIRenderingContext &aContext,
const gfxRect &aSourceRect,
const gfxRect &aSubimageRect,
const gfxRect &aDestRect) = 0;
/**

View File

@ -412,7 +412,6 @@ nsThebesImage::UnlockImagePixels(PRBool aMaskPixels)
NS_IMETHODIMP
nsThebesImage::Draw(nsIRenderingContext &aContext,
const gfxRect &aSourceRect,
const gfxRect &aSubimageRect,
const gfxRect &aDestRect)
{
if (NS_UNLIKELY(aDestRect.IsEmpty())) {
@ -453,14 +452,11 @@ nsThebesImage::Draw(nsIRenderingContext &aContext,
gfxFloat yscale = aDestRect.size.height / aSourceRect.size.height;
gfxRect srcRect(aSourceRect);
gfxRect subimageRect(aSubimageRect);
gfxRect destRect(aDestRect);
if (!GetIsImageComplete()) {
gfxRect decoded = gfxRect(mDecoded.x, mDecoded.y,
mDecoded.width, mDecoded.height);
srcRect = srcRect.Intersect(decoded);
subimageRect = subimageRect.Intersect(decoded);
srcRect = srcRect.Intersect(gfxRect(mDecoded.x, mDecoded.y,
mDecoded.width, mDecoded.height));
// This happens when mDecoded.width or height is zero. bug 368427.
if (NS_UNLIKELY(srcRect.size.width == 0 || srcRect.size.height == 0))
@ -482,34 +478,6 @@ nsThebesImage::Draw(nsIRenderingContext &aContext,
return NS_ERROR_FAILURE;
nsRefPtr<gfxPattern> pat;
if ((xscale == 1.0 && yscale == 1.0 &&
!ctx->CurrentMatrix().HasNonTranslation()) ||
subimageRect == gfxRect(0, 0, mWidth, mHeight)) {
// No need to worry about sampling outside the subimage rectangle,
// so no need for a temporary
// XXX should we also check for situations where the source rect
// is well inside the subimage so we can't sample outside?
pat = new gfxPattern(ThebesSurface());
} else {
gfxIntSize size(NSToIntCeil(subimageRect.Width()),
NSToIntCeil(subimageRect.Height()));
nsRefPtr<gfxASurface> temp =
gfxPlatform::GetPlatform()->CreateOffscreenSurface(size, mFormat);
if (!temp || temp->CairoStatus() != 0)
return NS_ERROR_FAILURE;
gfxContext tempctx(temp);
tempctx.SetSource(ThebesSurface(), -subimageRect.pos);
tempctx.SetOperator(gfxContext::OPERATOR_SOURCE);
// Use Fill instead of Paint because we want to sample exactly
// the subimageRect here and the subimage size might
// be non-integer...
tempctx.Rectangle(gfxRect(gfxPoint(0, 0), subimageRect.size));
tempctx.Fill();
pat = new gfxPattern(temp);
srcRect.MoveBy(-subimageRect.pos);
}
/* See bug 364968 to understand the necessity of this goop; we basically
* have to pre-downscale any image that would fall outside of a scaled 16-bit
@ -532,12 +500,13 @@ nsThebesImage::Draw(nsIRenderingContext &aContext,
gfxContext tempctx(temp);
gfxPattern srcpat(ThebesSurface());
gfxMatrix mat;
mat.Translate(srcRect.pos);
mat.Scale(1.0 / xscale, 1.0 / yscale);
pat->SetMatrix(mat);
srcpat.SetMatrix(mat);
tempctx.SetPattern(pat);
tempctx.SetPattern(&srcpat);
tempctx.SetOperator(gfxContext::OPERATOR_SOURCE);
tempctx.NewPath();
tempctx.Rectangle(gfxRect(0.0, 0.0, dim.width, dim.height));
@ -554,6 +523,10 @@ nsThebesImage::Draw(nsIRenderingContext &aContext,
yscale = 1.0;
}
if (!pat) {
pat = new gfxPattern(ThebesSurface());
}
gfxMatrix mat;
mat.Translate(srcRect.pos);
mat.Scale(1.0/xscale, 1.0/yscale);

View File

@ -76,7 +76,6 @@ public:
NS_IMETHOD Draw(nsIRenderingContext &aContext,
const gfxRect &aSourceRect,
const gfxRect &aSubimageRect,
const gfxRect &aDestRect);
nsresult ThebesDrawTile(gfxContext *thebesContext,

View File

@ -3916,14 +3916,7 @@ nsCSSRendering::PaintBackgroundWithSC(nsPresContext* aPresContext,
if (sourceRect.XMost() <= tileWidth && sourceRect.YMost() <= tileHeight) {
// The entire drawRect is contained inside a single tile; just
// draw the corresponding part of the image once.
// Pass in the subimage rectangle that we expect to be sampled.
// This is the tile rectangle, clipped to the bgClipArea, and then
// passed in relative to the image top-left.
nsRect destRect; // The rectangle we would draw ignoring dirty-rect
destRect.IntersectRect(absTileRect, bgClipArea);
nsRect subimageRect = destRect - aBorderArea.TopLeft() - tileRect.TopLeft();
nsLayoutUtils::DrawImage(&aRenderingContext, image,
destRect, drawRect, &subimageRect);
nsLayoutUtils::DrawImage(&aRenderingContext, image, absTileRect, drawRect);
} else {
aRenderingContext.DrawTile(image, absTileRect.x, absTileRect.y, &drawRect);
}

View File

@ -2314,7 +2314,6 @@ nsLayoutUtils::DrawImage(nsIRenderingContext* aRenderingContext,
pxSrc.size.width = gfxFloat(w);
pxSrc.size.height = gfxFloat(h);
}
gfxRect pxSubimage = pxSrc;
nsCOMPtr<nsIDeviceContext> dc;
aRenderingContext->GetDeviceContext(*getter_AddRefs(dc));
@ -2376,9 +2375,7 @@ nsLayoutUtils::DrawImage(nsIRenderingContext* aRenderingContext,
imgFrame->GetRect(pxImgFrameRect);
if (pxImgFrameRect.x > 0) {
gfxFloat fx(pxImgFrameRect.x);
pxSubimage.pos.x -= fx;
pxSrc.pos.x -= fx;
pxSrc.pos.x -= gfxFloat(pxImgFrameRect.x);
gfxFloat scaled_x = pxSrc.pos.x;
if (pxDirty.size.width != pxSrc.size.width) {
@ -2399,9 +2396,7 @@ nsLayoutUtils::DrawImage(nsIRenderingContext* aRenderingContext,
}
if (pxImgFrameRect.y > 0) {
gfxFloat fy(pxImgFrameRect.y);
pxSubimage.pos.y -= fy;
pxSrc.pos.y -= fy;
pxSrc.pos.y -= gfxFloat(pxImgFrameRect.y);
gfxFloat scaled_y = pxSrc.pos.y;
if (pxDirty.size.height != pxSrc.size.height) {
@ -2421,7 +2416,7 @@ nsLayoutUtils::DrawImage(nsIRenderingContext* aRenderingContext,
return NS_OK;
}
return img->Draw(*aRenderingContext, pxSrc, pxSubimage, pxDirty);
return img->Draw(*aRenderingContext, pxSrc, pxDirty);
}
void

View File

@ -715,8 +715,7 @@ public:
* @param aDestRect Where to draw the image (app units).
* @param aDirtyRect Draw only within this region (rounded to the
* nearest pixel); the intersection of
* invalidation and clipping (this is the
* destination clip)
* invalidation and clipping.
* @param aSourceRect If null, draw the entire image so it fits in
* aDestRect. If non-null, the subregion of the
* image that should be drawn (in app units, such

View File

@ -647,7 +647,6 @@ skip-if(MOZ_WIDGET_TOOLKIT!="windows") == 391045.html 391045-ref.html # windows-
== 403129-3.html 403129-3-ref.html
== 403129-4.html 403129-4-ref.html
random == 403134-1.html 403134-1-ref.html # bug 405377
== 403181-1.xml 403181-1-ref.xml
== 403249-1a.html 403249-1-ref.html
== 403249-1b.html 403249-1-ref.html
== 403249-2a.html 403249-2-ref.html