@ -7,15 +7,16 @@
* See the GNU General Public License for more details . You should have received a copy of the GNU General Public License along with OpenTTD . If not , see < http : //www.gnu.org/licenses/>.
*/
/** @file base.cpp Implementation of the base for all blitters. */
/** @file common.hpp Common functionality for all blitter implementations. */
# ifndef BLITTER_COMMON_HPP
# define BLITTER_COMMON_HPP
# include "../stdafx.h"
# include "base.hpp"
# include "../core/math_func.hpp"
# include "../safeguards.h"
void Blitter : : DrawLine ( void * video , int x , int y , int x2 , int y2 , int screen_width , int screen_height , uint8 colour , int width , int dash )
template < typename SetPixelT >
void Blitter : : DrawLineGeneric ( int x , int y , int x2 , int y2 , int screen_width , int screen_height , int width , int dash , SetPixelT set_pixel )
{
int dy ;
int dx ;
@ -40,7 +41,7 @@ void Blitter::DrawLine(void *video, int x, int y, int x2, int y2, int screen_wid
if ( dx = = 0 & & dy = = 0 ) {
/* The algorithm below cannot handle this special case; make it work at least for line width 1 */
if ( x > = 0 & & x < screen_width & & y > = 0 & & y < screen_height ) this - > SetPixel ( video , x , y , colour ) ;
if ( x > = 0 & & x < screen_width & & y > = 0 & & y < screen_height ) set_pixel ( x , y ) ;
return ;
}
@ -83,7 +84,7 @@ void Blitter::DrawLine(void *video, int x, int y, int x2, int y2, int screen_wid
while ( x ! = x2 ) {
if ( dash_count < dash & & x > = 0 & & x < screen_width ) {
for ( int y = y_low ; y ! = y_high ; y + = stepy ) {
if ( y > = 0 & & y < screen_height ) this - > SetPixel ( video , x , y , colour ) ;
if ( y > = 0 & & y < screen_height ) set_pixel ( x , y ) ;
}
}
if ( frac_low > = 0 ) {
@ -118,7 +119,7 @@ void Blitter::DrawLine(void *video, int x, int y, int x2, int y2, int screen_wid
while ( y ! = y2 ) {
if ( dash_count < dash & & y > = 0 & & y < screen_height ) {
for ( int x = x_low ; x ! = x_high ; x + = stepx ) {
if ( x > = 0 & & x < screen_width ) this - > SetPixel ( video , x , y , colour ) ;
if ( x > = 0 & & x < screen_width ) set_pixel ( x , y ) ;
}
}
if ( frac_low > = 0 ) {
@ -136,3 +137,5 @@ void Blitter::DrawLine(void *video, int x, int y, int x2, int y2, int screen_wid
}
}
}
# endif /* BLITTER_COMMON_HPP */