⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 msapi_osd.c

📁 mstar 776 开发的车载dvd
💻 C
📖 第 1 页 / 共 5 页
字号:
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2006-2007 MStar Semiconductor, Inc.
// All rights reserved.
//
// Unless otherwise stipulated in writing, any and all information contained
// herein regardless in any format shall remain the sole proprietary of
// MStar Semiconductor Inc. and be kept in strict confidence
// (¨MStar Confidential Information〃) by the recipient.
// Any unauthorized act including without limitation unauthorized disclosure,
// copying, use, reproduction, sale, distribution, modification, disassembling,
// reverse engineering and compiling of the contents of MStar Confidential
// Information is unlawful and strictly prohibited. MStar hereby reserves the
// rights to any and all damages, losses, costs and expenses resulting therefrom.
//
////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
//  [Doxygen]
/// @file msAPI_OSD.h
/// @brief API for OSD functions
/// @author MStar Semiconductor, Inc.
//
////////////////////////////////////////////////////////////////////////////////

#define MSAPI_OSD_C

/********************************************************************************/
/*                    Header Files                        						*/
/********************************************************************************/
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>

#include "DataType.h"
#include "drvge2.h"
#include "drvgop.h"
#include "msAPI_OSD.h"
#include "msAPI_Memory.h"
#include "msAPI_Font.h"
#include "msAPI_Timer.h"

#include "drvMIU.h"

#include "sysinfo.h"
#include "sramvar.h"

#define APIOSD_DBG(x) //x
//#define USE_EPG 0   //suppress compiler warning!


#define Very_Long_Word_Case 0
//#define MAX_OSD_STRING_BYTES    255

/********************************************************************************/
/*                     Local                    								*/
/********************************************************************************/
static GEClrBlock clrBlock;
//static GEClrPoint cpoint;
//static GEPoint point;             // not used
//static GEClrLine clrline;
//static GERGBColor b_clr,f_clr;    // not used
//static GELineFmt lineFmt;
//static GEBitmapFmt bmpfmt;        // not used
static GERectFmt rfmt;
//static GERoundFmt roundfmt;       // not used
//static GELineFmt lfmt;
//static GEPESettings    GEPE;      // not used
static GELineRectInfo  GELineRect;
//static GEPESettings  PESet;

#include "kerning.h"

//U8 g_au8OsdTempStr[MAX_OSD_STRING_BYTES+1];

/********************************************************************************/
/*                   Functions     												*/
/********************************************************************************/

//*************************************************************************
//Function name:        msAPI_OSD_u16Strlen
//Passing parameter:    U16 *pu16Str : string pointor
//Return parameter:     U16 : string length
//Description:          Transfer numer into string
//*************************************************************************

/******************************************************************************/
/// API for Get string length::
/// Get string length
/// @param pu16Str \b IN string pointor
///
/******************************************************************************/
U16 msAPI_OSD_u16Strlen(U16 *pu16Str)
{
    U16 u16Count;

    u16Count = 0;
    while( (*pu16Str++ != 0) && (u16Count < (MAX_OSD_STRING_BYTES / 2)) )
    {
        u16Count++;
    }
    return u16Count;
}

#if (KEEP_UNUSED_FUNC == 1)
void msAPI_OSD_u16Strcat(U16 *pu16Dest, U16 *pu16Src)
{
    memcpy(pu16Dest + msAPI_OSD_u16Strlen(pu16Dest), pu16Src, (msAPI_OSD_u16Strlen(pu16Src)+1) * 2);
}

//*************************************************************************
//Function name:        msAPI_OSD_u16Strcpy
//Passing parameter:    U16 *pu16Dest: destnation
//                      U16 *pu16Src: source
//Return parameter:     none
//Description:          string copy
//*************************************************************************

/******************************************************************************/
/// API for string copy::
/// @param pu16Dest \b OUT string destination
/// @param pu16Src \b IN string source
/******************************************************************************/
void msAPI_OSD_u16Strcpy(U16 *pu16Dest, U16 *pu16Src)
{
    memcpy(pu16Dest, pu16Src, (msAPI_OSD_u16Strlen(pu16Src)+1) * 2);
}

/******************************************************************************/
/// API for string compare::
/// get compared result
/// @param u16strA \b IN string destination
/// @param u16strB \b IN string source
/******************************************************************************/
S8 msAPI_OSD_u16Strcmp(U16 *u16strA, U16 *u16strB)
{
    U16 strlen_a, strlen_b;

    strlen_a = msAPI_OSD_u16Strlen(u16strA);
    strlen_b = msAPI_OSD_u16Strlen(u16strB);
    return memcmp((U8 *) u16strA, (U8 *) u16strB, MAX(strlen_a, strlen_b));
}
#endif
/******************************************************************************/
/// API for get string length::
/// Get string length
/// @param pu8Str \b IN pointer to string
/// @param u8NoOfBytesPerChar \b IN btyes per char
/******************************************************************************/
U16 msAPI_OSD_GetStrLength(U8 *pu8Str, U8 u8NoOfBytesPerChar)
{
    U16 length;

    if(u8NoOfBytesPerChar == CHAR_IDX_1BYTE)
    {
        length = strlen(pu8Str);
        if (length > MAX_OSD_STRING_BYTES)
        {
            length = MAX_OSD_STRING_BYTES;
        }
    }
    else //(u8NoOfBytesPerChar == CHAR_IDX_2BYTE)
    {
        length = msAPI_OSD_u16Strlen((U16 *)pu8Str);
    }

    return length;
}

#if (KEEP_UNUSED_FUNC == 1)
/******************************************************************************/
/// API for get string width::
/// Get string width
/// @param font_handle \b IN font handle
/// @param pu8Str \b IN pointer to string
/// @param pclrBtn \b IN color
/******************************************************************************/
U16 msAPI_OSD_GetStrWidth(FONTHANDLE font_handle, U8 *pu8Str, OSDClrBtn *pclrBtn)
{
	U16 i;
	U16 length, width;
	U16 *pu16Str;
	FONT_INFO finfo;
    GLYPH_BBOX_X BBox_X_Info;

	width = 0;
	length = msAPI_OSD_GetStrLength(pu8Str, pclrBtn->bStringIndexWidth);
	if( length )
	{
		if(pclrBtn->Fontfmt.flag & GEFONT_FLAG_VARWIDTH)
		{
			if(pclrBtn->bStringIndexWidth == CHAR_IDX_1BYTE)
			{
				for(i=0; i<length; i++)
				{
                    MDrv_GE_GetBBox_X(font_handle, pu8Str[i], &BBox_X_Info);
                    width += BBox_X_Info.u8Width;
				}
			}
			else //(pclrBtn->bStringIndexWidth == CHAR_IDX_2BYTE)
			{
				pu16Str = (U16*)pu8Str;
				for(i=0; i<length; i++)
				{
                    MDrv_GE_GetBBox_X(font_handle, pu16Str[i], &BBox_X_Info);
                    width += BBox_X_Info.u8Width;
				}
			}

			if(pclrBtn->Fontfmt.flag & GEFONT_FLAG_GAP)
			{
				width += ((length-1) * pclrBtn->Fontfmt.ifont_gap);
			}
		}
		else
		{
			MDrv_GE_GetFontInfo(font_handle, &finfo);
			width = length * finfo.width;
		}
	}

	return width;
}
#endif
#if 1
/******************************************************************************/
/// API for draw line::
/// @param p_clr_line \b IN line color
/******************************************************************************/
void msAPI_OSD_DrawLine(OSDClrLine *p_clr_line)
{
    GELineFmt lfmt;
    GEClrLine clrline;
/*
    if((pclrBtn->x + pclrBtn->width) > NEWUI_MAIN_MENU_GWIN_WIDTH)
    {
        return;
    }
    else if((pclrBtn->y + pclrBtn->height) > NEWUI_MAIN_MENU_GWIN_HEIGHT)
    {
        return;
    }
*/
#if GE_DRIVER_TEST

    GELineRect.LineRectCoordinate.v0_x = p_clr_line->x1;
    GELineRect.LineRectCoordinate.v0_y = p_clr_line->y1;
    GELineRect.LineRectCoordinate.v1_x = p_clr_line->x2;
    GELineRect.LineRectCoordinate.v1_y = p_clr_line->y2;
    GELineRect.Gradient_Color_Flag     = GECOLOR_FLAG_CONSTANT;
    GELineRect.ARGBClr.ForeGroundColor.u32Num
    = (p_clr_line->u32LineColor&0xff00ff00) + ((p_clr_line->u32LineColor&0xff)<<16) +((p_clr_line->u32LineColor>>16)&0xff);
    MDrv_GE_LineDraw(&GELineRect);

#else
	memcpy (&clrline, p_clr_line, sizeof(GEClrLine));
    lfmt.width = p_clr_line->u8LineWidth;
    MDrv_GE_LineTo(&clrline, &lfmt);
#endif

}
#else
/******************************************************************************/
/// API for draw line::
/// @param pclrBtn \b IN color
/******************************************************************************/
void msAPI_OSD_DrawLine(OSDClrBtn *pclrBtn)
{
/*
    if((pclrBtn->x + pclrBtn->width) > NEWUI_MAIN_MENU_GWIN_WIDTH)
    {
        return;
    }
    else if((pclrBtn->y + pclrBtn->height) > NEWUI_MAIN_MENU_GWIN_HEIGHT)
    {
        return;
    }
*/
#if GE_DRIVER_TEST

    GELineRect.LineRectCoordinate.v0_x = pclrBtn->x;
    GELineRect.LineRectCoordinate.v0_y = pclrBtn->y;
    GELineRect.LineRectCoordinate.v1_x = pclrBtn->x + pclrBtn->width;
    GELineRect.LineRectCoordinate.v1_y = pclrBtn->y + pclrBtn->height;
    GELineRect.Gradient_Color_Flag        = GECOLOR_FLAG_CONSTANT;
    GELineRect.ARGBClr.ForeGroundColor.u32Num
    = (pclrBtn->b_clr&0xff00ff00) + ((pclrBtn->b_clr&0xff)<<16) +((pclrBtn->b_clr>>16)&0xff);
    MDrv_GE_LineDraw(&GELineRect);

#else

    clrline.x1 = pclrBtn->x;
    clrline.y1 = pclrBtn->y;
    clrline.x2 = pclrBtn->x + pclrBtn->width;
    clrline.y2 = pclrBtn->y + pclrBtn->height;
    lfmt.width = pclrBtn->bFrameWidth;
    memcpy(&clrline.clr, &pclrBtn->b_clr, 4);
    MDrv_GE_LineTo(&clrline, &lfmt);
#endif

}
#endif
/*****************************************************************************************************/
static U8 kerningX_(U8 char1, U8 char2)
{
    U8 i;

    if (char1 == 0 || char2 == 0 || char1 > 'Z')
    {
	    return 0;
	}

    for (i = 0; i < kerningTblSize; i++)
    {
    	if (char1 == kerningTable[i].char1 && char2 == kerningTable[i].char2)
    	{
    	    return kerningTable[i].kVal;
    	}
    }
    return 0;
}

/******************************************************************************/
/// API for draw text::
/// @param font_handle \b IN font handle
/// @param pu8Str \b IN pointer to string
/// @param pclrBtn \b IN color
/******************************************************************************/
void msAPI_OSD_DrawText(FONTHANDLE font_handle, U8 *pu8Str, OSDClrBtn *pclrBtn)
{
    U16 i, len, u16StrWidth;
    U16 *pu16Str;
    U8 scale;
    FONT_INFO finfo;
    GLYPH_DISP_INFO *pGlyphDispInfo=NULL;
    GEClrPoint cpoint;

    /* check range */
    /*if((pclrBtn->x + pclrBtn->width) > NEWUI_MAIN_MENU_GWIN_WIDTH)
    {
        return;
    }
    else if((pclrBtn->y + pclrBtn->height) > NEWUI_MAIN_MENU_GWIN_HEIGHT)
    {
        return;
    }
    else*/ if((len = msAPI_OSD_GetStrLength(pu8Str, pclrBtn->bStringIndexWidth)) == 0)
    {
        return;
    }

    if(pclrBtn->bStringIndexWidth==CHAR_IDX_1BYTE)
    {
        if (len >= sizeof(g_au8OsdTempStr))
        {
            len = sizeof(g_au8OsdTempStr) - 1;
        }
        memcpy(g_au8OsdTempStr,pu8Str,len);
        g_au8OsdTempStr[len] = 0;

    }
    else
    {
        if (len >= sizeof(g_au8OsdTempStr)/2)
        {
            len = sizeof(g_au8OsdTempStr)/2 - 1;
        }
        memcpy(g_au8OsdTempStr,pu8Str,len*2);
        ((U16 *)g_au8OsdTempStr)[len] = 0;
    }

    MDrv_GE_GetFontInfo(font_handle, &finfo);

    scale = 1;
    if(pclrBtn->Fontfmt.flag & GEFONT_FLAG_SCALE)
    {
        scale = (U8)((U16)pclrBtn->Fontfmt.height / (U16)finfo.height);
        pclrBtn->Fontfmt.height = scale * finfo.height;

        scale = (U8)((U16)pclrBtn->Fontfmt.width / (U16)finfo.width);
        pclrBtn->Fontfmt.width = scale * finfo.width;
    }

    pGlyphDispInfo = msAPI_Memory_Allocate( sizeof(GLYPH_DISP_INFO) * len );
    if(pGlyphDispInfo == NULL)
    {
        APIOSD_DBG(printf("E_DrawText>> pGlyphDispInfo == NULL\n"));
        return;
    }

    if(pclrBtn->Fontfmt.flag & GEFONT_FLAG_VARWIDTH)
    {
        if(pclrBtn->bStringIndexWidth == CHAR_IDX_1BYTE)
        {
            for (i=0; i<len; i++)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -