Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1638910
  • 博文数量: 311
  • 博客积分: 7778
  • 博客等级: 少将
  • 技术积分: 4186
  • 用 户 组: 普通用户
  • 注册时间: 2009-11-09 19:59
个人简介

蓝点工坊(http://www.bluedrum.cn) 创始人,App和嵌入式产品开发。同时也做相应培训和外包工作。 详细介绍 http://pan.baidu.com/s/1y2g88

文章存档

2012年(3)

2011年(115)

2010年(170)

2009年(23)

分类: 嵌入式

2011-07-26 17:29:05

Andrew Huang

对于直接使用frame buffer进行绘点的系统,SDL在直接输出点前使用使用一个转换函数。blitFunc,这个函数是在static void FB_DirectUpdate(_THIS, int numrects, SDL_Rect *rects) 中调用的。调用语句如下.

  1. blitFunc((Uint8 *) src_start,
  2.                 shadow_right_delta, 
  3.                 shadow_down_delta, 
  4.                 (Uint8 *) dst_start,
  5.                 physlinebytes,
  6.                 scr_x2 - scr_x1,
  7.                 scr_y2 - scr_y1);

 如果对输出结果不旋转,则使用FB_blit16这个函数来输出的,
if (vinfo.bits_per_pixel == 16) {
blitFunc = (rotate == FBCON_ROTATE_NONE ||
rotate == FBCON_ROTATE_UD) ?
FB_blit16 : FB_blit16blocked;

而FB_blit16的内容如下:

 
  1. static void FB_blit16(Uint8 *byte_src_pos, int src_right_delta, int src_down_delta,
  2.         Uint8 *byte_dst_pos, int dst_linebytes, int width, int height)
  3. {
  4.     int w;
  5. #ifdef I80_FB_PATCH 
  6.     int is_odd =1;
  7. #endif
  8.     Uint16 *src_pos = (Uint16 *)byte_src_pos;
  9.     Uint16 *dst_pos = (Uint16 *)byte_dst_pos;
  10. #ifdef I80_FB_PATCH 
  11.    printf("%s:width %d,height %d\n",__FUNCTION__,width,height);
  12. #endif

  13.     while (height) {
  14.         Uint16 *src = src_pos;
  15.         Uint16 *dst = dst_pos;
  16.         

  17.         for (= width; w != 0; w--) {
  18. #ifdef I80_FB_PATCH 
  19.         if(is_odd)
  20.             {
  21.              //写在下一位
  22.              *(dst+1) = *src;
  23.              is_odd = 0;
  24.             }
  25.             else
  26.             {
  27.                 *(dst-1) = *src;
  28.                 is_odd = 1; 
  29.             }
  30. #else
  31.             *dst = *src;
  32. #endif
  33.             src += src_right_delta;
  34.             dst++;
  35.         }
  36.         dst_pos = (Uint16 *)((Uint8 *)dst_pos + dst_linebytes);
  37.         src_pos += src_down_delta;
  38.         height--;
  39.     }
  40. }
其中的#ifdef I80_FB_PATCH 内容就是调整内容,在运行前还在在FB_VideoInit()的最后面加入

#ifdef I80_FB_PATCH
            shadow_fb = 1;//作数据对调
#endif

实测效果不错,原来丢数据显示不清的图像基本显示成功,但效率上会有小的损失,因此现在相当于是两buffer保存同一个图像,在显示前还要做转换。但是在修改很快。因此使用这个方案。







阅读(1620) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~