Bug 1202317. Bail out early if RequestRect is going to do redundant work. r=mstange
authorRobert O'Callahan <robert@ocallahan.org>
Mon, 07 Sep 2015 17:08:36 +1200
changeset 294077 e416ad732757e2ad493f4f1c2daae08b9c7538c1
parent 294076 76826fe33431103c1a888c0f35caf13439760a01
child 294078 e3a099db7378d957698b73d61aca929fb830adc6
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1202317
milestone43.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 1202317. Bail out early if RequestRect is going to do redundant work. r=mstange
gfx/2d/FilterNodeSoftware.cpp
--- a/gfx/2d/FilterNodeSoftware.cpp
+++ b/gfx/2d/FilterNodeSoftware.cpp
@@ -624,16 +624,22 @@ FilterNodeSoftware::GetOutput(const IntR
     MOZ_ASSERT(mCachedOutput, "cached rect but no cached output?");
   }
   return GetDataSurfaceInRect(mCachedOutput, mCachedRect, aRect, EDGE_MODE_NONE);
 }
 
 void
 FilterNodeSoftware::RequestRect(const IntRect &aRect)
 {
+  if (mRequestedRect.Contains(aRect)) {
+    // Bail out now. Otherwise pathological filters can spend time exponential
+    // in the number of primitives, e.g. if each primitive takes the
+    // previous primitive as its two inputs.
+    return;
+  }
   mRequestedRect = mRequestedRect.Union(aRect);
   RequestFromInputsForRect(aRect);
 }
 
 void
 FilterNodeSoftware::RequestInputRect(uint32_t aInputEnumIndex, const IntRect &aRect)
 {
   if (aRect.Overflows()) {