Bug 1415326. Tolerate slight changes in scale for fallback items. r=ethlin
authorJeff Muizelaar <jmuizelaar@mozilla.com>
Fri, 10 Nov 2017 11:42:42 -0500
changeset 444584 5bee2596ae4d3f0169039953182b792c2eba0c35
parent 444583 af1af3c260f5b1e41132602df62dbe07ac8a4f6a
child 444587 092ccc6335a529133a8412a8f1bf1cdda872c6a9
child 444636 69d0e8d0a165d6348b7c8f370b02af51523fcd7c
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersethlin
bugs1415326
milestone58.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 1415326. Tolerate slight changes in scale for fallback items. r=ethlin This helps us avoid rerasterizing the blob images every frame. This makes a huge difference in performance. Our score goes from approx 75 to 380. Current Firefox gets about 200.
gfx/layers/wr/WebRenderCommandBuilder.cpp
--- a/gfx/layers/wr/WebRenderCommandBuilder.cpp
+++ b/gfx/layers/wr/WebRenderCommandBuilder.cpp
@@ -471,16 +471,24 @@ WebRenderCommandBuilder::GenerateFallbac
   // nsDisplayBoxShadowInner::ComputeVisibility().
   nsRegion visibleRegion(itemBounds);
   aItem->RecomputeVisibility(aDisplayListBuilder, &visibleRegion, useClipBounds);
 
   const int32_t appUnitsPerDevPixel = aItem->Frame()->PresContext()->AppUnitsPerDevPixel();
   LayoutDeviceRect bounds = LayoutDeviceRect::FromAppUnits(paintBounds, appUnitsPerDevPixel);
 
   gfx::Size scale = aSc.GetInheritedScale();
+  gfx::Size oldScale = fallbackData->GetScale();
+  // This scale determination should probably be done using
+  // ChooseScaleAndSetTransform but for now we just fake it.
+  // We tolerate slight changes in scale so that we don't, for example,
+  // rerasterize on MotionMark
+  bool differentScale = gfx::FuzzyEqual(scale.width, oldScale.width, 1e-6f) &&
+                        gfx::FuzzyEqual(scale.height, oldScale.height, 1e-6f);
+
   // XXX not sure if paintSize should be in layer or layoutdevice pixels, it
   // has some sort of scaling applied.
   LayerIntSize paintSize = RoundedToInt(LayerSize(bounds.width * scale.width, bounds.height * scale.height));
   if (paintSize.width == 0 || paintSize.height == 0) {
     return nullptr;
   }
 
   bool needPaint = true;
@@ -489,17 +497,17 @@ WebRenderCommandBuilder::GenerateFallbac
   LayerRect paintRect = LayerRect(LayerPoint(0, 0), LayerSize(paintSize));
   nsAutoPtr<nsDisplayItemGeometry> geometry = fallbackData->GetGeometry();
 
   // nsDisplayFilter is rendered via BasicLayerManager which means the invalidate
   // region is unknown until we traverse the displaylist contained by it.
   if (geometry && !fallbackData->IsInvalid() &&
       aItem->GetType() != DisplayItemType::TYPE_FILTER &&
       aItem->GetType() != DisplayItemType::TYPE_SVG_WRAPPER &&
-      scale == fallbackData->GetScale()) {
+      differentScale) {
     nsRect invalid;
     nsRegion invalidRegion;
 
     if (aItem->IsInvalid(invalid)) {
       invalidRegion.OrWith(paintBounds);
     } else {
       nsPoint shift = itemBounds.TopLeft() - geometry->mBounds.TopLeft();
       geometry->MoveBy(shift);