#include "DHL_OSAL.h" #include "DHL_DBG.h" #include "bgfx_types.h" #include "bsettop_graphics.h" static unsigned char* osd_mem=NULL; static bgraphics_t graphics; static bdisplay_t display; static int g_width = 720; static int g_height = 480; //¹Ýµå½Ã ÃÖÃÊ·Î ºÒ·¯ÁÙ °Í. --> TODO: initÀ¸·Î µû·Î ¶¼¾î³õÀ» °Í void dhl_set_display(bdisplay_t disp) { display=disp; } typedef struct dhl_bin_read_t { int cnt; int size; unsigned char *data; } dhl_bin_read_t; int bin_read( void *buffer, int size, int count, void *fp ) { dhl_bin_read_t *p_br = (dhl_bin_read_t*)fp; size = size * count; if (p_br->cnt + size > p_br->size) { printf("Requesting more bytes than available (cnt = %d, size = %d,total = %d)\n", p_br->cnt,size,p_br->size); size = p_br->size - p_br->cnt; } memcpy(buffer,&p_br->data[p_br->cnt],size); p_br->cnt += size; return size; } unsigned int bin_tell(void *fp ) { dhl_bin_read_t *p_br = (dhl_bin_read_t*)fp; return p_br->cnt; } int bin_set(void *fp, int offset, int whence ) { dhl_bin_read_t *p_br = (dhl_bin_read_t*)fp; if ((whence != 0) || ((unsigned int)offset > p_br->size)) return -1; p_br->cnt = offset; return 0; } static bgfx_io_t gfx_io = { bin_read, bin_tell, bin_set }; static bgfx_hw_t s_gfx_hw = {(BGFX_HW_FILL)bsurface_fill, (BGFX_HW_BLIT)bsurface_blit_surface, (BGFX_HW_SURFACE_CREATE)bsurface_create_surface}; static bgfx_hw_t *s_p_gfx_hw = &s_gfx_hw; int bgfx_init(bgfx_io_t *io_p,bgfx_prot_t *prot_p,bgfx_hw_t *hw_p); int bgfx_create(bgfx_surf_p p,uint16_t width,uint16_t height, uint8_t *ptr, uint16_t pitch, bgfx_palette_t *palette, uint32_t flags); DHL_RESULT DHL_GrpInit() { static bool binit = false; if (binit == true) return; binit = true; bgfx_surf_t surf; int pitch=0; unsigned int *main_palette; bgraphics_settings graphics_settings; bgraphics_get(&graphics_settings); graphics_settings.format = bgraphics_pixel_format_a8_r8_g8_b8; bgraphics_set(&graphics_settings); BDBG_ASSERT(display != NULL); graphics = bgraphics_open(B_ID(0),display); bgraphics_get_framebuffer(graphics,(void**)&osd_mem,&main_palette,&g_width,&g_height, &pitch); bgraphics_load_palette(graphics); bgfx_init(&gfx_io,NULL, s_p_gfx_hw); bgraphics_get_osd_params(graphics,(bsettop_surf_t*)&(surf),(void**)&(osd_mem),NULL,NULL); bgfx_create(&surf,g_width,g_height,(unsigned char *)osd_mem, pitch,NULL,BGFX_SURF_BPP(32)|BGFX_SURF_RGB|BGFX_SURF_GRC); memset(osd_mem, 0, g_width * g_height * 4); bgraphics_sync(graphics, false); return DHL_OK; } // NEWCON3KRÈ£Ãâ ÇÔ¼ö void dhl_draw_image2(char* src, int x, int y, int w, int h) { char* des = osd_mem + (y * g_width + x) * 4; int src_delta = w*4; int des_delta = g_width*4; int hh =h; while (hh--) { memcpy(des, src, src_delta); src += src_delta; des += des_delta; } bgraphics_sync(graphics, false); }