📄 apiosdgc.c
字号:
#include <DataType.h>
#include "Panel.h"
#include "Drvgop.h"
#include "apiOsd.h"
#include "apiOSDUtil.h"
#include "msAPI_OSD.h"
#include "msAPI_GOP.h"
//#include "apiFont.h"
//extern void GeneratePattern(void);
//-------------------------------------------------------------------------------------------------
/// MApi_Osd_Create_GC : Create graphic context resource
/// @param pGC \b IN: the GC
/// @return TRUE: success / FALSE: fail
/// @Note: You must specify the following parameters before.
/// pGC->s16Width
/// pGC->s16Height
/// pGC->fmt
/// pGC->colorBackground
//-------------------------------------------------------------------------------------------------
BOOLEAN MApi_Osd_Create_GC(OsdGC *pGC)
{
//U8 u8I;
GE_Buffer_Format fmtGE;
U32 u32pitch;
U8 u8ColorDepth;
U8 u8GEAlign = 4; //GE is 4 Byte Alignment;
//U16 ColorFmt;
//for (u8I = 0; u8I < MAX_SYSTEMFONT; u8I++)
//{
// pGC->hFont[u8I] = ERR_HANDLE;
//}
pGC->bIsOnscreen = FALSE;
fmtGE = MapGEColorType(pGC->fmt);
u8ColorDepth = MapGCColorDepth(pGC->fmt);
u32pitch = ((pGC->s16Width * u8ColorDepth)+(u8GEAlign-1)) & ~(u8GEAlign-1);
pGC->s16Width = u32pitch / u8ColorDepth; //recalculate the real GC width
// Create Frame Buffer
//ColorFmt = (U16)fmtGE | (fmtGE<<8);
pGC->u8FBID = msAPI_GOP_GWIN_GetFreeFBID();
printf("\r\n[creategc] get free FB id = %d, width = %d, height = %d", (U16)pGC->u8FBID, (U16)pGC->s16Width, (U16)pGC->s16Height);
//[NOTE!] need to refine in the future, to check return value
if (msAPI_GOP_GWIN_CreateFB(pGC->u8FBID, (U16)pGC->s16Width, (U16)pGC->s16Height, GE_FMT_RGB565/*DEFAULT_FB_FMT*/) == FALSE)
return FALSE;
// initial GC buffer
//if(pGC->pMemHandle.pMem)
//{
// MsOS_FreeMemory(pGC->pMemHandle.pMem, gs32DisplayPoolID);
// pGC->pMemHandle.pMem = NULL;
//}
//pGC->pMemHandle.pMem = MsOS_AllocateMemory(u32pitch * pGC->s16Height , gs32DisplayPoolID);
//if (pGC->pMemHandle.pMem == NULL)
//{
// PRINTE("MApi_Osd_Create_GC : Allocate GC Buffer Fail\n");
// return FALSE;
//}
//pGC->pMemHandle.pGEInfo = (GE_BUFFER_INFO*)MDrv_GE_PE_CreateBuffer((U32)pGC->pMemHandle.pMem, pGC->s16Width, pGC->s16Height, fmtGE);
//Generate_Pattern();
return TRUE;
}
//-------------------------------------------------------------------------------------------------
/// MApi_Osd_CreateGwin_by_GC : Create GOP Gwin base on GC
/// @param pGC \b IN: the GC
/// @param GOPnum \b IN: set GC to specified GOP number
/// @param GwinNum \b IN: set GC to specified Gwin number
/// @param u32DstXpos \b IN: set GC in x position of onscreen.
/// @param u32DstYpos \b IN: set GC in Y position of onscreen.
/// @return true: success
/// false: fail
//-------------------------------------------------------------------------------------------------
BOOLEAN MApi_Osd_CreateGwin_By_GC(OsdGC *pGC, U32 GOPnum, U32 GWinNum, U32 u32DstXpos, U32 u32DstYpos)
{
//GOPColorType eColorType;
//Rect rc;
if (GOPnum != 0)
return false;
//eColorType = MapGOPColorType(pGC->fmt);
//if (GOPnum > MAX_GOP_SUPPORT)
// return FALSE;
//else
pGC->gopnum = GOPnum;
if (GWinNum > MAX_GWIN_SUPPORT)
return FALSE;
else
pGC->gwin = (U8)GWinNum;
msAPI_GOP_GWIN_MapFBToWIN((U8)pGC->u8FBID, (U8)pGC->gwin);
//printf("\r\n[Note] map FB %d to GWin %d", (U16)pGC->u8FBID, (U16)pGC->gwin);
msAPI_GOP_GWIN_Switch2Gwin((U8)pGC->gwin);
//printf("\r\n[Note] set position (%d, %d)", (U16)u32DstXpos, (U16)u32DstYpos);
msAPI_GOP_GWIN_SetWinPosition((U8)pGC->gwin, (U16)u32DstXpos+PANEL_HSTART, (U16)u32DstYpos);
msAPI_OSD_SetClipWindow(0, 0, (U16)pGC->s16Width, (U16)pGC->s16Height);
msAPI_GOP_GWIN_SetBlending((U8)pGC->gwin, FALSE, NEWUI_GWIN_BLENDING); // disable blending
MDrv_GOP_GWIN_SetTransClr_8888(0xFF000000, 0);
MDrv_GOP_GWIN_EnableTransClr(GOPTRANSCLR_FMT0, TRUE);
//rc.left = (S16)0;
//rc.top = (S16)0;
//rc.width = (S16)pGC->s16Width;
//rc.height = (S16)pGC->s16Height;
//MApi_Osd_GCClear(pGC, &rc);
pGC->bIsOnscreen = TRUE;
return TRUE;
}
//-------------------------------------------------------------------------------------------------
/// MApi_Osd_GWin_Show : Show GOP Gwin base on GC
/// @param pGC \b IN: the GC
/// @return true: success false: fail
//-------------------------------------------------------------------------------------------------
BOOLEAN MApi_Osd_GWin_Show (OsdGC *pGC)
{
if (!pGC->bIsOnscreen)
{
//PRINTE ("MApi_Osd_GWin_Show : NotOnScree GC, can't show, please call MApi_Osd_CreateGwin_By_GC at first");
return FALSE;
}
MDrv_GOP_GWIN_Enable(pGC->gwin, TRUE);
return TRUE;
}
//-------------------------------------------------------------------------------------------------
/// MApi_Osd_GWin_Hide : Hide GOP Gwin base on GC
/// @param pGC \b IN: the GC
/// @return true: success false: fail
//-------------------------------------------------------------------------------------------------
/*BOOLEAN MApi_Osd_GWin_Hide (OsdGC *pGC)
{
if (!pGC->bIsOnscreen)
{
PRINTE ("MApi_Osd_GWin_Show : Not OnScree GC, can't show, please call MApi_Osd_CreateGwin_By_GC at first");
return FALSE;
}
MDrv_GOP_GWIN_Enable(pGC->gwin, FALSE);
return TRUE;
}*/
//-------------------------------------------------------------------------------------------------
/// MApi_Osd_ReleaseGC : Free graphic context resource
/// @param pGC \b IN: the GC
/// @return none
//-------------------------------------------------------------------------------------------------
/*void MApi_Osd_ReleaseGC(OsdGC *pGC)
{
U8 u8I;
for (u8I = 0; u8I < MAX_SYSTEMFONT; u8I++)
{
pGC->hFont[u8I] = ERR_HANDLE;
}
pGC->bIsOnscreen = FALSE;
//MDrv_GE_PE_DeleteBuffer(pGC->pMemHandle.pGEInfo);
pGC->pMemHandle.pMem = NULL;
}*/
//-------------------------------------------------------------------------------------------------
/// MApi_Osd_Release_GC : Free graphic context resource
/// @param pGC \b IN: the GC
/// @return none
//-------------------------------------------------------------------------------------------------
void MApi_Osd_Release_GC(OsdGC *pGC)
{
//U8 u8I;
//for (u8I = 0; u8I < MAX_SYSTEMFONT; u8I++)
//{
// pGC->hFont[u8I] = ERR_HANDLE;
//}
pGC->bIsOnscreen = FALSE;
MDrv_GOP_GWIN_DestroyFB(pGC->u8FBID);
pGC->u8FBID = 0xFF;
//MDrv_GE_PE_DeleteBuffer(pGC->pMemHandle.pGEInfo);
//pGC->pMemHandle.pGEInfo =NULL;
//MsOS_FreeMemory(pGC->pMemHandle.pMem, gs32DisplayPoolID);
//pGC->pMemHandle.pMem = NULL;
}
//-------------------------------------------------------------------------------------------------
/// MApi_Osd_GCClear : Clear on screen
/// @param thiz \b IN: the GC
/// r \b IN: the clear rectangle
/// @return none
//-------------------------------------------------------------------------------------------------
void MApi_Osd_GCClear(OsdGC *pGC, Rect *r)
{
#if 1
OSD_COLOR colorBg;
OSD_ALPHA_BLENDING Osd_Blending = {0};
Osd_Blending.bEnable_Blend = FALSE;
Osd_Blending.eALPHA_SRC_FROM = ABL_FROM_ASRC;
//if (thiz->fmt == FMT_I8)
//{
// MApi_Osd_DrawFillRect(thiz ,r ,OSD_I8 , (OSD_COLOR)thiz->colorBackground, (OSD_COLOR)thiz->colorBackground, OSD_GRADIENT_DISABLE, &Osd_Blending);
//}
//else
//{
colorBg = pGC->colorBackground;
MApi_Osd_DrawFillRect(pGC ,r ,OSD_ARGB8888, colorBg, colorBg, OSD_GRADIENT_DISABLE, &Osd_Blending);
//}
#else
OSDClrBtn clrBtn1;
clrBtn1.x = r->left;
clrBtn1.y = r->top;
clrBtn1.width = (U16)r->width;
clrBtn1.height = (U16)r->height;
clrBtn1.radius = 0;
clrBtn1.t_clr = COLOR_WHITE;
clrBtn1.b_clr = pGC->colorBackground;
clrBtn1.u8Gradient = CONSTANT_COLOR;
clrBtn1.f_clr = COLOR_TRANSPARENT;
clrBtn1.fHighLight = FALSE;
clrBtn1.bFrameWidth = false;
printf("\r\n[GCClear] rect(%d, %d, %d, %d)", (U16)clrBtn1.x, (U16)clrBtn1.y, (U16)clrBtn1.width, (U16)clrBtn1.height);
msAPI_OSD_DrawBlock(&clrBtn1);
#endif
}
/*
//-------------------------------------------------------------------------------------------------
/// MApi_Osd_GCFillRect : Fill GC width color
/// @param thiz \b IN: the GC
/// r \b IN: the rectangle
/// color \b IN: the filled color
/// @return none
//-------------------------------------------------------------------------------------------------
void MApi_Osd_GCFillRect(OsdGC *thiz, Rect *r, U32 color)
{
// SetDstBuffer(thiz, BUFFER_DISPLAY, false, White);
MApi_Osd_BeginDraw(thiz);
MApi_Osd_DrawFillRect(r, &color, &color, GERECT_FLAG_COLOR_CONSTANT);
MApi_Osd_EndDraw(thiz);
}
//-------------------------------------------------------------------------------------------------
/// MApi_Osd_GCFillRect : draw rectangle on GC
/// @param thiz \b IN: the GC
/// r \b IN: the rectangle
/// color \b IN: the rectangle color
/// thickness \b IN: the border thickness
/// @return none
//-------------------------------------------------------------------------------------------------
void MApi_Osd_GCDrawRectangle(OsdGC *thiz, Rect *r, U32 color, U8 thickness)
{
// SetDstBuffer(thiz, BUFFER_DISPLAY, false, White);
MApi_Osd_BeginDraw(thiz);
MApi_Osd_DrawRectangleBorder(r, color, color, thickness, eSolidLine);
MApi_Osd_EndDraw(thiz);
}
*/
//-------------------------------------------------------------------------------------------------
/// MApi_GCGetColorFmt : GC color format
/// @return none
//-------------------------------------------------------------------------------------------------
/*GC_ColorFmt MApi_Osd_GCGetColorFmt(OsdGC *pGC)
{
return GC_FMT(pGC);
}*/
//-------------------------------------------------------------------------------------------------
/// MApi_GCGetSystemFont : Get system font handle
/// @param gc \b IN: the GC
/// index \b IN: system font index
/// @return handle of font
//-------------------------------------------------------------------------------------------------
/*FONTHANDLE MApi_Osd_GCGetSystemFont(OsdGC *gc, SystemFont index)
{
return gc->hFont[index];
}*/
//-------------------------------------------------------------------------------------------------
/// MApi_GCGetSystemFont : Get system font handle
/// @param gc \b IN: the GC
/// @param index \b IN: system font index
/// @param pFontHandle \b Out: system font handle
/// @param pFontType \b Out: system font Type
/// @return handle of font
//-------------------------------------------------------------------------------------------------
/*BOOLEAN MApi_Osd_GCGetSysFont(OsdGC *gc, SystemFont index, FONTHANDLE *pFontHandle, U32 *pFontType)
{
*pFontHandle = gc->hFont[index];
*pFontType = gc->u32FontType[index];
return TRUE;
}*/
//-------------------------------------------------------------------------------------------------
/// MApi_GCSetSystemFont : Set system font handle
/// @param gc \b IN: the GC
/// index \b IN: system font index
/// handle \b IN: the font handle
/// @return none
//-------------------------------------------------------------------------------------------------
/*void MApi_Osd_GCSetSystemFont(OsdGC *gc, SystemFont index, FONTHANDLE handle)
{
gc->hFont[index] = handle;
}*/
//-------------------------------------------------------------------------------------------------
/// MApi_GC_SetSystemFont : Set GC system font based on FontType
/// @param gc \b IN: the GC
/// index \b IN: GC system font index
/// u32FontType \b IN: FontType
/// @return none
//-------------------------------------------------------------------------------------------------
/*BOOLEAN MApi_Osd_GCSetSysFont(OsdGC *gc, SystemFont index, U32 u32FontType)
{
gc->u32FontType[index] = u32FontType;
//if (MApi_FONT_GetSysFontHandle(u32FontType, &gc->hFont[index]) != FONTSTATUS_SUCCESS)
//{
// PRINTE ("MApi_Osd_GCSetSysFont : Load SYS font Fail\n");
// return FALSE;
//}
return TRUE;
}*/
//-------------------------------------------------------------------------------------------------
/// MApi_GCGetSystemFont : Set system defined color
/// @param color \b IN: the system color index
/// @return the color
//-------------------------------------------------------------------------------------------------
U32 MApi_Osd_GetSystemColor(OsdGC *pGC, SystemColor color)
{
return SYSCOLOR(pGC, color);
}
//-------------------------------------------------------------------------------------------------
/// MApi_GetSystemGWin : Get OnScreen GC gwin number
/// @param gc \b IN: the GC
/// @param u8GwinNum \b OUT: the u8GwinNum
/// @return true: success false: fail
//-------------------------------------------------------------------------------------------------
/*BOOLEAN MApi_Osd_GetSystemGWin(OsdGC *pGC, U8 *u8GwinNum)
{
if (pGC->bIsOnscreen)
{
*u8GwinNum = pGC->gwin;
return TRUE;
}
else
{
PRINTE ("MApi_Osd_GetSystemGWin : NotOnScree GC !!");
return FALSE;
}
}*/
//-------------------------------------------------------------------------------------------------
/// MApi_GetSystemGOP : Get OnScreen GC gop number
/// @param gc \b IN: the GC
/// @param u8GOPNum \b OUT: the GOP
/// @return true: success false: fail
//-------------------------------------------------------------------------------------------------
/*BOOLEAN MApi_Osd_GetSystemGOP(OsdGC *pGC, U8 *u8GOPNum)
{
if (pGC->bIsOnscreen)
{
*u8GOPNum = pGC->gopnum;
return TRUE;
}
else
{
PRINTE ("MApi_Osd_GetSystemGWin : NotOnScree GC !!");
return FALSE;
}
}*/
//-------------------------------------------------------------------------------------------------
/// MApi_GetSystemColorKey : Get system internal color key
/// @param none
/// @return the color key
//-------------------------------------------------------------------------------------------------
/*U32 MApi_Osd_GetSystemColorKey(OsdGC *pGC)
{
return ARGB(0, 0x7, 0x7, 0x7);
}
void MApi_Osd_SetSystemColor(OsdGC *pGC, U8 index, U32 color)
{
pGC->colorSys[index] = color;
}*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -