From 6dccb811b733410fc0359ad1baae9416703ad29b Mon Sep 17 00:00:00 2001 From: Kp Date: Sat, 9 May 2015 17:39:00 +0000 Subject: [PATCH] Pass unsigned x/y to gr_pixel --- common/2d/pixel.cpp | 11 ++++++----- common/include/gr.h | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/common/2d/pixel.cpp b/common/2d/pixel.cpp index 312dc69a9..3be494ff5 100644 --- a/common/2d/pixel.cpp +++ b/common/2d/pixel.cpp @@ -30,8 +30,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "ogl_init.h" #endif - -void gr_upixel( int x, int y ) +void gr_upixel(unsigned x, unsigned y) { switch (TYPE) { @@ -46,9 +45,10 @@ void gr_upixel( int x, int y ) } } -void gr_pixel( int x, int y ) +void gr_pixel(unsigned x, unsigned y) { - if ((x<0) || (y<0) || (x>=GWIDTH) || (y>=GHEIGHT)) return; + if (unlikely(x >= GWIDTH || y >= GHEIGHT)) + return; gr_upixel (x, y); } @@ -69,6 +69,7 @@ static inline void gr_bm_upixel(grs_bitmap &bm, uint_fast32_t x, uint_fast32_t y void gr_bm_pixel(grs_bitmap &bm, uint_fast32_t x, uint_fast32_t y, uint8_t color ) { - if (x >= bm.bm_w || y >= bm.bm_h) return; + if (unlikely(x >= bm.bm_w || y >= bm.bm_h)) + return; gr_bm_upixel (bm, x, y, color); } diff --git a/common/include/gr.h b/common/include/gr.h index 3eb87ca85..8b08dc96b 100644 --- a/common/include/gr.h +++ b/common/include/gr.h @@ -311,8 +311,8 @@ void gr_setcolor(color_t color); void gr_settransblend(int fade_level, ubyte blend_func); // Draws a point into the current canvas in the current color and drawmode. -void gr_pixel(int x,int y); -void gr_upixel(int x,int y); +void gr_pixel(unsigned x, unsigned y); +void gr_upixel(unsigned x, unsigned y); // Gets a pixel; unsigned char gr_gpixel(const grs_bitmap &bitmap, int x, int y );