aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkBitmapProcState_matrix_template.h
diff options
context:
space:
mode:
authorGravatar Florin Malita <fmalita@chromium.org>2017-01-04 13:01:55 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-01-06 18:41:34 +0000
commit9953737bcf885a52c08ade6c503f2202e4dd9aa5 (patch)
treed53ac822a3eec694d78b6a3c36daa99a4f1e7021 /src/core/SkBitmapProcState_matrix_template.h
parent1c4717b54b21bc6c640864caf600ef16496803ec (diff)
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>
Diffstat (limited to 'src/core/SkBitmapProcState_matrix_template.h')
-rw-r--r--src/core/SkBitmapProcState_matrix_template.h45
1 files changed, 25 insertions, 20 deletions
diff --git a/src/core/SkBitmapProcState_matrix_template.h b/src/core/SkBitmapProcState_matrix_template.h
index 0c9371851c..c38610a077 100644
--- a/src/core/SkBitmapProcState_matrix_template.h
+++ b/src/core/SkBitmapProcState_matrix_template.h
@@ -36,32 +36,37 @@ void NoFilterProc_Scale(const SkBitmapProcState& s, uint32_t xy[],
const SkFractionalInt dx = s.fInvSxFractionalInt;
- if (tryDecal && can_truncate_to_fixed_for_decal(fx, dx, count, maxX)) {
- decal_nofilter_scale(xy, SkFractionalIntToFixed(fx),
- SkFractionalIntToFixed(dx), count);
- } else {
- int i;
- for (i = (count >> 2); i > 0; --i) {
- unsigned a, b;
- a = TileProc::X(s, SkFractionalIntToFixed(fx), maxX); fx += dx;
- b = TileProc::X(s, SkFractionalIntToFixed(fx), maxX); fx += dx;
+ if (tryDecal) {
+ const SkFixed fixedFx = SkFractionalIntToFixed(fx);
+ const SkFixed fixedDx = SkFractionalIntToFixed(dx);
+
+ if (can_truncate_to_fixed_for_decal(fixedFx, fixedDx, count, maxX)) {
+ decal_nofilter_scale(xy, fixedFx, fixedDx, count);
+ return;
+ }
+ }
+
+ int i;
+ for (i = (count >> 2); i > 0; --i) {
+ unsigned a, b;
+ a = TileProc::X(s, SkFractionalIntToFixed(fx), maxX); fx += dx;
+ b = TileProc::X(s, SkFractionalIntToFixed(fx), maxX); fx += dx;
#ifdef SK_CPU_BENDIAN
- *xy++ = (a << 16) | b;
+ *xy++ = (a << 16) | b;
#else
- *xy++ = (b << 16) | a;
+ *xy++ = (b << 16) | a;
#endif
- a = TileProc::X(s, SkFractionalIntToFixed(fx), maxX); fx += dx;
- b = TileProc::X(s, SkFractionalIntToFixed(fx), maxX); fx += dx;
+ a = TileProc::X(s, SkFractionalIntToFixed(fx), maxX); fx += dx;
+ b = TileProc::X(s, SkFractionalIntToFixed(fx), maxX); fx += dx;
#ifdef SK_CPU_BENDIAN
- *xy++ = (a << 16) | b;
+ *xy++ = (a << 16) | b;
#else
- *xy++ = (b << 16) | a;
+ *xy++ = (b << 16) | a;
#endif
- }
- uint16_t* xx = (uint16_t*)xy;
- for (i = (count & 3); i > 0; --i) {
- *xx++ = TileProc::X(s, SkFractionalIntToFixed(fx), maxX); fx += dx;
- }
+ }
+ uint16_t* xx = (uint16_t*)xy;
+ for (i = (count & 3); i > 0; --i) {
+ *xx++ = TileProc::X(s, SkFractionalIntToFixed(fx), maxX); fx += dx;
}
}