📄 2d_engine.c
字号:
if (g2d_data->font_background_mode)
*(font_buff_ptr+j) = g2d_data->pat_bg_color;
}
}
}
x_pos++;
font_data>>=1;
font_bit_count++;
if (font_bit_count==8)
{ /* get next byte */
font_data=*(font_data_ptr+font_count);
font_bit_count=0;
font_count++;
}
}
}
}
else
{
for (i=0;i<g2d_data->src_height;i++)
{
if (g2d_data->italic_mode==0)
{
x_pos=g2d_data->dest_x;
y_pos=g2d_data->dest_y+i;
}
else
{
x_pos=g2d_data->dest_x+ (GET_G2D_TILT(i));
y_pos=g2d_data->dest_y+i;
}
font_buff_ptr1=((kal_uint8 *)g2d_data->dest_base_address + ((y_pos*g2d_data->dest_pitch + x_pos)));
for (j=0;j<g2d_data->src_width;j++)
{
font_bit = font_data & 0x01;
if ((x_pos>=0)&&(y_pos>=0))
{
if (g2d_data->clip_mode)
{
if ((x_pos>=g2d_data->clip_start_x) && (x_pos <=g2d_data->clip_end_x) &&
(y_pos>=g2d_data->clip_start_y) && (y_pos <=g2d_data->clip_end_y))
{ /* in clip range */
if (font_bit)
{
*(font_buff_ptr1+j) = g2d_data->pat_fg_color;
}
else
{
if (g2d_data->font_background_mode)
*(font_buff_ptr1+j) = g2d_data->pat_bg_color;
}
}
}
else
{
if (font_bit)
{
*(font_buff_ptr1+j) = g2d_data->pat_fg_color;
}
else
{
if (g2d_data->font_background_mode)
*(font_buff_ptr1+j) = g2d_data->pat_bg_color;
}
}
}
x_pos++;
font_data>>=1;
font_bit_count++;
if (font_bit_count==8)
{ /* get next byte */
font_data=*(font_data_ptr+font_count);
font_bit_count=0;
font_count++;
}
}
}
}
#endif
} /* g2d_sw_font_caching() */
#endif
void g2d_accelerator(g2d_parameter_struct *g2d_data)
{
#ifdef __MTK_TARGET__
#if (defined (MT6219)||defined(MT6226)||defined(MT6226M)||defined(MT6227))
kal_uint8 run_twice=KAL_FALSE;
kal_uint16 first_width,second_width;
short temp_width_height;
switch (g2d_data->g2d_operation_mode)
{
case G2D_OPERATION_LINE_DRAWING:
if ((g2d_data->end_x<0)||(g2d_data->end_y<0))
return;
if (g2d_data->start_x<0)
{
if (g2d_data->start_y>g2d_data->end_y)
{
g2d_data->start_y=g2d_data->start_y-(g2d_data->start_y-g2d_data->end_y)*(0-g2d_data->start_x)
/(g2d_data->end_x-g2d_data->start_x);
}
else
{
g2d_data->start_y=g2d_data->start_y+(g2d_data->end_y-g2d_data->start_y)*(0-g2d_data->start_x)
/(g2d_data->end_x-g2d_data->start_x);
}
g2d_data->start_x=0;
}
if (g2d_data->start_y<0)
{
if (g2d_data->end_x!=0)
{
if (g2d_data->start_x<g2d_data->end_x)
g2d_data->start_x=g2d_data->start_y*g2d_data->end_x/(g2d_data->end_y-g2d_data->start_y)*(-1);
else
g2d_data->start_x=g2d_data->start_x+g2d_data->start_y*(g2d_data->start_x-g2d_data->end_x)/
(g2d_data->end_y-g2d_data->start_y);
}
g2d_data->start_y=0;
}
if (g2d_data->dest_color_mode==G2D_DEST_16BPP_LUT_DISABLE)
{
g2d_data->dest_base_address += ((g2d_data->start_y * g2d_data->dest_pitch_width + g2d_data->start_x)<<1);
g2d_data->dest_pitch=(g2d_data->dest_pitch_width<<1);
}
else
{
g2d_data->dest_base_address += (g2d_data->start_y * g2d_data->dest_pitch_width + g2d_data->start_x);
g2d_data->dest_pitch=(g2d_data->dest_pitch_width);
}
g2d_line_drawing(g2d_data);
break;
case G2D_OPERATION_FONT_CACHING:
if ((g2d_data->dest_x>=0) && (g2d_data->dest_y>=0))
{
if (g2d_data->dest_color_mode==G2D_DEST_16BPP_LUT_DISABLE)
{
g2d_data->dest_base_address += ((g2d_data->dest_y * g2d_data->dest_pitch_width + g2d_data->dest_x)<<1);
g2d_data->dest_pitch=(g2d_data->dest_pitch_width<<1);
}
else if (g2d_data->dest_color_mode==G2D_DEST_8BPP_LUT_DISABLE)
{
g2d_data->dest_base_address += (g2d_data->dest_y * g2d_data->dest_pitch_width + g2d_data->dest_x);
g2d_data->dest_pitch=g2d_data->dest_pitch_width;
}
g2d_font_caching(g2d_data);
}
else
g2d_sw_font_caching(g2d_data);
break;
default:
if (g2d_data->g2d_operation_mode == G2D_OPERATION_BITBLT)
{
switch (g2d_data->bitblt_mode)
{
case BITBLT_TRANSFORM_MIRROR_ROTATE_90:
case BITBLT_TRANSFORM_ROTATE_90:
case BITBLT_TRANSFORM_ROTATE_270:
case BITBLT_TRANSFORM_MIRROR_ROTATE_270:
g2d_data->dest_width=g2d_data->src_height;
g2d_data->dest_height=g2d_data->src_width;
break;
case BITBLT_TRANSFORM_ROTATE_180:
case BITBLT_TRANSFORM_MIRROR:
case BITBLT_TRANSFORM_MIRROR_ROTATE_180:
g2d_data->dest_width=g2d_data->src_width;
g2d_data->dest_height=g2d_data->src_height;
break;
case BITBLT_TRANSFORM_COPY:
if (((g2d_data->src_width!=g2d_data->dest_width)||
(g2d_data->src_height!=g2d_data->dest_height))&&
((g2d_data->dest_x<0)||(g2d_data->dest_y<0)))
{
g2d_multi_bitblt(g2d_data);
return;
}
break;
}
}
else if (g2d_data->g2d_operation_mode==G2D_OPERATION_ALPHA_BLENDING)
{
g2d_data->dest_width=g2d_data->src_width;
g2d_data->dest_height=g2d_data->src_height;
}
if (g2d_data->dest_x<0)
{
temp_width_height=g2d_data->dest_x+g2d_data->dest_width;
if (temp_width_height<0)
return;
g2d_data->dest_width=temp_width_height;
if (g2d_data->g2d_operation_mode == G2D_OPERATION_BITBLT)
{
switch (g2d_data->bitblt_mode)
{
case BITBLT_TRANSFORM_ROTATE_90:
case BITBLT_TRANSFORM_MIRROR_ROTATE_90:
g2d_data->src_height=g2d_data->dest_width;
break;
case BITBLT_TRANSFORM_ROTATE_180:
case BITBLT_TRANSFORM_MIRROR:
g2d_data->src_width=g2d_data->dest_width;
break;
case BITBLT_TRANSFORM_ROTATE_270:
case BITBLT_TRANSFORM_MIRROR_ROTATE_270:
g2d_data->src_height=g2d_data->dest_width;
g2d_data->src_y-=g2d_data->dest_x;
break;
case BITBLT_TRANSFORM_COPY:
case BITBLT_TRANSFORM_MIRROR_ROTATE_180:
g2d_data->src_x-=g2d_data->dest_x;
g2d_data->src_width=g2d_data->dest_width;
break;
}
}
else if (g2d_data->g2d_operation_mode == G2D_OPERATION_ALPHA_BLENDING)
{
g2d_data->src_x-=g2d_data->dest_x;
g2d_data->src_width=g2d_data->dest_width;
}
g2d_data->dest_x=0;
}
if (g2d_data->dest_y<0)
{
temp_width_height=g2d_data->dest_y+g2d_data->dest_height;
if (temp_width_height<0)
return;
g2d_data->dest_height=temp_width_height;
if (g2d_data->g2d_operation_mode == G2D_OPERATION_BITBLT)
{
switch (g2d_data->bitblt_mode)
{
case BITBLT_TRANSFORM_ROTATE_90:
case BITBLT_TRANSFORM_MIRROR_ROTATE_270:
g2d_data->src_width=g2d_data->dest_height;
g2d_data->src_x-=g2d_data->dest_y;
break;
case BITBLT_TRANSFORM_ROTATE_180:
case BITBLT_TRANSFORM_MIRROR_ROTATE_180:
g2d_data->src_height=g2d_data->dest_height;
break;
case BITBLT_TRANSFORM_ROTATE_270:
case BITBLT_TRANSFORM_MIRROR_ROTATE_90:
g2d_data->src_width=g2d_data->dest_height;
break;
case BITBLT_TRANSFORM_COPY:
case BITBLT_TRANSFORM_MIRROR:
g2d_data->src_y-=g2d_data->dest_y;
g2d_data->src_height=g2d_data->dest_height;
break;
}
}
else if (g2d_data->g2d_operation_mode == G2D_OPERATION_ALPHA_BLENDING)
{
g2d_data->src_y-=g2d_data->dest_y;
g2d_data->src_height=g2d_data->dest_height;
}
g2d_data->dest_y=0;
}
switch (g2d_data->dest_color_mode)
{
case G2D_DEST_16BPP_LUT_DISABLE:
case G2D_DEST_16BPP_LUT_ENABLE:
g2d_data->dest_pitch=(g2d_data->dest_pitch_width<<1);
if (g2d_data->g2d_operation_mode==G2D_OPERATION_BITBLT)
{
switch (g2d_data->bitblt_mode)
{
case BITBLT_TRANSFORM_COPY:
case BITBLT_TRANSFORM_MIRROR_ROTATE_270:
g2d_data->dest_base_address += ((g2d_data->dest_pitch_width * g2d_data->dest_y + g2d_data->dest_x)<<1);
break;
case BITBLT_TRANSFORM_ROTATE_90:
case BITBLT_TRANSFORM_MIRROR:
g2d_data->dest_base_address += ((g2d_data->dest_pitch_width * g2d_data->dest_y +
g2d_data->dest_x + g2d_data->dest_width-1)<<1);
break;
case BITBLT_TRANSFORM_ROTATE_180:
case BITBLT_TRANSFORM_MIRROR_ROTATE_90:
g2d_data->dest_base_address += ((g2d_data->dest_pitch_width * (g2d_data->dest_y+g2d_data->dest_height-1)+
g2d_data->dest_x + g2d_data->dest_width-1)<<1);
break;
case BITBLT_TRANSFORM_ROTATE_270 :
case BITBLT_TRANSFORM_MIRROR_ROTATE_180:
g2d_data->dest_base_address += ((g2d_data->dest_pitch_width * (g2d_data->dest_y+g2d_data->dest_height-1)+
g2d_data->dest_x)<<1);
break;
}
}
else
g2d_data->dest_base_address += ((g2d_data->dest_pitch_width * g2d_data->dest_y + g2d_data->dest_x)<<1);
break;
case G2D_DEST_8BPP_LUT_DISABLE:
g2d_data->dest_pitch=g2d_data->dest_pitch_width;
if (g2d_data->g2d_operation_mode==G2D_OPERATION_BITBLT)
{
switch (g2d_data->bitblt_mode)
{
case BITBLT_TRANSFORM_COPY:
case BITBLT_TRANSFORM_MIRROR_ROTATE_270:
g2d_data->dest_base_address += ((g2d_data->dest_pitch_width * g2d_data->dest_y + g2d_data->dest_x));
break;
case BITBLT_TRANSFORM_ROTATE_90:
case BITBLT_TRANSFORM_MIRROR:
g2d_data->dest_base_address += ((g2d_data->dest_pitch_width * g2d_data->dest_y +
g2d_data->dest_x + g2d_data->dest_width-1));
break;
case BITBLT_TRANSFORM_ROTATE_180:
case BITBLT_TRANSFORM_MIRROR_ROTATE_90:
g2d_data->dest_base_address += ((g2d_data->dest_pitch_width * (g2d_data->dest_y+g2d_data->dest_height-1)+
g2d_data->dest_x + g2d_data->dest_width-1));
break;
case BITBLT_TRANSFORM_ROTATE_270 :
case BITBLT_TRANSFORM_MIRROR_ROTATE_180:
g2d_data->dest_base_address += ((g2d_data->dest_pitch_width * (g2d_data->dest_y+g2d_data->dest_height-1)+
g2d_data->dest_x));
break;
}
}
else
g2d_data->dest_base_address += (g2d_data->dest_pitch_width * g2d_data->dest_y + g2d_data->dest_x);
break;
}
switch (g2d_data->src_color_mode)
{
case G2D_SRC_16BPP_LUT_DISABLE:
g2d_data->src_pitch=(g2d_data->src_pitch_width<<1);
g2d_data->src_base_address += ((g2d_data->src_pitch_width * g2d_data->src_y + g2d_data->src_x)<<1);
break;
case G2D_SRC_8BPP_LUT_DISABLE:
case G2D_SRC_8BPP_LUT_ENABLE:
g2d_data->src_pitch=g2d_data->src_pitch_width;
g2d_data->src_base_address += (g2d_data->src_pitch_width * g2d_data->src_y + g2d_data->src_x);
break;
}
if (g2d_data->dest_width==g2d_data->dest_pitch_width)
{
run_twice=KAL_TRUE;
first_width=(g2d_data->dest_width>>1);
second_width=g2d_data->dest_width-first_width;
g2d_data->dest_width=first_width;
}
switch (g2d_data->g2d_operation_mode)
{
case G2D_OPERATION_RECTANGLE_FILL:
g2d_rectangle_fill(g2d_data);
break;
case G2D_OPERATION_BITBLT:
g2d_bitblt(g2d_data);
break;
case G2D_OPERATION_ALPHA_BLENDING:
g2d_alpha_bitblt(g2d_data);
break;
case G2D_OPERATION_FONT_CACHING:
break;
}
if (run_twice==KAL_TRUE)
{
g2d_data->dest_x+=first_width;
if (g2d_data->dest_color_mode==G2D_DEST_16BPP_LUT_DISABLE)
{
g2d_data->src_base_address+=(first_width<<1);
g2d_data->dest_base_address+=(first_width<<1);
}
else if (g2d_data->dest_color_mode==G2D_DEST_8BPP_LUT_DISABLE)
{
g2d_data->src_base_address+=(first_width);
g2d_data->dest_base_address+=(first_width);
}
g2d_data->dest_width=second_width;
switch (g2d_data->g2d_operation_mode)
{
case G2D_OPERATION_RECTANGLE_FILL:
g2d_rectangle_fill(g2d_data);
break;
case G2D_OPERATION_BITBLT:
g2d_bitblt(g2d_data);
break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -