src/blitter/32bpp_base.cpp
changeset 6948 d7d326482813
parent 6947 2e14760f63f9
child 6951 b24e0f108ede
equal deleted inserted replaced
6947:2e14760f63f9 6948:d7d326482813
    30 		}
    30 		}
    31 		video = (uint32 *)video + _screen.pitch;
    31 		video = (uint32 *)video + _screen.pitch;
    32 	} while (--height);
    32 	} while (--height);
    33 }
    33 }
    34 
    34 
       
    35 void Blitter_32bppBase::DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 color)
       
    36 {
       
    37 	int dy;
       
    38 	int dx;
       
    39 	int stepx;
       
    40 	int stepy;
       
    41 	int frac;
       
    42 
       
    43 	dy = (y2 - y) * 2;
       
    44 	if (dy < 0) {
       
    45 		dy = -dy;
       
    46 		stepy = -1;
       
    47 	} else {
       
    48 		stepy = 1;
       
    49 	}
       
    50 
       
    51 	dx = (x2 - x) * 2;
       
    52 	if (dx < 0) {
       
    53 		dx = -dx;
       
    54 		stepx = -1;
       
    55 	} else {
       
    56 		stepx = 1;
       
    57 	}
       
    58 
       
    59 	this->SetPixel(video, x, y, color);
       
    60 	if (dx > dy) {
       
    61 		frac = dy - (dx / 2);
       
    62 		while (x != x2) {
       
    63 			if (frac >= 0) {
       
    64 				y += stepy;
       
    65 				frac -= dx;
       
    66 			}
       
    67 			x += stepx;
       
    68 			frac += dy;
       
    69 			if (x > 0 && y > 0 && x < screen_width && y < screen_height) this->SetPixel(video, x, y, color);
       
    70 		}
       
    71 	} else {
       
    72 		frac = dx - (dy / 2);
       
    73 		while (y != y2) {
       
    74 			if (frac >= 0) {
       
    75 				x += stepx;
       
    76 				frac -= dy;
       
    77 			}
       
    78 			y += stepy;
       
    79 			frac += dx;
       
    80 			if (x > 0 && y > 0 && x < screen_width && y < screen_height) this->SetPixel(video, x, y, color);
       
    81 		}
       
    82 	}
       
    83 }
    35 void Blitter_32bppBase::CopyFromBuffer(void *video, const void *src, int width, int height, int src_pitch)
    84 void Blitter_32bppBase::CopyFromBuffer(void *video, const void *src, int width, int height, int src_pitch)
    36 {
    85 {
    37 	int direction = (height < 0) ? -1 : 1;
    86 	int direction = (height < 0) ? -1 : 1;
    38 	uint32 *dst = (uint32 *)video;
    87 	uint32 *dst = (uint32 *)video;
    39 	uint32 *usrc = (uint32 *)src;
    88 	uint32 *usrc = (uint32 *)src;