Ver código fonte

update:lcd_draw改成默认行拷贝,减少拷贝次数

alienwalker 1 ano atrás
pai
commit
bb4e815ff5
1 arquivos alterados com 24 adições e 0 exclusões
  1. 24 0
      components/lcd/luat_lcd.c

+ 24 - 0
components/lcd/luat_lcd.c

@@ -372,6 +372,7 @@ int luat_lcd_draw_default(luat_lcd_conf_t* conf, int16_t x1, int16_t y1, int16_t
         return 0;
     }
     // buff模式
+#if 0
     int16_t x_end = x2 >= conf->w?  (conf->w - 1):x2;
     luat_color_t* dst = (conf->buff);
     size_t lsize = (x2 - x1 + 1);
@@ -396,6 +397,29 @@ int luat_lcd_draw_default(luat_lcd_conf_t* conf, int16_t x1, int16_t y1, int16_t
     if (y2 > conf->flush_y_max) {
         conf->flush_y_max = y2;
     }
+#endif
+    //LLOGI("X1 %d Y1 %d X2 %d Y2 %d", x1, y1, x2, y2);
+    int16_t x_end = (x2 >= conf->w)?(conf->w - 1):x2;
+    int16_t y_end = (y2 >= conf->h)?(conf->h - 1):y2;
+    luat_color_t* dst = (conf->buff);
+    size_t fromlsize = (x2 - x1 + 1);
+    size_t tolsize = (x_end - x1 + 1);
+    for (int16_t y = y1; y <= y_end; y++)
+    {
+        if (y < 0) continue;
+        //LLOGI("H%d L %d <- %d X2 %d Y2 %d", y, conf->w * y + x1, fromlsize * (y - y1));
+    	memcpy(&dst[(conf->w * y + x1)], &color[fromlsize * (y - y1)], tolsize * sizeof(luat_color_t));
+    }
+    // 存储需要刷新的区域
+    if (y1 < conf->flush_y_min) {
+        if (y1 >= 0)
+            conf->flush_y_min = y1;
+        else
+            conf->flush_y_min = 0;
+    }
+    if (y_end > conf->flush_y_max) {
+        conf->flush_y_max = y_end;
+    }
     return 0;
 }