?? g2d_test.c
字號:
UART_Getc();
}
G2D_InitSetting(uG2dFbAddr, eBpp, uG2dWidth, uG2dHeight, 0, 0, uG2dWidth, uG2dHeight);
G2D_ClearFrameEcolor(G2D_YELLOW, 0, 0);
// Screen to Screen Test
printf("Screen to Screen Color Expansion with ROP, press any key to continue!\n");
G2D_SetColorExpansionMethod(SCREEN2SCREEN);
G2D_SetFontType(FONT8BY8, &uFontWidth, &uFontHeight);
uTextDrawingFbAddr=(uG2dFbAddr&0xff000000)+0x800000;
G2D_FillMemoryForTextDrawing(FONT8BY8, uTextDrawingFbAddr);
G2D_SetFontAddr(uTextDrawingFbAddr);
G2D_Set3rdOperand(G2D_OPERAND3_PAT);
UART_Getc();
for(k=0; k<=8; k++) {
G2D_SetRopEtype((G2D_ROP_TYPE)(k));
switch((G2D_ROP_TYPE)k){
case ROP_DST_ONLY:
printf("Destination Only, press any key to continue\n");
break;
case ROP_SRC_ONLY:
printf("Source Only, press any key to continue\n");
break;
case ROP_3RD_OPRND_ONLY:
printf("Third Operand Only, press any key to continue\n");
break;
case ROP_SRC_AND_DST:
printf("Source AND Destination, press any key to continue\n");
break;
case ROP_SRC_AND_3RD_OPRND:
printf("Source AND Third Operand, press any key to continue\n");
break;
case ROP_SRC_OR_DST:
printf("Source OR Destination, press any key to continue\n");
break;
case ROP_SRC_OR_3RD_OPRND:
printf("Source OR Third Operand, press any key to continue\n");
break;
case ROP_DST_OR_3RD:
printf("Destination OR Third Operand, press any key to continue\n");
break;
case ROP_SRC_XOR_3RD_OPRND:
printf("Source XOR Third Operand, press any key to continue\n");
break;
default:
break;
}
G2D_SetFontColor(G2D_RED, G2D_BLACK, bIsTransparent);
G2D_Printf(5, 5, "[2D]Screen to Screen Color Expansion");
G2D_SetFontColor(G2D_GREEN, G2D_BLACK, bIsTransparent);
G2D_Printf(5, uG2dHeight*1/4+5, "[2D]Screen to Screen Color Expansion");
G2D_SetFontColor(G2D_BLUE, G2D_BLACK, bIsTransparent);
G2D_Printf(5, uG2dHeight*2/4+5, "[2D]Screen to Screen Color Expansion");
G2D_SetFontColor(G2D_WHITE, G2D_BLACK, bIsTransparent);
G2D_Printf(5, uG2dHeight*3/4+5, "[2D]Screen to Screen Color Expansion");
UART_Getc();
}
G2D_InterruptDisable();
INTC_Disable(NUM_2D);
G2D_InitSetting(uG2dFbAddr, eBpp, uG2dWidth, uG2dHeight, 0, 0, uG2dWidth, uG2dHeight);
}
void TestColorExpansionWithRotation(void)
{
u32 i,j;
u32 uG2dFbAddr, uG2dWidth, uG2dHeight;
u32 uFontWidth, uFontHeight;
u32 uTextDrawingFbAddr;
CSPACE eBpp;
bool bIsTransparent=1;
INTC_SetVectAddr(NUM_2D, Isr_G2d);
INTC_Enable(NUM_2D);
G2D_InterruptEnable();
G2D_GetFrmSz(&uG2dWidth, &uG2dHeight);
G2D_GetFbAddr(&uG2dFbAddr);
G2D_GetBppMode(&eBpp);
printf("Width=%d, Height=%d, Framebuffer:0x%x\n", uG2dWidth, uG2dHeight, uG2dFbAddr);
// Host to Screen Test
printf("Simple Host to Screen Color Expansion, press any key to continue");
G2D_ClearFrameEcolor(G2D_BLACK, 0, 0);
for(j=0; j<uG2dHeight; j++)
for(i=0; i<uG2dWidth; i++) {
if(i==(uG2dWidth/2-1)) G2D_PutPixelEcolor(i, j, G2D_MAGENTA);
if(j==(uG2dHeight/2-1)) G2D_PutPixelEcolor(i, j, G2D_MAGENTA);
}
UART_Getc();
G2D_SetColorExpansionMethod(HOST2SCREEN);
G2D_SetFontType(FONT8BY8, &uFontWidth, &uFontHeight);
G2D_SetRotationMode(G2D_ROTATION_0_DEG_BIT);
G2D_SetFontColor(G2D_WHITE, G2D_BLACK, bIsTransparent);
G2D_Printf(uG2dWidth/2-1, uG2dHeight/2-1, "ROTATION");
printf("8x8 font is dispayed using color expansion, press any key to continue.\n");
UART_Getc();
G2D_SetRotationMode(G2D_ROTATION_90_DEG_BIT);
G2D_SetRotationOrg((u16)(uG2dWidth/2-1), (u16)(uG2dHeight/2-1));
G2D_SetFontColor(G2D_RED, G2D_BLACK, bIsTransparent);
G2D_Printf(uG2dWidth/2-1, uG2dHeight/2-1, "ROTATION");
printf("90 degree rotation, press any key to test rotation\n");
UART_Getc();
G2D_SetRotationMode(G2D_ROTATION_180_DEG_BIT);
G2D_SetRotationOrg((u16)(uG2dWidth/2-1), (u16)(uG2dHeight/2-1));
G2D_SetFontColor(G2D_GREEN, G2D_BLACK, bIsTransparent);
G2D_Printf(uG2dWidth/2-1, uG2dHeight/2-1, "ROTATION");
printf("180 degree rotation, press any key to test rotation\n");
UART_Getc();
G2D_SetRotationMode(G2D_ROTATION_270_DEG_BIT);
G2D_SetRotationOrg((u16)(uG2dWidth/2-1), (u16)(uG2dHeight/2-1));
G2D_SetFontColor(G2D_BLUE, G2D_BLACK, bIsTransparent);
G2D_Printf(uG2dWidth/2-1, uG2dHeight/2-1, "ROTATION");
printf("270 degree rotation, press any key to test rotation\n");
UART_Getc();
G2D_SetRotationMode(G2D_ROTATION_0_DEG_BIT);
G2D_ClearFrameEcolor(G2D_BLACK, 0, 0);
for(j=0; j<uG2dHeight; j++)
for(i=0; i<uG2dWidth; i++) {
if(i==(uG2dWidth/2-1)) G2D_PutPixelEcolor(i, j, G2D_MAGENTA);
if(j==(uG2dHeight/2-1)) G2D_PutPixelEcolor(i, j, G2D_MAGENTA);
}
G2D_SetFontColor(G2D_WHITE, G2D_BLACK, bIsTransparent);
G2D_Printf(uG2dWidth/2-1, uG2dHeight/2-1, "FLIP");
printf("8x8 font is dispayed using color expansion, press any key to continue.\n");
UART_Getc();
G2D_SetRotationMode(G2D_X_FLIP);
G2D_SetRotationOrg((u16)(uG2dWidth/2-1), (u16)(uG2dHeight/2-1));
G2D_SetFontColor(G2D_RED, G2D_BLACK, bIsTransparent);
G2D_Printf(uG2dWidth/2-1, uG2dHeight/2-1, "FLIP");
printf("X-flip using color expansion, press any key to continue.\n");
UART_Getc();
G2D_SetRotationMode(G2D_Y_FLIP);
G2D_SetRotationOrg((u16)(uG2dWidth/2-1), (u16)(uG2dHeight/2-1));
G2D_SetFontColor(G2D_BLUE, G2D_BLACK, bIsTransparent);
G2D_Printf(uG2dWidth/2-1, uG2dHeight/2-1, "FLIP");
printf("Y-flip using color expansion, press any key to continue.\n");
UART_Getc();
// Screen to Screen Test
printf("Simple Screen to Screen Color Expansion, press any key to continue");
G2D_SetRotationMode(G2D_ROTATION_0_DEG_BIT);
G2D_ClearFrameEcolor(G2D_BLACK, 0, 0);
for(j=0; j<uG2dHeight; j++)
for(i=0; i<uG2dWidth; i++) {
if(i==(uG2dWidth/2-1)) G2D_PutPixelEcolor(i, j, G2D_MAGENTA);
if(j==(uG2dHeight/2-1)) G2D_PutPixelEcolor(i, j, G2D_MAGENTA);
}
UART_Getc();
uTextDrawingFbAddr=(uG2dFbAddr&0xff000000)+0x800000;
G2D_SetColorExpansionMethod(SCREEN2SCREEN);
G2D_FillMemoryForTextDrawing(FONT8BY8, uTextDrawingFbAddr);
G2D_SetFontAddr(uTextDrawingFbAddr);
G2D_SetFontType(FONT8BY8, &uFontWidth, &uFontHeight);
G2D_SetRotationMode(G2D_ROTATION_0_DEG_BIT);
G2D_SetFontColor(G2D_WHITE, G2D_BLACK, bIsTransparent);
G2D_Printf(uG2dWidth/2-1, uG2dHeight/2-1, "ROTATION");
printf("8x8 font is dispayed using color expansion, press any key to continue.\n");
UART_Getc();
G2D_SetFontColor(G2D_RED, G2D_BLACK, bIsTransparent);
G2D_SetRotationMode(G2D_ROTATION_90_DEG_BIT);
G2D_SetRotationOrg((u16)(uG2dWidth/2-1), (u16)(uG2dHeight/2-1));
G2D_Printf(uG2dWidth/2-1, uG2dHeight/2-1, "ROTATION");
printf("90 degree rotation using color expansion, press any key to continue.\n");
UART_Getc();
G2D_SetFontColor(G2D_GREEN, G2D_BLACK, bIsTransparent);
G2D_SetRotationMode(G2D_ROTATION_180_DEG_BIT);
G2D_SetRotationOrg((u16)(uG2dWidth/2-1), (u16)(uG2dHeight/2-1));
G2D_Printf(uG2dWidth/2-1, uG2dHeight/2-1, "ROTATION");
printf("180 degree rotation using color expansion, press any key to continue.\n");
UART_Getc();
G2D_SetFontColor(G2D_BLUE, G2D_BLACK, bIsTransparent);
G2D_SetRotationMode(G2D_ROTATION_270_DEG_BIT);
G2D_SetRotationOrg((u16)(uG2dWidth/2-1), (u16)(uG2dHeight/2-1));
G2D_Printf(uG2dWidth/2-1, uG2dHeight/2-1, "ROTATION");
printf("270 degree rotation using color expansion, press any key to continue.\n");
UART_Getc();
G2D_SetRotationMode(G2D_ROTATION_0_DEG_BIT);
G2D_ClearFrameEcolor(G2D_BLACK, 0, 0);
for(j=0; j<uG2dHeight; j++)
for(i=0; i<uG2dWidth; i++) {
if(i==(uG2dWidth/2-1)) G2D_PutPixelEcolor(i, j, G2D_MAGENTA);
if(j==(uG2dHeight/2-1)) G2D_PutPixelEcolor(i, j, G2D_MAGENTA);
}
G2D_SetFontColor(G2D_WHITE, G2D_BLACK, bIsTransparent);
G2D_Printf(uG2dWidth/2-1, uG2dHeight/2-1, "FLIP");
printf("8x8 font is dispayed using color expansion, press any key to continue.\n");
UART_Getc();
G2D_SetRotationMode(G2D_X_FLIP);
G2D_SetRotationOrg((u16)(uG2dWidth/2-1), (u16)(uG2dHeight/2-1));
G2D_SetFontColor(G2D_RED, G2D_BLACK, bIsTransparent);
G2D_Printf(uG2dWidth/2-1, uG2dHeight/2-1, "FLIP");
printf("X-flip using color expansion, press any key to continue.\n");
UART_Getc();
G2D_SetRotationMode(G2D_Y_FLIP);
G2D_SetRotationOrg((u16)(uG2dWidth/2-1), (u16)(uG2dHeight/2-1));
G2D_SetFontColor(G2D_BLUE, G2D_BLACK, bIsTransparent);
G2D_Printf(uG2dWidth/2-1, uG2dHeight/2-1, "FLIP");
printf("Y-flip using color expansion, press any key to exit.\n");
UART_Getc();
G2D_InterruptDisable();
INTC_Disable(NUM_2D);
G2D_InitSetting(uG2dFbAddr, eBpp, uG2dWidth, uG2dHeight, 0, 0, uG2dWidth, uG2dHeight);
}
void TestColorExpansionWithBlending(void) //Not Implemented yet
{
u32 uG2dFbAddr, uG2dWidth, uG2dHeight;
u32 uFontWidth, uFontHeight;
u32 uTextDrawingFbAddr;
s32 sAlphaVal;
CSPACE eBpp;
bool bIsTransparent=1;
INTC_SetVectAddr(NUM_2D, Isr_G2d);
INTC_Enable(NUM_2D);
G2D_InterruptEnable();
G2D_GetFrmSz(&uG2dWidth, &uG2dHeight);
G2D_GetFbAddr(&uG2dFbAddr);
G2D_GetBppMode(&eBpp);
printf("Width=%d, Height=%d, Framebuffer:0x%x\n", uG2dWidth, uG2dHeight, uG2dFbAddr);
G2D_ClearFrameEcolor(G2D_YELLOW, 0, 0);
// Host to Screen Test
printf("Host to Screen Color Expansion with Blending, press any key to continue!\n");
G2D_SetColorExpansionMethod(HOST2SCREEN);
G2D_SetFontType(FONT8BY8, &uFontWidth, &uFontHeight);
G2D_SetAlphaMode(G2D_ALPHA_MODE);
G2D_SetAlphaValue(0xff);
G2D_SetFontColor(G2D_RED, G2D_BLACK, bIsTransparent);
G2D_Printf(5, 5, "[2D]Host to Screen Color Expansion");
G2D_SetFontColor(G2D_GREEN, G2D_BLACK, bIsTransparent);
G2D_Printf(5, uG2dHeight*1/4+5, "[2D]Host to Screen Color Expansion");
G2D_SetFontColor(G2D_BLUE, G2D_BLACK, bIsTransparent);
G2D_Printf(5, uG2dHeight*2/4+5, "[2D]Host to Screen Color Expansion");
G2D_SetFontColor(G2D_WHITE, G2D_BLACK, bIsTransparent);
G2D_Printf(5, uG2dHeight*3/4+5, "[2D]Host to Screen Color Expansion");
UART_Getc();
sAlphaVal=255;
while(1) {
sAlphaVal -= 8;
if(sAlphaVal<=0) sAlphaVal=0;
G2D_SetAlphaValue((u8)sAlphaVal);
G2D_ClearFrameEcolor(G2D_YELLOW, 0, 0);
G2D_SetFontColor(G2D_RED, G2D_BLACK, bIsTransparent);
G2D_Printf(5, 5, "[2D]Host to Screen Color Expansion");
G2D_SetFontColor(G2D_GREEN, G2D_BLACK, bIsTransparent);
G2D_Printf(5, uG2dHeight*1/4+5, "[2D]Host to Screen Color Expansion");
G2D_SetFontColor(G2D_BLUE, G2D_BLACK, bIsTransparent);
G2D_Printf(5, uG2dHeight*2/4+5, "[2D]Host to Screen Color Expansion");
G2D_SetFontColor(G2D_WHITE, G2D_BLACK, bIsTransparent);
G2D_Printf(5, uG2dHeight*3/4+5, "[2D]Host to Screen Color Expansion");
printf("Alpha:%d\n", sAlphaVal);
if(sAlphaVal==0) break;
UART_Getc();
}
printf("press any key to continue!\n");
UART_Getc();
G2D_InitSetting(uG2dFbAddr, eBpp, uG2dWidth, uG2dHeight, 0, 0, uG2dWidth, uG2dHeight);
G2D_ClearFrameEcolor(G2D_YELLOW, 0, 0);
// Screen to Screen Test
printf("Screen to Screen Color Expansion with Blending, press any key to continue!\n");
G2D_SetColorExpansionMethod(SCREEN2SCREEN);
G2D_SetFontType(FONT8BY8, &uFontWidth, &uFontHeight);
uTextDrawingFbAddr=(uG2dFbAddr&0xff000000)+0x800000;
G2D_FillMemoryForTextDrawing(FONT8BY8, uTextDrawingFbAddr);
G2D_SetFontAddr(uTextDrawingFbAddr);
G2D_SetAlphaMode(G2D_ALPHA_MODE);
G2D_SetAlphaValue(0xff);
G2D_SetFontColor(G2D_RED, G2D_BLACK, bIsTransparent);
G2D_Printf(5, 5, "[2D]Screen to Screen Color Expansion");
G2D_SetFontColor(G2D_GREEN, G2D_BLACK, bIsTransparent);
G2D_Printf(5, uG2dHeight*1/4+5, "[2D]Screen to Screen Color Expansion");
G2D_SetFontColor(G2D_BLUE, G2D_BLACK, bIsTransparent);
G2D_Printf(5, uG2dHeight*2/4+5, "[2D]Screen to Screen Color Expansion");
G2D_SetFontColor(G2D_WHITE, G2D_BLACK, bIsTransparent);
G2D_Printf(5, uG2dHeight*3/4+5, "[2D]Screen to Screen Color Expansion");
UART_Getc();
sAlphaVal=255;
while(1) {
sAlphaVal -= 8;
if(sAlphaVal<=0) sAlphaVal=0;
G2D_SetAlphaValue((u8)sAlphaVal);
G2D_ClearFrameEcolor(G2D_YELLOW, 0, 0);
G2D_SetFontColor(G2D_RED, G2D_BLACK, bIsTransparent);
G2D_Printf(5, 5, "[2D]Screen to Screen Color Expansion");
G2D_SetFontColor(G2D_GREEN, G2D_BLACK, bIsTransparent);
G2D_Printf(5, uG2dHeight*1/4+5, "[2D]Screen to Screen Color Expansion");
G2D_SetFontColor(G2D_BLUE, G2D_BLACK, bIsTransparent);
G2D_Printf(5, uG2dHeight*2/4+5, "[2D]Screen to Screen Color Expansion");
G2D_SetFontColor(G2D_WHITE, G2D_BLACK, bIsTransparent);
G2D_Printf(5, uG2dHeight*3/4+5, "[2D]Screen to Screen Color Expansion");
printf("Alpha:%d\n", sAlphaVal);
if(sAlphaVal==0) break;
UART_Getc();
}
G2D_InterruptEnable();
INTC_Enable(NUM_2D);
G2D_InitSetting(uG2dFbAddr, eBpp, uG2dWidth, uG2dHeight, 0, 0, uG2dWidth, uG2dHeight);
}
void TestColorExpansionWithClipping(void)
{
u32 uG2dFbAddr, uG2dWidth, uG2dHeight;
u32 uFontWidth, uFontHeight;
u32 uTextDrawingFbAddr;
u32 uDec;
CSPACE eBpp;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -