|
发表于 2006-12-13 13:58:38
|
显示全部楼层
//画屏幕水平直线,不检查合法性;
void Screen_Draw_Hline(int y, int x0,int x1, int Color);
//取得水平直线在矩形中合法的水平线段;
void Get_Rect_Hline(RECT *rect,int *y, int *x0,int *x1);
//在矩形中画水平直线;要求合法的矩形(在屏幕内);
void Draw_Rect_Hline(RECT *rect,int y, int x0,int x1, int Color);
//取得窗口中需要更新的矩形(在屏幕内);
void Get_Window_Invalidated(WINDOW *window,RECT *rect,int nrect);
//在窗口中画水平直线;
void Draw_Window_Hline(WINDOW *window,int y, int x0,int x1, int Color);
void Screen_Draw_Hline(int y, int x0,int x1, int Color)
{
//用的FRAMMEBUFFER,BPP=16;
unsigned short *offset = Screen.baseaddr + Screen.width * y + x0;
while(x0 <= x1)
{
*offset++ = Color;
}
}
void Get_Rect_Hline(RECT *rect,int *y, int *x0,int *x1);
{
if(*y < rect->y0 || *y > rect->y1)
{
*y = -1;
return;
}
if((*x0< rect->x0 && *x1< rect->x0) || (*x0 > rect->x1 && *x1 > rect->x1))
{
*y = -1;
return;
}
if(*x0 > *x1)
{
temp = *x0;
x0 = *x1;
*x1 = temp;
}
if(*x0 < rect->x0)
{
*x0 = rect->x0;
}
if(*x1 > rect->x1)
{
*x1 = rect->x1;
}
}
void Draw_Rect_Hline(RECT *rect,int y, int x0,int x1, int Color)
{
Get_Rect_Hline(rect, &y, &x0, &x1);
if(y>0)
{
Screen_Draw_Hline(y, x0, x1, Color);
}
}
void Get_Window_Invalidated(WINDOW *window,RECT *rect,int nrect)
{
//暂时没想好,因为我还没想好窗口因该定义成什么样的结构比较合适。
//目前想到,因该有个屏幕和所有窗口的全局MASK表,等等,还没定下来。
}
void Draw_Window_Hline(WINDOW *window,int y, int x0,int x1, int Color)
{
int nrect;
RECT *prect;
Get_Window_Invalidated(window,prect,&nrect);
for(;nrect>0;nrect--)
{
Draw_Rect_Hline(prect+nrect-1, y, x0, x1, Color);
}
free(prect);
} |
|