Avoid SkFixed overflow in decal bitmap procs
The check for decal mode can overflow in SkFixed. Promote to
64bit (48.16) instead.
Also update can_truncate_to_fixed_for_decal() to take SkFixed params and
used it in ClampX_ClampY_filter_scale_SSE2().
BUG=chromium:675444
R=reed@google.com
CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD
Change-Id: I759464cdaa5c005159e38e32167fb1937e2a1d28
Reviewed-on: https://skia-review.googlesource.com/6538
Reviewed-by: Cary Clark <caryclark@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
diff --git a/src/opts/SkBitmapProcState_matrix_neon.h b/src/opts/SkBitmapProcState_matrix_neon.h
index a7f4753..fb91547 100644
--- a/src/opts/SkBitmapProcState_matrix_neon.h
+++ b/src/opts/SkBitmapProcState_matrix_neon.h
@@ -54,9 +54,10 @@
#ifdef CHECK_FOR_DECAL
// test if we don't need to apply the tile proc
- if (can_truncate_to_fixed_for_decal(fx, dx, count, maxX)) {
- decal_nofilter_scale_neon(xy, SkFractionalIntToFixed(fx),
- SkFractionalIntToFixed(dx), count);
+ const SkFixed fixedFx = SkFractionalIntToFixed(fx);
+ const SkFixed fixedDx = SkFractionalIntToFixed(dx);
+ if (can_truncate_to_fixed_for_decal(fixedFx, fixedDx, count, maxX)) {
+ decal_nofilter_scale_neon(xy, fixedFx, fixedDx, count);
return;
}
#endif
@@ -309,9 +310,10 @@
#ifdef CHECK_FOR_DECAL
// test if we don't need to apply the tile proc
- if (can_truncate_to_fixed_for_decal(fx, dx, count, maxX)) {
- decal_filter_scale_neon(xy, SkFractionalIntToFixed(fx),
- SkFractionalIntToFixed(dx), count);
+ const SkFixed fixedFx = SkFractionalIntToFixed(fx);
+ const SkFixed fixedDx = SkFractionalIntToFixed(dx);
+ if (can_truncate_to_fixed_for_decal(fixedFx, fixedDx, count, maxX)) {
+ decal_filter_scale_neon(xy, fixedFx, fixedDx, count);
return;
}
#endif