Bug 1486377. Avoid repeat sampling when not wanted. r=mstange
authorJeff Muizelaar <jmuizelaar@mozilla.com>
Fri, 07 Sep 2018 12:00:43 -0400
changeset 435289 c1583f2f382b23fa742faa4d50d6081ede64f309
parent 435288 b04a830d12cdaa298b97a8135c10b64255d88ffe
child 435290 293719637a6250a9ff98082e03b89b940c3ce761
push id34602
push userdvarga@mozilla.com
push dateSat, 08 Sep 2018 03:54:14 +0000
treeherdermozilla-central@da268c77ac76 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1486377
milestone64.0a1
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
Bug 1486377. Avoid repeat sampling when not wanted. r=mstange Differential Revision: https://phabricator.services.mozilla.com/D5279
image/test/reftest/downscaling/reftest.list
layout/painting/nsImageRenderer.cpp
--- a/image/test/reftest/downscaling/reftest.list
+++ b/image/test/reftest/downscaling/reftest.list
@@ -21,22 +21,22 @@
 # Also note that Mac OS X has its own system-level downscaling algorithm, so
 # tests here may need Mac-specific "fuzzy-if(cocoaWidget,...)" annotations.
 # Similarly, modern versions of Windows have slightly different downscaling
 # behavior than other platforms, and may require "fuzzy-if(winWidget,...)".
 
 
 # RUN TESTS NOT AFFECTED BY DOWNSCALE-DURING-DECODE:
 # ==================================================
-fuzzy-if(skiaContent,0-14,0-416) fuzzy-if(webrender,14-14,397-473) == downscale-svg-1a.html downscale-svg-1-ref.html?80
-fuzzy(0-80,0-468) fuzzy-if(webrender,65-65,579-580) == downscale-svg-1b.html downscale-svg-1-ref.html?72
-fuzzy-if(/^Windows\x20NT\x2010\.0/.test(http.oscpu),0-1,0-62) fuzzy-if(skiaContent,0-8,0-292) fuzzy-if(webrender,14-14,316-316) == downscale-svg-1c.html downscale-svg-1-ref.html?64
-fuzzy(0-17,0-208) fuzzy-if(webrender,83-84,274-325) == downscale-svg-1d.html downscale-svg-1-ref.html?53
-fuzzy(0-80,0-216) fuzzy-if(skiaContent,0-110,0-181) fuzzy-if(webrender,84-84,216-216) == downscale-svg-1e.html downscale-svg-1-ref.html?40
-fuzzy(0-51,0-90) fuzzy-if(skiaContent,0-142,0-77) fuzzy-if(webrender,62-62,98-98) == downscale-svg-1f.html downscale-svg-1-ref.html?24
+fuzzy-if(skiaContent,0-14,0-416) fuzzy-if(webrender,1-1,2-2) == downscale-svg-1a.html downscale-svg-1-ref.html?80
+fuzzy(0-80,0-468) fuzzy-if(webrender,65-65,468-468) == downscale-svg-1b.html downscale-svg-1-ref.html?72
+fuzzy-if(/^Windows\x20NT\x2010\.0/.test(http.oscpu),0-1,0-62) fuzzy-if(skiaContent,0-8,0-292) fuzzy-if(webrender,1-1,2-2) == downscale-svg-1c.html downscale-svg-1-ref.html?64
+fuzzy(0-17,0-208) fuzzy-if(webrender,7-7,208-208) == downscale-svg-1d.html downscale-svg-1-ref.html?53
+fuzzy(0-80,0-216) fuzzy-if(skiaContent,0-110,0-181) fuzzy-if(webrender,54-54,178-178) == downscale-svg-1e.html downscale-svg-1-ref.html?40
+fuzzy(0-51,0-90) fuzzy-if(skiaContent,0-142,0-77) fuzzy-if(webrender,64-64,31-31) == downscale-svg-1f.html downscale-svg-1-ref.html?24
 
 # RUN TESTS WITH DOWNSCALE-DURING-DECODE DISABLED:
 # ================================================
 default-preferences pref(image.downscale-during-decode.enabled,false)
 
 fuzzy-if(winWidget,0-16,0-20) fuzzy-if(cocoaWidget,0-106,0-31) == downscale-1.html downscale-1-ref.html
 
 fuzzy(0-20,0-999) != downscale-2a.html?203,52,left about:blank
--- a/layout/painting/nsImageRenderer.cpp
+++ b/layout/painting/nsImageRenderer.cpp
@@ -670,26 +670,53 @@ nsImageRenderer::BuildWebRenderDisplayIt
         aDest.TopLeft(), aFill.TopLeft(), aRepeatSize);
       LayoutDeviceRect fillRect =
         LayoutDeviceRect::FromAppUnits(nsRect(firstTilePos.x,
                                               firstTilePos.y,
                                               aFill.XMost() - firstTilePos.x,
                                               aFill.YMost() - firstTilePos.y),
                                        appUnitsPerDevPixel);
       wr::LayoutRect fill = wr::ToRoundedLayoutRect(fillRect);
+
+      wr::LayoutRect roundedDest = wr::ToRoundedLayoutRect(destRect);
+      auto stretchSize = wr::ToLayoutSize(destRect.Size());
+
+      // WebRender special cases situations where stretchSize == fillSize to
+      // infer that it shouldn't use repeat sampling. This makes sure
+      // we hit those special cases when not repeating.
+
+      switch (mExtendMode) {
+        case ExtendMode::CLAMP:
+          fill = roundedDest;
+          stretchSize = roundedDest.size;
+          break;
+        case ExtendMode::REPEAT_Y:
+          fill.origin.x = roundedDest.origin.x;
+          fill.size.width = roundedDest.size.width;
+          stretchSize.width = roundedDest.size.width;
+          break;
+        case ExtendMode::REPEAT_X:
+          fill.origin.y = roundedDest.origin.y;
+          fill.size.height = roundedDest.size.height;
+          stretchSize.height = roundedDest.size.height;
+          break;
+        default:
+          break;
+      }
+
       wr::LayoutRect clip = wr::ToRoundedLayoutRect(
         LayoutDeviceRect::FromAppUnits(aFill, appUnitsPerDevPixel));
 
       LayoutDeviceSize gapSize = LayoutDeviceSize::FromAppUnits(
         aRepeatSize - aDest.Size(), appUnitsPerDevPixel);
 
       aBuilder.PushImage(fill,
                          clip,
                          !aItem->BackfaceIsHidden(),
-                         wr::ToLayoutSize(destRect.Size()),
+                         stretchSize,
                          wr::ToLayoutSize(gapSize),
                          rendering,
                          key.value());
       break;
     }
     default:
       break;
   }