summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbernard.xiong <[email protected]>2010-09-14 03:12:30 +0000
committerbernard.xiong <[email protected]>2010-09-14 03:12:30 +0000
commitc89ea7615ea42d07c861b2cf81dca5fe6e1c0543 (patch)
tree21a9fcdce8944cfe74cb4d76c45b5f4bcc278039
parent37b79104128df75d33e6b825095332b1c1de252a (diff)
fix vline and hline coordinate issue
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@911 bbd45198-f89e-11dd-88c7-29a3b14d5316
-rw-r--r--components/rtgui/common/dc_client.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/components/rtgui/common/dc_client.c b/components/rtgui/common/dc_client.c
index 74dedbc712..2e29a17160 100644
--- a/components/rtgui/common/dc_client.c
+++ b/components/rtgui/common/dc_client.c
@@ -13,6 +13,7 @@
* 2010-08-09 Bernard rename hardware dc to client dc
* 2010-09-13 Bernard fix rtgui_dc_client_blit_line issue, which found
* by appele
+ * 2010-09-14 Bernard fix vline and hline coordinate issue
*/
#include <rtgui/dc.h>
#include <rtgui/dc_hw.h>
@@ -41,6 +42,7 @@ static void rtgui_dc_client_get_rect(struct rtgui_dc* dc, rtgui_rect_t* rect);
#define hw_driver (rtgui_graphic_driver_get_default())
#define dc_set_foreground(c) dc->gc.foreground = c
#define dc_set_background(c) dc->gc.background = c
+#define _int_swap(x, y) do {x ^= y; y ^= x; x ^= y;} while (0)
struct rtgui_dc* rtgui_dc_begin_drawing(rtgui_widget_t* owner)
{
@@ -298,6 +300,7 @@ static void rtgui_dc_client_draw_vline(struct rtgui_dc* self, int x, int y1, int
x = x + owner->extent.x1;
y1 = y1 + owner->extent.y1;
y2 = y2 + owner->extent.y1;
+ if (y1 > y2) _int_swap(y1, y2);
if (owner->clip.data == RT_NULL)
{
@@ -353,6 +356,7 @@ static void rtgui_dc_client_draw_hline(struct rtgui_dc* self, int x1, int x2, in
/* convert logic to device */
x1 = x1 + owner->extent.x1;
x2 = x2 + owner->extent.x1;
+ if (x1 > x2) _int_swap(x1, x2);
y = y + owner->extent.y1;
if (owner->clip.data == RT_NULL)
@@ -434,6 +438,7 @@ static void rtgui_dc_client_blit_line (struct rtgui_dc* self, int x1, int x2, in
/* convert logic to device */
x1 = x1 + owner->extent.x1;
x2 = x2 + owner->extent.x1;
+ if (x1 > x2) _int_swap(x1, x2);
y = y + owner->extent.y1;
if (rtgui_region_is_flat(&(owner->clip)) == RT_EOK)
@@ -494,15 +499,11 @@ static rtgui_gc_t* rtgui_dc_client_get_gc(struct rtgui_dc* self)
{
rtgui_widget_t *owner;
- if (self == RT_NULL)
- {
- rt_kprintf("why!!\n");
- return RT_NULL;
- }
+ RT_ASSERT(self != RT_NULL);
/* get owner */
owner = RTGUI_CONTAINER_OF(self, struct rtgui_widget, dc_type);
-
+
return &(owner->gc);
}