Issue #2364 - Only use HWA AlphaBoxBlur when targets are large enough.

There's considerable cost associated with creating HWA draw targets
which would negate and regress the performance won by it if used for
too small targets (like small spans of text).
This only uses HWA if >= 8K SurfaceAllocationSize to balance HWA draw
target cost with box blur cost.
This commit is contained in:
Moonchild 2023-10-30 14:29:54 +01:00 committed by roytam1
commit f1ccc95daf
2 changed files with 6 additions and 1 deletions

View file

@ -75,7 +75,12 @@ gfxAlphaBoxBlur::InitDrawTarget(const DrawTarget* aReferenceDT,
// 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 of text, the cost of
// creating and flushing an accelerated draw target exceeds the gains from
// the faster HWA blur, so we also make sure the blurred data exceeds
// a sufficient number of pixels before HWA kicks in to offset this cost.
if (aBlurRadius.IsSquare() && aSpreadRadius.IsEmpty() &&
blurDataSize >= 8192 &&
backend == BackendType::DIRECT2D1_1) {
mAccelerated = true;
mDrawTarget =

View file

@ -26,7 +26,7 @@ fuzzy-if(OSX==1010,1,24) fuzzy-if(d2d,16,908) == boxshadow-large-border-radius.h
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.