Fix up signed-integer-overflow warnings
When checking whether a matrix was a pure scale, we subtracted 0x3f800000 from the diagonals; if the diagonal value was already very negative, we'd underflow. Replace subtraction with XOR. When dealing with repeating tiled bitmaps, when the bitmap was very large, we'd multiply an offset by 65535, possibly causing underflow. Throw in a cast to long (casting to unsigned also silences the warning and wouldn't involve extension, but I can't convince myself that it's correct). BUG=skia:4635 R=mtklein@google.com Review URL: https://codereview.chromium.org/1504933002
This commit is contained in:
parent
d18b1b5adc
commit
d5c4265b49
@ -95,18 +95,20 @@ static SkBitmapProcState::MatrixProc ClampX_ClampY_Procs[] = {
|
||||
};
|
||||
|
||||
#define MAKENAME(suffix) RepeatX_RepeatY ## suffix
|
||||
#define TILEX_PROCF(fx, max) SK_USHIFT16(((fx) & 0xFFFF) * ((max) + 1))
|
||||
#define TILEY_PROCF(fy, max) SK_USHIFT16(((fy) & 0xFFFF) * ((max) + 1))
|
||||
#define TILEX_LOW_BITS(fx, max) ((((fx) & 0xFFFF) * ((max) + 1) >> 12) & 0xF)
|
||||
#define TILEY_LOW_BITS(fy, max) ((((fy) & 0xFFFF) * ((max) + 1) >> 12) & 0xF)
|
||||
#define TILEX_PROCF(fx, max) SK_USHIFT16((unsigned)((fx) & 0xFFFF) * ((max) + 1))
|
||||
#define TILEY_PROCF(fy, max) SK_USHIFT16((unsigned)((fy) & 0xFFFF) * ((max) + 1))
|
||||
#define TILEX_LOW_BITS(fx, max) (((unsigned)((fx) & 0xFFFF) * ((max) + 1) >> 12) & 0xF)
|
||||
#define TILEY_LOW_BITS(fy, max) (((unsigned)((fy) & 0xFFFF) * ((max) + 1) >> 12) & 0xF)
|
||||
#include "SkBitmapProcState_matrix.h"
|
||||
|
||||
struct RepeatTileProcs {
|
||||
static unsigned X(const SkBitmapProcState&, SkFixed fx, int max) {
|
||||
return SK_USHIFT16(((fx) & 0xFFFF) * ((max) + 1));
|
||||
SkASSERT(max < 65535);
|
||||
return SK_USHIFT16((unsigned)((fx) & 0xFFFF) * ((max) + 1));
|
||||
}
|
||||
static unsigned Y(const SkBitmapProcState&, SkFixed fy, int max) {
|
||||
return SK_USHIFT16(((fy) & 0xFFFF) * ((max) + 1));
|
||||
SkASSERT(max < 65535);
|
||||
return SK_USHIFT16((unsigned)((fy) & 0xFFFF) * ((max) + 1));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -156,7 +156,7 @@ uint8_t SkMatrix::computeTypeMask() const {
|
||||
} else {
|
||||
// Only test for scale explicitly if not affine, since affine sets the
|
||||
// scale bit.
|
||||
if ((m00 - kScalar1Int) | (m11 - kScalar1Int)) {
|
||||
if ((m00 ^ kScalar1Int) | (m11 ^ kScalar1Int)) {
|
||||
mask |= kScale_Mask;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user