aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJez Ng <me@jezng.com>2013-07-10 15:20:27 -0700
committerJez Ng <me@jezng.com>2013-07-10 15:28:04 -0700
commit827d8314b1ecab7e2ea5d171521c505928c55202 (patch)
tree6b4b8d578762ea765c34876dcf4605eefd1ce8da
parente45d35c401bed52cc096187db3912e63b6ecce64 (diff)
Cast signedness in library_SDL functions.
-rw-r--r--src/library_sdl.js14
-rwxr-xr-xtests/runner.py2
2 files changed, 14 insertions, 2 deletions
diff --git a/src/library_sdl.js b/src/library_sdl.js
index 2dd347d7..de644aac 100644
--- a/src/library_sdl.js
+++ b/src/library_sdl.js
@@ -246,7 +246,7 @@ var LibrarySDL = {
},
translateRGBAToCSSRGBA: function(r, g, b, a) {
- return 'rgba(' + r + ',' + g + ',' + b + ',' + (a/255) + ')';
+ return 'rgba(' + (r&0xff) + ',' + (g&0xff) + ',' + (b&0xff) + ',' + (a&0xff)/255 + ')';
},
translateRGBAToColor: function(r, g, b, a) {
@@ -1713,6 +1713,10 @@ var LibrarySDL = {
$SDL_gfx: {
drawRectangle: function(surf, x1, y1, x2, y2, action, cssColor) {
+ x1 = x1 << 16 >> 16;
+ y1 = y1 << 16 >> 16;
+ x2 = x2 << 16 >> 16;
+ y2 = y2 << 16 >> 16;
var surfData = SDL.surfaces[surf];
assert(!surfData.locked); // but we could unlock and re-lock if we must..
// TODO: if ctx does not change, leave as is, and also do not re-set xStyle etc.
@@ -1726,6 +1730,10 @@ var LibrarySDL = {
surfData.ctx.restore();
},
drawLine: function(surf, x1, y1, x2, y2, cssColor) {
+ x1 = x1 << 16 >> 16;
+ y1 = y1 << 16 >> 16;
+ x2 = x2 << 16 >> 16;
+ y2 = y2 << 16 >> 16;
var surfData = SDL.surfaces[surf];
assert(!surfData.locked); // but we could unlock and re-lock if we must..
surfData.ctx.save();
@@ -1738,6 +1746,10 @@ var LibrarySDL = {
},
// See http://stackoverflow.com/questions/2172798/how-to-draw-an-oval-in-html5-canvas
drawEllipse: function(surf, x, y, rx, ry, action, cssColor) {
+ x = x << 16 >> 16;
+ y = y << 16 >> 16;
+ rx = rx << 16 >> 16;
+ ry = ry << 16 >> 16;
var surfData = SDL.surfaces[surf];
assert(!surfData.locked); // but we could unlock and re-lock if we must..
diff --git a/tests/runner.py b/tests/runner.py
index 722f8130..7b894110 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -13187,7 +13187,7 @@ Press any key to continue.'''
self.btest('sdl_rotozoom.c', reference='sdl_rotozoom.png', args=['--preload-file', 'screenshot.png'], reference_slack=3)
def test_sdl_gfx_primitives(self):
- self.btest('sdl_gfx_primitives.c', reference='sdl_gfx_primitives.png', reference_slack=3)
+ self.btest('sdl_gfx_primitives.c', reference='sdl_gfx_primitives.png', reference_slack=1)
def test_sdl_canvas_palette_2(self):
open(os.path.join(self.get_dir(), 'pre.js'), 'w').write('''