📄 r2d_vertical_lcd_i.c
字号:
{
if (rx>0)
h=-1;
else
h=1;
if (ry>0)
v=-1;
else
v=1;
}
*h_direction=h;
*v_direction=v;
}
#if (R2D_ASM == R2D_OFF)
static UINT32 r2d_get_pixel_value(T_R2D_GC_PTR gc,R2D_BOOLEAN foreground,INT16 x,INT16 y)
{
UINT32 pixel_value;
if (foreground)
{
#if (R2D_DITHERING == R2D_OFF)
pixel_value=((T_R2D_GC*)gc)->foreground_pixel_value;
#else
pixel_value=r2d_get_dithering_matrix_entry(((T_R2D_GC*)gc)->p_foreground_dithered_cache,x,y);
#endif
}
else
{
#if (R2D_DITHERING == R2D_OFF)
pixel_value=((T_R2D_GC*)gc)->background_pixel_value;
#else
pixel_value=r2d_get_dithering_matrix_entry(((T_R2D_GC*)gc)->p_background_dithered_cache,x,y);
#endif
}
return(pixel_value);
}
// When foreground color is used, the source pixel
// is converted to the background or foreground color
// then dithered
static UINT32 r2d_convert_from_lcd_to_lcd(R2D_BOOLEAN use_foreground,UINT32 src,T_R2D_GC_PTR src_gc,T_R2D_GC_PTR dst_gc,INT16 x,INT16 y)
{
if (use_foreground)
{
UINT32 pixel_value;
if (IND_r2d_lcd_foreground_pixel(src,src_gc))
pixel_value=r2d_get_pixel_value(dst_gc,TRUE,x,y);
else
pixel_value=r2d_get_pixel_value(dst_gc,FALSE,x,y);
return(pixel_value);
}
else return(src);
}
static UINT32 r2d_convert_from_color_to_color(R2D_BOOLEAN use_foreground,UINT32 src,T_R2D_GC_PTR src_gc,T_R2D_GC_PTR dst_gc,INT16 x,INT16 y)
{
if (use_foreground)
{
UINT32 pixel_value;
if (IND_r2d_color_framebuffer_foreground_pixel(src,src_gc))
pixel_value=r2d_get_pixel_value(dst_gc,TRUE,x,y);
else
pixel_value=r2d_get_pixel_value(dst_gc,FALSE,x,y);
return(pixel_value);
}
else return(src);
}
static UINT32 r2d_convert_from_color_to_lcd(R2D_BOOLEAN use_foreground,UINT32 src,T_R2D_GC_PTR src_gc,T_R2D_GC_PTR dst_gc,INT16 x,INT16 y)
{
if (use_foreground)
{
UINT32 pixel_value;
if (IND_r2d_color_framebuffer_foreground_pixel(src,src_gc))
pixel_value=r2d_get_pixel_value(dst_gc,TRUE,x,y);
else
pixel_value=r2d_get_pixel_value(dst_gc,FALSE,x,y);
return(pixel_value);
}
else return(IND_r2d_color_to_lcd(src,x,y));
}
static UINT32 r2d_convert_from_lcd_to_color(R2D_BOOLEAN use_foreground,UINT32 src,T_R2D_GC_PTR src_gc,T_R2D_GC_PTR dst_gc,INT16 x,INT16 y)
{
if (use_foreground)
{
UINT32 pixel_value;
if (IND_r2d_lcd_foreground_pixel(src,src_gc))
pixel_value=r2d_get_pixel_value(dst_gc,TRUE,x,y);
else
pixel_value=r2d_get_pixel_value(dst_gc,FALSE,x,y);
return(pixel_value);
}
else
{
return(IND_r2d_lcd_to_color(src));
}
}
// FOR DEBUG
//#define dop(a,b) b
#define r2d_shift_pixel_down_and_write(dst,src) {\
dst##value =R2D_PIXEL_DOWN_OUT(dst##value); \
dst##value|=dop((dst##_current & R2D_PIXEL_MASK), \
r2d_convert_from_lcd_to_lcd(use_foreground_color,\
src##_current & R2D_PIXEL_MASK,src_gc,dst_gc,x,y)) \
<< ((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH) ; \
src##_current=R2D_PIXEL_DOWN_OUT(src##_current); \
dst##_current=R2D_PIXEL_DOWN_OUT(dst##_current); \
dst##counter--; \
src##counter--; \
if (src##counter==0) \
{ \
src##counter=(1<<R2D_PIXELS_PER_MEMORY_WORD); \
src##_current=*++p_##src##_current; \
} \
if (dst##counter==0) \
{ \
dst##counter=(1<<R2D_PIXELS_PER_MEMORY_WORD); \
} \
}
#define r2d_shift_pixel_up_and_write(dst,src) {\
dst##value =R2D_PIXEL_UP_OUT(dst##value); \
dst##value |=dop( \
(dst##_current >> ((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH)) & R2D_PIXEL_MASK, \
r2d_convert_from_lcd_to_lcd(use_foreground_color,\
(src##_current >> ((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH)) & R2D_PIXEL_MASK, \
src_gc,dst_gc,x,y)); \
src##_current=R2D_PIXEL_UP_OUT(src##_current); \
dst##_current=R2D_PIXEL_UP_OUT(dst##_current); \
dst##counter--; \
src##counter--; \
if (src##counter==0) \
{ \
src##counter=(1<<R2D_PIXELS_PER_MEMORY_WORD); \
src##_current=*--p_##src##_current; \
} \
if (dst##counter==0) \
{ \
dst##counter=(1<<R2D_PIXELS_PER_MEMORY_WORD); \
} \
}
extern UINT32 r2d_lcd_xor_operator(UINT32 old, UINT32 value);
extern UINT32 r2d_lcd_copy_operator(UINT32 old, UINT32 value);
extern UINT32 r2d_lcd_and_operator(UINT32 old, UINT32 value);
extern UINT32 r2d_lcd_or_operator(UINT32 old,UINT32 value);
// Requires shapes in graphic context coordinates
void r2d_blit_lcd_to_lcd(T_R2D_GC_PTR src_gc,T_R2D_GC_PTR dst_gc,
T_R2D_SHAPE_PTR src_rectangle,
T_R2D_SHAPE_PTR dst_rectangle,
R2D_BOOLEAN use_foreground_color)
{
UINT32 *p_src,*p_dst,*p_src_current,*p_dst_current,*p_src_start,*p_dst_start;
INT16 rect_width,rect_height,src_x,src_y,dst_x,dst_y;
INT16 src_offset,dst_offset,src_height,dst_height;
INT16 xnb,ynb,src_nb_rows,dst_nb_rows;
INT16 src_dy,dst_dy,end_dst_dy,end_src_dy; // distance from word boundary
INT16 shift; // relative position (modulo a memory word) between both rectangles
// in bits
INT16 current_src_dy,current_dst_dy;
INT16 temp,dstcounter,srccounter;
register UINT32 dstvalue,dst_current;
register UINT32 srcvalue,src_current;
INT32 h_direction,v_direction;
INT16 x,y;
T_R2D_DRAWING_MODE mode;
T_R2D_DRAWING_OP dop;
BOOLEAN compensate=TRUE;
dop=((T_R2D_GC*)dst_gc)->drawing_op;
{
p_src=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)src_gc)->p_frame_buffer))->p_memory_words;
p_dst=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))->p_memory_words;
rect_width=r2d_get_xmax(src_rectangle)-r2d_get_xmin(src_rectangle);
rect_height=r2d_get_ymax(src_rectangle)-r2d_get_ymin(src_rectangle);
mode=IND_r2d_get_drawing_mode(dst_gc);
src_x=r2d_get_xmin(src_rectangle);
src_y=r2d_get_ymin(src_rectangle);
dst_x=r2d_get_xmin(dst_rectangle);
dst_y=r2d_get_ymin(dst_rectangle);
src_dy=(src_y & R2D_WORD_POSITION_MASK);
dst_dy=(dst_y & R2D_WORD_POSITION_MASK);
// Clipping convention such end_dst_dy is the first y position which must not
// be copied at the end of a column
//printf("dest y max=%d\n",r2d_get_ymax(dst_rectangle));
end_dst_dy=((r2d_get_ymax(dst_rectangle)-1) & R2D_WORD_POSITION_MASK) ;
end_src_dy=((r2d_get_ymax(src_rectangle)-1) & R2D_WORD_POSITION_MASK) ;
//printf("dst_dy, end_dst_dy before reverse=%d,%d\n",dst_dy,end_dst_dy);
// Number of rows is word containing last point - word containing first point
// + 1
// We remove - 1 because last PIXEL is at 1 from the frontier line
dst_nb_rows=R2D_ALIGNED_MWLENGTH(r2d_get_ymax(dst_rectangle)-1)-R2D_ALIGNED_MWLENGTH(dst_y)+1;
src_nb_rows=R2D_ALIGNED_MWLENGTH(r2d_get_ymax(src_rectangle)-1)-R2D_ALIGNED_MWLENGTH(src_y)+1;
//printf("src_nb_rows %d\n",src_nb_rows);
//printf("dst_nb_rows %d\n",dst_nb_rows);
h_direction=1;
v_direction=1;
if (((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)src_gc)->p_frame_buffer))==
((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer)))
r2d_check_rectangle_overlap(src_x,src_y,dst_x,dst_y,
rect_width,rect_height,&h_direction,&v_direction);
//printf("h,v=%d,%d\n",h_direction,v_direction);
#if (R2D_REFRESH == R2D_VERTICAL)
src_height=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)src_gc)->p_frame_buffer))->height;
dst_height=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))->height;
#else
src_height=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)src_gc)->p_frame_buffer))->width;
dst_height=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))->width;
#endif
src_offset=R2D_ALIGNED_MWLENGTH(src_height);
dst_offset=R2D_ALIGNED_MWLENGTH(dst_height);
//printf("%08X,dst offset=%08X\n",p_dst,dst_offset);
p_src_start=p_src
+((src_x*src_offset+(src_y>>R2D_PIXELS_PER_MEMORY_WORD)));
p_dst_start=p_dst
+((dst_x*dst_offset+(dst_y>>R2D_PIXELS_PER_MEMORY_WORD)));
xnb=rect_width;
//printf("src start %08X contains %08X\n",p_src_start,*p_src_start);
//printf("dst start %08X contains %08X\n",p_dst_start,*p_dst_start);
//printf("rect_width %d\n",rect_width);
if (h_direction==-1)
{
x=r2d_get_xmax(dst_rectangle)-1;
p_src_start+=(rect_width-1)*src_offset;
p_dst_start+=(rect_width-1)*dst_offset;
}
else
x=r2d_get_xmin(dst_rectangle);
//printf("src start %08X contains %08X\n",p_src_start,*p_src_start);
//printf("dst start %08X contains %08X\n",p_dst_start,*p_dst_start);
if (v_direction==-1)
{
p_src_start+=src_nb_rows-1;
p_dst_start+=dst_nb_rows-1;
temp=src_dy;
src_dy=end_src_dy;
end_src_dy=temp;
temp=dst_dy;
dst_dy=end_dst_dy;
end_dst_dy=temp;
}
//printf("src start %08X contains %08X\n",p_src_start,*p_src_start);
//printf("dst start %08X contains %08X\n",p_dst_start,*p_dst_start);
//printf("dst_start=%08X contains %08X\n",p_dst_start,*p_dst_start);
while(xnb!=0)
{
p_dst_current=p_dst_start;
p_src_current=p_src_start;
//printf("xnb=%d\n",xnb);
//printf("src start %08X contains %08X\n",p_src_start,*p_src_start);
//printf("dst start %08X contains %08X\n",p_dst_start,*p_dst_start);
ynb=dst_nb_rows-1;
if (v_direction==-1)
{
y=r2d_get_ymax(dst_rectangle) - 1;
current_src_dy=(1<<R2D_PIXELS_PER_MEMORY_WORD)-1;
current_dst_dy=(1<<R2D_PIXELS_PER_MEMORY_WORD)-1;
}
else
{
current_src_dy=0;
current_dst_dy=0;
y=r2d_get_ymin(dst_rectangle);
}
dstcounter=(1<<R2D_PIXELS_PER_MEMORY_WORD);
srccounter=(1<<R2D_PIXELS_PER_MEMORY_WORD);
dst_current=*p_dst_current;
src_current=*p_src_current;
//printf("src_current=%08X, dst_current=%08X\n",src_current,dst_current);
temp=0;
//printf("new column\n dst=%08X\n",p_dst_current);
//printf("current_dst_dy =%d, dst_dy=%d\n",current_dst_dy,dst_dy);
dstvalue=0;
if (v_direction==-1)
{
while(current_dst_dy!=dst_dy)
{
r2d_shift_pixel_up(dstvalue,dst_current,dstcounter,p_dst_current);
current_dst_dy--;
//printf("dstcounter=%d\n",dstcounter);
y--;
}
while(current_src_dy!=src_dy)
{
//printf("current_src_dy=%d\n",current_src_dy);
//printf("srccounter=%d\n",srccounter);
r2d_shift_pixel_up(temp,src_current,srccounter,p_src_current);
current_src_dy--;
//printf("src_current=%08X\n",src_current);
}
while(ynb!=0)
{
r2d_shift_pixel_up_and_write(dst,src);
//printf("srccounter=%d\n",srccounter);
y--;
if (dstcounter==(1<<R2D_PIXELS_PER_MEMORY_WORD))
{
ynb--;
*p_dst_current--=dstvalue;
#if (R2D_DEBUG == R2D_ON)
#if (R2D_DEBUG_WARNING == R2D_DEBUG_HIGH)
if ((p_dst_current<((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))->p_memory_words)
|| (p_dst_current>((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))->p_frame_buffer_end))
{
//printf("Error : frame_buffer overflow\n");
IND_rvf_send_trace("R2D : Framebuffer overflow B",28, NULL_PARAM,
RV_TRACE_LEVEL_ERROR, R2D_USE_ID );
}
#endif
#endif
current_dst_dy=(1<<R2D_PIXELS_PER_MEMORY_WORD)-1;
dst_current=*p_dst_current;
//printf("%08X <- %08X\n",p_dst_current,dstvalue);
dstvalue=0;
}
}
current_dst_dy++;
while(current_dst_dy!=end_dst_dy)
{
r2d_shift_pixel_up_and_write(dst,src);
current_dst_dy--;
//printf("Last row %08X, %08X\n",p_dst_current,current_dst_dy);
y--;
}
if (dstcounter==(1<<R2D_PIXELS_PER_MEMORY_WORD))
compensate=FALSE;
while(dstcounter!=(1<<R2D_PIXELS_PER_MEMORY_WORD))
{
r2d_shift_pixel_up(dstvalue,dst_current,dstcounter,p_dst_current);
current_dst_dy--;
//printf(" Last row %08X\n",p_src_current);
//printf("dstcounter=%d\n",dstcounter);
y--;
}
if (compensate==TRUE)
{
*++p_dst_current=dstvalue;
}
else
{
*p_dst_current=dstvalue;
}
#if (R2D_DEBUG == R2D_ON)
#if (R2D_DEBUG_WARNING == R2D_DEBUG_HIGH)
if ((p_dst_current<((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))->p_memory_words)
|| (p_dst_current>((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))->p_frame_buffer_end))
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -