Bug 1357692 - Only accelerate gfxAlphaBoxBlur when blur area is large enough to balance resource creation costs. r=mchang, a=gchang
authorLee Salzman <lsalzman@mozilla.com>
Tue, 09 May 2017 16:27:19 -0400
changeset 396259 de9ea8491a29b467e2624b4de28977b199536981
parent 396258 13b604cdefa40a97bb3b24bd2ec0f8ab504deb55
child 396260 82aba3466ff1fbe40d30e6a74267a59da4106a71
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmchang, gchang
bugs1357692
milestone54.0
Bug 1357692 - Only accelerate gfxAlphaBoxBlur when blur area is large enough to balance resource creation costs. r=mchang, a=gchang MozReview-Commit-ID: HcRahaq8ORa
gfx/thebes/gfxBlur.cpp
layout/reftests/box-shadow/reftest.list
--- a/gfx/thebes/gfxBlur.cpp
+++ b/gfx/thebes/gfxBlur.cpp
@@ -70,17 +70,22 @@ gfxAlphaBoxBlur::InitDrawTarget(const Dr
     return nullptr;
   }
 
   BackendType backend = aReferenceDT->GetBackendType();
 
   // Check if the backend has an accelerated DrawSurfaceWithShadow.
   // Currently, only D2D1.1 supports this.
   // Otherwise, DrawSurfaceWithShadow only supports square blurs without spread.
+  // When blurring small draw targets such as short spans text, the cost of
+  // creating and flushing an accelerated draw target may exceed the speedup
+  // gained from the faster blur, so we also make sure the blurred data exceeds
+  // a sufficient number of pixels to offset this cost.
   if (aBlurRadius.IsSquare() && aSpreadRadius.IsEmpty() &&
+      blurDataSize >= 8192 &&
       backend == BackendType::DIRECT2D1_1) {
     mAccelerated = true;
     mDrawTarget =
       aReferenceDT->CreateShadowDrawTarget(mBlur.GetSize(),
                                            SurfaceFormat::A8,
                                            AlphaBoxBlur::CalculateBlurSigma(aBlurRadius.width));
   } else {
     // Make an alpha-only surface to draw on. We will play with the data after
--- a/layout/reftests/box-shadow/reftest.list
+++ b/layout/reftests/box-shadow/reftest.list
@@ -21,17 +21,17 @@ random-if(d2d) == boxshadow-threecorners
 fuzzy(2,440) == boxshadow-skiprect.html boxshadow-skiprect-ref.html
 == boxshadow-opacity.html boxshadow-opacity-ref.html
 == boxshadow-color-rounding.html boxshadow-color-rounding-ref.html
 == boxshadow-color-rounding-middle.html boxshadow-color-rounding-middle-ref.html
 fuzzy-if(OSX==1010,1,24) fuzzy-if(d2d,16,908) == boxshadow-large-border-radius.html boxshadow-large-border-radius-ref.html # Bug 1209649
 fuzzy(3,500) fuzzy-if(d2d,2,1080) == boxshadow-border-radius-int.html boxshadow-border-radius-int-ref.html
 == boxshadow-inset-neg-spread.html about:blank
 == boxshadow-inset-neg-spread2.html boxshadow-inset-neg-spread2-ref.html
-fuzzy(26,3610) == boxshadow-rotated.html boxshadow-rotated-ref.html # Bug 1211264
+fuzzy(26,3610) fuzzy-if(d2d,26,5910) == boxshadow-rotated.html boxshadow-rotated-ref.html # Bug 1211264
 == boxshadow-inset-large-border-radius.html boxshadow-inset-large-border-radius-ref.html
 
 # fuzzy due to blur going inside, but as long as it's essentially black instead of a light gray its ok.
 fuzzy(12,9445) fuzzy-if(d2d,13,10926) == boxshadow-inset-large-offset.html boxshadow-inset-large-offset-ref.html
 
 == overflow-not-scrollable-1.html overflow-not-scrollable-1-ref.html
 == overflow-not-scrollable-1.html overflow-not-scrollable-1-ref2.html
 == overflow-not-scrollable-2.html overflow-not-scrollable-2-ref.html