Prevent bit shifting if num bits is negative
Causes OpenGL Software Renderer to generate incorrect window
coordinates on MIPS & possibly x86
Change-Id: I3c51b6a5a4e6af75e9b31d9d47e4e4d894825888
Signed-off-by: Bhanu Chetlapalli <bhanu@mips.com>
diff --git a/libpixelflinger/fixed.cpp b/libpixelflinger/fixed.cpp
index 5b92062..5094537 100644
--- a/libpixelflinger/fixed.cpp
+++ b/libpixelflinger/fixed.cpp
@@ -62,7 +62,8 @@
int shift;
x = gglRecipQNormalized(x, &shift);
shift += 16-q;
- x += 1L << (shift-1); // rounding
+ if (shift > 0)
+ x += 1L << (shift-1); // rounding
x >>= shift;
return x;
}