📄 gdi.c
字号:
rect.rect.wTop = rect.rect.wBottom = pParm->rect.wTop+i; rect.rect.wLeft = pParm->rect.wLeft + pbArcStart[bArcStart-i-1]; rect.rect.wRight = pParm->rect.wLeft + dwRightArcStart + bArcStart-1-pbArcStart[bArcStart-i-1]; GDI_FillRect(bRegionId, &rect); } // printf ("GDI_DrawRoundRect\n"); for (i= bArcStart-bArcEnd ; i<bArcStart; i++) { //asm volatile ( "" : : : "memory" ); rect.rect.wTop = rect.rect.wBottom = pParm->rect.wTop+i; rect.rect.wLeft = pParm->rect.wLeft + pbArcStart[bArcStart-i-1]; rect.rect.wRight = pParm->rect.wLeft + dwGap + pbArcEnd[bArcEnd-i-1 + dwGap] - 1; GDI_FillRect(bRegionId, &rect); //printf("x1 = %d, y1 = %d, x2 = %d, y2 = %d\n", rect.rect.wLeft, rect.rect.wTop, rect.rect.wRight, rect.rect.wBottom); //asm volatile ( "" : : : "memory" ); rect.rect.wLeft = pParm->rect.wLeft + dwRightArcStart + bArcEnd-1-pbArcEnd[bArcEnd-i-1 + dwGap] + 1; rect.rect.wRight = pParm->rect.wLeft + dwRightArcStart + bArcStart-1-pbArcStart[bArcStart-i-1]; GDI_FillRect(bRegionId, &rect); // printf("x1 = %d, y1 = %d, x2 = %d, y2 = %d\n", rect.rect.wLeft, rect.rect.wTop, rect.rect.wRight, rect.rect.wBottom); } // fill left vertical rect rect.rect.wLeft = pParm->rect.wLeft; rect.rect.wTop = pParm->rect.wTop + bArcStart; rect.rect.wRight = pParm->rect.wLeft + bArcStart - bArcEnd-1; rect.rect.wBottom = pParm->rect.wBottom - bArcStart; GDI_FillRect(bRegionId, &rect); // fill right vertical rect rect.rect.wLeft = pParm->rect.wRight - (bArcStart - bArcEnd)+1; rect.rect.wTop = pParm->rect.wTop + bArcStart; rect.rect.wRight = pParm->rect.wRight; rect.rect.wBottom = pParm->rect.wBottom - bArcStart; GDI_FillRect(bRegionId, &rect); for (i= 0 ; i<bArcEnd; i++) { rect.rect.wTop = rect.rect.wBottom = pParm->rect.wBottom - bArcStart + 1 + i; rect.rect.wLeft = pParm->rect.wLeft + pbArcStart[i]; rect.rect.wRight = pParm->rect.wLeft + dwGap + pbArcEnd[i]-1; GDI_FillRect(bRegionId, &rect); rect.rect.wLeft = pParm->rect.wLeft + dwRightArcStart + bArcEnd -1-pbArcEnd[i] + 1; rect.rect.wRight = pParm->rect.wLeft + dwRightArcStart + bArcStart -1-pbArcStart[i]; GDI_FillRect(bRegionId, &rect); } for (i= bArcEnd; i<bArcStart; i++) { rect.rect.wTop = rect.rect.wBottom = pParm->rect.wBottom - bArcStart + 1 + i; rect.rect.wLeft = pParm->rect.wLeft + pbArcStart[i]; rect.rect.wRight = pParm->rect.wLeft + dwRightArcStart + bArcStart-1-pbArcStart[i]; GDI_FillRect(bRegionId, &rect); }}// *********************************************************************// Function : GDI_LoadBMP// Description : This function load the BMP data from code array into BMP OSD region// : the region is decided by the __bCurrentRegionId// Arguments : pParm: point to a Bitmap structure// The Bitmap data is generated by bmp2data tool// Return : None// Side Effect :// ** Note ** : In order to speed up the load process and reduce the complexity// : We have made the following assumption, and we must follow it.// : [1] bitmap width is 4-pixel alignment// : [2] bitmap height is even// : [3] The destination X-coordinate must be 4-pixel alignment// : [4] The destination Y-coordinate must be even// *********************************************************************// Brian, support GDI libraryvoid GDI_LoadBMP(DWORD **aPtr, DWORD dwMaxNum){ // Brian2.11, copy BMP directly from BMPArray, this function is not needed anymore /*#ifndef NO_GDI DWORD i, j, dwSize; DWORD *dwPtr; __pBMPAryptr = aPtr; // keep the last BMP array dwPtr = (DWORD *)GDI_BMP_BASE_ADDRESS; for (i=0; i<dwMaxNum; i++) { dwSize = (aPtr[i])[0]; for (j=0; j<dwSize; j++) { (*(volatile DWORD*)(dwPtr++) )= (aPtr[i])[j+4]; } }#endif //#ifndef NO_GDI*/}// *********************************************************************// Function : GDI_DrawBitmapBySW// Description : This function copies the bmp to the specified location// *** the bmp source is put in a continuous dram address space// Arguments : pParm points to the PARM_DRAW_BITMAP// Return : none// Side Effect :// Note :// *********************************************************************//*** Only support 8/4/2-bit OSD mode//*** x position and width of BMP must be DWORD alignment//*** for example://*** 8-bit mode: x pos must be 4n, BMP width must be 4n//*** 4-bit mode: x pos must be 8n, BMP width must be 8n//*** 16-bit mode: x pos must be 16n, BMP width must be 16nvoid GDI_DrawBitmapBySW(PARM_DRAW_BITMAP *pParm, const DWORD ** BMPAryptr){ DWORD i, j, dwStartAddress, dwByteOffset, dwAddressCount; // the byte address DWORD dwRegionWidthInByte; BYTE bRegionId; DWORD dwBMPIndex; WORD wOSDSrcWidth, wOSDSrcHeight, wX, wY; DWORD *pdwPtr, *pdwBMPPtr; DWORD dwColorMode, dwAlignment; bRegionId = pParm->bDestRegion; dwColorMode = __RegionList[bRegionId].bColorMode; dwBMPIndex = pParm->bBitmapID; dwAlignment = 4 << (dwColorMode); wX = ((pParm->wDestX)/dwAlignment) * dwAlignment; // DWORD alignment for 8/4/2-bit case. wY = pParm->wDestY; wOSDSrcWidth = (BMPAryptr[dwBMPIndex])[2]; // get the width of BMP wOSDSrcHeight = (BMPAryptr[dwBMPIndex])[3]; // get the height of BMP dwRegionWidthInByte = __RegionList[bRegionId].wWidth >> dwColorMode; dwByteOffset = ((DWORD)wY*__RegionList[bRegionId].wWidth + wX) >> dwColorMode; dwStartAddress = __RegionList[bRegionId].dwTAddr + dwByteOffset; pdwBMPPtr = (DWORD *) (BMPAryptr[dwBMPIndex]+4); for (i = 0 ; i<wOSDSrcHeight; i++) { dwAddressCount = dwStartAddress + dwRegionWidthInByte*i; pdwPtr = (DWORD *) dwAddressCount; for (j = 0 ; j<wOSDSrcWidth/dwAlignment; j++) // write one DWORD each time { *pdwPtr++ = *pdwBMPPtr++; } }}//Aron2.55, support drawing of compressed bitmap data.// *********************************************************************// Function : GDI_DrawZipBitmap// Description : This function decompressed the zipped Bitmap and call // GDI_DrawBitmap to draw it// Arguments : pParm points to the PARM_DRAW_BITMAP// point array of zipped bitmap data// pbDest decompressing destination// dwZIPWM unzipped window buffer// Return : none// Side Effect :// Note :// *********************************************************************void GDI_DrawZipBitmap(PARM_DRAW_BITMAP *pParm, const BYTE **BMPAry, PBYTE pbDest, DWORD dwZIPWM){ PARM_DRAW_BITMAP parm; DWORD *BMPArray[1]; UTL_Decompress((PBYTE)BMPAry[pParm->bBitmapID], (PBYTE)pbDest, (PBYTE)dwZIPWM); parm = *pParm; parm.bBitmapID = 0; BMPArray[0] = (DWORD*)pbDest; GDI_DrawBitmapBySW(&parm, (const DWORD **) BMPArray);}// *********************************************************************// Function : GDI_DrawBitmap// Description : This function copies the bmp to the specified location// *** the bmp source is put in a continuous dram address space// Arguments : pParm points to the PARM_DRAW_BITMAP// Return : none// Side Effect :// Note :// *********************************************************************//void GDI_DrawBitmap(PARM_DRAW_BITMAP *pParm)// Brian, support GDI libraryvoid GDI_DrawBitmap(PARM_DRAW_BITMAP *pParm, DWORD ** BMPAryptr){#ifndef NO_GDI DWORD dwSrcAddr, dwDstAddr; WORD wOp_width, wOp_height; WORD wSrcAg_width, wSrcAg_offset; WORD wDstAg_width, wDstAg_offset; BYTE bHVInc; WORD wOSDSrcWidth, wOSDSrcHeight, wOSDDstWidth, wOSDDstHeight; DWORD dwOSDSrcBase, dwOSDDstBase; BYTE b4bitMode; BYTE bColorKeyEnable = 0; //DWORD ** BMPAryptr; DWORD dwBMPIndex; if (BMPAryptr == 0) { // if call doesn't pass the BMP array point, means use the last (current) BMP array BMPAryptr = __pBMPAryptr; } dwBMPIndex = pParm->bBitmapID; // Brian2.11, copy BMP directly from BMPArray dwOSDSrcBase = (DWORD)(BMPAryptr[dwBMPIndex]+4); /* dwOSDSrcBase = GDI_BMP_BASE_ADDRESS; for (dwSrcAddr=0; dwSrcAddr<dwBMPIndex; dwSrcAddr++) { //dwOSDSrcBase += (_aGDIBMPArray[dwSrcAddr])[0]<<2; // get the size of BMP dwOSDSrcBase += (BMPAryptr[dwSrcAddr])[0]<<2; // get the size of BMP } */ // Brian2.11, use dwBMPIndex wOSDSrcWidth = (BMPAryptr[dwBMPIndex])[2]; // get the width of BMP wOSDSrcHeight = (BMPAryptr[dwBMPIndex])[3]; // get the height of BMP b4bitMode = __RegionList[pParm->bDestRegion].bColorMode; wOSDDstWidth = __RegionList[pParm->bDestRegion].wWidth; wOSDDstHeight = __RegionList[pParm->bDestRegion].wHeight; dwOSDDstBase = __RegionList[pParm->bDestRegion].dwTAddr; //if ((pParm->SrcRect.wLeft > wOSDSrcWidth) || (pParm->wDestX > wOSDDstWidth)) //{ // return ; //}#ifndef GDI_WITHOUT_OS OS_LockMutex(&__mutexGDIIdle);#endif _gdi_ResetVPU(); // if (pParm->SrcRect.wRight >= wOSDSrcWidth) // { // pParm->SrcRect.wRight = wOSDSrcWidth-1; // } dwSrcAddr = dwOSDSrcBase; // + ((pParm->SrcRect.wTop*wOSDSrcWidth + pParm->SrcRect.wLeft)>>b4bitMode); dwDstAddr = dwOSDDstBase + ((pParm->wDestY*wOSDDstWidth + pParm->wDestX)>>b4bitMode);#ifdef SUPPORT_CT909S wOp_width = (wOSDSrcWidth & 0x3ff)>>b4bitMode; // use 10 bit wOp_height = (wOSDSrcHeight & 0x3ff); // use 10 bit wSrcAg_width = (wOp_width + (dwSrcAddr & 0x3) + 3) >> 2; wSrcAg_offset = (((wOSDSrcWidth>>b4bitMode) + 3)>>2) - wSrcAg_width + 1; wDstAg_width = (wOp_width + (dwDstAddr & 0x3) + 3) >> 2; wDstAg_offset = (((wOSDDstWidth>>b4bitMode) + 3)>>2) - wDstAg_width + 1;#else wOp_width = (wOSDSrcWidth & 0xfff)>>b4bitMode; // use 12 bit wOp_height = (wOSDSrcHeight & 0x7ff); // use 11 bit wSrcAg_width = (wOp_width + (dwSrcAddr & 0x7) + 7) >> 3; wSrcAg_offset = (((wOSDSrcWidth>>b4bitMode) + 7)>>3) - wSrcAg_width + 1; wDstAg_width = (wOp_width + (dwDstAddr & 0x7) + 7) >> 3; wDstAg_offset = (((wOSDDstWidth>>b4bitMode) + 7)>>3) - wDstAg_width + 1;#endif // Just use case 1's H V copy direction // Case 1 bHVInc = (GPU_SRC_INCH | GPU_SRC_INCV | GPU_DST_INCH | GPU_DST_INCV); REG_GPU_OP_SIZE = (wOp_height << 16) + wOp_width;#ifdef SUPPORT_CT909S REG_GPU_AG_OFF = (wDstAg_offset << 16) + (wSrcAg_offset);#else REG_GPU_AG_OFF = (((wDstAg_width << 8) + wDstAg_offset) << 16) + ((wSrcAg_width << 8) + wSrcAg_offset);#endif REG_GPU_SRC_ADDR = dwSrcAddr; REG_GPU_DEST_ADDR = dwDstAddr; //REG_GPU_CTL1 = __bTransparentColor << 16; // Color Key is not enabled in this function asm volatile ( "" : : : "memory" ); //HAL_REORDER_BARRIER();#ifdef SUPPORT_CT909S REG_GPU_CTL0 = GPU_INT_EN | GPU_OP | (4 << 16) | (4 << 20) | (bHVInc << 12) | (bColorKeyEnable << 8) | (GPU_BMPCOPY << 2) | GPU_START;#else REG_GPU_CTL0 = GPU_INT_EN | GPU_REQ_EN | GPU_W_REL_EN | (0x10 << 16) | (bHVInc << 12) | (bColorKeyEnable << 8) | (GPU_BMPCOPY << 2) | GPU_START;#endif //while (REG_GPU_CTL0 & GPU_STATUS) { } _gdi_CheckCmdComplete();#ifndef GDI_WITHOUT_OS OS_UnlockMutex(&__mutexGDIIdle);#endif#endif // #ifndef NO_GDI}// *********************************************************************// Function : GDI_BitmapCopy// Description : This function copies the content of the region from one place to another place// the region width & height of Source and Destination must be the same// Arguments : pParm points to the PARM_BITMAP_COPY// Return : none// Side Effect :// Note : This function doesn't handle horizontal shift copy// *********************************************************************void GDI_BitmapCopy(PARM_BITMAP_COPY *pParm){#ifndef NO_GDI DWORD dwSrcAddr, dwDstAddr; WORD wOp_width, wOp_height; WORD wSrcAg_width, wSrcAg_offset; WORD wDstAg_width, wDstAg_offset; BYTE bHVInc; WORD wOSDSrcWidth, wOSDSrcHeight, wOSDDstWidth, wOSDDstHeight; DWORD dwOSDSrcBase, dwOSDDstBase; BYTE b4bitMode; BYTE bColorKeyEnable = 0; wOSDSrcWidth = __RegionList[pParm->bSrcRegion].wWidth; wOSDSrcHeight = __RegionList[pParm->bSrcRegion].wHeight; dwOSDSrcBase = __RegionList[pParm->bSrcRegion].dwTAddr; b4bitMode = __RegionList[pParm->bSrcRegion].bColorMode; wOSDDstWidth = __RegionList[pParm->bDestRegion].wWidth; wOSDDstHeight = __RegionList[pParm->bDestRegion].wHeight; dwOSDDstBase = __RegionList[pParm->bDestRegion].dwTAddr; if ((pParm->SrcRect.wLeft > wOSDSrcWidth) || (pParm->wDestX > wOSDDstWidth)) { return ; }#ifndef GDI_WITHOUT_OS OS_LockMutex(&__mutexGDIIdle);#endif _gdi_ResetVPU(); if (pParm->SrcRect.wRight >= wOSDSrcWidth) { pParm->SrcRect.wRight = wOSDSrcWidth-1; } dwSrcAddr = dwOSDSrcBase + ((pParm->SrcRect.wTop*wOSDSrcWidth + pParm->SrcRect.wLeft)>>b4bitMode); dwDstAddr = dwOSDDstBase + ((pParm->wDestY*wOSDDstWidth + pParm->wDestX)>>b4bitMode);#ifdef SUPPORT_CT909S wOp_width = ((pParm->SrcRect.wRight - pParm->SrcRect.wLeft + 1) & 0x3ff)>>b4bitMode; // use 10 bit wOp_height = ((pParm->SrcRect.wBottom - pParm->SrcRect.wTop + 1) &0x3ff); // use 10 bit wSrcAg_width = (wOp_width + (dwSrcAddr & 0x3) + 3) >> 2; wSrcAg_offset = (((wOSDSrcWidth>>b4bitMode) + 3)>>2) - wSrcAg_width + 1; wDstAg_width = (wOp_width + (dwDstAddr & 0x3) + 3) >> 2; wDstAg_offset = (((wOSDDstWidth>>b4bitMode) + 3)>>2) - wDstAg_width + 1;#else wOp_width = ((pParm->SrcRect.wRight - pParm->SrcRect.wLeft + 1) & 0xfff)>>b4bitMode; // use 12 bit wOp_height = ((pParm->SrcRect.wBottom - pParm->SrcRect.wTop + 1) &0x7ff); // use 11 bit wSrcAg_width = (wOp_width + (dwSrcAddr & 0x7) + 7) >> 3; wSrcAg_offset = (((wOSDSrcWidth>>b4bitMode) + 7)>>3) - wSrcAg_width + 1; wDstAg_width = (wOp_width + (dwDstAddr & 0x7) + 7) >> 3; wDstAg_offset = (((wOSDDstWidth>>b4bitMode) + 7)>>3) - wDstAg_width + 1;#endif if ((pParm->SrcRect.wTop == pParm->wDestY) && (pParm->SrcRect.wLeft < pParm->wDestX) && (pParm->SrcRect.wRight > pParm->wDestX)) { //printf("\n HW Limitation: Case 2/3"); //printf("\nCase 2.."); bHVInc = (GPU_SRC_DECH | GPU_SRC_INCV | GPU_DST_DECH | GPU_DST_INCV); dwSrcAddr += wOp_width -1; dwDstAddr += wOp_width -1; //wSrcAg_offset = (((__wOSDFrame_HDS>>_bOsd_4b_mode) + 7)>>3) + wSrcAg_width - 1; //wDstAg_offset = (((__wOSDFrame_HDS>>_bOsd_4b_mode) + 7)>>3) + wDstAg_width - 1; wSrcAg_offset += (wSrcAg_width - 1)<<1; wDstAg_offset += (wDstAg_width - 1)<<1; /* // Case 3 printf("\nCase 3.."); bHVInc = (GPU_SRC_DECH | GPU_SRC_DECV | GPU_DST_DECH | GPU_DST_DECV); dwSrcAddr += ((wOp_height - 1)*(
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -