From 54089722c3cb29539e2706f01db5162316eb6542 Mon Sep 17 00:00:00 2001 From: "bernard.xiong@gmail.com" Date: Sun, 22 Aug 2010 13:12:22 +0000 Subject: [PATCH] fix hardware DC object creation issue in rtgui_dc_begin_drawing function. git-svn-id: https://rt-thread.googlecode.com/svn/trunk@874 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- components/rtgui/common/dc_client.c | 3 ++- components/rtgui/common/font_freetype.c | 2 ++ components/rtgui/common/region.c | 11 +++++++++++ components/rtgui/include/rtgui/region.h | 1 + 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/components/rtgui/common/dc_client.c b/components/rtgui/common/dc_client.c index 2fa527069e..6dcf3181c0 100644 --- a/components/rtgui/common/dc_client.c +++ b/components/rtgui/common/dc_client.c @@ -42,7 +42,8 @@ static void rtgui_dc_client_get_rect(struct rtgui_dc* dc, rtgui_rect_t* rect); struct rtgui_dc* rtgui_dc_begin_drawing(rtgui_widget_t* owner) { - if (rtgui_region_is_flat(&owner->clip) == RT_EOK) + if ((rtgui_region_is_flat(&owner->clip) == RT_EOK) && + rtgui_rect_is_equal(&(owner->extent), &(owner->clip.extents)) == RT_EOK) { /* use hardware DC */ return rtgui_dc_hw_create(owner); diff --git a/components/rtgui/common/font_freetype.c b/components/rtgui/common/font_freetype.c index 906e986227..48db47d7c6 100644 --- a/components/rtgui/common/font_freetype.c +++ b/components/rtgui/common/font_freetype.c @@ -1,3 +1,4 @@ +#ifdef RTGUI_USING_TTF #include #include #include @@ -199,3 +200,4 @@ void rtgui_freetype_font_destroy(rtgui_font_t* font) rtgui_free(freetype); rtgui_free(font); } +#endif diff --git a/components/rtgui/common/region.c b/components/rtgui/common/region.c index 9fee345e1f..bcb8bacb2e 100644 --- a/components/rtgui/common/region.c +++ b/components/rtgui/common/region.c @@ -2239,3 +2239,14 @@ int rtgui_rect_is_intersect(const rtgui_rect_t *rect1, const rtgui_rect_t *rect2 return -RT_ERROR; } + +int rtgui_rect_is_equal(const rtgui_rect_t *rect1, const rtgui_rect_t *rect2) +{ + if (*((rt_uint32_t*)(rect1)) == *((rt_uint32_t*)(rect2)) && + *(((rt_uint32_t*)(rect1)) + 1) == *(((rt_uint32_t*)(rect2)) + 1)) + { + return RT_EOK; + } + + return -RT_ERROR; +} diff --git a/components/rtgui/include/rtgui/region.h b/components/rtgui/include/rtgui/region.h index 38d50a1f85..5a2362892c 100644 --- a/components/rtgui/include/rtgui/region.h +++ b/components/rtgui/include/rtgui/region.h @@ -93,6 +93,7 @@ void rtgui_rect_inflate(rtgui_rect_t *rect, int d); void rtgui_rect_intersect(rtgui_rect_t *src, rtgui_rect_t *dest); int rtgui_rect_contains_point(const rtgui_rect_t *rect, int x, int y); int rtgui_rect_is_intersect(const rtgui_rect_t *rect1, const rtgui_rect_t *rect2); +int rtgui_rect_is_equal(const rtgui_rect_t *rect1, const rtgui_rect_t *rect2); #if defined(__cplusplus) || defined(c_plusplus) } -- GitLab