//从内存缓冲区到screen位块传送,只支持块拷贝,不支持rop操作。 //镜像显示器的driver须提供这个函数 bool_t __lcd_bm_to_screen(struct tagRectangle *dst_rect, struct tagRectBitmap *src_bitmap,s32 xsrc,s32 ysrc) { s32 x,y,width,height; u16 *lineoffset; if(src_bitmap->PixelFormat != CN_SYS_PF_RGB565) return false; width = dst_rect->right-dst_rect->left; height = dst_rect->bottom-dst_rect->top; //转换坐标 lineoffset = (u16*)((u32)src_bitmap->bm_bits + (ysrc+height-1)*src_bitmap->linebytes); lineoffset +=xsrc; //转换坐标 __ili9325_set_window(LCD_XSIZE-dst_rect->right, LCD_YSIZE-dst_rect->bottom,width,height); __ili9325_write_cmd(0x0022); for(y = 0; y < height; y++) { for(x = width-1; x >= 0; x--) { __ili9325_write_data(lineoffset[x]); } lineoffset -= (src_bitmap->linebytes)>>1; } __ili9325_close_window(); return true; }
//screen中矩形填充,如硬件加速不支持在screen上矩形填充,或者有frame_buffer, //driver可以简化,直接返回false即可 bool_t __lcd_fill_rect_screen(struct tagRectangle *Target, struct tagRectangle *Focus, u32 Color0,u32 Color1,u32 Mode) { u32 x,y,width,height; u16 pixel; if(Mode != CN_FILLRECT_MODE_N) return false; pixel = GK_ConvertRGB24ToPF(CN_SYS_PF_RGB565,Color0); width = Focus->right-Focus->left; height = Focus->bottom-Focus->top; //转换坐标 __ili9325_set_window(LCD_XSIZE-Focus->right, LCD_YSIZE-Focus->bottom,width,height); __ili9325_write_cmd(0x0022); for(y = 0; y < height; y++) { for(x = 0; x < width; x++) { __ili9325_write_data(pixel); } } __ili9325_close_window(); return true; }
//从内存缓冲区到screen位块传送,只支持块拷贝,不支持rop操作。 //镜像显示器的driver须提供这个函数 bool_t __lcd_bm_to_screen(struct Rectangle *dst_rect, struct RectBitmap *src_bitmap,s32 xsrc,s32 ysrc) { s32 x,y,width,height; s32 n,m; u16 *lineoffset; register u16 *lineP; if(src_bitmap->PixelFormat != CN_SYS_PF_RGB565) return false; width = dst_rect->right-dst_rect->left; height = dst_rect->bottom-dst_rect->top; //转换坐标 lineoffset = (u16*)((u32)src_bitmap->bm_bits + (ysrc+height-1)*src_bitmap->linebytes); lineoffset +=xsrc; //转换坐标 __ili9325_set_window(CN_LCD_XSIZE-dst_rect->right, CN_LCD_YSIZE-dst_rect->bottom,width,height); __ili9325_write_cmd(0x0022); n = (width+7)/8; for(y = 0; y < height; y++) { m = width%8; lineP = lineoffset+width-1; for(x = 0; x < n; x++) { switch(m) { case 0: __ili9325_write_data(*lineP--); case 7: __ili9325_write_data(*lineP--); case 6: __ili9325_write_data(*lineP--); case 5: __ili9325_write_data(*lineP--); case 4: __ili9325_write_data(*lineP--); case 3: __ili9325_write_data(*lineP--); case 2: __ili9325_write_data(*lineP--); case 1: __ili9325_write_data(*lineP--); } m = 0; } lineoffset -= (src_bitmap->linebytes)>>1; } __ili9325_close_window(); return true; }
//screen中矩形填充,如硬件加速不支持在screen上矩形填充,或者有frame_buffer, //driver可以简化,直接返回false即可 bool_t __lcd_fill_rect_screen(struct Rectangle *Target, struct Rectangle *Focus, u32 Color0,u32 Color1,u32 Mode) { u32 x,y,width,height; u16 pixel; s32 n,m; if(Mode != CN_FILLRECT_MODE_N) return false; pixel = GK_ConvertRGB24ToPF(CN_SYS_PF_RGB565,Color0); width = Focus->right-Focus->left; height = Focus->bottom-Focus->top; //转换坐标 __ili9325_set_window(CN_LCD_XSIZE-Focus->right, CN_LCD_YSIZE-Focus->bottom,width,height); __ili9325_write_cmd(0x0022); n = (width+7)/8; for(y = 0; y < height; y++) { m = width%8; for(x = 0; x < n; x++) { switch(m) { case 0: __ili9325_write_data(pixel); case 7: __ili9325_write_data(pixel); case 6: __ili9325_write_data(pixel); case 5: __ili9325_write_data(pixel); case 4: __ili9325_write_data(pixel); case 3: __ili9325_write_data(pixel); case 2: __ili9325_write_data(pixel); case 1: __ili9325_write_data(pixel); } m = 0; } } __ili9325_close_window(); return true; }