void directdraw_update(int mode) { RECT source; RECT destination; RECT rectosd, rct, rectwindow; POINT point; int rw, rh, rx = 0, ry = 0; /* relative sizes */ int tmprw, tmprh, tmprx = 0, tmpry = 0; /* temporary relative sizes */ int ww, wh; /* video window sizes */ float sc; /* scale */ int r_frame_w, r_frame_h; /* resized values of frame size (aspect ratio based) */ if(!video_window) return; if(!lpDDS)return; if(use_osd_surface && !surface_osd)return; if(!lpDDS_secondary)return; //frame_w = default_sw; //frame_h = default_sh; if(lpDDS) { r_frame_w = frame_w; r_frame_h = frame_h; if(aspect_ratio > 0.0) r_frame_h = (int)((double)r_frame_h / aspect_ratio); source.left = 0; source.top = 0; source.right = d_width; source.bottom = d_height; rectwindow.left = 0; rectwindow.top = 0; rectwindow.right = window_w; rectwindow.bottom = window_h; point.x = 0; point.y = 0; ClientToScreen(video_window, &point); GetClientRect(video_window, &destination); GetClientRect(video_window, &rct); destination.left += point.x; destination.top += point.y; destination.right += point.x; destination.bottom += point.y; //vdata.getdata(get_window_video_rect, 0, &rct, 0); //vdata.getdata(get_window_video_dc, 0, &hdc, 0); //if(w <= 0)w = 256; //if(h <= 0)h = 256; ww = rw = rct.right - rct.left; wh = rh = rct.bottom - rct.top; if(frame_w > frame_h) { sc = (float)rw / (float)r_frame_w; }else{ sc = (float)rh / (float)r_frame_h; } /* to keep aspect ratio, both width and height should be scaled equally */ rw = (int)((float)r_frame_w * sc); rh = (int)((float)r_frame_h * sc); /* we gotta handle video's corners vertically and check if it's gonna surpass the parent window's borders */ if(rh > wh) sc = (float)wh / (float)r_frame_h; if(rw > ww) sc = (float)ww / (float)r_frame_w; /* any changes? calculate'em again */ rw = (int)((float)r_frame_w * sc); rh = (int)((float)r_frame_h * sc); /* calculate video position */ rx = (ww - rw) / 2; ry = (wh - rh) / 2; if(use_osd_surface) { if(video_zoom_x <= 1.0) { video_zoom_x = 1.0; crop_pos_x = 0; } if(video_zoom_y <= 1.0) { video_zoom_y = 1.0; crop_pos_y = 0; } //tmprw = (rx + rw) * video_zoom; //tmprh = (ry + rh) * video_zoom; /*if(tmprw < destination.right && tmprh < destination.bottom) { rw *= video_zoom; rh *= video_zoom; }else{ source.right /= video_zoom; source.bottom /= video_zoom; } */ //if(source.left + crop_pos_x > source.right)crop_pos_x = source.right - source.left; //if(source.top + crop_pos_y > source.bottom)crop_pos_y = source.bottom - source.top; source.left = crop_pos_x; source.top = crop_pos_y; source.right = crop_pos_x + (d_width / video_zoom_x); source.bottom = crop_pos_y + (d_height / video_zoom_y); if(source.left < 0) { source.left = 0; source.right = (d_width / video_zoom_x); } if(source.top < 0) { source.top = 0; source.bottom = (d_height / video_zoom_y); } if(source.right > d_width) { source.left = d_width - (d_width / video_zoom_x); source.right = d_width; } if(source.bottom > d_height) { source.top = d_height - (d_height / video_zoom_y); source.bottom = d_height; } rectosd.left = rx; rectosd.top = ry; rectosd.right = rw + rx; rectosd.bottom = rh + ry; if(video_zoom_y > 1.0 || video_zoom_x > 1.0) { rectosd.left = 0; rectosd.top = 0; rectosd.right = window_w; rectosd.bottom = window_h; } } if(!use_osd_surface) { IDirectDrawSurface2_Blt(lpDDS, &destination, lpDDS_secondary, &source, DDBLT_WAIT, 0); }else{ HDC hdc; DDBLTFX bfx; memset(&bfx, 0, sizeof(bfx)); bfx.dwFillColor = 0x000000; bfx.dwSize = sizeof(bfx); IDirectDrawSurface2_Blt(surface_osd, 0, 0, 0, DDBLT_COLORFILL | DDBLT_WAIT, &bfx); if(mode) { HRESULT res = IDirectDrawSurface2_Blt(surface_osd, &rectosd, lpDDS_secondary, &source, DDBLT_WAIT | DDBLT_ZBUFFER, 0); if(show_crop_rect) { RECT rcr; float ar; int vsize = 100, vw; ar = d_width / d_height; vw = (vsize * ar); rcr.top = 5; rcr.left = 5; rcr.bottom = 5 + vsize; rcr.right = 5 + vw; IDirectDrawSurface2_Blt(surface_osd, &rcr, lpDDS_secondary, &source, DDBLT_WAIT | DDBLT_ZBUFFER, 0); } } if(!FAILED(IDirectDrawSurface2_GetDC(surface_osd, &hdc))) { float ar; int vsize = 100, vw; HPEN hold_pen; HBRUSH hold_brush; if(subtitle_text && show_subtitles) { RECT rct, nrct; HFONT nfont, ofont; int subs_fontsize, soffset; string subtitle_font_face = uni("Arial"); static letter subtitle_str[4096]; static int sub_italic = 0, sub_bold = 0, sub_underlined = 0; static string last_substr; if(subtitle_text != last_substr) { last_substr = subtitle_text; str_cpy(subtitle_str, subtitle_text); if(replace_i_str(subtitle_str, uni("<i>"), uni(""))) { sub_italic = 1; replace_i_str(subtitle_str, uni("</i>"), uni("")); } if(replace_i_str(subtitle_str, uni("<b>"), uni(""))) { sub_bold = 1; replace_i_str(subtitle_str, uni("</b>"), uni("")); } if(replace_i_str(subtitle_str, uni("<u>"), uni(""))) { sub_underlined = 1; replace_i_str(subtitle_str, uni("</u>"), uni("")); } } rct.top = window_h; rct.bottom = window_h; rct.left = 0; rct.right = window_w; subs_fontsize = min(max((min(window_h, window_w) * 15) / 250, 10), 22); soffset = min(subs_fontsize / 10, 2); nfont = CreateFont(-MulDiv(subs_fontsize, GetDeviceCaps(hdc, LOGPIXELSY), 72), 0, 0, 0, sub_bold ? FW_BOLD : FW_NORMAL, sub_italic, sub_underlined, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH, subtitle_font_face); ofont = (HFONT) SelectObject(hdc, nfont); SetBkMode(hdc, TRANSPARENT); nrct.left = 0; nrct.right = window_w; DrawText(hdc, subtitle_str, str_len(subtitle_str), &nrct, DT_CENTER | DT_WORDBREAK | DT_CALCRECT); rct.top -= nrct.bottom - nrct.top; rct.top -= window_h / 12; SetTextColor(hdc, 0x000000); rct.top -= soffset; rct.left -= soffset; rct.right -= soffset; DrawText(hdc, subtitle_str, str_len(subtitle_str), &rct, DT_CENTER | DT_WORDBREAK); rct.top += soffset; rct.left += soffset; rct.right += soffset; rct.top += soffset; rct.left += soffset; rct.right += soffset; DrawText(hdc, subtitle_str, str_len(subtitle_str), &rct, DT_CENTER | DT_WORDBREAK); rct.top -= soffset; rct.left -= soffset; rct.right -= soffset; SetTextColor(hdc, 0xffffff); DrawText(hdc, subtitle_str, str_len(subtitle_str), &rct, DT_CENTER | DT_WORDBREAK); SelectObject(hdc, ofont); DeleteObject(nfont); } /* </if - subtitles_text> */ if(subtitle_text_sec) { RECT rct, nrct; HFONT nfont, ofont; int subs_fontsize, soffset; string subtitle_font_face = uni("Arial"); static letter subtitle_str[4096]; static int sub_italic = 0, sub_bold = 0, sub_underlined = 0; static string last_substr; if(subtitle_text_sec != last_substr) { last_substr = subtitle_text_sec; str_cpy(subtitle_str, subtitle_text_sec); if(replace_i_str(subtitle_str, uni("<i>"), uni(""))) { sub_italic = 1; replace_i_str(subtitle_str, uni("</i>"), uni("")); } if(replace_i_str(subtitle_str, uni("<b>"), uni(""))) { sub_bold = 1; replace_i_str(subtitle_str, uni("</b>"), uni("")); } if(replace_i_str(subtitle_str, uni("<u>"), uni(""))) { sub_underlined = 1; replace_i_str(subtitle_str, uni("</u>"), uni("")); } } rct.top = window_h; rct.bottom = window_h; rct.left = 0; rct.right = window_w; subs_fontsize = min(max((min(window_h, window_w) * 15) / 250, 10), 22); soffset = min(subs_fontsize / 10, 2); nfont = CreateFont(-MulDiv(subs_fontsize, GetDeviceCaps(hdc, LOGPIXELSY), 72), 0, 0, 0, sub_bold ? FW_BOLD : FW_NORMAL, sub_italic, sub_underlined, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH, subtitle_font_face); ofont = (HFONT) SelectObject(hdc, nfont); SetBkMode(hdc, TRANSPARENT); nrct.left = 0; nrct.right = window_w; DrawText(hdc, subtitle_str, str_len(subtitle_str), &nrct, DT_CENTER | DT_WORDBREAK | DT_CALCRECT); rct.top = window_h / 16; SetTextColor(hdc, 0x000000); rct.top -= soffset; rct.left -= soffset; rct.right -= soffset; DrawText(hdc, subtitle_str, str_len(subtitle_str), &rct, DT_CENTER | DT_WORDBREAK); rct.top += soffset; rct.left += soffset; rct.right += soffset; rct.top += soffset; rct.left += soffset; rct.right += soffset; DrawText(hdc, subtitle_str, str_len(subtitle_str), &rct, DT_CENTER | DT_WORDBREAK); rct.top -= soffset; rct.left -= soffset; rct.right -= soffset; SetTextColor(hdc, 0xffffff); DrawText(hdc, subtitle_str, str_len(subtitle_str), &rct, DT_CENTER | DT_WORDBREAK); SelectObject(hdc, ofont); DeleteObject(nfont); } /* </if - subtitles_text> */ /* draw osd controls */ osd_display(hdc, rectosd.right, rectosd.bottom); if(show_crop_rect) { ar = d_width / d_height; vw = (vsize * ar); hold_pen = (HPEN)SelectObject(hdc, crop_rect_pen); hold_brush = (HBRUSH)SelectObject(hdc, crop_rect_brush); Rectangle(hdc, 5, 5, 5 + vw, 5 + vsize); Rectangle(hdc, 5 + ((source.left * vw) / d_width), 5 + ((source.top * vsize) / d_height), 5 + ((source.right * vw) / d_width), 5 + ((source.bottom * vsize) / d_height)); SelectObject(hdc, hold_pen); SelectObject(hdc, hold_brush); } IDirectDrawSurface2_ReleaseDC(surface_osd, hdc); } IDirectDrawSurface2_Blt(lpDDS, &destination, surface_osd, &rectwindow, DDBLT_WAIT, 0); } } }
void start_arcboot(void) { DECLARE_GLOBAL_DATA_PTR; static gd_t gd_data; static bd_t bd_data; init_fnc_t **init_fnc_ptr; extern void *__text_end; unsigned stage = sizeof(init_sequence)/sizeof(init_sequence[0]); show_boot_progress(stage--); /* Init Global Data */ gd = global_data = &gd_data; gd->bd = &bd_data; gd->cpu_clk=get_cpu_clk(); gd->bd->bi_boot_params=BOOT_PARAMS_OFFSET; gd->bd->bi_memstart=PHYS_MEMORY_START; gd->bd->bi_memsize=PHYS_MEMORY_SIZE; gd->bd->bi_flashstart=CONFIG_SYS_FLASH_BASE; gd->bd->bi_flashoffset=0; /* frame buffer will sit after end of program */ gd->fb_base = TEXT_BASE; for (init_fnc_ptr = init_sequence;*init_fnc_ptr;++init_fnc_ptr) { show_boot_progress(stage--); if ((*init_fnc_ptr)() != 0) { printf("stage:%d",stage); hang(); } } /* Setup malloc area */ mem_malloc_init((ulong)&_start - CONFIG_SYS_MALLOC_LEN, CONFIG_SYS_MALLOC_LEN); // __builtin_arc_sleep(0); #ifdef CONFIG_CMD_NAND puts ("NAND: "); nand_init(); #endif env_relocate(); stdio_init (); /* get the devices list going. */ jumptable_init(); console_init_r(); #ifdef CONFIG_MMC mmc_initialize(&bd_data); #endif #ifdef CONFIG_CMD_NET puts ("Net: "); gd->bd->bi_ip_addr = getenv_IPaddr ("ipaddr"); // eth_io_init(); eth_initialize(gd->bd); #if defined(CONFIG_RESET_PHY_R) debug ("Reset Ethernet PHY\n"); reset_phy(); #endif #endif #if defined(CONFIG_ARCH_MISC_INIT) /* miscellaneous arch dependent initialisations */ arch_misc_init (); #endif #if defined(CONFIG_MISC_INIT_R) /* miscellaneous platform dependent initialisations */ misc_init_r (); #endif #if defined(CONFIG_CMD_KGDB) puts("KGDB: "); kgdb_init(); #endif /* enable exceptions */ enable_interrupts (); icache_enable(); dcache_enable(); printf("Dcache status %d\n",dcache_status()); printf("Icache status %d\n",icache_status()); #ifdef CONFIG_A3_DISPLAY osd_display(); #endif #ifdef CONFIG_A3_I2C disable_i2c_pinmux();//disable hard i2c pinmux #endif // kgdb_test(); // init_osd_dev() ; for(;;){ main_loop(); } }