#include "DHL_OSAL.h" #include "DHL_DBG.h" #include "DHL_Graphic.h" #include "DMG_Draw.h" #include "DMG_Util.h" #if SUPPORT_JUNGLE #include "grp_jungle.h" #endif #if SUPPORT_BMF #include "BMF.h" #endif //#include //#include DHL_MODULE("DMG_D", 0); /* config */ #define USE_KOR_AUTO_CHANGE 1 #define USE_GRP_MTX 0 #if USE_KOR_AUTO_CHANGE #define DEF_KOR_FONT (eDMG_FONT_DHL+1) /*±âº» ÇÑ±Û ÆùÆ®*/ #endif static tDHL_GrpRect p_rect={0,0,0,0}; static tDHL_PlaneID p_plane_id; static tDMG_FontAttr p_font_attr; #if USE_GRP_MTX static OS_SEMAPHORE_ID p_mtx; #endif static int p_temp_font_size; #if COMMENT __Local_Func__() {} #endif #if USE_GRP_MTX static void p_lock(BOOL block) { if(!p_mtx) return; if(block) OS_TakeSemaphore(p_mtx); else OS_GiveSemaphore(p_mtx); } #else #define p_lock(lock) #endif static void p_merge_rect(tDHL_GrpRect *r1, int x, int y, int w, int h) { /* r1¿¡ r2¸¦ mergeÇÔ */ if(r1->w==0 && r1->h==0) {r1->x=x; r1->y=y; r1->w=w; r1->h=h; return;} if(r1->x>x) {r1->w+=r1->x-x; r1->x=x;} if(r1->y>y) {r1->h+=r1->y-y; r1->y=y;} if(r1->x+r1->ww=x+w-r1->x; if(r1->y+r1->hh=y+h-r1->y; dprint(2, "--> auto refresh(%d,%d,%d,%d)->(%d,%d,%d,%d)\n", x, y, w, h, r1->x, r1->y, r1->w, r1->h); } const static UINT32 p_color_table[][2]={ {eDMG_C_TRANSPARENT, 0x00000000}, {eDMG_C_BLACK, 0xff000000}, {eDMG_C_RED, 0xffff0000}, {eDMG_C_GREEN, 0xff00ff00}, {eDMG_C_BLUE, 0xff0000ff}, {eDMG_C_YELLOW, 0xffffff00}, {eDMG_C_MAGENTA, 0xffff00ff}, {eDMG_C_CYAN, 0xff00ffff}, {eDMG_C_WHITE, 0xffffffff}, {eDMG_C_H_BLACK, 0x8f000000}, {eDMG_C_H_RED, 0x8fff0000}, {eDMG_C_H_GREEN, 0x8f00ff00}, {eDMG_C_H_BLUE, 0x8f0000ff}, {eDMG_C_H_YELLOW, 0x8fffff00}, {eDMG_C_H_MAGENTA, 0x8fff00ff}, {eDMG_C_H_CYAN, 0x8f00ffff}, {eDMG_C_H_WHITE, 0x8fffffff} }; static UINT32 p_convert_color(UINT32 color) { UINT32 ret_color; unsigned int i; tDHL_PixelType pixel_type; for(i=0; i<(int)sizeof(p_color_table)/sizeof(p_color_table[0]); i++) { if(color==p_color_table[i][0]) return p_color_table[i][1]; } return color; } #if COMMENT __Draw_Func__() {} #endif void DMG_SetPlane(tDHL_PlaneID id) { p_lock(TRUE); p_plane_id=id; p_lock(FALSE); } tDHL_PlaneID DMG_GetPlane() { return p_plane_id; } UINT32 DMG_ConvertDefColor(UINT32 color) { return p_convert_color(color); } void DMG_FillRect(int x, int y, int w, int h, UINT32 color) { p_lock(TRUE); DHL_FillRect(p_plane_id, x, y, w, h, p_convert_color(color)); p_merge_rect(&p_rect, x, y, w, h); p_lock(FALSE); } void DMG_EraseRect(int x, int y, int w, int h, UINT32 color) { p_lock(TRUE); DHL_EraseRect(p_plane_id, x, y, w, h, p_convert_color(color)); p_merge_rect(&p_rect, x, y, w, h); p_lock(FALSE); } void DMG_DrawHLine(int x, int y, int w, UINT32 color) { p_lock(TRUE); DHL_DrawHLine(p_plane_id, x, y, w, p_convert_color(color)); p_merge_rect(&p_rect, x, y, w, 1); p_lock(FALSE); } void DMG_DrawVLine(int x, int y, int h, UINT32 color) { p_lock(TRUE); DHL_DrawVLine(p_plane_id, x, y, h, p_convert_color(color)); p_merge_rect(&p_rect, x, y, 1, h); p_lock(FALSE); } void DMG_BLT(tDHL_PlaneID src_id, tDHL_PlaneID dst_id, tDHL_GrpRect *src_r, tDHL_GrpRect *dst_r) { if(src_r->w==0 || src_r->h==0 || dst_r->w==0 || dst_r->h==0) return; p_lock(TRUE); DHL_PostDraw(dst_id, src_r->x, src_r->y, src_r->w, src_r->h); DHL_BLT(src_id, dst_id, src_r, dst_r); p_merge_rect(&p_rect, src_r->x, src_r->y, src_r->w, src_r->h); p_merge_rect(&p_rect, dst_r->x, dst_r->y, dst_r->w, dst_r->h); p_lock(FALSE); } void DMG_DrawLine(int x1, int y1, int x2, int y2) { /* not implemented yet */ dprint(0, "not implemented yet!\n"); } void DMG_DrawBox(int x, int y, int w, int h, UINT32 color) { p_lock(TRUE); DHL_DrawHLine(p_plane_id, x, y, w, p_convert_color(color)); DHL_DrawVLine(p_plane_id, x, y, h, p_convert_color(color)); DHL_DrawHLine(p_plane_id, x, y+h-1, w, p_convert_color(color)); DHL_DrawVLine(p_plane_id, x+w-1, y, h, p_convert_color(color)); dprint(2, "[%s] (x,y,w,h) -> (%d,%d,%d,%d)\n", __FUNCTION__, x, y, w, h); p_merge_rect(&p_rect, x, y, w, h); p_lock(FALSE); } void DMG_DrawEllipse(int ox, int oy, int rw, int rh) { dprint(0, "not implemented yet!\n"); } void DMG_AutoRefresh() { p_lock(TRUE); if(p_rect.w>0 && p_rect.h>0) { DHL_PostDraw(p_plane_id, p_rect.x, p_rect.y, p_rect.w, p_rect.h); DHL_RefreshPlane(p_plane_id, p_rect.x, p_rect.y, p_rect.w, p_rect.h); p_rect.x=0; p_rect.y=0; p_rect.w=0; p_rect.h=0; } p_lock(FALSE); } #if COMMENT __Image_Func__() {} #endif void DMG_DrawImage(int x, int y, int w, int h, void *pimg) { tDHL_Image img; if (pimg == NULL) { return; } img.is_file=FALSE; img.src.image.buf=pimg; img.src.image.is_png=FALSE; img.src.image.width=w; img.src.image.height=h; p_lock(TRUE); DHL_DrawImage(p_plane_id, x, y, &img); p_merge_rect(&p_rect, x, y, w, h); p_lock(FALSE); } void DMG_DrawImagePng(int x, int y, void *pimg) { tDHL_Image img; int w=0, h=0; dprint(1, "%s:(%x)\n", __FUNCTION__, pimg); if (pimg == NULL) { return; } img.is_file=FALSE; img.src.image.buf=pimg; img.src.image.is_png=TRUE; p_lock(TRUE); DHL_DrawImage(p_plane_id, x, y, &img); DHL_GetImageSize(&img, &w, &h); p_merge_rect(&p_rect, x, y, w, h); p_lock(FALSE); } void DMG_DrawImageFile(int x, int y, char *file_name) { tDHL_Image img; int w=0, h=0; if (file_name == NULL) { return; } img.is_file=TRUE; img.src.file_name=file_name; p_lock(TRUE); DHL_DrawImage(p_plane_id, x, y, &img); DHL_GetImageSize(&img, &w, &h); p_merge_rect(&p_rect, x, y, w, h); p_lock(FALSE); } #if COMMENT __Print_Func__() {} #endif typedef struct { UINT16 idx; UINT16 len; UINT16 width; /* line width */ } tPRIV_RowInfo; /* local variables */ // zooyouny : default¸¦ BMF·Î º¯°æ #if 0 // todo cc Å×½ºÆ® ÇÒ¶§´Â 0À¸·Î ¼³Á¤ ÇÒ °Í static tDMG_Font p_font=eDMG_FONT_JUNGLE; #else static tDMG_Font p_font=eDMG_FONT_BMF; #endif static tDMG_Language p_lang=eDMG_LANG_ENG; static int p_inter_line_gap=4; /* local functions */ static BOOL p_is_alphabet(UINT16 ch) { //return ((ch>='a' && ch<='z') || (ch>='A' && ch<='Z') || (ch>=0xc0 && ch<=0xff)); return (ch!=' '); } static BOOL p_is_wansung(UINT8 ch1, UINT8 ch2) { //return (ch1>=0xa1 && ch2>=0xa0); return FALSE; //±¹³»ÇâÀÌ ¾Æ´Ï¸é FALSE¸¦ ¸®ÅÏÇÔ. } static void p_convert_hex_ch(char *pstr) { int i; int hex_mode=-1; char hex_buf[3]={0,0,0}; for(i=0; pstr[i]; i++) { if(pstr[i]=='#') { /* ##À̳ª #x#ÀÇ °æ¿ì #¸¸ ÂïÀ½ */ if(hex_mode>=0) { hex_mode=-1; } else { /* #À̸é hex mode·Î ÁøÀÔ */ hex_mode=0; continue; } } /* ÀÌ¹Ì hex mode·Î ÁøÀÔÇßÀ¸¸é hexdecimal °ªÀ» ÀúÀå */ else if(hex_mode>=0) { hex_buf[hex_mode++]=pstr[i]; if(hex_mode>=2) { /* hex°ª 2°³¸¦ ÀÔ·Â ¹Þ¾ÒÀ¸¸é PrintÇÔ */ int temp, j; sscanf(hex_buf, "%x", &temp); i-=2; pstr[i]=temp; //i+3À» i+1·Î ¿Å°Ü¾ß ÇÔ for(j=i+3; pstr[j]; j++) { pstr[j-2]=pstr[j]; } pstr[j-2]='\0'; hex_mode=-1; continue; } } } } static int p_get_ch_width(UINT16 ch, BOOL bconvert_to_uni) { int ret_val=0; if(ch>=0xa1a0 && bconvert_to_uni) { //¿Ï¼ºÇüÀ» unicode·Î º¯°æÇÔ. ch=DMG_Ksx1001toUnicode(ch); } if(p_font==eDMG_FONT_JUNGLE) { #if SUPPORT_JUNGLE ret_val=Jungle_GetChWidth(ch); #else dprint(0, "!! %s : jungle is not spported\n"); #endif } else if(p_font==eDMG_FONT_BMF) { #if SUPPORT_BMF ret_val=BMF_GetChWidth(ch); #else dprint(0, "!! %s : bmf is not spported\n"); #endif } else if(p_font>=eDMG_FONT_DHL && p_font<=eDMG_FONT_DHL_END) { #if USE_DHL_FONT ret_val=DHL_GetChWidth(ch); #else dprint(0, "!! %s : DHL font is not supported\n", __FUNCTION__); #endif } #if USE_KOR_AUTO_CHANGE && USE_DHL_FONT if(ret_val==0) { /* ÆùÆ® º¯°æÀ» ½ÃµµÇÑ´Ù */ int temp=p_font; DMG_SetFont(DEF_KOR_FONT); ret_val=DHL_GetChWidth(ch); DMG_SetFont(temp); } #endif if(ret_val==0) { dprint(2, "!! %s fail to get ch(0x%x)\n", __FUNCTION__, ch); } return ret_val; } static int p_get_str_width(char *pstr, int num) { int i; int width; UINT8 *pbuf=(UINT8 *)pstr; for(i=0, width=0; pstr[i] && ((num<0) || (i=0xa1a0 && bconvert_to_uni) { //¿Ï¼ºÇüÀ» unicode·Î º¯°æÇÔ. ch=DMG_Ksx1001toUnicode(ch); } p_lock(TRUE); if(p_font==eDMG_FONT_JUNGLE) { #if SUPPORT_JUNGLE ret_val=Jungle_PrintCh(p_plane_id, x, y, ch, color); #else dprint(0, "!! %s : jungle is not spported\n"); #endif } else if(p_font==eDMG_FONT_BMF) { #if SUPPORT_BMF ret_val=BMF_PrintCh(p_plane_id, x, y, ch, color); #else dprint(0, "!! %s : BMF is not spported\n"); #endif } else if(p_font>=eDMG_FONT_DHL && p_font<=eDMG_FONT_DHL_END) { #if USE_DHL_FONT ret_val=DHL_PrintCh(p_plane_id, x, y, ch, color); #else dprint(0, "!! %s : DHL Font is not supported\n", __FUNCTION__); #endif } #if USE_KOR_AUTO_CHANGE && USE_DHL_FONT if(ret_val==0) { /* ÆùÆ® º¯°æÀ» ½ÃµµÇÑ´Ù */ int temp=p_font; DMG_SetFont(DEF_KOR_FONT); ret_val=DHL_PrintCh(p_plane_id, x, y, ch, color); DMG_SetFont(temp); } #endif p_merge_rect(&p_rect, x, y, ret_val, DMG_GetChHeight(ch)+2); //³Ë³ËÇÏ°Ô rect¸¦ ÀâÀ½. p_lock(FALSE); return ret_val; } static int p_print_str(int x, int y, char *pstr, int num, UINT32 color) { int i, posx; UINT8 *pbuf=(UINT8 *)pstr; for(i=0, posx=x; pstr[i] && ((num<0) || (i=row_info[num_line].idx; j--) { if(j>row_info[num_line].idx && p_is_wansung(pbuf[j-1], pbuf[j])) { if(j word wrap Àû¿ë ¾ÈÇÔ*/ //ÇöÀç °ÍÀº »èÁ¦ÇØ¾ß ÇÔ. //row_info[num_line].len=(i-1)-row_info[num_line].idx; row_info[num_line].len=i-row_info[num_line].idx; row_info[num_line].width=twidth; row_info[num_line+1].idx=row_info[num_line].idx+row_info[num_line].len; str_w=0; num_line++; } } } if(num_line==MAX_NUM_DRAW_ROW) return num_line; row_info[num_line].len=i-row_info[num_line].idx; row_info[num_line].width=str_w; return num_line+1; } static int p_compute_ustr_rows(UINT16 *pstr, int box_w, tPRIV_RowInfo *row_info) { int i, j; int str_w; int ch_w; int num_line=0; UINT16 *pbuf=(UINT16 *)pstr; BOOL bcr=FALSE; //carriage return row_info[num_line].idx=0; for(i=0, str_w=0; pbuf[i] && num_line=row_info[num_line].idx; j--) { if(p_is_alphabet(pbuf[j])) { if(j word wrap Àû¿ë ¾ÈÇÔ*/ //ÇöÀç °ÍÀº »èÁ¦ÇØ¾ß ÇÔ. //row_info[num_line].len=(i-1)-row_info[num_line].idx; row_info[num_line].len=i-row_info[num_line].idx; row_info[num_line].width=twidth; row_info[num_line+1].idx=row_info[num_line].idx+row_info[num_line].len; i--; str_w=0; num_line++; } } } if(num_line==MAX_NUM_DRAW_ROW) return num_line; row_info[num_line].len=i-row_info[num_line].idx; row_info[num_line].width=str_w; return num_line+1; } static int p_print_row_ex(int x, int y, int w, char *pstr, int num, UINT32 color, UINT32 opt, int strw) { int startx; if(opt&DMG_OPT_A_CT) startx=x+(w-strw)/2; else if(opt&DMG_OPT_A_RT) startx=x+(w-strw); else startx=x; return p_print_str(startx, y, pstr, num, color); } static int p_uprint_row_ex(int x, int y, int w, UINT16 *pstr, int num, UINT32 color, UINT32 opt, int strw) { int startx, starty; if(opt&DMG_OPT_A_CT) startx=x+(w-strw)/2; else if(opt&DMG_OPT_A_RT) startx=x+(w-strw); else startx=x; return p_print_ustr(startx, y, pstr, num, color); } /* apis */ #if COMMENT ______________() {} #endif int DMG_PrintCh(int x, int y, UINT16 ch, UINT32 color) { return p_print_ch(x, y, ch, color, FALSE); } int DMG_PrintStr(int x, int y, char *pstr, UINT32 color) { int width; if(!pstr) return 0; p_lock(TRUE); p_convert_hex_ch(pstr); width=p_print_str(x, y, pstr, -1, p_convert_color(color)); p_lock(FALSE); return width; } void DMG_PrintStrEx(int x, int y, int w, int h, char *pstr, UINT32 color, UINT32 opt) { int i; int starty, strh; int num_rows; tPRIV_RowInfo row_info[MAX_NUM_DRAW_ROW]; int dot_width=0; UINT8 *pbuf=(UINT8 *)pstr; if(!pstr) return; if(wh) { /*stringÀÌ ÁÖ¾îÁø boxÀÇ ¿µ¿ªÀ» ¹þ¾î³²*/ dot_width=DMG_GetStrWidth("..."); num_rows=(h+p_inter_line_gap)/(strh+p_inter_line_gap); while(w-row_info[num_rows-1].width0 && i==num_rows-1) { char temp[256]; if(row_info[i].len>=250) { dprint(0, "!! warning : character nums in row is over 250\n"); return; } strncpy(temp, &pstr[row_info[i].idx], row_info[i].len); temp[row_info[i].len]='\0'; strcat(temp, "..."); row_info[i].len+=3; p_print_row_ex(x, starty+i*(strh+p_inter_line_gap), w, temp, row_info[i].len, color, opt, row_info[i].width); } else { p_print_row_ex(x, starty+i*(strh+p_inter_line_gap), w, &pstr[row_info[i].idx], row_info[i].len, color, opt, row_info[i].width); } } p_lock(FALSE); } int DMG_PrintStr3Lang(int x, int y, char *pstr1, char *pstr2, char *pstr3, UINT32 color) { char *pprint_str=eDMG_LANG_ENG; int width; p_lock(TRUE); if(p_lang==eDMG_LANG_ENG) pprint_str=pstr1; else if(p_lang==eDMG_LANG_SPA) pprint_str=pstr2; else if(p_lang==eDMG_LANG_FRE) pprint_str=pstr3; if(!pprint_str) pprint_str=pstr1; if(!pprint_str) return 0; p_convert_hex_ch(pprint_str); width=p_print_str(x, y, pprint_str, -1, p_convert_color(color)); p_lock(FALSE); return width; } void DMG_PrintStrEx3Lang(int x, int y, int w, int h, char *pstr1, char *pstr2, char *pstr3, UINT32 color, UINT32 opt) { char *pprint_str=eDMG_LANG_ENG; p_lock(TRUE); if(p_lang==eDMG_LANG_ENG) pprint_str=pstr1; else if(p_lang==eDMG_LANG_SPA) pprint_str=pstr2; else if(p_lang==eDMG_LANG_FRE) pprint_str=pstr3; if(!pprint_str) pprint_str=pstr1; if(!pprint_str) return; DMG_PrintStrEx(x, y, w, h, pprint_str, p_convert_color(color), opt); p_lock(FALSE); } int DMG_PrintUStr(int x, int y, UINT16 *pstr, UINT32 color) { int i, posx; if(!pstr) return 0; color=p_convert_color(color); p_lock(TRUE); for(i=0, posx=x; pstr[i]; i++) posx+=p_print_ch(posx, y, pstr[i], color, !p_font_attr.is_unicode); p_lock(FALSE); return posx; } void DMG_PrintUStrEx(int x, int y, int w, int h, UINT16 *pstr, UINT32 color, UINT32 opt) { int i; int starty, strh; int num_rows, total_num_rows; tPRIV_RowInfo row_info[MAX_NUM_DRAW_ROW]; int dot_width=0; if(!pstr) return; if(wh) { /*stringÀÌ ÁÖ¾îÁø boxÀÇ ¿µ¿ªÀ» ¹þ¾î³²*/ dot_width=DMG_GetStrWidth("..."); num_rows=(h+p_inter_line_gap)/(strh+p_inter_line_gap); while(w-row_info[num_rows-1].width num_rows) { int ch_w, tmp_i; for(tmp_i = 0 ; tmp_i < row_info[num_rows].len ; tmp_i++) { ch_w=p_get_ch_width(pstr[row_info[num_rows].idx + tmp_i], !p_font_attr.is_unicode); if(row_info[num_rows-1].width + ch_w > w) { break; } row_info[num_rows-1].width += ch_w; row_info[num_rows-1].len += 1; } } } if(opt&DMG_OPT_A_TP) starty=y; else if(opt&DMG_OPT_A_BT) starty=y+(h-(strh*num_rows+p_inter_line_gap*(num_rows-1))); else starty=y+(h-(strh*num_rows+p_inter_line_gap*(num_rows-1)))/2; p_lock(TRUE); for(i=0; i0 && i==num_rows-1) { UINT16 temp[256]; if(row_info[i].len>=250) { dprint(0, "!! warning : character nums in row is over 250\n"); break; } DMG_UStrNCpy(temp, &pstr[row_info[i].idx], row_info[i].len); temp[row_info[i].len]='\0'; DMG_UStrCat(temp, DMG_MakeUniStr2("...")); row_info[i].len+=3; p_uprint_row_ex(x, starty+i*(strh+p_inter_line_gap), w, temp, row_info[i].len, color, opt, DMG_GetUStrWidth(temp)); } else { p_uprint_row_ex(x, starty+i*(strh+p_inter_line_gap), w, &pstr[row_info[i].idx], row_info[i].len, color, opt, row_info[i].width); } } p_lock(FALSE); } void DMG_PrintNUStrEx(int x, int y, int w, int h, int str_start, int str_len, UINT16* pstr, UINT32 color, UINT32 opt) { UINT16 str[500]; int i; if(!pstr || str_start < 0) return; for(i = 0 ; i < str_len ; i++) { str[i] = pstr[str_start + i]; } str[str_len] = '\0'; DMG_PrintUStrEx(x, y, w, h, str, color, opt); } int DMG_GetChWidth(UINT16 ch) { return p_get_ch_width(ch, !p_font_attr.is_unicode); } int DMG_GetStrWidth(char *pstr) { if(!pstr) return 0; p_convert_hex_ch(pstr); return p_get_str_width(pstr, -1); } int DMG_GetUStrWidth(UINT16 *pstr) { if(!pstr) return 0; return p_get_ustr_width(pstr, -1); } int DMG_GetChHeight(UINT16 ch) { int ret_val=0; if(p_font==eDMG_FONT_JUNGLE) { #if SUPPORT_JUNGLE ret_val=Jungle_GetChHeight(ch); #else dprint(0, "!! %s : jungle is not spported\n"); #endif } else if(p_font==eDMG_FONT_BMF) { #if SUPPORT_BMF ret_val=BMF_GetChHeight(ch); #else dprint(0, "!! %s : jungle is not spported\n"); #endif } else if(p_font>=eDMG_FONT_DHL && p_font<=eDMG_FONT_DHL_END) { #if USE_DHL_FONT ret_val=DHL_GetChHeight(ch); #else dprint(0, "!! %s : DHL Font is not supported\n", __FUNCTION__); #endif } #if USE_KOR_AUTO_CHANGE && USE_DHL_FONT if(ret_val==0) { /* ÆùÆ® º¯°æÀ» ½ÃµµÇÑ´Ù */ int temp=p_font; DMG_SetFont(DEF_KOR_FONT); ret_val=DHL_GetChHeight(ch); DMG_SetFont(temp); } #endif return ret_val; } int DMG_GetStrHeight(char *pstr) { int i; int height=0, temp; if(!pstr) return 0; p_convert_hex_ch(pstr); for(i=0; pstr[i]; i++) { temp=DMG_GetChHeight(pstr[i]); if(temp>height) height=temp; } return height; } int DMG_GetUStrHeight(UINT16 *pstr) { int i; int height=0, temp; if(!pstr) return 0; for(i=0; pstr[i]; i++) { temp=DMG_GetChHeight(pstr[i]); if(temp>height) height=temp; } return height; } void DMG_GetDefaultFontAttr(tDMG_FontAttr *pfont_attr) { if(!pfont_attr) { dprint(0, "!! %s : font_attr is NULL\n", __FUNCTION__); return; } pfont_attr->size=DEFAULT_FONT_SIZE; pfont_attr->is_bold=FALSE; pfont_attr->is_italic=FALSE; pfont_attr->is_underline=FALSE; pfont_attr->is_unicode=TRUE; pfont_attr->font_style=eDMG_FS_SANSERIF; pfont_attr->edge_type=eDMG_ET_NONE; } void DMG_GetFontAttr(tDMG_FontAttr *pfont_attr) { if(p_font==eDMG_FONT_NONE) { DMG_GetDefaultFontAttr(pfont_attr); } else { *pfont_attr=p_font_attr; } } void DMG_SetFontAttr(tDMG_FontAttr *pfont_attr) { p_lock(TRUE); p_font_attr=*pfont_attr; if(p_font==eDMG_FONT_JUNGLE) { #if SUPPORT_JUNGLE Jungle_FontAttr attr; attr.size=pfont_attr->size; attr.is_bold=pfont_attr->is_bold; attr.is_italic=pfont_attr->is_italic; attr.is_underline=pfont_attr->is_underline; attr.is_unicode=pfont_attr->is_unicode; attr.font_style=pfont_attr->font_style; attr.edge_type=pfont_attr->edge_type; attr.c_edge=pfont_attr->c_edge; Jungle_SetFontAttr(&attr); #else dprint(0, "!! %s : jungle is not spported\n"); #endif } else if(p_font==eDMG_FONT_BMF) { #if SUPPORT_BMF BMF_FontAttr attr; attr.size=pfont_attr->size; attr.is_bold=pfont_attr->is_bold; attr.is_italic=pfont_attr->is_italic; attr.is_underline=pfont_attr->is_underline; attr.is_unicode=pfont_attr->is_unicode; attr.font_style=pfont_attr->font_style; attr.edge_type=pfont_attr->edge_type; attr.c_edge=pfont_attr->c_edge; BMF_SetFontAttr(&attr); #else dprint(0, "!! %s : jungle is not spported\n"); #endif } else if(p_font>=eDMG_FONT_DHL && p_font<=eDMG_FONT_DHL_END) { #if USE_DHL_FONT tDHL_FontAttr attr; attr.type=p_font-eDMG_FONT_DHL; attr.size=pfont_attr->size; attr.is_bold=pfont_attr->is_bold; attr.is_italic=pfont_attr->is_italic; attr.is_underline=pfont_attr->is_underline; DHL_SetFontAttr(&attr); #else dprint(0, "!! %s : only Jungle is supported\n", __FUNCTION__); #endif } p_lock(FALSE); } void DMG_SetFontSize(int size) { tDMG_FontAttr attr; DMG_GetFontAttr(&attr); p_lock(TRUE); attr.size=size; DMG_SetFontAttr(&attr); p_lock(FALSE); } int DMG_GetFontSize() { tDMG_FontAttr attr; DMG_GetFontAttr(&attr); return attr.size; } int DMG_GetUStrLineCount(int w, UINT16 *pstr, DMG_STR_RowInfo_t* return_str_info_t) { int i; int num_rows; // , total_num_rows; tPRIV_RowInfo row_info[MAX_NUM_DRAW_ROW]; if(!pstr) return 0; num_rows=p_compute_ustr_rows(pstr, w, row_info); for(i = 0 ; i < num_rows ; i++) { return_str_info_t[i].idx = row_info[i].idx; return_str_info_t[i].len = row_info[i].len; } return num_rows; } void DMG_SetTempFontSize(int size) { //Àӽ÷Πfont¸¦ »ç¿ëÇÒ ¶§ ÀÌ ÇÔ¼ö¸¦ »ç¿ëÇÔ. if(p_temp_font_size==0) p_temp_font_size=DMG_GetFontSize(); DMG_SetFontSize(size); } void DMG_RestoreFontSize() { if(p_temp_font_size>0) { DMG_SetFontSize(p_temp_font_size); p_temp_font_size=0; } } void DMG_SetLanguage(tDMG_Language lang) { p_lock(TRUE); p_lang=lang; p_lock(FALSE); } int DMG_GetLanguage() { return p_lang; } void DMG_SetFont(tDMG_Font font) { p_lock(TRUE); p_font=font; #if SUPPORT_JUNGLE if(p_font==eDMG_FONT_JUNGLE) { } #endif #if SUPPORT_BMF if(p_font==eDMG_FONT_BMF) { } #endif if(p_font>=eDMG_FONT_DHL && p_font<=eDMG_FONT_DHL_END) { #if USE_DHL_FONT tDHL_FontAttr attr; DHL_GetFontAttr(&attr); attr.type=p_font-eDMG_FONT_DHL; DHL_SetFontAttr(&attr); #else dprint(0, "!! %s : only Jungle is supported\n", __FUNCTION__); #endif } p_lock(FALSE); } void DMG_SetInterLineGap(int gap) { p_lock(TRUE); p_inter_line_gap=gap; p_lock(FALSE); } void DMG_DrawInit() { tDMG_FontAttr font_attr; #if USE_GRP_MTX p_mtx=OS_CreateMutexSemaphore("dmg_mtx"); /* mutex init */ #endif DMG_GetDefaultFontAttr(&font_attr); #if SUPPORT_JUNGLE if(1) { Jungle_FontAttr attr; attr.size=font_attr.size; attr.is_bold=font_attr.is_bold; attr.is_italic=font_attr.is_italic; attr.is_underline=font_attr.is_underline; attr.is_unicode=font_attr.is_unicode; attr.font_style=font_attr.font_style; attr.edge_type=font_attr.edge_type; attr.c_edge=font_attr.c_edge; Jungle_FontInit(&attr); } #endif #if SUPPORT_BMF if(1) { BMF_FontAttr attr; attr.size=font_attr.size; attr.is_bold=font_attr.is_bold; attr.is_italic=font_attr.is_italic; attr.is_underline=font_attr.is_underline; attr.is_unicode=font_attr.is_unicode; attr.font_style=font_attr.font_style; attr.edge_type=font_attr.edge_type; attr.c_edge=font_attr.c_edge; BMF_FontInit(&attr); } #endif #if USE_DHL_FONT if(1) { tDHL_FontAttr attr; attr.type=0; attr.size=font_attr.size; attr.is_bold=font_attr.is_bold; attr.is_italic=font_attr.is_italic; attr.is_underline=font_attr.is_underline; DHL_FontInit(&attr); } #endif #if SUPPORT_BMFONT #endif p_font_attr=font_attr; } #if 0 ___Debug___() {} #endif void pixel_info(int x, int y) { UINT32 color; DHL_GetPixel(0, x, y, &color); printf("------------------------------------\n"); printf("pixel(%d,%d) color : 0x%08x\n", x, y, color); printf("------------------------------------\n"); } void change_fstyle(int style) { tDMG_FontAttr attr; DMG_GetFontAttr(&attr); attr.font_style=(tDMG_FontStyle)style; DMG_SetFontAttr(&attr); } void print_ch(int x, int y, UINT16 ch, UINT32 color) { DMG_PrintCh(x, y, ch, color); DMG_AutoRefresh(); } void print_str(int x, int y, int size, char *pstr, UINT32 color) { DMG_SetFontSize(size); DMG_EraseRect(x, y, 200, 100, 0xff000000); DMG_PrintStr(x, y, pstr, color); DMG_AutoRefresh(); } void print_str_ex(int x, int y, int w, int h, int size, char *pstr) { DMG_SetFontSize(size); DMG_EraseRect(x, y, w, h, 0xff000000); DMG_PrintStrEx(x, y, w, h, pstr, 0xffff0000, DMG_OPT_A_TP); DMG_AutoRefresh(); } void test_print(int x, int y, int w, int h, int opt) { char *str="TV guide abc def ghi jkl"; DMG_PrintStrEx(x, y, w, h, str, 0xff000000, opt); DMG_AutoRefresh(); } void print_draw_time() { int i; UINT32 start_ms; int x=0; start_ms=DHL_OS_GetMsCount(); DMG_EraseRect(0, 0, 720, 480, 0xff000000); dprint(0, "BG Draw Time : %d(ms)\n", DHL_OS_GetMsCount()-start_ms); start_ms=DHL_OS_GetMsCount(); for(x=0,i=0; x<680; i++) x+=DMG_PrintCh(x, 50, 0x20+i%0x10, 0xffffffff); for(x=0,i=0; x<680; i++) x+=DMG_PrintCh(x, 80, 0x30+i%0x10, 0xffffffff); for(x=0,i=0; x<680; i++) x+=DMG_PrintCh(x, 110, 0x40+i%0x10, 0xffffffff); for(x=0,i=0; x<680; i++) x+=DMG_PrintCh(x, 140, 0x50+i%0x10, 0xffffffff); for(x=0,i=0; x<680; i++) x+=DMG_PrintCh(x, 170, 0x60+i%0x10, 0xffffffff); for(x=0,i=0; x<680; i++) x+=DMG_PrintCh(x, 200, 0x70+i%0x10, 0xffffffff); for(x=0,i=0; x<680; i++) x+=DMG_PrintCh(x, 230, 0x20+i%0x10, 0xffffffff); for(x=0,i=0; x<680; i++) x+=DMG_PrintCh(x, 260, 0x30+i%0x10, 0xffffffff); for(x=0,i=0; x<680; i++) x+=DMG_PrintCh(x, 290, 0x40+i%0x10, 0xffffffff); for(x=0,i=0; x<680; i++) x+=DMG_PrintCh(x, 320, 0x50+i%0x10, 0xffffffff); for(x=0,i=0; x<680; i++) x+=DMG_PrintCh(x, 350, 0x60+i%0x10, 0xffffffff); for(x=0,i=0; x<680; i++) x+=DMG_PrintCh(x, 380, 0x70+i%0x10, 0xffffffff); dprint(0, "Print Time : %d(ms)\n", DHL_OS_GetMsCount()-start_ms); start_ms=DHL_OS_GetMsCount(); DMG_AutoRefresh(); #if 0 dprint(0, "Refresh Time : %d(ms)\n", DHL_OS_GetMsCount()-start_ms); start_ms=DHL_OS_GetMsCount(); App_OSD_BackupScreen(0, 0, 720, 480); dprint(0, "Backup Time : %d(ms)\n", DHL_OS_GetMsCount()-start_ms); start_ms=DHL_OS_GetMsCount(); App_OSD_RestoreScreen(0, 0, 720, 480); dprint(0, "Restore Time : %d(ms)\n", DHL_OS_GetMsCount()-start_ms); start_ms=DHL_OS_GetMsCount(); //grp_pixel_rect(0, 0, 0, 720, 480, 0xff000000); //dprint(0, "pixel rect Time : %d(ms)\n", DHL_OS_GetMsCount()-start_ms); //start_ms=DHL_OS_GetMsCount(); #endif } /* end of file */