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

📄 gdi.c

📁 ct952 source code use for Digital Frame Photo
💻 C
📖 第 1 页 / 共 5 页
字号:
// Graphic Device Interface Module Source File// Brian, support GDI library//#define GDI_WITHOUT_OS// if define this, GDI is like a library, the difference will be// (1) Shoud not call OSD fucntions: OSD_AdjsutOSDPos// (2) Won't use COMUTL_RGB2YUV: use it own RGB2YUV function//#define GDI_STANDALONE_LIBRARY//#define GDI_NO_PRINTF#define SUPPORT_CT909S//#define TEST_1_BIT_FONT#include "winav.h"// Micky2.16p, for simple AP#include    "hsys.h"#ifdef AP_FRAMEWORK#define GDI_WITHOUT_OS#define GDI_STANDALONE_LIBRARY#define GDI_NO_PRINTF#endif#include "ctkav.h"#define GDI_MAIN_FILE// Micky2.16p, for simple AP/*#ifdef GDI_STANDALONE_LIBRARY#include "comdef.h"#else#include "winav.h"#endif*/#ifndef GDI_STANDALONE_LIBRARY#include "osd.h"#include "comutl.h"#endif#include "gdi.h"#include "fontindex.h" //++CoCo2.37P//Aron,2.77-909P, Port Damon's code to files to support Unicode DIR/FILE name & external subtitle.#ifdef SUPPORT_UNICODE_CODING#include "convchar.h"#endif#ifndef SYSTEM_8051#include <string.h>#endif#include "disp.h"#ifdef GDI_STANDALONE_LIBRARY// Micky2.16p, for simple AP//#include "utl_ap.h"DWORD COMUTL_RGB2YUV(DWORD dwRGB);#else#include "utl.h"#endif//#include "hal.h"// Brian1.02// define this to avoid the Display-During-Update case in FillRect// but the FillRect performance will be much worse.//#define GDI_CHECK_DISP_MEM_LINE//#define GDI_CHECK_DISP_MEM_LINE_BY_HW// just borrow from ComUtl#define RGB_R(rgb)              ((BYTE)((DWORD)rgb>>16))#define RGB_G(rgb)              ((BYTE)((DWORD)rgb>>8))#define RGB_B(rgb)              ((BYTE)rgb)#define MAKE_RGB(r, g, b)       ( ((DWORD)r<<16) | ((DWORD)g<<8) | (DWORD)b ) // LLY.102#ifdef GDI_STANDALONE_LIBRARYtypedef union tagUNIONDWORD{    BYTE    cS[4];    DWORD   dwVal;}   UDWORD;#endif#ifdef SUPPORT_CT909S#define GPU_4B_FONT_MODE        0x0L#define GPU_8B_FONT_MODE        0x1L#define GPU_2B_FONT_MODE        0x2L#define GPU_BMPCOPY                   0x4L#define GPU_BMPCOPY_HP             0x5L   // higher performance#define GPU_FILLRECTANGLE         0x6L#define GPU_FILLRECTANGLE_HP   0x7L // higher performance#else#define GPU_4B_FONT_MODE        0x0L#define GPU_8B_FONT_MODE        0x1L#define GPU_BMPCOPY         0x2L#define GPU_FILLRECTANGLE   0x3L#endif//move the definition into gdi.h/*#define GDI_OSD_8B_MODE         (0)#define GDI_OSD_4B_MODE         (1)#define GDI_OSD_2B_MODE         (2)*/#define GPU_FONT128         0x0L#define GPU_FONT256         0x1L#define GPU_FONT512         0x2L#define GPU_FONT1024        0x3L#define GPU_SRC_INCH        0x0L#define GPU_SRC_DECH        0x1L#define GPU_SRC_INCV        0x0L#define GPU_SRC_DECV        0x2L#define GPU_DST_INCH        0x0L#define GPU_DST_DECH        0x4L#define GPU_DST_INCV        0x0L#define GPU_DST_DECV        0x8Ltypedef struct tagTEXT_COLOR{    BYTE  bShadowColor_2;    BYTE  bShadowColor_1;    BYTE  bTextFgColor;    BYTE  bTextBgColor;}TEXT_COLOR, *PTEXT_COLOR;// #define NO_GDI#ifndef NO_GDI#define SETUP_ICON_USE_ONE_BMP#define SPEAKER_HIGHLIGHT_WITH_RECTANGLEDWORD Palette_0[]=    // Palette 0 data, it will be put at palette entry 254, 255{                          // the purpose is to make sure palette entry 255 is transparency1,                          // one DWORD entry,0x00000000                  // bit 19 indicate Mix_Enable};GDI_REGION_INFO  __RegionList[NUMBER_OF_REGION] =    // declare the region list{                    {   // region ID 0                        GDI_REGION_WIDTH, GDI_REGION_HEIGHT,        // width, height#ifdef USE_MINI_OSD_REGION                        GDI_OSD_4B_MODE,              // 0: 256 colors, 1: 16 colors, 2: 4 colors#else                        GDI_OSD_8B_MODE,              // 0: 256 colors, 1: 16 colors, 2: 4 colors#endif                        DS_OSDFRAME_ST,    //OSD region DRAM address                    },                    {   // region ID 1, for screen saver                        120, 64,                       // width, height                        GDI_OSD_8B_MODE,  // 0: 256 colors, 1: 16 colors, 2: 4 colors                        DS_OSDFRAME_ST,    //OSD region DRAM address                    }                     ,                   {   // region ID 2, for SP OSD                        GDI_SP_OSD_REGION_WIDTH, GDI_SP_OSD_REGION_HEIGHT,                       // width, height                        GDI_OSD_2B_MODE,  // 0: 256 colors, 1: 16 colors, 2: 4 colors                        DS_SP_OSD_ST,    //OSD region DRAM address                    }                     ,				   //*** this region is for STB OSD Offscreen buffer only, DVD application doesn't have this region                   {   // region ID 3, for backup STB OSD                        320, 200,                       // width, height                        GDI_OSD_8B_MODE,  // 0: 256 colors, 1: 16 colors, 2: 4 colors                       	0x40400000,    //DVB use this region. Will configrue it in STB_mode.                    }#ifdef SUPPORT_RADIO_RDS					                     ,                   {   // region ID 4, DMP1.21, for radio RDS OSD                        616, 70,                       // width, height                        GDI_OSD_8B_MODE,  // 0: 256 colors, 1: 16 colors, 2: 4 colors                        DS_RADIO_BMPDATA_ST,    //OSD region DRAM address                    }#endif};//Brian, support GDI libraryGDI_PALETTE_INFO    __PaletteInfo_Transparent = {0, PAL_ADDR, Palette_0};BYTE    _bGDIInit=0;BYTE    _bGDITemp;WORD    _wGDITemp;DWORD   _dwGDITemp;// Internal to GDI modulePARM_RECT _GDIRect;GDI_PARAMETER _GDIParm0;DWORD * _pdwGDIPTR;    // a point to DWORD unitvoid _gdi_DrawString(BYTE bRegionId, PARM_DRAW_STRING *pParm, WORD *pwString, BYTE b2BitFont, BYTE bMultipleH);void _gdi_CheckCmdComplete(void);void _gdi_ResetVPU(void);void _gdi_FillRect(BYTE bRegionId, PARM_RECT *pParm);#endif //NO_GDIBYTE    __bCurrentRegionId; // the cuurent region ID, which is referenced by many functionsGDI_PARAMETER __GDIParm; // Global for all// Brian1.00, this global is used as a "parameter" for Macro.// Currently it is only used by GDI_OUTPUT_TEXT// Brian1.08, use global variable to replace ColorMode field of region//BYTE __bColorMode; //--Brian1.15, reduce code size.#ifdef NO_GDIBYTE code GDIDummy[]={0};#endif//extern BYTE __bOSDDisabled;WORD _wFontNumberInTable;BYTE _bFontWidth; // The font height selected in the font tool.// If the font height is selected to 26 and the bimmap H is 16, it will be appended 0 to 26 heightBYTE _bFontHeightInTable;DWORD _dwGDIPalette[256];#ifndef GDI_WITHOUT_OSMUTEX_T     __mutexGDIIdle;#endif// Brian0.1, these two should be variable//DWORD     DS_OSD_FRAME=(0x401F6ED0L);   // 620x420x8DWORD     __dwGDIFontTableBase= OSD_FONT_TABLE_BASE_ADDRESS; //0x40400000L; //256 font //(0x401EEED0L);   // 128 Font#ifdef TEST909S#define GDI_NUM_OF_FONT GPU_FONT512 //GPU_FONT256#else#define GDI_NUM_OF_FONT GPU_FONT512#endifBYTE _aArc_13[13]={0,0,0,0,1,1,2,2,3,4,5,7,9};BYTE _aArc_15[15]={0,0,0,0,1,1,1,2,3,3,4,5,7,8,11};BYTE _aArc_17[17]={0,0,0,0,1,1,1,2,2,3,4,4,5,7,8,10,13};BYTE _aArc_19[19]={0,0,0,0,1,1,1,2,2,3,3,4,5,6,7,8,10,12,15};BYTE _aArc_21[21]={0,0,0,0,0,1,1,1,2,2,3,3,4,5,6,7,8,9,11,13,16};BYTE _aArc_23[23]={0,0,0,0,0,1,1,1,2,2,3,3,4,4,5,6,7,8,9,11,13,15,18};BYTE _aArc_25[25]={0,0,0,0,0,1,1,1,1,2,2,3,3,4,5,5,6,7,8,9,11,12,14,16,20};BYTE *_ArcOffsetPtr;DWORD **__pBMPAryptr; // Support GDI library#ifdef TEST909S#ifdef GDI_CHECK_DISP_MEM_LINE#undef GDI_CHECK_DISP_MEM_LINE#endif#endif#ifdef SUPPORT_CT909SDWORD   _dwGPUFontWidth, _dwGPUFontCapacity;#endif//  *********************************************************************//  Function    :   GDI_Initial//  Description :   This function initializes the GDI environment//  Arguments   :   None//  Return      :   None//  Side Effect ://  Note        :   It will do the following task://                       Load transparent palette (assign entry 255 as transparent color)//                       Set palette entries used by GDI module//                       Initialize region 0//                       Clear region 0//                       Set font table address and configurate font atble//  *********************************************************************void GDI_Initial(void){#ifndef NO_GDI#ifndef GDI_WITHOUT_OS    OS_InitMutex(&__mutexGDIIdle);#endif    //Brian,  support GDI library    GDI_LoadPalette(&__PaletteInfo_Transparent);    GDI_SetGDIPalEntry(); //CoCo, Initialize palette at the beginning.    GDI_InitialRegion(0);#ifndef GDI_STANDALONE_LIBRARY    // if GDI is going to be a library, it should not call OSD module functions, because there may be no OSD module    // so the AP need to adjust OSD position accroding TV mode and Scan mode.    OSD_AdjustOSDPos();#endif    GDI_ClearRegion(0);	// Set font table address#ifdef SUPPORT_CT909S   REG_GPU_FONT_ADDR = __dwGDIFontTableBase; // just assign the byte address, but need to be 4-byte alignment   //GDI_SetFontTableSize(2, 64); // default set as 32x32, 2-bit font#ifdef TEST_1_BIT_FONT   GDI_SetFontTableSize(1, 26); // default set as 32x26, 1-bit font#else   GDI_SetFontTableSize(2, 52); // default set as 32x26, 2-bit font#endif#else    REG_GPU_FONT_ADDR = __dwGDIFontTableBase>>3;#endif    _bGDIInit = 1;#endif //#ifndef NO_GDI}#ifdef SUPPORT_CT909Svoid GDI_SetFontTableSize(BYTE bFontWidth, WORD wFontCapacity){    // Font width and capacity will be set to REG_GPU_FONT_CONFIG in DrawString    _dwGPUFontWidth = bFontWidth;           //how many DW of 1 horizontal font line used    _dwGPUFontCapacity = wFontCapacity;  // how many DW of 1 font used}void GDI_SetFontTableAddress(DWORD dwAddress){    __dwGDIFontTableBase = dwAddress; // just assign the byte address, but need to be 4-byte alignment}#endifDWORD GDI_GetFontTableAddress(VOID){    return __dwGDIFontTableBase;}void GDI_SetFontWidth(BYTE bFontWidth){    _bFontWidth = bFontWidth;    //Currently, this function is for Chinese EPG. }void GDI_SetFontHeightInTable(BYTE bFontHeight){    _bFontHeightInTable = bFontHeight;}void GDI_SetFontNumberInTable(WORD wFontNumber){    _wFontNumberInTable = wFontNumber;}void GDI_ConfigRegionInfo(BYTE bRegionId, GDI_REGION_INFO *regionInfo){    if (bRegionId >= NUMBER_OF_REGION)        return;    __RegionList[bRegionId].wWidth = regionInfo->wWidth;    __RegionList[bRegionId].wHeight = regionInfo->wHeight;    __RegionList[bRegionId].bColorMode= regionInfo->bColorMode;    __RegionList[bRegionId].dwTAddr= regionInfo->dwTAddr;}void GDI_ConfigRegionAddress(BYTE bRegionId, DWORD dwTAddr){    if (bRegionId >= NUMBER_OF_REGION)        return;    __RegionList[bRegionId].dwTAddr= dwTAddr;}//  *********************************************************************//  Function    :   GDI_SetGDIPalEntry//  Description :   This function sets the palette entries used by GDI module//  Arguments   :   None//  Return      :   None//  Side Effect ://  *********************************************************************void GDI_SetGDIPalEntry(void){#ifndef NO_GDI    //Brian0.86#ifdef GDI_4_BIT_OSD    // load transparent color to ebtry 15    GDI_LoadPalette(3);    GDI_ChangePALEntry(GDI_ENTRY_4B_COLOR_BRIGHT, GDI_VALUE_4B_COLOR_BRIGHT, FALSE);    GDI_ChangePALEntry(GDI_ENTRY_4B_COLOR_DARK, GDI_VALUE_4B_COLOR_DARK, FALSE);    GDI_ChangePALEntry(GDI_ENTRY_4B_COLOR_CENTER, GDI_VALUE_4B_COLOR_CENTER, FALSE);    GDI_ChangePALEntry(GDI_ENTRY_4B_COLOR_BAR_BG, GDI_VALUE_4B_COLOR_BAR_BG, FALSE);    GDI_ChangePALEntry(GDI_ENTRY_4B_COLOR_GENERAL_BG_BLACK, GDI_VALUE_4B_COLOR_GENERAL_BG_BLACK, TRUE);    GDI_ChangePALEntry(GDI_ENTRY_4B_COLOR_GENERAL_BG_BLUE, GDI_VALUE_4B_COLOR_GENERAL_BG_BLUE, TRUE);    GDI_ChangePALEntry(GDI_ENTRY_4B_COLOR_GREEN, GDI_VALUE_4B_COLOR_GREEN, FALSE);    GDI_ChangePALEntry(GDI_ENTRY_4B_COLOR_YELLOW, GDI_VALUE_4B_COLOR_YELLOW, FALSE);    GDI_ChangePALEntry(GDI_ENTRY_4B_COLOR_ORANGE, GDI_VALUE_4B_COLOR_ORANGE, FALSE);    GDI_ChangePALEntry(GDI_ENTRY_4B_COLOR_BLACK, GDI_VALUE_4B_COLOR_BLACK, FALSE);    GDI_ChangePALEntry(GDI_ENTRY_4B_COLOR_TEXT_DISABLED, GDI_VALUE_4B_COLOR_TEXT_DISABLED, FALSE);    GDI_ChangePALEntry(GDI_ENTRY_4B_COLOR_RED, GDI_VALUE_4B_COLOR_RED, FALSE);    GDI_ChangePALEntry(GDI_ENTRY_4B_COLOR_ORANGE_TRANSPARENT, GDI_VALUE_4B_COLOR_ORANGE_TRANSPARENT, TRUE);    GDI_ChangePALEntry(GDI_ENTRY_4B_COLOR_BUTTON_NORMAL, GDI_VALUE_4B_COLOR_BUTTON_NORMAL, FALSE);#endif    //GDI_ChangePALEntry(GDI_ENTRY_BUTTON_COLOR_NORMAL, GDI_VALUE_BUTTON_COLOR_NORMAL, FALSE);    //GDI_ChangePALEntry(GDI_ENTRY_BUTTON_COLOR_HIGHLIGHT, GDI_VALUE_BUTTON_COLOR_HIGHLIGHT, FALSE);    //GDI_ChangePALEntry(GDI_ENTRY_BUTTON_COLOR_DISABLE, GDI_VALUE_BUTTON_COLOR_DISABLE, FALSE);#endif

⌨️ 快捷键说明

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