Backing out fix for bug 479852 due to regressions
authorRobert O'Callahan <robert@ocallahan.org>
Fri, 08 May 2009 14:35:47 +1200
changeset 28114 c9db288cd5cca9ff3b7a58e57c763b95909be2ba
parent 28113 665b73eb15c804b90b4978b7820e41067a955d59 (current diff)
parent 28107 6333316bdfbb5d445e9cb11fd8ff75fe92c44459 (diff)
child 28115 26c4c46fcaac14ede31283854e2bb830c7dece99
push id6896
push userrocallahan@mozilla.com
push dateFri, 08 May 2009 03:22:56 +0000
treeherdermozilla-central@c97e93f23f89 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs479852
milestone1.9.2a1pre
Backing out fix for bug 479852 due to regressions
gfx/src/thebes/nsThebesImage.cpp
--- a/gfx/src/thebes/nsThebesImage.cpp
+++ b/gfx/src/thebes/nsThebesImage.cpp
@@ -492,21 +492,22 @@ nsThebesImage::Draw(gfxContext*        a
     gfxRect subimage(aSubimage.x, aSubimage.y, aSubimage.width, aSubimage.height);
     gfxRect fill = aFill;
     nsRefPtr<gfxASurface> surface;
     gfxImageSurface::gfxImageFormat format;
 
     NS_ASSERTION(!sourceRect.Intersect(subimage).IsEmpty(),
                  "We must be allowed to sample *some* source pixels!");
 
+    PRBool doTile = !imageRect.Contains(sourceRect);
     if (doPadding || doPartialDecode) {
         gfxRect available = gfxRect(mDecoded.x, mDecoded.y, mDecoded.width, mDecoded.height) +
             gfxPoint(aPadding.left, aPadding.top);
   
-        if (imageRect.Contains(sourceRect) && !mSinglePixel) {
+        if (!doTile && !mSinglePixel) {
             // Not tiling, and we have a surface, so we can account for
             // padding and/or a partial decode just by twiddling parameters.
             // First, update our user-space fill rect.
             sourceRect = sourceRect.Intersect(available);
             gfxMatrix imageSpaceToUserSpace = userSpaceToImageSpace;
             imageSpaceToUserSpace.Invert();
             fill = imageSpaceToUserSpace.Transform(sourceRect);
   
@@ -599,54 +600,31 @@ nsThebesImage::Draw(gfxContext*        a
         pushedGroup = PR_TRUE;
     }
     // END working around cairo/pixman bug (bug 364968)
     }
   
     nsRefPtr<gfxPattern> pattern = new gfxPattern(surface);
     pattern->SetMatrix(userSpaceToImageSpace);
 
-    // Figure out if we're tiling in either direction
-    PRBool doTileX = (subimage.X() < imageRect.X()) ||
-        (subimage.XMost() > imageRect.XMost());
-    PRBool doTileY = (subimage.Y() < imageRect.Y()) ||
-        (subimage.YMost() > imageRect.YMost());
-
     // OK now, the hard part left is to account for the subimage sampling
     // restriction. If all the transforms involved are just integer
     // translations, then we assume no resampling will occur so there's
     // nothing to do.
     // XXX if only we had source-clipping in cairo!
-
-    // If we're tiling a 1px wide/tall image in the 1px direction, then
-    // we don't care about handling the sampling correctly -- it will always
-    // sample the same pixel.  Note that we can't have a 1x1 image here,
-    // because that's handled by mSinglePixel.
-    if ((mWidth == 1 && doTileX && !doTileY) ||
-        (mHeight == 1 && doTileY && !doTileX) ||
-        (!currentMatrix.HasNonIntegerTranslation() &&
-         !userSpaceToImageSpace.HasNonIntegerTranslation()))
-    {
-        if (doTileX || doTileY) {
+    if (!currentMatrix.HasNonIntegerTranslation() &&
+        !userSpaceToImageSpace.HasNonIntegerTranslation()) {
+        if (doTile) {
             pattern->SetExtend(gfxPattern::EXTEND_REPEAT);
         }
     } else {
-        if (doTileX || doTileY || !subimage.Contains(imageRect)) {
+        if (doTile || !subimage.Contains(imageRect)) {
             // EXTEND_PAD won't help us here; we have to create a temporary
             // surface to hold the subimage of pixels we're allowed to
             // sample
-
-            // XXX this is going to create a very large temporary
-            // surface if we're tiling; it will be the size of the
-            // full destination area to be tiled, regardless of the
-            // current dirty region.  Instead, we should create a new
-            // tile so that the destiation region can be tiled without
-            // scaling (so we don't have to worry about the edge
-            // filtering problem).
-
             gfxRect needed = subimage.Intersect(sourceRect);
             needed.RoundOut();
             gfxIntSize size(PRInt32(needed.Width()), PRInt32(needed.Height()));
             NS_ASSERTION(size.width > 0 && size.height > 0,
                          "We must have some needed pixels, otherwise we don't know what to sample");
             nsRefPtr<gfxASurface> temp =
                 gfxPlatform::GetPlatform()->CreateOffscreenSurface(size, format);
             if (temp && temp->CairoStatus() == 0) {