浏览代码

update dc.c rtgui_driver.c 调整 rtgui_dc_end_drawing 接口

Signed-off-by: yangfasheng <yangfasheng@rt-thread.com>
yangfasheng 7 年之前
父节点
当前提交
de27b413a0
共有 2 个文件被更改,包括 22 次插入8 次删除
  1. 7 4
      src/dc.c
  2. 15 4
      src/rtgui_driver.c

+ 7 - 4
src/dc.c

@@ -1949,11 +1949,14 @@ void rtgui_dc_end_drawing(struct rtgui_dc *dc, rt_bool_t update)
             else
             {
                 /* send to server for window update */
-                struct rtgui_event_update_end eupdate;
-                RTGUI_EVENT_UPDATE_END_INIT(&(eupdate));
-                eupdate.rect = owner->extent;
+                //struct rtgui_event_update_end eupdate;
+                //RTGUI_EVENT_UPDATE_END_INIT(&(eupdate));
+                //eupdate.rect = owner->extent;
 
-                rtgui_server_post_event((struct rtgui_event *)&eupdate, sizeof(eupdate));
+                //rtgui_server_post_event((struct rtgui_event *)&eupdate, sizeof(eupdate));
+
+                /* update screen */
+                rtgui_graphic_driver_screen_update(rtgui_graphic_driver_get_default(), &(owner->extent));
             }
         }
     }

+ 15 - 4
src/rtgui_driver.c

@@ -245,10 +245,21 @@ void rtgui_graphic_driver_screen_update(const struct rtgui_graphic_driver *drive
     {
         struct rt_device_rect_info rect_info;
 
-        rect_info.x = rect->x1;
-        rect_info.y = rect->y1;
-        rect_info.width = rect->x2 - rect->x1;
-        rect_info.height = rect->y2 - rect->y1;
+        if (rect->x1 >= driver->width || rect->y1 >= driver->height)
+            return;
+        
+        if (rect->x2 <= 0 || rect->y2 <= 0)
+            return;
+    
+        rect_info.x = rect->x1 > 0 ? rect->x1 : 0;
+        rect_info.y = rect->y1 > 0 ? rect->y1 : 0;
+        
+        rect_info.width = rect->x2 > driver->width ? driver->width : rect->x2;
+        rect_info.height = rect->y2 > driver->height ? driver->height : rect->y2;
+        
+        rect_info.width -= rect_info.x;
+        rect_info.height -= rect_info.y;
+
         rt_device_control(driver->device, RTGRAPHIC_CTRL_RECT_UPDATE, &rect_info);
     }
 }