📄 msapi_osd2.c
字号:
////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
/// @file msAPI_OSD.h
/// @brief API for OSD Drawing functions
/// @author MStar Semiconductor, Inc.
//
////////////////////////////////////////////////////////////////////////////////
#define MSAPI_OSD2_C
/******************************************************************************/
/* Header Files */
/******************************************************************************/
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "DataType.h"
#include "drvge2.h"
#include "msAPI_OSD.h"
#include "drvgop.h"
#define APIOSD_DBG(x) //x
#define AQU_BOUND_WIDTH 4
/********************************************************************************/
/* Local */
/********************************************************************************/
static GELineRectInfo GELineRect;
static OSDClrBtn OSDClrBtnRec;
static GEBitBltInfo BitbltInfo;
static GEPitBaseInfo PitBaseInfo;
/********************************************************************************/
/* Functions */
/********************************************************************************/
/******************************************************************************/
/// API for copy one rectangle from one buffer to another:
/// @param src \b IN pointer to a struct defining one osd region as source.
/// @param dst \b IN pointer to a struct defining one osd region as destination.
/******************************************************************************/
U8 msAPI_OSD_CopyRegion(MSAPI_OSDRegion *src, MSAPI_OSDRegion *dst)
{
Gwin_FB_Attr fbAttr;
// ASSERT(src==NULL);
// ASSERT(dst==NULL);
BitbltInfo.BitbltCoordinate.v0_x = dst->x;
BitbltInfo.BitbltCoordinate.v0_y = dst->y;
BitbltInfo.BitbltCoordinate.v2_x = src->x;
BitbltInfo.BitbltCoordinate.v2_y = src->y;
BitbltInfo.BitbltCoordinate.height = dst->height;
BitbltInfo.BitbltCoordinate.width = dst->width;
BitbltInfo.BitBltTypeFlag = GEBitbltType_Normal;
BitbltInfo.src_height = src->height;
BitbltInfo.src_width = src->width;
MDrv_GOP_GWIN_GetFBInfo(src->fbID, &fbAttr);
BitbltInfo.src_fm = fbAttr.fbFmt;
PitBaseInfo.sb_base = fbAttr.addr;
PitBaseInfo.sb_pit = fbAttr.pitch;
MDrv_GOP_GWIN_GetFBInfo(dst->fbID, &fbAttr);
BitbltInfo.dst_fm = fbAttr.fbFmt;
PitBaseInfo.db_base = fbAttr.addr;
PitBaseInfo.db_pit = fbAttr.pitch;
MDrv_GE_BitBlt(&BitbltInfo, &PitBaseInfo);
return 0;
}
#ifdef MSAPI_OSD_AQUA
static U16 angular_increment;
static U16 normalised_angle;
static U16 x, y, last_y;
static U16 u16Temp1, u16Temp2, u16Temp3, u16Temp4, u16Temp5;
static U32 u32Loop;
static S32 s32OR,s32OG,s32OB;
static S32 s32DR,s32DG,s32DB;
static U16 u16GrdHight;
static GEPESettings PESet;
static LONG32_BYTE l32Clr;
/*****************************************************************************************************/
static void setGradientInfo_(U32 bc, U32 gc, U16 h)
{
s32OR = ((bc & 0x00ff0000)>>16);
s32OG = ((bc & 0x0000ff00)>>8);
s32OB = (bc & 0x000000ff);
s32DR = ((gc & 0x00ff0000)>>16) - s32OR;
s32DG = ((gc & 0x0000ff00)>>8) - s32OG;
s32DB = (gc & 0x000000ff) - s32OB;
u16GrdHight = h;
}
static U32 getColorByHight_(U16 u16H)
{
S32 s32R,s32G,s32B;
U32 u32Tmp;
s32R = (s32OR + ((s32DR*u16H)/u16GrdHight)) << 16;
s32G = (s32OG + ((s32DG*u16H)/u16GrdHight)) << 8;
s32B = (s32OB + ((s32DB*u16H)/u16GrdHight));
u32Tmp = 0xff000000 | s32R | s32G | s32B;
return u32Tmp;
}
/******************************************************************************/
/// API for Draw Gradient Round Block::
/// @param pclrBtn \b IN color
/******************************************************************************/
void msAPI_OSD_DrawGradientRoundBlock(OSDClrBtn *pclrBtn)
{
/* for Y gradient only */
if ( pclrBtn->radius > pclrBtn->width / 2 || pclrBtn->radius > pclrBtn->height / 2 )
{
return;
}
if(pclrBtn->u8Gradient == GECOLOR_FLAG_GRADIENT_X)
{
U16 sX,sY,eX,eY;
sX = pclrBtn->x;
sY = pclrBtn->y;
eX = pclrBtn->x + pclrBtn->width-1;
eY = pclrBtn->y + pclrBtn->height-1;
for ( y=sY;y<=eY ; y++ )
{
GELineRect.LineRectCoordinate.v0_x =sX;
GELineRect.LineRectCoordinate.v0_y = y;
GELineRect.LineRectCoordinate.direction = 0x0;
GELineRect.LineRectCoordinate.v1_x = eX;
GELineRect.LineRectCoordinate.v1_y = y;
GELineRect.Gradient_Color_Flag = GECOLOR_FLAG_GRADIENT_X;
GELineRect.ARGBClr.ForeGroundColor.u32Num
= (pclrBtn->b_clr&0xff00ff00) + ((pclrBtn->b_clr&0xff)<<16) +((pclrBtn->b_clr>>16)&0xff);
GELineRect.ARGBClr.GradientXColor.u32Num
= (pclrBtn->g_clr&0xff00ff00) + ((pclrBtn->g_clr&0xff)<<16) +((pclrBtn->g_clr>>16)&0xff);
MDrv_GE_RectDraw(&GELineRect);
}
}
else
{
setGradientInfo_(pclrBtn->b_clr,
pclrBtn->g_clr,
pclrBtn->height );
GELineRect.LineRectCoordinate.direction = 0x0;
GELineRect.LineRectCoordinate.v0_x = pclrBtn->x;
GELineRect.LineRectCoordinate.v1_x = pclrBtn->x + pclrBtn->width - 1;
GELineRect.LineRectCoordinate.v0_y = pclrBtn->y + pclrBtn->radius - 1;
GELineRect.LineRectCoordinate.v1_y = GELineRect.LineRectCoordinate.v0_y +pclrBtn->height - (2*pclrBtn->radius) + 1;
GELineRect.Gradient_Color_Flag = GECOLOR_FLAG_GRADIENT_Y;
GELineRect.ARGBClr.ForeGroundColor.u32Num = getColorByHight_(pclrBtn->radius);
GELineRect.ARGBClr.GradientYColor.u32Num = getColorByHight_(pclrBtn->height - pclrBtn->radius);
MDrv_GE_RectDraw(&GELineRect);
GELineRect.Gradient_Color_Flag = GECOLOR_FLAG_CONSTANT;
/* draw top and bottom round */
u16Temp1 = pclrBtn->x + pclrBtn->radius - 1;
u16Temp2 = GELineRect.LineRectCoordinate.v0_y;
u16Temp3 = pclrBtn->width - 2 * pclrBtn->radius + 2;
u16Temp4 = pclrBtn->y + pclrBtn->height - pclrBtn->radius;
last_y = 0;
u16Temp5 = (pclrBtn->radius*pclrBtn->radius)<<2;
for ( y=1; ; y++ )
{
u16Temp5 = u16Temp5 - (y<<3) - 4;
x = sqrt(u16Temp5);
x = (x - 1)>>1;
/* draw top round */
GELineRect.LineRectCoordinate.direction = 0x0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -