Backout 4c6759dcecd3 (bug 750598) for Android reftest-1 failures in background-size-zoom-repeat.html
authorEd Morley <emorley@mozilla.com>
Fri, 04 May 2012 09:57:59 +0100
changeset 93147 6a9a1e259aeb60d5cd2e45146bb6c6324f43e87f
parent 93146 5854da577bcb0c85053a210d548770233811aa94
child 93148 9c2c2046677f6a8520e7ae10eeb7549c926152bd
push id22611
push usereakhgari@mozilla.com
push dateFri, 04 May 2012 20:23:57 +0000
treeherdermozilla-central@dc93a3faa54e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs750598
milestone15.0a1
backs out4c6759dcecd3ba2d92258e45d497af29613a4dde
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backout 4c6759dcecd3 (bug 750598) for Android reftest-1 failures in background-size-zoom-repeat.html
gfx/thebes/gfxUtils.cpp
gfx/thebes/gfxUtils.h
modules/libpref/src/init/all.js
--- a/gfx/thebes/gfxUtils.cpp
+++ b/gfx/thebes/gfxUtils.cpp
@@ -409,93 +409,26 @@ DeviceToImageTransform(gfxContext* aCont
     nsRefPtr<gfxASurface> currentTarget =
         aContext->CurrentSurface(&deviceX, &deviceY);
     gfxMatrix currentMatrix = aContext->CurrentMatrix();
     gfxMatrix deviceToUser = gfxMatrix(currentMatrix).Invert();
     deviceToUser.Translate(-gfxPoint(-deviceX, -deviceY));
     return gfxMatrix(deviceToUser).Multiply(aUserSpaceToImageSpace);
 }
 
-/* These heuristics are based on Source/WebCore/platform/graphics/skia/ImageSkia.cpp:computeResamplingMode() */
-#ifdef MOZ_GFX_OPTIMIZE_MOBILE
-static gfxPattern::GraphicsFilter ReduceResamplingFilter(gfxPattern::GraphicsFilter aFilter,
-                                                         int aImgWidth, int aImgHeight,
-                                                         float aSourceWidth, float aSourceHeight)
-{
-    // Images smaller than this in either direction are considered "small" and
-    // are not resampled ever (see below).
-    const int kSmallImageSizeThreshold = 8;
-
-    // The amount an image can be stretched in a single direction before we
-    // say that it is being stretched so much that it must be a line or
-    // background that doesn't need resampling.
-    const float kLargeStretch = 3.0f;
-
-    if (aImgWidth <= kSmallImageSizeThreshold
-        || aImgHeight <= kSmallImageSizeThreshold) {
-        // Never resample small images. These are often used for borders and
-        // rules (think 1x1 images used to make lines).
-        return gfxPattern::FILTER_NEAREST;
-    }
-
-    if (aImgHeight * kLargeStretch <= aSourceHeight || aImgWidth * kLargeStretch <= aSourceWidth) {
-        // Large image tiling detected.
-
-        // Don't resample if it is being tiled a lot in only one direction.
-        // This is trying to catch cases where somebody has created a border
-        // (which might be large) and then is stretching it to fill some part
-        // of the page.
-        if (fabs(aSourceWidth - aImgWidth)/aImgWidth < 0.5 || fabs(aSourceHeight - aImgHeight)/aImgHeight < 0.5)
-            return gfxPattern::FILTER_NEAREST;
-
-        // The image is growing a lot and in more than one direction. Resampling
-        // is slow and doesn't give us very much when growing a lot.
-        return aFilter;
-    }
-
-    /* Some notes on other heuristics:
-       The Skia backend also uses nearest for backgrounds that are stretched by
-       a large amount. I'm not sure this is common enough for us to worry about
-       now. It also uses nearest for backgrounds/avoids high quality for images
-       that are very slightly scaled.  I'm also not sure that very slightly
-       scaled backgrounds are common enough us to worry about.
-
-       We don't currently have much support for doing high quality interpolation.
-       The only place this currently happens is on Quartz and we don't have as
-       much control over it as would be needed. Webkit avoids using high quality
-       resampling during load. It also avoids high quality if the transformation
-       is not just a scale and translation
-
-       WebKit bug #40045 added code to avoid resampling different parts
-       of an image with different methods by using a resampling hint size.
-       It currently looks unused in WebKit but it's something to watch out for.
-    */
-
-    return aFilter;
-}
-#else
-static gfxPattern::GraphicsFilter ReduceResamplingFilter(gfxPattern::GraphicsFilter aFilter,
-                                                          int aImgWidth, int aImgHeight,
-                                                          int aSourceWidth, int aSourceHeight)
-{
-    // Just pass the filter through unchanged
-    return aFilter;
-}
-#endif
-
 /* static */ void
 gfxUtils::DrawPixelSnapped(gfxContext*      aContext,
                            gfxDrawable*     aDrawable,
                            const gfxMatrix& aUserSpaceToImageSpace,
                            const gfxRect&   aSubimage,
                            const gfxRect&   aSourceRect,
                            const gfxRect&   aImageRect,
                            const gfxRect&   aFill,
                            const gfxImageSurface::gfxImageFormat aFormat,
-                           gfxPattern::GraphicsFilter aFilter,
+                           const gfxPattern::GraphicsFilter& aFilter,
                            PRUint32         aImageFlags)
 {
     SAMPLE_LABEL("gfxUtils", "DrawPixelSnapped");
     bool doTile = !aImageRect.Contains(aSourceRect) &&
                   !(aImageFlags & imgIContainer::FLAG_CLAMP);
 
     nsRefPtr<gfxASurface> currentTarget = aContext->CurrentSurface();
     gfxMatrix deviceSpaceToImageSpace =
@@ -503,18 +436,16 @@ gfxUtils::DrawPixelSnapped(gfxContext*  
 
     AutoCairoPixmanBugWorkaround workaround(aContext, deviceSpaceToImageSpace,
                                             aFill, currentTarget);
     if (!workaround.Succeeded())
         return;
 
     nsRefPtr<gfxDrawable> drawable = aDrawable;
 
-    aFilter = ReduceResamplingFilter(aFilter, aImageRect.Width(), aImageRect.Height(), aSourceRect.Width(), aSourceRect.Height());
-
     // 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 (aContext->CurrentMatrix().HasNonIntegerTranslation() ||
         aUserSpaceToImageSpace.HasNonIntegerTranslation()) {
         if (doTile || !aSubimage.Contains(aImageRect)) {
--- a/gfx/thebes/gfxUtils.h
+++ b/gfx/thebes/gfxUtils.h
@@ -85,17 +85,17 @@ public:
     static void DrawPixelSnapped(gfxContext*      aContext,
                                  gfxDrawable*     aDrawable,
                                  const gfxMatrix& aUserSpaceToImageSpace,
                                  const gfxRect&   aSubimage,
                                  const gfxRect&   aSourceRect,
                                  const gfxRect&   aImageRect,
                                  const gfxRect&   aFill,
                                  const gfxImageSurface::gfxImageFormat aFormat,
-                                 gfxPattern::GraphicsFilter aFilter,
+                                 const gfxPattern::GraphicsFilter& aFilter,
                                  PRUint32         aImageFlags = imgIContainer::FLAG_NONE);
 
     /**
      * Clip aContext to the region aRegion.
      */
     static void ClipToRegion(gfxContext* aContext, const nsIntRegion& aRegion);
 
     /**
@@ -180,20 +180,20 @@ public:
 #endif
 };
 
 namespace mozilla {
 namespace gfx {
 
 
 /*
- * Copyright 2008 The Android Open Source Project
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
+ * Copyright 2008 The Android Open Source Project
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
  */
 
 /**
  * Returns true if |aNumber| is a power of two
  */
 static inline bool
 IsPowerOfTwo(int aNumber)
 {
@@ -205,22 +205,22 @@ IsPowerOfTwo(int aNumber)
  * Undefined for |aNumber| < 0
  */
 static inline int
 NextPowerOfTwo(int aNumber)
 {
 #if defined(__arm__)
     return 1 << (32 - __builtin_clz(aNumber - 1));
 #else
-    --aNumber;
-    aNumber |= aNumber >> 1;
-    aNumber |= aNumber >> 2;
-    aNumber |= aNumber >> 4;
-    aNumber |= aNumber >> 8;
-    aNumber |= aNumber >> 16;
+    --aNumber;
+    aNumber |= aNumber >> 1;
+    aNumber |= aNumber >> 2;
+    aNumber |= aNumber >> 4;
+    aNumber |= aNumber >> 8;
+    aNumber |= aNumber >> 16;
     return ++aNumber;
 #endif
 }
 
 } // namespace gfx
 } // namespace mozilla
 
 #endif
--- a/modules/libpref/src/init/all.js
+++ b/modules/libpref/src/init/all.js
@@ -210,17 +210,21 @@ pref("gfx.color_management.mode", 2);
 pref("gfx.color_management.display_profile", "");
 pref("gfx.color_management.rendering_intent", 0);
 pref("gfx.color_management.enablev4", false);
 
 pref("gfx.downloadable_fonts.enabled", true);
 pref("gfx.downloadable_fonts.fallback_delay", 3000);
 pref("gfx.downloadable_fonts.sanitize", true);
 
+#ifdef ANDROID
+pref("gfx.filter.nearest.force-enabled", true);
+#else
 pref("gfx.filter.nearest.force-enabled", false);
+#endif
 
 // whether to always search all font cmaps during system font fallback
 pref("gfx.font_rendering.fallback.always_use_cmaps", false);
 
 #ifdef MOZ_GRAPHITE
 pref("gfx.font_rendering.graphite.enabled", false);
 #endif