📄 g2d_test.c
字号:
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_BLACK, 0, 0);
// Host to Screen Test
printf("Host to Screen Color Expansion with Clipping, press any key to continue!\n");
G2D_SetColorExpansionMethod(HOST2SCREEN);
G2D_SetFontType(FONT8BY8, &uFontWidth, &uFontHeight);
G2D_SetFontColor(G2D_RED, G2D_BLACK, bIsTransparent);
G2D_Printf(0, 5, "[2D]Host to Screen Color Expansion Test");
G2D_SetFontColor(G2D_GREEN, G2D_BLACK, bIsTransparent);
G2D_Printf(0, uG2dHeight*1/4+5, "[2D]Host to Screen Color Expansion Test");
G2D_SetFontColor(G2D_BLUE, G2D_BLACK, bIsTransparent);
G2D_Printf(0, uG2dHeight*2/4+5, "[2D]Host to Screen Color Expansion Test");
G2D_SetFontColor(G2D_WHITE, G2D_BLACK, bIsTransparent);
G2D_Printf(0, uG2dHeight*3/4+5, "[2D]Host to Screen Color Expansion Test");
UART_Getc();
uDec=0;
while(1) {
uDec+=8;
if((uG2dWidth-2*uDec <=32)||(uG2dHeight-2*uDec <=32)) break;
G2D_ClearFrameEcolor(G2D_BLACK, 0, 0);
G2D_SetClippingWindow(0+uDec, 0+uDec, uG2dWidth-uDec, uG2dHeight-uDec);
printf("[Clipping]x1=%d,y1=%d,x2=%d,y2=%d\n",uG2dWidth-uDec, uG2dHeight-uDec, uG2dWidth-uDec, uG2dHeight-uDec);
G2D_SetFontColor(G2D_RED, G2D_BLACK, bIsTransparent);
G2D_Printf(0, 5, "[2D]Host to Screen Color Expansion Test");
G2D_SetFontColor(G2D_GREEN, G2D_BLACK, bIsTransparent);
G2D_Printf(0, uG2dHeight*1/4+5, "[2D]Host to Screen Color Expansion Test");
G2D_SetFontColor(G2D_BLUE, G2D_BLACK, bIsTransparent);
G2D_Printf(0, uG2dHeight*2/4+5, "[2D]Host to Screen Color Expansion Test");
G2D_SetFontColor(G2D_WHITE, G2D_BLACK, bIsTransparent);
G2D_Printf(0, uG2dHeight*3/4+5, "[2D]Host to Screen Color Expansion Test");
UART_Getc();
}
G2D_InitSetting(uG2dFbAddr, eBpp, uG2dWidth, uG2dHeight, 0, 0, uG2dWidth, uG2dHeight);
G2D_ClearFrameEcolor(G2D_BLACK, 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_SetFontColor(G2D_RED, G2D_BLACK, bIsTransparent);
G2D_Printf(0, 5, "[2D]Screen to Screen Color Expansion Test");
G2D_SetFontColor(G2D_GREEN, G2D_BLACK, bIsTransparent);
G2D_Printf(0, uG2dHeight*1/4+5, "[2D]Screen to Screen Color Expansion Test");
G2D_SetFontColor(G2D_BLUE, G2D_BLACK, bIsTransparent);
G2D_Printf(0, uG2dHeight*2/4+5, "[2D]Screen to Screen Color Expansion Test");
G2D_SetFontColor(G2D_WHITE, G2D_BLACK, bIsTransparent);
G2D_Printf(0, uG2dHeight*3/4+5, "[2D]Screen to Screen Color Expansion Test");
UART_Getc();
uDec=0;
while(1) {
uDec+=8;
if((uG2dWidth-2*uDec <=32)||(uG2dHeight-2*uDec <=32)) break;
G2D_ClearFrameEcolor(G2D_BLACK, 0, 0);
G2D_SetClippingWindow(0+uDec, 0+uDec, uG2dWidth-uDec, uG2dHeight-uDec);
printf("[Clipping]x1=%d,y1=%d,x2=%d,y2=%d\n",uG2dWidth-uDec, uG2dHeight-uDec, uG2dWidth-uDec, uG2dHeight-uDec);
G2D_SetFontColor(G2D_RED, G2D_BLACK, bIsTransparent);
G2D_Printf(0, 5, "[2D]Screen to Screen Color Expansion Test");
G2D_SetFontColor(G2D_GREEN, G2D_BLACK, bIsTransparent);
G2D_Printf(0, uG2dHeight*1/4+5, "[2D]Screen to Screen Color Expansion Test");
G2D_SetFontColor(G2D_BLUE, G2D_BLACK, bIsTransparent);
G2D_Printf(0, uG2dHeight*2/4+5, "[2D]Screen to Screen Color Expansion Test");
G2D_SetFontColor(G2D_WHITE, G2D_BLACK, bIsTransparent);
G2D_Printf(0, uG2dHeight*3/4+5, "[2D]Screen to Screen Color Expansion Test");
UART_Getc();
}
G2D_InterruptEnable();
INTC_Enable(NUM_2D);
G2D_InitSetting(uG2dFbAddr, eBpp, uG2dWidth, uG2dHeight, 0, 0, uG2dWidth, uG2dHeight);
}
void TestColorExpansionTransparency(void)
{
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);
UART_Getc();
G2D_SetColorExpansionMethod(HOST2SCREEN);
bIsTransparent=1;
G2D_SetFontColor(G2D_RED, G2D_BLUE, bIsTransparent);
G2D_SetFontType(FONT8BY8, &uFontWidth, &uFontHeight);
G2D_Printf(5, 5, "[2D]Host to Screen Color Expansion Transparent");
bIsTransparent=0;
G2D_SetFontColor(G2D_GREEN, G2D_MAGENTA, bIsTransparent);
G2D_SetFontType(FONT8BY15, &uFontWidth, &uFontHeight);
G2D_Printf(5, uG2dHeight*1/4+5, "[2D]Host to Screen Color Expansion Opqaue");
bIsTransparent=1;
G2D_SetFontColor(G2D_BLUE, G2D_WHITE, bIsTransparent);
G2D_SetFontType(FONT8BY16T, &uFontWidth, &uFontHeight);
G2D_Printf(5, uG2dHeight*2/4+5, "[2D]Host to Screen Color Expansion Transparent");
bIsTransparent=0;
G2D_SetFontColor(G2D_WHITE, G2D_CYAN, bIsTransparent);
G2D_SetFontType(FONT8BY16, &uFontWidth, &uFontHeight);
G2D_Printf(5, uG2dHeight*3/4+5, "[2D]Host to Screen Color Expansion Opaque");
UART_Getc();
// Screen to Screen Test
printf("Simple Screen to Screen Color Expansion, press any key to continue");
G2D_ClearFrameEcolor(G2D_BLACK, 0, 0);
UART_Getc();
uTextDrawingFbAddr=(uG2dFbAddr&0xff000000)+0x800000;
G2D_SetColorExpansionMethod(SCREEN2SCREEN);
G2D_SetFontAddr(uTextDrawingFbAddr);
bIsTransparent=1;
G2D_SetFontColor(G2D_RED, G2D_BLUE, bIsTransparent);
G2D_FillMemoryForTextDrawing(FONT8BY8, uTextDrawingFbAddr);
G2D_SetFontType(FONT8BY8, &uFontWidth, &uFontHeight);
G2D_Printf(5, 5, "[2D]Screen to Screen Color Expansion");
bIsTransparent=0;
G2D_SetFontColor(G2D_GREEN, G2D_MAGENTA, bIsTransparent);
G2D_FillMemoryForTextDrawing(FONT8BY15, uTextDrawingFbAddr);
G2D_SetFontType(FONT8BY15, &uFontWidth, &uFontHeight);
G2D_Printf(5, uG2dHeight*1/4+5, "[2D]Screen to Screen Color Expansion");
bIsTransparent=1;
G2D_SetFontColor(G2D_BLUE, G2D_WHITE, bIsTransparent);
G2D_FillMemoryForTextDrawing(FONT8BY16T, uTextDrawingFbAddr);
G2D_SetFontType(FONT8BY16T, &uFontWidth, &uFontHeight);
G2D_Printf(5, uG2dHeight*2/4+5, "[2D]Screen to Screen Color Expansion");
bIsTransparent=0;
G2D_SetFontColor(G2D_WHITE, G2D_CYAN, bIsTransparent);
G2D_FillMemoryForTextDrawing(FONT8BY16, uTextDrawingFbAddr);
G2D_SetFontType(FONT8BY16, &uFontWidth, &uFontHeight);
G2D_Printf(5, uG2dHeight*3/4+5, "[2D]Screen to Screen Color Expansion");
G2D_InterruptDisable();
INTC_Disable(NUM_2D);
G2D_InitSetting(uG2dFbAddr, eBpp, uG2dWidth, uG2dHeight, 0, 0, uG2dWidth, uG2dHeight);
}
void TestColorExpansionWithAll(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);
printf("Point Drawing with All Operations, press any key to test.\n");
G2D_ClearFrameEcolor(G2D_YELLOW, 0, 0);
G2D_RegisterPattern(pat8x8_rgbw);
UART_Getc();
G2D_SetAlphaMode(G2D_ALPHA_MODE);
G2D_SetAlphaValue(0xcf);
G2D_SetClippingWindow(uG2dWidth/4, uG2dHeight/4,uG2dWidth*3/4, uG2dHeight*3/4);
G2D_Set3rdOperand(G2D_OPERAND3_PAT);
G2D_SetRopEtype(ROP_SRC_XOR_3RD_OPRND);
G2D_ClearFrameEcolor(G2D_YELLOW, 0, 0);
// Host to Screen Test
printf("Host to Screen Color Expansion with All Operations, press any key to continue!\n");
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 TEST ALL");
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 TEST ALL");
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 TEST ALL");
G2D_SetRotationMode(G2D_ROTATION_270_DEG_BIT);
G2D_SetRotationOrg((u16)(uG2dWidth/2-1), (u16)(uG2dHeight/2-1));
G2D_SetFontColor(G2D_BLUE, G2D_MAGENTA, 0);
G2D_Printf(uG2dWidth/2-1, uG2dHeight/2-1, "ROTATION TEST ALL");
G2D_SetRotationMode(G2D_ROTATION_0_DEG_BIT);
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");
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");
G2D_SetRotationMode(G2D_Y_FLIP);
G2D_SetRotationOrg((u16)(uG2dWidth/2-1), (u16)(uG2dHeight/2-1));
G2D_SetFontColor(G2D_BLUE, G2D_MAGENTA, 0);
G2D_Printf(uG2dWidth/2-1, uG2dHeight/2-1, "FLIP");
printf("Press any key to continue.\n");
UART_Getc();
// 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_ClearFrameEcolor(G2D_YELLOW, 0, 0);
UART_Getc();
G2D_Set3rdOperand(G2D_OPERAND3_PAT);
G2D_SetRopEtype(ROP_SRC_XOR_3RD_OPRND);
G2D_SetRotationMode(G2D_ROTATION_0_DEG_BIT);
G2D_SetFontColor(G2D_WHITE, G2D_BLACK, bIsTransparent);
G2D_Printf(uG2dWidth/2-1, uG2dHeight/2-1, "ROTATION TEST ALL");
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 TEST ALL");
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 TEST ALL");
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 TEST ALL");
G2D_SetRotationMode(G2D_ROTATION_0_DEG_BIT);
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");
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");
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("press any key to exit!\n");
G2D_InterruptEnable();
INTC_Enable(NUM_2D);
G2D_InitSetting(uG2dFbAddr, eBpp, uG2dWidth, uG2dHeight, 0, 0, uG2dWidth, uG2dHeight);
}
void TestBitBLTSimple(void)
{
u32 uG2dFbAddr, uG2dWidth, uG2dHeight;
CSPACE eBpp;
bool uIsStretch=0;
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_DrawImage(eBpp);
printf("BitBLT Test, Press any key to continue!\n");
UART_Getc();
// Normal BitBLT
printf("[Source Coordinate] x1=%d, y1=%d, x2=%d, y2=%d\n", 5, 5, 34, 34);
printf("Press any key to test Normal BitBLT!\n");
G2D_PutRectangleEcolor(5,5,30,30,G2D_MAGENTA) ;
UART_Getc();
uIsStretch=0;
G2D_BitBlt(5, 5, 34, 34, uG2dWidth/2-1, uG2dHeight/2-1, uG2dWidth/2-1+29, uG2dHeight/2-1+29,uIsStretch);
printf("[Destination Coordinate] x1=%d, y1=%d, x2=%d, y2=%d\n", uG2dWidth/2-1, uG2dHeight/2-1, uG2dWidth/2-1+29, uG2dHeight/2-1+29);
printf("Press any key to continue!\n");
UART_Getc();
// Stretched BitBLT
printf("Stretched BitBLT Test, Press any key to continue!\n");
prin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -