Optimize filterBounds() of SkArithmeticImageFilter/SkXfermodeImageFilter

This brings the optimization in blink's FEComposit::MapRect() [1]
into skia.

Previously for these classes we used the default SkImageFilter::
onFilterBounds() which returns the union of the bounds of input filters.
However, this was not optimized if some input filters don't contribute
to the output. When we switch blink SPv2 paint invalidation from using
blink's FilterOperations to cc/skia's filter classes, the non-
optimization caused over-raster-invalidations.

Now override SkImageFilter::onFilterBounds() in these classes to make
their filterBounds() return the same results as the blink counterparts.

Also fix a bug of SkArithmeticImageFilter when k4 is non-zero by
overriding affectsTransparentBlack() to return true in the case, so
that we will use the crop as the final bounds.

[1] https://cs.chromium.org/chromium/src/third_party/WebKit/Source/platform/graphics/filters/FEComposite.cpp?l=115

Change-Id: I91d4cadc267e6262ee3f050a0ddac90154419775
Reviewed-on: https://skia-review.googlesource.com/38921
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
3 files changed