|
发表于 2015-8-27 00:21:00
|
显示全部楼层
有一个非常重要的地方你好像忘记修改了,就是绘制16bpp的地方,这个地方优化后你显示对话框等控件的时候,速度才快。
这里有以前做的uCGUI3.98工程,你可以参考下底层接口部分:
http://www.armbbs.cn/forum.php?mod=viewthread&tid=2133
==================================================
我这里其单独整理出来了:
bsp_tft_ucgui.rar
(3 KB, 下载次数: 57)
- /*
- *********************************************************************************************************
- *
- * 模块名称 : uCGUI底层驱动接口
- * 文件名称 : bsp_tft_ucgui.h
- * 版 本 : V1.0
- * 说 明 : uCGUI底层驱动接口
- *********************************************************************************************************
- */
- #include "LCD_Private.h" /* private modul definitions & config */
- #include "GUI_Private.h"
- #include "GUIDebug.h"
- #include "LCD_RA8875.h"
- #include "stm32f4xx.h"
- #define BKCOLOR LCD_BKCOLORINDEX
- #define COLOR LCD_COLORINDEX
- __IO uint8_t s_ucRA8875BusyNow = 0;
- int LCD_L0_Init(void)
- {
- return 0;
- }
- void LCD_L0_SetPixelIndex(int x, int y, int PixelIndex)
- {
- s_ucRA8875BusyNow = 1;
- LCD_PutPixel(x,y,PixelIndex);
- s_ucRA8875BusyNow = 0;
- }
- unsigned int LCD_L0_GetPixelIndex(int x, int y)
- {
- unsigned int PixelIndex;
- s_ucRA8875BusyNow = 1;
- PixelIndex = LCD_GetPixel(x, y);
- s_ucRA8875BusyNow = 0;
- return PixelIndex;
- }
- void LCD_L0_SetOrg(int x,int y)
- {
- }
- void LCD_L0_XorPixel(int x, int y)
- {
- LCD_PIXELINDEX Index;
- s_ucRA8875BusyNow = 1;
- Index = LCD_GetPixel(x,y);
- s_ucRA8875BusyNow = 0;
- LCD_PutPixel(x,y,LCD_NUM_COLORS-1-Index);
- }
- void LCD_L0_DrawHLine (int x0, int y, int x1)
- {
- LCD_DrawLineH(x0, y, x1, LCD_COLORINDEX);
- }
- void LCD_L0_DrawVLine (int x, int y0, int y1)
- {
- LCD_DrawLineV(x, y0, y1, LCD_COLORINDEX);
- }
- void LCD_L0_FillRect(int x0, int y0, int x1, int y1) {
- s_ucRA8875BusyNow = 1;
- BTE_SetTarBlock(x0, y0, y1-y0+1, x1-x0+1, 0); /* 设置BTE位置和宽度高度 */
- BTE_SetOperateCode(0x0C); /* 设定BTE 操作码和光栅运算码 REG[51h] Bit[3:0] = 0Ch */
- RA8875_SetFrontColor(LCD_COLORINDEX); /* 设置BTE前景色 */
- BTE_Start(); /* 开启BTE 功能 */
- BTE_Wait(); /* 等待操作结束 */
- s_ucRA8875BusyNow = 0;
- }
- void DrawBitLine1BPP(int x, int y, U8 const*p, int Diff, int xsize, const LCD_PIXELINDEX*pTrans)
- {
- LCD_PIXELINDEX pixels;
- LCD_PIXELINDEX Index0 = *(pTrans+0);
- LCD_PIXELINDEX Index1 = *(pTrans+1);
- /*
- // Jump to right entry point
- */
- pixels = *p;
- switch (GUI_Context.DrawMode & (LCD_DRAWMODE_TRANS|LCD_DRAWMODE_XOR)) {
- case 0:
- #if defined (SETNEXTPIXEL) /* Optimization ! */
- x+=Diff;
- LCD_PutPixel(x,y);
- #endif
- switch (Diff&7) {
- case 0:
- goto WriteBit0;
- case 1:
- goto WriteBit1;
- case 2:
- goto WriteBit2;
- case 3:
- goto WriteBit3;
- case 4:
- goto WriteBit4;
- case 5:
- goto WriteBit5;
- case 6:
- goto WriteBit6;
- case 7:
- goto WriteBit7;
- }
- break;
- case LCD_DRAWMODE_TRANS:
- switch (Diff&7) {
- case 0:
- goto WriteTBit0;
- case 1:
- goto WriteTBit1;
- case 2:
- goto WriteTBit2;
- case 3:
- goto WriteTBit3;
- case 4:
- goto WriteTBit4;
- case 5:
- goto WriteTBit5;
- case 6:
- goto WriteTBit6;
- case 7:
- goto WriteTBit7;
- }
- break;
- case LCD_DRAWMODE_XOR:
- switch (Diff&7) {
- case 0:
- goto WriteXBit0;
- case 1:
- goto WriteXBit1;
- case 2:
- goto WriteXBit2;
- case 3:
- goto WriteXBit3;
- case 4:
- goto WriteXBit4;
- case 5:
- goto WriteXBit5;
- case 6:
- goto WriteXBit6;
- case 7:
- goto WriteXBit7;
- }
- }
- /*
- Write with transparency
- */
- WriteTBit0:
- if (pixels&(1<<7)) LCD_PutPixel(x+0, y, Index1);
- if (!--xsize)
- return;
- WriteTBit1:
- if (pixels&(1<<6)) LCD_PutPixel(x+1, y, Index1);
- if (!--xsize)
- return;
- WriteTBit2:
- if (pixels&(1<<5)) LCD_PutPixel(x+2, y, Index1);
- if (!--xsize)
- return;
- WriteTBit3:
- if (pixels&(1<<4)) LCD_PutPixel(x+3, y, Index1);
- if (!--xsize)
- return;
- WriteTBit4:
- if (pixels&(1<<3)) LCD_PutPixel(x+4, y, Index1);
- if (!--xsize)
- return;
- WriteTBit5:
- if (pixels&(1<<2)) LCD_PutPixel(x+5, y, Index1);
- if (!--xsize)
- return;
- WriteTBit6:
- if (pixels&(1<<1)) LCD_PutPixel(x+6, y, Index1);
- if (!--xsize)
- return;
- WriteTBit7:
- if (pixels&(1<<0)) LCD_PutPixel(x+7, y, Index1);
- if (!--xsize)
- return;
- x+=8;
- pixels = *(++p);
- goto WriteTBit0;
- /*
- Write without transparency
- */
- WriteBit0:
- LCD_PutPixel(x+0, y, (pixels&(1<<7)) ? Index1 : Index0);
- if (!--xsize)
- return;
- WriteBit1:
- LCD_PutPixel(x+1, y, (pixels&(1<<6)) ? Index1 : Index0);
- if (!--xsize)
- return;
- WriteBit2:
- LCD_PutPixel(x+2, y, (pixels&(1<<5)) ? Index1 : Index0);
- if (!--xsize)
- return;
- WriteBit3:
- LCD_PutPixel(x+3, y, (pixels&(1<<4)) ? Index1 : Index0);
- if (!--xsize)
- return;
- WriteBit4:
- LCD_PutPixel(x+4, y, (pixels&(1<<3)) ? Index1 : Index0);
- if (!--xsize)
- return;
- WriteBit5:
- LCD_PutPixel(x+5, y, (pixels&(1<<2)) ? Index1 : Index0);
- if (!--xsize)
- return;
- WriteBit6:
- LCD_PutPixel(x+6, y, (pixels&(1<<1)) ? Index1 : Index0);
- if (!--xsize)
- return;
- WriteBit7:
- LCD_PutPixel(x+7, y, (pixels&(1<<0)) ? Index1 : Index0);
- if (!--xsize)
- return;
- x+=8;
- pixels = *(++p);
- goto WriteBit0;
- /*
- Write XOR mode
- */
- WriteXBit0:
- if (pixels&(1<<7))
- LCD_L0_XorPixel(x+0, y);
- if (!--xsize)
- return;
- WriteXBit1:
- if (pixels&(1<<6))
- LCD_L0_XorPixel(x+1, y);
- if (!--xsize)
- return;
- WriteXBit2:
- if (pixels&(1<<5))
- LCD_L0_XorPixel(x+2, y);
- if (!--xsize)
- return;
- WriteXBit3:
- if (pixels&(1<<4))
- LCD_L0_XorPixel(x+3, y);
- if (!--xsize)
- return;
- WriteXBit4:
- if (pixels&(1<<3))
- LCD_L0_XorPixel(x+4, y);
- if (!--xsize)
- return;
- WriteXBit5:
- if (pixels&(1<<2))
- LCD_L0_XorPixel(x+5, y);
- if (!--xsize)
- return;
- WriteXBit6:
- if (pixels&(1<<1))
- LCD_L0_XorPixel(x+6, y);
- if (!--xsize)
- return;
- WriteXBit7:
- if (pixels&(1<<0))
- LCD_L0_XorPixel(x+7, y);
- if (!--xsize)
- return;
- x+=8;
- pixels = *(++p);
- goto WriteXBit0;
-
- }
- static void DrawBitLine2BPP(int x, int y, U8 const*p, int Diff, int xsize, const LCD_PIXELINDEX*pTrans) {
- LCD_PIXELINDEX pixels;
- /*
- // Jump to right entry point
- */
- pixels = *p;
- if (pTrans) {
- /*
- with palette
- */
- if (GUI_Context.DrawMode & LCD_DRAWMODE_TRANS) switch (Diff&3) {
- case 0:
- goto WriteTBit0;
- case 1:
- goto WriteTBit1;
- case 2:
- goto WriteTBit2;
- default:
- goto WriteTBit3;
- } else switch (Diff&3) {
- case 0:
- goto WriteBit0;
- case 1:
- goto WriteBit1;
- case 2:
- goto WriteBit2;
- default:
- goto WriteBit3;
- }
- /*
- Write without transparency
- */
- WriteBit0:
- LCD_PutPixel(x+0, y, *(pTrans+(pixels>>6)));
- if (!--xsize)
- return;
- WriteBit1:
- LCD_PutPixel(x+1, y, *(pTrans+(3&(pixels>>4))));
- if (!--xsize)
- return;
- WriteBit2:
- LCD_PutPixel(x+2, y, *(pTrans+(3&(pixels>>2))));
- if (!--xsize)
- return;
- WriteBit3:
- LCD_PutPixel(x+3, y, *(pTrans+(3&(pixels))));
- if (!--xsize)
- return;
- pixels = *(++p);
- x+=4;
- goto WriteBit0;
- /*
- Write with transparency
- */
- WriteTBit0:
- if (pixels&(3<<6))
- LCD_PutPixel(x+0, y, *(pTrans+(pixels>>6)));
- if (!--xsize)
- return;
- WriteTBit1:
- if (pixels&(3<<4))
- LCD_PutPixel(x+1, y, *(pTrans+(3&(pixels>>4))));
- if (!--xsize)
- return;
- WriteTBit2:
- if (pixels&(3<<2))
- LCD_PutPixel(x+2, y, *(pTrans+(3&(pixels>>2))));
- if (!--xsize)
- return;
- WriteTBit3:
- if (pixels&(3<<0))
- LCD_PutPixel(x+3, y, *(pTrans+(3&(pixels))));
- if (!--xsize)
- return;
- pixels = *(++p);
- x+=4;
- goto WriteTBit0;
- } else {
- /*
- without palette
- */
- if (GUI_Context.DrawMode & LCD_DRAWMODE_TRANS) switch (Diff&3) {
- case 0:
- goto WriteDDPTBit0;
- case 1:
- goto WriteDDPTBit1;
- case 2:
- goto WriteDDPTBit2;
- default:
- goto WriteDDPTBit3;
- } else switch (Diff&3) {
- case 0:
- goto WriteDDPBit0;
- case 1:
- goto WriteDDPBit1;
- case 2:
- goto WriteDDPBit2;
- default:
- goto WriteDDPBit3;
- }
- /*
- Write without transparency
- */
- WriteDDPBit0:
- LCD_PutPixel(x+0, y, (pixels>>6));
- if (!--xsize)
- return;
- WriteDDPBit1:
- LCD_PutPixel(x+1, y, (3&(pixels>>4)));
- if (!--xsize)
- return;
- WriteDDPBit2:
- LCD_PutPixel(x+2, y, (3&(pixels>>2)));
- if (!--xsize)
- return;
- WriteDDPBit3:
- LCD_PutPixel(x+3, y, (3&(pixels)));
- if (!--xsize)
- return;
- pixels = *(++p);
- x+=4;
- goto WriteDDPBit0;
- /*
- Write with transparency
- */
- WriteDDPTBit0:
- if (pixels&(3<<6))
- LCD_PutPixel(x+0, y, (pixels>>6));
- if (!--xsize)
- return;
- WriteDDPTBit1:
- if (pixels&(3<<4))
- LCD_PutPixel(x+1, y, (3&(pixels>>4)));
- if (!--xsize)
- return;
- WriteDDPTBit2:
- if (pixels&(3<<2))
- LCD_PutPixel(x+2, y, (3&(pixels>>2)));
- if (!--xsize)
- return;
- WriteDDPTBit3:
- if (pixels&(3<<0))
- LCD_PutPixel(x+3, y, (3&(pixels)));
- if (!--xsize)
- return;
- pixels = *(++p);
- x+=4;
- goto WriteDDPTBit0;
- }
- }
- static void DrawBitLine4BPP(int x, int y, U8 const*p, int Diff, int xsize, const LCD_PIXELINDEX*pTrans)
- {
- LCD_PIXELINDEX pixels;
- pixels = *p;
- if (pTrans)
- {
- if (GUI_Context.DrawMode & LCD_DRAWMODE_TRANS)
- {
- if ((Diff&1) ==0)
- goto WriteTBit0;
- goto WriteTBit1;
- }
- else
- {
- if ((Diff&1) ==0)
- goto WriteBit0;
- goto WriteBit1;
- }
- WriteBit0:
- LCD_PutPixel(x+0, y, *(pTrans+(pixels>>4)));
- if (!--xsize)
- return;
- WriteBit1:
- LCD_PutPixel(x+1, y, *(pTrans+(pixels&0xf)));
- if (!--xsize)
- return;
- x+=2;
- pixels = *(++p);
- goto WriteBit0;
- /*
- Write with transparency
- */
- WriteTBit0:
- if (pixels>>4)
- LCD_PutPixel(x+0, y, *(pTrans+(pixels>>4)));
- if (!--xsize)
- return;
- WriteTBit1:
- if (pixels&0xf)
- LCD_PutPixel(x+1, y, *(pTrans+(pixels&0xf)));
- if (!--xsize)
- return;
- x+=2;
- pixels = *(++p);
- goto WriteTBit0;
- } else {
- /*
- without palette
- */
- if (GUI_Context.DrawMode & LCD_DRAWMODE_TRANS) {
- if ((Diff&1) ==0)
- goto WriteDDPTBit0;
- goto WriteDDPTBit1;
- } else {
- if ((Diff&1) ==0)
- goto WriteDDPBit0;
- goto WriteDDPBit1;
- }
- /*
- Write without transparency
- */
- WriteDDPBit0:
- LCD_PutPixel(x+0, y, (pixels>>4));
- if (!--xsize)
- return;
- WriteDDPBit1:
- LCD_PutPixel(x+1, y, (pixels&0xf));
- if (!--xsize)
- return;
- x+=2;
- pixels = *(++p);
- goto WriteDDPBit0;
- /*
- Write with transparency
- */
- WriteDDPTBit0:
- if (pixels>>4)
- LCD_PutPixel(x+0, y, (pixels>>4));
- if (!--xsize)
- return;
- WriteDDPTBit1:
- if (pixels&0xf)
- LCD_PutPixel(x+1, y, (pixels&0xf));
- if (!--xsize)
- return;
- x+=2;
- pixels = *(++p);
- goto WriteDDPTBit0;
- }
- }
- void DrawBitLine8BPP(int x, int y, U8 const*p, int xsize, const LCD_PIXELINDEX*pTrans) {
- LCD_PIXELINDEX pixel;
- if ((GUI_Context.DrawMode & LCD_DRAWMODE_TRANS)==0) {
- if (pTrans) {
- for (;xsize > 0; xsize--,x++,p++) {
- pixel = *p;
- LCD_PutPixel(x, y, *(pTrans+pixel));
- }
- } else {
- for (;xsize > 0; xsize--,x++,p++) {
- LCD_PutPixel(x, y, *p);
- }
- }
- } else { /* Handle transparent bitmap */
- if (pTrans) {
- for (; xsize > 0; xsize--, x++, p++) {
- pixel = *p;
- if (pixel) {
- LCD_PutPixel(x+0, y, *(pTrans+pixel));
- }
- }
- } else {
- for (; xsize > 0; xsize--, x++, p++) {
- pixel = *p;
- if (pixel) {
- LCD_PutPixel(x+0, y, pixel);
- }
- }
- }
- }
- }
- void DrawBitLine16BPP(int x, int y, U16 const*p, int xsize)
- {
- LCD_PIXELINDEX Index;
- int j = 0;
- if ((GUI_Context.DrawMode & LCD_DRAWMODE_TRANS)==0)
- {
- // for (;xsize > 0; xsize--,x++,p++)
- // {
- // LCD_PutPixel(x, y, *p);
- // }
- s_ucRA8875BusyNow = 1;
- RA8875_SetCursor(x,y);
- RA8875_REG = 0x02;
- for (;xsize > 0; xsize--,p++)
- {
- RA8875_RAM = *p;
- }
- s_ucRA8875BusyNow = 0;
- }
- else
- { /* Handle transparent bitmap */
- // for (; xsize > 0; xsize--, x++, p++)
- // {
- // Index = *p;
- // if (Index)
- // {
- // LCD_PutPixel(x+0, y, Index);
- // }
- // }
- s_ucRA8875BusyNow = 1;
- RA8875_SetCursor(x,y);
- RA8875_REG = 0x02;
- for (;xsize > 0; xsize--,p++,j++)
- {
- Index = *p;
- if(Index)
- {
- RA8875_RAM = *p;
- }
- else
- {
- RA8875_SetCursor(x+j,y);
- RA8875_REG = 0x02;
- RA8875_RAM = *p;
- }
- }
- s_ucRA8875BusyNow = 0;
- }
- }
- void LCD_L0_DrawBitmap (int x0, int y0,
- int xsize, int ysize,
- int BitsPerPixel,
- int BytesPerLine,
- const U8* pData, int Diff,
- const LCD_PIXELINDEX* pTrans)
- {
- int i;
- switch (BitsPerPixel)
- {
- case 1:
- for (i=0; i<ysize; i++)
- {
- DrawBitLine1BPP(x0, i+y0, pData, Diff, xsize, pTrans);
- pData += BytesPerLine;
- }
- break;
- case 2:
- for (i=0; i<ysize; i++)
- {
- DrawBitLine2BPP(x0, i+y0, pData, Diff, xsize, pTrans);
- pData += BytesPerLine;
- }
- break;
- case 4:
- for (i=0; i<ysize; i++)
- {
- DrawBitLine4BPP(x0, i+y0, pData, Diff, xsize, pTrans);
- pData += BytesPerLine;
- }
- break;
- case 8:
- for (i=0; i<ysize; i++)
- {
- DrawBitLine8BPP(x0, i+y0, pData, xsize, pTrans);
- pData += BytesPerLine;
- }
- break;
- case 16:
- for (i=0; i<ysize; i++)
- {
- DrawBitLine16BPP(x0, i+y0, (U16*)pData, xsize);
- pData += BytesPerLine;
- }
- break;
- }
- }
- void LCD_L0_SetLUTEntry(U8 Pos, LCD_COLOR color){}
- void LCD_L0_On(void){}
- void * LCD_L0_GetDevFunc(int Index) {
- GUI_USE_PARA(Index);
- return 0;
- }
复制代码 |
|