/*************************************************************************** * Copyright (c) 2002-2005, Broadcom Corporation * All Rights Reserved * Confidential Property of Broadcom Corporation * * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. * * $brcm_Workfile: bccwinlib.c $ * $brcm_Revision: 3 $ * $brcm_Date: 5/17/05 7:50p $ * * Module Description: * * Revision History: * * $brcm_Log: /BSEAV/lib/ccgfx/winlib/bccwinlib.c $ * * 3 5/17/05 7:50p shyam * PR 8365 : Making it work at runtime * * 3 5/17/05 7:48p shyam * PR 8365 : Making it work at runtime * ***************************************************************************/ #include "bdcc_kernel.h" #include "bccwinlib.h" #include "bstd.h" #include "bapp_eia708.h" #include "genericlist.h" #include "bdccengine.h" #include "bdccpriv.h" #include "ministd.h" BDBG_MODULE(bdcc_winlib); #define MAX_UNI_LEN 256 #define MAX_ZORDER 8 #define DEF_LINE_SPACING 4 struct BCCGFX_WINLIB_P_Object { void *p_app; bgfx_surf_t *p_osd_surf; bccgfx_update_cb_t update_cb; unsigned int uni_str[MAX_UNI_LEN]; LIST_T surf_list; /* list of surfaces created */ LIST_T free_surf_list; /* list of surfaces created */ int alloc_cnt; bccgfx_get_wide_aspect_ratio_cb_t wide_aspect_ratio_cb; } BCCGFX_WINLIB_P_Object; struct BCCGFX_WINLIB_P_Window { LINKS_T links; BCCGFX_WINLIB_P_Handle hWinLibHandle; bgfx_surf_t surf; BCCGFX_WINLIB_P_Font font ; uint32_t EdgeColor; BDCC_Edge EdgeType; uint32_t EdgeWidth; uint32_t ForeGroundColor; uint32_t BackGroundColor; uint32_t PenPositionx ; uint32_t PenPositiony ; uint16_t x; uint16_t y; uint16_t width; uint16_t height; int zorder; bool show; bool bClippedOut; int italics; int underline; BCCGFX_WINLIB_P_Rect clip_rect; int id; } BCCGFX_WINLIB_P_Window; struct BCCGFX_WINLIB_P_FontInfo { bgfx_font_t *p_font; BCCGFX_WINLIB_P_Handle hWinLibHandle; uint32_t TextBase; } BCCGFX_WINLIB_P_FontInfo; extern unsigned int c_to_uni_str( unsigned char *str_p, /* Null terminated c-string */ unsigned int *p_uni_str, /* buffer to use for contructing UNI string */ unsigned int max_size); /* maximum buffer size in words */ static bgfx_palette_t ColorLookup = {{0,128,192,255,0,128,192,255,0,128,192,255,0,128,192,255}} ; /* Summary: Remap characters */ static void remap_chars(unsigned int *p_uni_str, int len) { int i; for (i = 0; i < len; ++i) { switch(p_uni_str[i]) { case 0x7F: p_uni_str[i] = 0x266A; break; case 0x82: p_uni_str[i] = 0x215B; break; case 0x83: p_uni_str[i] = 0x215C; break; case 0x84: p_uni_str[i] = 0x215D; break; case 0x85: p_uni_str[i] = 0x2026; break; case 0x86: p_uni_str[i] = 0x215E; break; case 0x87: p_uni_str[i] = 0x7C; break; case 0x88: p_uni_str[i] = 0x2510; break; case 0x89: p_uni_str[i] = 0x2514; break; case 0x8A: p_uni_str[i] = 0x160; break; case 0x8B: p_uni_str[i] = 0x2015; break; case 0x8C: p_uni_str[i] = 0x152; break; case 0x8D: p_uni_str[i] = 0x250C; break; case 0x8F: p_uni_str[i] = 0x2518; break; case 0x90: p_uni_str[i] = 0x25A0; break; case 0x91: p_uni_str[i] = 0x2018; break; case 0x92: p_uni_str[i] = 0x2019; break; case 0x93: p_uni_str[i] = 0x201C; break; case 0x94: p_uni_str[i] = 0x201D; break; case 0x95: p_uni_str[i] = 0x2022; break; case 0x99: p_uni_str[i] = 0x2122; break; case 0x9A: p_uni_str[i] = 0x161; break; case 0x9C: p_uni_str[i] = 0x153; break; case 0x9D: p_uni_str[i] = 0x2120; break; case 0x9F: p_uni_str[i] = 0x178; break; default: break; } } } /* Summary: Construct a UNI string in the buffer provided from the cstring. */ static BCCGFX_WINLIB_P_ErrCode BCCGFX_WINLIB_P_AllocWindow( BCCGFX_WINLIB_P_Handle hWinLibHandle, BCCGFX_WINLIB_P_hWin *pwin, uint32_t width, uint32_t height) { *pwin = (BCCGFX_WINLIB_P_hWin)BKNI_Malloc(sizeof(struct BCCGFX_WINLIB_P_Window)); if(*pwin == NULL) { return BERR_TRACE(BCCGFX_WINLIB_P_ERROR_NO_MEMORY) ; } BKNI_Memset(*pwin,0,sizeof(BCCGFX_WINLIB_P_Window)); (*pwin)->hWinLibHandle = hWinLibHandle ; if ((width == 0) || (height == 0)) { width = hWinLibHandle->p_osd_surf->surface.width; height = hWinLibHandle->p_osd_surf->surface.height; } #ifdef CONFIG_GFX_ARGB32 if (bgfx_create(&((*pwin)->surf),width,height,NULL,0,NULL,BGFX_SURF_BPP(32)|BGFX_SURF_RGB|BGFX_SURF_GRC)!=0) #else if (bgfx_create(&((*pwin)->surf), width , height,NULL,0,NULL,BGFX_SURF_BPP(4)) != 0) #endif { BDCC_DBG_ERR(("bgfx_create err! \n")); return BCCGFX_WINLIB_P_ERROR_NO_MEMORY; } #ifndef CONFIG_GFX_ARGB32 bgfx_set_palette(&((*pwin)->surf),&ColorLookup); #endif bgfx_fill_rect(&((*pwin)->surf),0,0,width,height,DCCGFX_COLOR_CLEAR); (*pwin)->width = width; (*pwin)->height = height; (*pwin)->id = hWinLibHandle->alloc_cnt++; return BCCGFX_WINLIB_P_SUCCESS; } BCCGFX_WINLIB_P_ErrCode BCCGFX_WINLIB_P_Init( BCCGFX_WINLIB_P_Handle *phWinLibHandle, bgfx_surf_t *p_osd_surf, bccgfx_update_cb_t update_cb, bccgfx_get_wide_aspect_ratio_cb_t wide_aspect_ratio_cb, void *p_app ) { BCCGFX_WINLIB_P_Handle hWinLibHandle; BCCGFX_WINLIB_P_hWin win; int sidx; BDCC_DBG_MSG(("BCCGFX_WINLIB_P_Init")); *phWinLibHandle = hWinLibHandle = (BCCGFX_WINLIB_P_Handle) BKNI_Malloc(sizeof(BCCGFX_WINLIB_P_Object)); if(hWinLibHandle == NULL) { return BERR_TRACE(BCCGFX_WINLIB_P_ERROR_NO_MEMORY) ; } memcpy(ColorLookup.clut,g_eia708_palette,16 * sizeof(unsigned int)); BKNI_Memset(hWinLibHandle,0,sizeof(BCCGFX_WINLIB_P_Object)); hWinLibHandle->p_app = p_app ; hWinLibHandle->update_cb = update_cb ; hWinLibHandle->p_osd_surf = p_osd_surf; hWinLibHandle->wide_aspect_ratio_cb = wide_aspect_ratio_cb; initl(&hWinLibHandle->surf_list); initl(&hWinLibHandle->free_surf_list); /* need to match the one defined in gdccgfx.c, CCGFX_MAX_ROWS_PER_WND */ for (sidx = 0; sidx < CCGFX_NUM_WNDS * 15; sidx++) { if (BCCGFX_WINLIB_P_AllocWindow(hWinLibHandle,&win,hWinLibHandle->p_osd_surf->surface.width,DCCGFX_MAX_CELL_HEIGHT + BDCC_Max_Edge_Width + 1) != BCCGFX_WINLIB_P_SUCCESS) { BDCC_DBG_WRN(("BCCGFX_WINLIB_P_AllocWindow failed %d\n",win)); continue; } inslt(&(hWinLibHandle->free_surf_list),win); } return BCCGFX_WINLIB_P_SUCCESS; } void BCCGFX_WINLIB_Sync(BCCGFX_WINLIB_P_Handle hWinLibHandle) { BCCGFX_WINLIB_P_hWin p_win; //int zorder; //for (zorder = 0; zorder < MAX_ZORDER; ++zorder) { /* copy the list to the build list. */ for (p_win = (BCCGFX_WINLIB_P_hWin)LHEAD(&(hWinLibHandle->surf_list)); p_win != NULL; p_win = (BCCGFX_WINLIB_P_hWin)LNEXT(p_win)) { if ((p_win->show) && (!p_win->bClippedOut)) { BCCGFX_WINLIB_P_Rect srcRect; BCCGFX_WINLIB_P_GetRect(p_win,&srcRect); //bgfx_blit_rect(&p_win->surf,hWinLibHandle->p_osd_surf,0,0,p_win->x,p_win->y,p_win->width,p_win->height); BDCC_DBG_MSG(("%s %d(%d,%d,%d,%d) => (%d,%d,%d,%d)\n",__FUNCTION__,p_win->id,p_win->clip_rect.x,p_win->clip_rect.y, p_win->clip_rect.width,p_win->clip_rect.height, srcRect.x,srcRect.y,srcRect.width,srcRect.height)); bgfx_blit_rect(&p_win->surf,hWinLibHandle->p_osd_surf,p_win->clip_rect.x,p_win->clip_rect.y,srcRect.x,srcRect.y,srcRect.width,srcRect.height); } } } } BCCGFX_WINLIB_P_ErrCode BCCGFX_WINLIB_P_OpenWindow( BCCGFX_WINLIB_P_Handle hWinLibHandle, BCCGFX_WINLIB_P_hWin *pwin, uint32_t width, uint32_t height) { BCCGFX_WINLIB_P_hWin win = remlh(&(hWinLibHandle->free_surf_list)); BDCC_ASSERT(hWinLibHandle); if ((width > hWinLibHandle->p_osd_surf->surface.width) || (height > DCCGFX_MAX_CELL_HEIGHT + BDCC_Max_Edge_Width)) { BDCC_DBG_ERR(("BCCGFX_WINLIB_P_OpenWindow failed, width = %d, height = %d",width,height)); return BERR_TRACE(BCCGFX_WINLIB_P_ERROR_NO_MEMORY) ; } if (!win) { BDCC_DBG_ERR(("BCCGFX_WINLIB_P_OpenWindow failed, no windows in free list")); return BERR_TRACE(BCCGFX_WINLIB_P_ERROR_NO_MEMORY) ; } inslt(&(hWinLibHandle->surf_list),win); memset(&(win->EdgeColor),0, (unsigned int)&(win->id) - (unsigned int)&(win->EdgeColor)); win->width = width; win->height = height; *pwin = win; return BCCGFX_WINLIB_P_SUCCESS; } BCCGFX_WINLIB_P_ErrCode BCCGFX_WINLIB_P_CloseWindow(BCCGFX_WINLIB_P_hWin win) { BDCC_ASSERT(win); if (!win || !win->hWinLibHandle) return BCCGFX_WINLIB_P_ERROR_NO_MEMORY; BDCC_DBG_MSG(("%s(%d)", __FUNCTION__,win->id)); reml(&win->hWinLibHandle->surf_list,win); inslt(&(win->hWinLibHandle->free_surf_list),win); return BCCGFX_WINLIB_P_SUCCESS; } BCCGFX_WINLIB_P_ErrCode BCCGFX_WINLIB_P_SetZorder(BCCGFX_WINLIB_P_hWin win, int zorder) { BDCC_ASSERT(win); BDCC_DBG_MSG(("%s(%d,%d)", __FUNCTION__,win->id,zorder)); win->zorder = zorder; return BCCGFX_WINLIB_P_SUCCESS; } BCCGFX_WINLIB_P_ErrCode BCCGFX_WINLIB_P_Show(BCCGFX_WINLIB_P_hWin win) { BDCC_ASSERT(win); BDCC_DBG_MSG(("%s(%d)", __FUNCTION__,win->id)); win->show = true; return BCCGFX_WINLIB_P_SUCCESS; } bool BCCGFX_WINLIB_P_IsShown(BCCGFX_WINLIB_P_hWin win) { BDCC_ASSERT(win); BDCC_DBG_MSG(("%s", __FUNCTION__)); return win->show; } BCCGFX_WINLIB_P_ErrCode BCCGFX_WINLIB_P_Hide(BCCGFX_WINLIB_P_hWin win) { BDCC_ASSERT(win); BDCC_DBG_MSG(("%s", __FUNCTION__)); win->show = false; return BCCGFX_WINLIB_P_SUCCESS; } BCCGFX_WINLIB_P_ErrCode BCCGFX_WINLIB_P_GetPenPosition(BCCGFX_WINLIB_P_hWin win, uint32_t *px, uint32_t *py) { BDCC_ASSERT(px) ; BDCC_ASSERT(py) ; BDCC_DBG_MSG(("%s x=%d,y=%d", __FUNCTION__,win->PenPositionx,win->PenPositiony)); *px = win->PenPositionx ; *py = win->PenPositiony ; return BCCGFX_WINLIB_P_SUCCESS; } BCCGFX_WINLIB_P_ErrCode BCCGFX_WINLIB_P_SetPenPosition(BCCGFX_WINLIB_P_hWin win, uint32_t x, uint32_t y) { BDCC_ASSERT(win); BDCC_DBG_MSG(("%s %d(%d,%d)", __FUNCTION__,win->id,x,y)); win->PenPositionx = x ; win->PenPositiony = y ; return BCCGFX_WINLIB_P_SUCCESS; } BCCGFX_WINLIB_P_ErrCode BCCGFX_WINLIB_P_SetPosition(BCCGFX_WINLIB_P_hWin win, uint32_t x, uint32_t y) { BDCC_ASSERT(win); BDCC_DBG_MSG(("%s %d(%d,%d)", __FUNCTION__,win->id,x,y)); win->x = x; win->y = y; return BCCGFX_WINLIB_P_SUCCESS; } BCCGFX_WINLIB_P_ErrCode BCCGFX_WINLIB_P_SetViewRect(BCCGFX_WINLIB_P_hWin win, const BCCGFX_WINLIB_P_Rect *pRect) { BDCC_ASSERT(win); BDCC_DBG_MSG(("%s %d(%d,%d,%d,%d)", __FUNCTION__,win->id,pRect->x,pRect->y,pRect->width,pRect->height)); memcpy(&(win->clip_rect),pRect,sizeof(BCCGFX_WINLIB_P_Rect)); return BCCGFX_WINLIB_P_SUCCESS; } BCCGFX_WINLIB_P_ErrCode BCCGFX_WINLIB_P_GetRect(BCCGFX_WINLIB_P_hWin win, BCCGFX_WINLIB_P_Rect *pRect) { BDCC_ASSERT(win); pRect->x = win->x ; pRect->y = win->y ; pRect->width = win->width ; pRect->height = win->height ; BDCC_DBG_MSG(("%s %d(%d,%d,%d,%d)", __FUNCTION__,win->id,pRect->x,pRect->y,pRect->width,pRect->height)); return BCCGFX_WINLIB_P_SUCCESS; } BCCGFX_WINLIB_P_ErrCode BCCGFX_WINLIB_P_SetRect(BCCGFX_WINLIB_P_hWin win, BCCGFX_WINLIB_P_Rect *pRect ) { BDCC_ASSERT(win); BDCC_DBG_MSG(("%s %d(%d,%d,%d,%d)", __FUNCTION__,win->id,pRect->x,pRect->y,pRect->width,pRect->height)); win->x = pRect->x; win->y = pRect->y; win->width = pRect->width; win->height = pRect->height; return BCCGFX_WINLIB_P_SUCCESS; } BCCGFX_WINLIB_P_ErrCode BCCGFX_WINLIB_P_SetForegroundColor(BCCGFX_WINLIB_P_hWin win, uint32_t ForeGroundColor) { BDCC_DBG_MSG(("%s", __FUNCTION__)); BDCC_ASSERT(win); win->ForeGroundColor = ForeGroundColor ; return BCCGFX_WINLIB_P_SUCCESS; } BCCGFX_WINLIB_P_ErrCode BCCGFX_WINLIB_P_SetBackgroundColor(BCCGFX_WINLIB_P_hWin win, uint32_t BackGroundColor) { BDCC_ASSERT(win); BDCC_DBG_MSG(("%s", __FUNCTION__)); win->BackGroundColor = BackGroundColor ; return BCCGFX_WINLIB_P_SUCCESS; } BCCGFX_WINLIB_P_ErrCode BCCGFX_WINLIB_P_SetEdgeColor(BCCGFX_WINLIB_P_hWin win, uint32_t EdgeColor) { BDCC_ASSERT(win); BDCC_DBG_MSG(("%s", __FUNCTION__)); win->EdgeColor = EdgeColor ; return BCCGFX_WINLIB_P_SUCCESS; } BCCGFX_WINLIB_P_ErrCode BCCGFX_WINLIB_P_SetEdgeType(BCCGFX_WINLIB_P_hWin win, BDCC_Edge EdgeType ) { BDCC_ASSERT(win); BDCC_DBG_MSG(("%s", __FUNCTION__)); win->EdgeType = EdgeType ; return BCCGFX_WINLIB_P_SUCCESS; } BCCGFX_WINLIB_P_ErrCode BCCGFX_WINLIB_P_SetEdgeWidth(BCCGFX_WINLIB_P_hWin win, uint32_t EdgeWidth ) { BDCC_DBG_MSG(("%s", __FUNCTION__)); BDCC_ASSERT(win); win->EdgeWidth = EdgeWidth ; return BCCGFX_WINLIB_P_SUCCESS; } BCCGFX_WINLIB_P_ErrCode BCCGFX_WINLIB_P_FillRect(BCCGFX_WINLIB_P_hWin win, const BCCGFX_WINLIB_P_Rect *rect, uint32_t color) { BDCC_DBG_MSG(("%s %d(%d,%d,%d,%d - %d)", __FUNCTION__,win->id,rect->x,rect->y,rect->width,rect->height,color)); BDCC_ASSERT(win); bgfx_fill_rect(&win->surf,rect->x,rect->y,rect->width,rect->height,color); return BCCGFX_WINLIB_P_SUCCESS; } BCCGFX_WINLIB_P_ErrCode BCCGFX_WINLIB_P_LoadFont(BCCGFX_WINLIB_P_Handle hWinLibHandle, const char *pFontFile, int iFontSize, BCCGFX_WINLIB_P_Font *phFont) { BCCGFX_WINLIB_P_Font hFont ; BDCC_DBG_MSG(("%s", __FUNCTION__)); *phFont = hFont = (BCCGFX_WINLIB_P_Font)BKNI_Malloc(sizeof(BCCGFX_WINLIB_P_FontInfo)); if(hFont == NULL) { return BERR_TRACE(BCCGFX_WINLIB_P_ERROR_NO_MEMORY) ; } hFont->p_font = (bgfx_font_t*)pFontFile; hFont->TextBase = hFont->p_font->ascender; //iFontSize; hFont->hWinLibHandle = hWinLibHandle; return BCCGFX_WINLIB_P_SUCCESS; } BCCGFX_WINLIB_P_ErrCode BCCGFX_WINLIB_P_UnloadFont(BCCGFX_WINLIB_P_Font font) { BDCC_DBG_MSG(("%s", __FUNCTION__)); BKNI_Free(font); return BCCGFX_WINLIB_P_SUCCESS; } BCCGFX_WINLIB_P_ErrCode BCCGFX_WINLIB_P_SetFont(BCCGFX_WINLIB_P_hWin win, BCCGFX_WINLIB_P_Font font, int italics, int underline) { BDCC_DBG_MSG(("%s", __FUNCTION__)); win->font = font; win->italics = italics; win->underline = underline; return BCCGFX_WINLIB_P_SUCCESS; } BCCGFX_WINLIB_P_ErrCode BCCGFX_WINLIB_P_DrawString(BCCGFX_WINLIB_P_hWin win, const char *str) { int uni_str_len, x = 0, y = 0; bgfx_text_style style = eBGFX_NORMAL; BDCC_ASSERT(win); BDCC_ASSERT(win->font); BDCC_DBG_MSG(("%s %d(%d,%d,%d,%s)",__FUNCTION__, win->id,win->PenPositionx, win->PenPositiony, win->ForeGroundColor,str)); uni_str_len = c_to_uni_str((unsigned char*)str,win->hWinLibHandle->uni_str,MAX_UNI_LEN); remap_chars(win->hWinLibHandle->uni_str,uni_str_len); if (win->underline) style |= eBGFX_UNDERLINE; if (win->italics) style |= eBGFX_ITALIC; switch( win->EdgeType ) { /* ** This is arbitrary, but default to "Right Drop Shadow" for "Raised", "Depressed" and "Uniform". ** A simple multi-rendering approach doesn't work with these styles. */ case BDCC_Edge_Style_Raised: case BDCC_Edge_Style_Depressed: case BDCC_Edge_Style_Uniform: case BDCC_Edge_Style_RightDropShadow: bgfx_draw_text(&win->surf,win->PenPositionx+win->EdgeWidth, win->PenPositiony+win->EdgeWidth + win->font->TextBase, (const unsigned long *)win->hWinLibHandle->uni_str,uni_str_len, win->font->p_font,win->EdgeColor,style); break; case BDCC_Edge_Style_LeftDropShadow: if (win->EdgeWidth > 1) x = win->EdgeWidth - 1; else x = 1; //x = win->EdgeWidth; y = win->EdgeWidth; bgfx_draw_text(&win->surf,win->PenPositionx, win->PenPositiony + win->font->TextBase, (const unsigned long *)win->hWinLibHandle->uni_str,uni_str_len, win->font->p_font,win->EdgeColor,style); break; case BDCC_Edge_Style_None: default: break; } bgfx_draw_text(&win->surf,win->PenPositionx + x, win->PenPositiony + win->font->TextBase - y, (const unsigned long *)win->hWinLibHandle->uni_str,uni_str_len, win->font->p_font,win->ForeGroundColor,style); return BCCGFX_WINLIB_P_SUCCESS; } BCCGFX_WINLIB_P_ErrCode BCCGFX_WINLIB_P_DrawHLine( BCCGFX_WINLIB_P_hWin win, uint32_t x, uint32_t y, uint32_t wide, uint32_t length, uint32_t FgColor) { BDCC_ASSERT(win) ; BDCC_DBG_ERR(("%s %d(%d,%d,%d)",__FUNCTION__, win->id,x, y, FgColor)); bgfx_h_draw_line(&win->surf,x,y,length,FgColor); return BCCGFX_WINLIB_P_SUCCESS; } BCCGFX_WINLIB_P_ErrCode BCCGFX_WINLIB_P_GetGlyphMetrics( BCCGFX_WINLIB_P_Font hFont, const char ch, int *pWidth, int * pHeight ) { int uni_str_len ; char str[2] ; unsigned int uni_str[2] ; int height, width ; BDCC_ASSERT(hFont) ; BDCC_ASSERT(pWidth) ; str[0] = ch; str[1] = 0 ; uni_str_len = c_to_uni_str((unsigned char*)str,uni_str,1); remap_chars(uni_str,uni_str_len); bgfx_string_info(hFont->p_font,(const unsigned long *)uni_str,uni_str_len,&width,&height); *pWidth = width; *pHeight = height; return BCCGFX_WINLIB_P_SUCCESS; } BCCGFX_WINLIB_P_ErrCode BCCGFX_WINLIB_P_GetFrameBufferSettings( BCCGFX_WINLIB_P_Handle hWinLibHandle, BCCGFX_WINLIB_P_FrameBufferSettings * pSettings ) { pSettings->iHeight = hWinLibHandle->p_osd_surf->surface.height; pSettings->iWidth = hWinLibHandle->p_osd_surf->surface.width; return BCCGFX_WINLIB_P_SUCCESS; } /*end of BCCGFX_WINLIB_P_GetFrameBufferSettings() */ BCCGFX_WINLIB_P_ErrCode BCCGFX_WINLIB_P_GetSurfaceSettings( BCCGFX_WINLIB_P_hWin pSurface, BCCGFX_WINLIB_P_SurfaceSettings * pSettings ) { pSettings->iHeight = pSurface->surf.surface.height; pSettings->iWidth = pSurface->surf.surface.width; return BCCGFX_WINLIB_P_SUCCESS; } /*end of BCCGFX_WINLIB_P_GetSurfaceSettings() */ BCCGFX_WINLIB_P_ErrCode BCCGFX_WINLIB_P_SetClipState(BCCGFX_WINLIB_P_hWin win, bool bClipState ) { BDCC_ASSERT(win); BDCC_DBG_MSG(("%s %d(%d)", __FUNCTION__,win->id,bClipState)); /* ** TODO: does the following logic work when a flashing surface scrolls onto the screen? */ win->bClippedOut = bClipState; return BCCGFX_WINLIB_P_SUCCESS; } BCCGFX_WINLIB_P_ErrCode BCCGFX_WINLIB_P_GetFontHandle(BCCGFX_WINLIB_P_hWin win, BCCGFX_WINLIB_P_Font *pFontHandle ) { BDCC_ASSERT(win) ; BDCC_ASSERT(pFontHandle) ; BDCC_DBG_MSG(("%s", __FUNCTION__)); *pFontHandle = win->font; return BCCGFX_WINLIB_P_SUCCESS; } bool BCCGFX_WINLIB_P_GetClipState(BCCGFX_WINLIB_P_hWin win ) { BDCC_ASSERT(win); BDCC_DBG_MSG(("%s %d", __FUNCTION__,win->id)); return ( win->bClippedOut ) ; } BCCGFX_WINLIB_P_ErrCode BCCGFX_WINLIB_P_Copy(BCCGFX_WINLIB_P_hWin src, BCCGFX_WINLIB_P_hWin dst, const BCCGFX_WINLIB_P_Rect *pSrcRect, const BCCGFX_WINLIB_P_Rect *pDstRect ) { BDCC_ASSERT(src) ; BDCC_ASSERT(dst) ; BDCC_ASSERT(pSrcRect) ; BDCC_ASSERT(pDstRect) ; BDCC_DBG_MSG(("%s %d(%d,%d,%d,%d)=>%d(%d,%d,%d,%d)", __FUNCTION__,src->id,pSrcRect->x,pSrcRect->y, pSrcRect->width,pSrcRect->height,dst->id,pDstRect->x,pDstRect->y,pDstRect->width,pDstRect->height)); bgfx_blit_rect(&src->surf,&dst->surf,pSrcRect->x,pSrcRect->y,pDstRect->x,pDstRect->y,pSrcRect->width,pSrcRect->height); return BCCGFX_WINLIB_P_SUCCESS; } /* ** For use when the CC library is managing the framebuffer direclty. ** Look in the routine "BCCGFX_P_RedrawScreen()" to see how this is used. */ BCCGFX_WINLIB_P_ErrCode BCCGFX_WINLIB_P_CopyToFrameBuffer( BCCGFX_WINLIB_P_hWin src, BCCGFX_WINLIB_P_Handle hWinLibHandle, const BCCGFX_WINLIB_P_Rect *pSrcRect, const BCCGFX_WINLIB_P_Rect *pDstRect ) { BDCC_ASSERT(src) ; BDCC_ASSERT(hWinLibHandle) ; BDCC_ASSERT(pSrcRect) ; BDCC_ASSERT(pDstRect) ; BDCC_DBG_MSG(("%s %d(%d,%d,%d,%d)=>(%d,%d,%d,%d)", __FUNCTION__,src->id,pSrcRect->x,pSrcRect->y, pSrcRect->width,pSrcRect->height,pDstRect->x,pDstRect->y,pDstRect->width,pDstRect->height)); bgfx_blit_rect(&src->surf,hWinLibHandle->p_osd_surf,pSrcRect->x,pSrcRect->y,pDstRect->x,pDstRect->y,pSrcRect->width,pSrcRect->height); return BCCGFX_WINLIB_P_SUCCESS; } /* ** For use when the CC library is managing the framebuffer direclty. ** Look in the routine "BCCGFX_P_RedrawScreen()" to see how this is used. */ BCCGFX_WINLIB_P_ErrCode BCCGFX_WINLIB_P_FillFrameBuffer( BCCGFX_WINLIB_P_Handle hWinLibHandle, const BCCGFX_WINLIB_P_Rect *rect, uint32_t color ) { BDCC_ASSERT(hWinLibHandle); BDCC_DBG_MSG(("%s (%d,%d,%d,%d)", __FUNCTION__,rect->x,rect->y,rect->width,rect->height)); bgfx_fill_rect(hWinLibHandle->p_osd_surf,rect->x,rect->y,rect->width,rect->height,color); return BCCGFX_WINLIB_P_SUCCESS; } BCCGFX_WINLIB_P_ErrCode BCCGFX_WINLIB_P_RedrawScreen(BCCGFX_WINLIB_P_Handle hWinLibHandle ) { BDCC_ASSERT(hWinLibHandle); BDCC_DBG_MSG(("%s", __FUNCTION__)); bgfx_fill_rect(hWinLibHandle->p_osd_surf,0,0,hWinLibHandle->p_osd_surf->surface.width,hWinLibHandle->p_osd_surf->surface.height,0); BCCGFX_WINLIB_Sync(hWinLibHandle); hWinLibHandle->update_cb(hWinLibHandle->p_app, eGRAPHICS_BOTH); return BCCGFX_WINLIB_P_SUCCESS; } int BDCC_WINLIB_P_GetActiveWindowSettings(BCCGFX_WINLIB_P_Handle phWinLibHandle, unsigned int *colors, unsigned int *style) { BCCGFX_WINLIB_P_hWin win, win_parent, win_flash; /* which is pointer of BCCGFX_WINLIB_P_Window */ win_parent = win_flash = NULL; for (win = (BCCGFX_WINLIB_P_hWin)LHEAD(&(phWinLibHandle->surf_list)); win != NULL; win = (BCCGFX_WINLIB_P_hWin)LNEXT(win)) { if(win->zorder == 0) { if (win->show == false && (win->ForeGroundColor||win->BackGroundColor)) { if(win_parent == NULL) win_parent = win; else{ win_flash = win; break; } } } } if(win_parent && win_flash) { colors[0] = win_parent->ForeGroundColor; colors[1] = win_parent->BackGroundColor; colors[2] = win_parent->EdgeColor; *style = (win_parent->EdgeType<<8); if (win_parent->italics) *style |= 0x01; else if (win_parent->underline) *style |= 0x02; if (win_parent->ForeGroundColor != win_flash->ForeGroundColor) *style |= 0x04; if (win_parent->BackGroundColor != win_flash->BackGroundColor) *style |= 0x08; return 1; } return 0; } int BCCGFX_WINLIB_GetWideAspectRatio(BCCGFX_WINLIB_P_Handle hWinLibHandle) { BDCC_ASSERT(hWinLibHandle); if (hWinLibHandle->wide_aspect_ratio_cb) return hWinLibHandle->wide_aspect_ratio_cb(); /* default not wide_aspect_ratio */ return 0; }