diff --git a/components/rtgui/common/dc_buffer.c b/components/rtgui/common/dc_buffer.c index d1c48f213a5a91edf88ed47a10f6092915e86252..eb692dc6478de842fbc741d58523532999ce2785 100644 --- a/components/rtgui/common/dc_buffer.c +++ b/components/rtgui/common/dc_buffer.c @@ -254,7 +254,7 @@ static void rtgui_dc_buffer_blit(struct rtgui_dc* self, struct rtgui_point* dc_p if (dc_point == RT_NULL) dc_point = &rtgui_empty_point; - if (dest->type == RTGUI_DC_HW) + if ((dest->type == RTGUI_DC_HW) || (dest->type == RTGUI_DC_CLIENT)) { rtgui_color_t* pixel; rt_uint8_t *line_ptr; @@ -305,7 +305,7 @@ static void rtgui_dc_buffer_blit(struct rtgui_dc* self, struct rtgui_point* dc_p pixel += dc->width; /* draw on hardware dc */ - rtgui_dc_hw_draw_raw_hline(hw, line_ptr, rect->x1, rect->x1 + rect_width, index); + rtgui_dc_client_draw_raw_hline(hw, line_ptr, rect->x1, rect->x1 + rect_width, index); } /* release line buffer */ diff --git a/components/rtgui/common/dc_client.c b/components/rtgui/common/dc_client.c new file mode 100644 index 0000000000000000000000000000000000000000..6a87cc8af33ffc51776034d38eb554ca9cd3f03a --- /dev/null +++ b/components/rtgui/common/dc_client.c @@ -0,0 +1,517 @@ +/* + * File : dc_client.c + * This file is part of RT-Thread RTOS + * COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rt-thread.org/license/LICENSE + * + * Change Logs: + * Date Author Notes + * 2009-10-16 Bernard first version + * 2010-08-09 Bernard rename hardware dc to client dc + */ +#include +#include +#include +#include +#include +#include +#include +#include + +static void rtgui_dc_client_draw_point(struct rtgui_dc* dc, int x, int y); +static void rtgui_dc_client_draw_color_point(struct rtgui_dc* dc, int x, int y, rtgui_color_t color); +static void rtgui_dc_client_draw_hline(struct rtgui_dc* dc, int x1, int x2, int y); +static void rtgui_dc_client_draw_vline(struct rtgui_dc* dc, int x, int y1, int y2); +static void rtgui_dc_client_fill_rect (struct rtgui_dc* dc, rtgui_rect_t* rect); +static void rtgui_dc_client_blit (struct rtgui_dc* dc, struct rtgui_point* dc_point, struct rtgui_dc* dest, rtgui_rect_t* rect); +static void rtgui_dc_client_set_gc (struct rtgui_dc* dc, rtgui_gc_t *gc); +static rtgui_gc_t *rtgui_dc_client_get_gc (struct rtgui_dc* dc); +static rt_bool_t rtgui_dc_client_fini(struct rtgui_dc* dc); +static rt_bool_t rtgui_dc_client_get_visible(struct rtgui_dc* dc); +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 + +struct rtgui_dc* rtgui_dc_begin_drawing(rtgui_widget_t* owner) +{ + return rtgui_dc_client_create(owner); +} + +void rtgui_dc_end_drawing(struct rtgui_dc* dc) +{ + rtgui_dc_client_fini(dc); +} + +const struct rtgui_dc_engine dc_client_engine = +{ + rtgui_dc_client_draw_point, + rtgui_dc_client_draw_color_point, + rtgui_dc_client_draw_vline, + rtgui_dc_client_draw_hline, + rtgui_dc_client_fill_rect, + rtgui_dc_client_blit, + + rtgui_dc_client_set_gc, + rtgui_dc_client_get_gc, + + rtgui_dc_client_get_visible, + rtgui_dc_client_get_rect, + + rtgui_dc_client_fini, +}; + +void rtgui_dc_client_init(rtgui_widget_t* owner) +{ + struct rtgui_dc* dc; + + RT_ASSERT(owner != RT_NULL); + + dc = RTGUI_WIDGET_DC(owner); + dc->type = RTGUI_DC_CLIENT; + dc->engine = &dc_client_engine; +} + +extern struct rt_mutex cursor_mutex; +extern void rtgui_mouse_show_cursor(void); +extern void rtgui_mouse_hide_cursor(void); +struct rtgui_dc* rtgui_dc_client_create(rtgui_widget_t* owner) +{ + struct rtgui_dc* dc; + rtgui_widget_t* widget; + + /* adjudge owner */ + if (owner == RT_NULL || owner->toplevel == RT_NULL) return RT_NULL; + if (!RTGUI_IS_TOPLEVEL(owner->toplevel)) return RT_NULL; + + dc = RTGUI_WIDGET_DC(owner); + /* set init visible as true */ + RTGUI_WIDGET_DC_SET_VISIBLE(owner); + + /* check widget visible */ + widget = owner; + while (widget != RT_NULL) + { + if (RTGUI_WIDGET_IS_HIDE(widget)) + { + RTGUI_WIDGET_DC_SET_UNVISIBLE(owner); + break; + } + + widget = widget->parent; + } + + if (RTGUI_IS_WINTITLE(owner->toplevel)) + { + rtgui_toplevel_t* top = RTGUI_TOPLEVEL(owner->toplevel); + top->drawing ++; + + if (top->drawing == 1) + { +#ifdef RTGUI_USING_MOUSE_CURSOR +#ifdef __WIN32__ + rt_mutex_take(&cursor_mutex, RT_WAITING_FOREVER); + rt_kprintf("hide cursor\n"); + rtgui_mouse_hide_cursor(); +#else + /* hide cursor */ + rtgui_mouse_hide_cursor(); +#endif +#endif + } + } + else if (RTGUI_IS_WORKBENCH(owner->toplevel) || + RTGUI_IS_WIN(owner->toplevel)) + { + rtgui_toplevel_t* top = RTGUI_TOPLEVEL(owner->toplevel); + top->drawing ++; + + if (top->drawing == 1) + { +#ifdef __WIN32__ +#ifdef RTGUI_USING_MOUSE_CURSOR + rt_mutex_take(&cursor_mutex, RT_WAITING_FOREVER); + rt_kprintf("hide cursor\n"); + rtgui_mouse_hide_cursor(); +#endif +#else + /* send draw begin to server */ + struct rtgui_event_update_begin eupdate; + RTGUI_EVENT_UPDATE_BEGIN_INIT(&(eupdate)); + eupdate.rect = RTGUI_WIDGET(top)->extent; + + rtgui_thread_send(top->server, (struct rtgui_event*)&eupdate, sizeof(eupdate)); +#endif + } + } + + return dc; +} + +static rt_bool_t rtgui_dc_client_fini(struct rtgui_dc* dc) +{ + rtgui_widget_t* owner; + + if (dc == RT_NULL || dc->type != RTGUI_DC_CLIENT) return RT_FALSE; + + /* get owner */ + owner = RTGUI_CONTAINER_OF(dc, struct rtgui_widget, dc_type); + + if (RTGUI_IS_WINTITLE(owner->toplevel)) + { + /* update title extent */ + rtgui_toplevel_t* top = RTGUI_TOPLEVEL(owner->toplevel); + + top->drawing --; + if ((top->drawing == 0) && RTGUI_WIDGET_IS_DC_VISIBLE(owner)) + { +#ifdef __WIN32__ +#ifdef RTGUI_USING_MOUSE_CURSOR + rt_mutex_release(&cursor_mutex); + /* show cursor */ + rtgui_mouse_show_cursor(); + rt_kprintf("show cursor\n"); +#endif + /* update screen */ + hw_driver->screen_update(&(owner->extent)); +#else +#ifdef RTGUI_USING_MOUSE_CURSOR + /* show cursor */ + rtgui_mouse_show_cursor(); +#endif + + /* update screen */ + hw_driver->screen_update(&(owner->extent)); +#endif + } + } + else if (RTGUI_IS_WORKBENCH(owner->toplevel) || + RTGUI_IS_WIN(owner->toplevel)) + { + rtgui_toplevel_t* top = RTGUI_TOPLEVEL(owner->toplevel); + top->drawing --; + + if ((top->drawing == 0) && RTGUI_WIDGET_IS_DC_VISIBLE(owner)) + { +#ifdef __WIN32__ +#ifdef RTGUI_USING_MOUSE_CURSOR + rt_mutex_release(&cursor_mutex); + /* show cursor */ + rtgui_mouse_show_cursor(); + rt_kprintf("show cursor\n"); +#endif + /* update screen */ + hw_driver->screen_update(&(owner->extent)); +#else + /* send to server to end drawing */ + struct rtgui_event_update_end eupdate; + RTGUI_EVENT_UPDATE_END_INIT(&(eupdate)); + eupdate.rect = owner->extent; + + rtgui_thread_send(top->server, (struct rtgui_event*)&eupdate, sizeof(eupdate)); +#endif + } + } + + return RT_TRUE; +} + +/* + * draw a logic point on device + */ +static void rtgui_dc_client_draw_point(struct rtgui_dc* self, int x, int y) +{ + rtgui_rect_t rect; + rtgui_widget_t *owner; + + if (self == RT_NULL) return; + + /* get owner */ + owner = RTGUI_CONTAINER_OF(self, struct rtgui_widget, dc_type); + if (!RTGUI_WIDGET_IS_DC_VISIBLE(owner)) return; + + + x = x + owner->extent.x1; + y = y + owner->extent.y1; + + if (rtgui_region_contains_point(&(owner->clip), x, y, &rect) == RT_EOK) + { + /* draw this point */ + hw_driver->set_pixel(&(owner->gc.foreground), x, y); + } +} + +static void rtgui_dc_client_draw_color_point(struct rtgui_dc* self, int x, int y, rtgui_color_t color) +{ + rtgui_rect_t rect; + rtgui_widget_t *owner; + + if (self == RT_NULL) return; + + /* get owner */ + owner = RTGUI_CONTAINER_OF(self, struct rtgui_widget, dc_type); + if (!RTGUI_WIDGET_IS_DC_VISIBLE(owner)) return; + + x = x + owner->extent.x1; + y = y + owner->extent.y1; + + if (rtgui_region_contains_point(&(owner->clip), x, y, &rect) == RT_EOK) + { + /* draw this point */ + hw_driver->set_pixel(&color, x, y); + } +} + +/* + * draw a logic vertical line on device + */ +static void rtgui_dc_client_draw_vline(struct rtgui_dc* self, int x, int y1, int y2) +{ + register rt_base_t index; + rtgui_widget_t *owner; + + if (self == RT_NULL) return; + + /* get owner */ + owner = RTGUI_CONTAINER_OF(self, struct rtgui_widget, dc_type); + if (!RTGUI_WIDGET_IS_DC_VISIBLE(owner)) return; + + x = x + owner->extent.x1; + y1 = y1 + owner->extent.y1; + y2 = y2 + owner->extent.y1; + + if (owner->clip.data == RT_NULL) + { + rtgui_rect_t* prect; + + prect = &(owner->clip.extents); + + /* calculate vline intersect */ + if (prect->x1 > x || prect->x2 <= x) return; + if (prect->y2 <= y1 || prect->y1 > y2) return; + + if (prect->y1 > y1) y1 = prect->y1; + if (prect->y2 < y2) y2 = prect->y2; + + /* draw vline */ + hw_driver->draw_vline(&(owner->gc.foreground), x, y1, y2); + } + else for (index = 0; index < rtgui_region_num_rects(&(owner->clip)); index ++) + { + rtgui_rect_t* prect; + register rt_base_t draw_y1, draw_y2; + + prect = ((rtgui_rect_t *)(owner->clip.data + index + 1)); + draw_y1 = y1; + draw_y2 = y2; + + /* calculate vline clip */ + if (prect->x1 > x || prect->x2 <= x) continue; + if (prect->y2 <= y1 || prect->y1 > y2) continue; + + if (prect->y1 > y1) draw_y1 = prect->y1; + if (prect->y2 < y2) draw_y2 = prect->y2; + + /* draw vline */ + hw_driver->draw_vline(&(owner->gc.foreground), x, draw_y1, draw_y2); + } +} + +/* + * draw a logic horizontal line on device + */ +static void rtgui_dc_client_draw_hline(struct rtgui_dc* self, int x1, int x2, int y) +{ + register rt_base_t index; + rtgui_widget_t *owner; + + if (self == RT_NULL) return; + + /* get owner */ + owner = RTGUI_CONTAINER_OF(self, struct rtgui_widget, dc_type); + if (!RTGUI_WIDGET_IS_DC_VISIBLE(owner)) return; + + /* convert logic to device */ + x1 = x1 + owner->extent.x1; + x2 = x2 + owner->extent.x1; + y = y + owner->extent.y1; + + if (owner->clip.data == RT_NULL) + { + rtgui_rect_t* prect; + + prect = &(owner->clip.extents); + + /* calculate vline intersect */ + if (prect->y1 > y || prect->y2 <= y ) return; + if (prect->x2 <= x1 || prect->x1 > x2) return; + + if (prect->x1 > x1) x1 = prect->x1; + if (prect->x2 < x2) x2 = prect->x2; + + /* draw hline */ + hw_driver->draw_hline(&(owner->gc.foreground), x1, x2, y); + } + else for (index = 0; index < rtgui_region_num_rects(&(owner->clip)); index ++) + { + rtgui_rect_t* prect; + register rt_base_t draw_x1, draw_x2; + + prect = ((rtgui_rect_t *)(owner->clip.data + index + 1)); + draw_x1 = x1; + draw_x2 = x2; + + /* calculate hline clip */ + if (prect->y1 > y || prect->y2 <= y ) continue; + if (prect->x2 <= x1 || prect->x1 > x2) continue; + + if (prect->x1 > x1) draw_x1 = prect->x1; + if (prect->x2 < x2) draw_x2 = prect->x2; + + /* draw hline */ + hw_driver->draw_hline(&(owner->gc.foreground), draw_x1, draw_x2, y); + } +} + +static void rtgui_dc_client_fill_rect (struct rtgui_dc* self, struct rtgui_rect* rect) +{ + rtgui_color_t foreground; + register rt_base_t index; + rtgui_widget_t *owner; + + if (self == RT_NULL) return; + + /* get owner */ + owner = RTGUI_CONTAINER_OF(self, struct rtgui_widget, dc_type); + if (!RTGUI_WIDGET_IS_DC_VISIBLE(owner)) return; + + /* save foreground color */ + foreground = owner->gc.foreground; + + /* set background color as foreground color */ + owner->gc.foreground = owner->gc.background; + + /* fill rect */ + for (index = rect->y1; index < rect->y2; index ++) + { + rtgui_dc_client_draw_hline(self, rect->x1, rect->x2, index); + } + + /* restore foreground color */ + owner->gc.foreground = foreground; +} + +static void rtgui_dc_client_blit(struct rtgui_dc* dc, struct rtgui_point* dc_point, struct rtgui_dc* dest, rtgui_rect_t* rect) +{ + /* not blit in hardware dc */ + return ; +} + +static void rtgui_dc_client_set_gc(struct rtgui_dc* self, rtgui_gc_t *gc) +{ + rtgui_widget_t *owner; + + if (self == RT_NULL) return; + + /* get owner */ + owner = RTGUI_CONTAINER_OF(self, struct rtgui_widget, dc_type); + owner->gc = *gc; +} + +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; + } + + /* get owner */ + owner = RTGUI_CONTAINER_OF(self, struct rtgui_widget, dc_type); + + return &(owner->gc); +} + +static rt_bool_t rtgui_dc_client_get_visible(struct rtgui_dc* self) +{ + rtgui_widget_t *owner; + + if (self == RT_NULL) return RT_FALSE; + + /* get owner */ + owner = RTGUI_CONTAINER_OF(self, struct rtgui_widget, dc_type); + if (!RTGUI_WIDGET_IS_DC_VISIBLE(owner)) return RT_FALSE; + + return RT_TRUE; +} + +static void rtgui_dc_client_get_rect(struct rtgui_dc* self, rtgui_rect_t* rect) +{ + rtgui_widget_t *owner; + + if (self == RT_NULL) return; + + /* get owner */ + owner = RTGUI_CONTAINER_OF(self, struct rtgui_widget, dc_type); + rtgui_widget_get_rect(owner, rect); +} + +void rtgui_dc_client_draw_raw_hline(struct rtgui_dc* self, rt_uint8_t* raw_ptr, int x1, int x2, int y) +{ + register rt_base_t index; + rtgui_widget_t *owner; + + if (self == RT_NULL) return; + + /* get owner */ + owner = RTGUI_CONTAINER_OF(self, struct rtgui_widget, dc_type); + if (!RTGUI_WIDGET_IS_DC_VISIBLE(owner)) return; + + /* convert logic to device */ + x1 = x1 + owner->extent.x1; + x2 = x2 + owner->extent.x1; + y = y + owner->extent.y1; + + if (owner->clip.data == RT_NULL) + { + rtgui_rect_t* prect; + + prect = &(owner->clip.extents); + + /* calculate hline intersect */ + if (prect->y1 > y || prect->y2 <= y ) return; + if (prect->x2 <= x1 || prect->x1 > x2) return; + + if (prect->x1 > x1) x1 = prect->x1; + if (prect->x2 < x2) x2 = prect->x2; + + /* draw raw hline */ + hw_driver->draw_raw_hline(raw_ptr, x1, x2, y); + } + else for (index = 0; index < rtgui_region_num_rects(&(owner->clip)); index ++) + { + rtgui_rect_t* prect; + register rt_base_t draw_x1, draw_x2; + + prect = ((rtgui_rect_t *)(owner->clip.data + index + 1)); + draw_x1 = x1; + draw_x2 = x2; + + /* calculate hline clip */ + if (prect->y1 > y || prect->y2 <= y ) continue; + if (prect->x2 <= x1 || prect->x1 > x2) continue; + + if (prect->x1 > x1) draw_x1 = prect->x1; + if (prect->x2 < x2) draw_x2 = prect->x2; + + /* draw raw hline */ + hw_driver->draw_raw_hline(raw_ptr + (draw_x1 - x1) * hw_driver->byte_per_pixel, draw_x1, draw_x2, y); + } +} + diff --git a/components/rtgui/common/dc_hw.c b/components/rtgui/common/dc_hw.c index 49bc3c60a6bf78fb3f91e347bfe4977cd603bf05..f403daecd9ef06a373c6db10bb9a3616b80fc0e9 100644 --- a/components/rtgui/common/dc_hw.c +++ b/components/rtgui/common/dc_hw.c @@ -36,16 +36,6 @@ static void rtgui_dc_hw_get_rect(struct rtgui_dc* dc, rtgui_rect_t* rect); #define dc_set_foreground(c) dc->gc.foreground = c #define dc_set_background(c) dc->gc.background = c -struct rtgui_dc* rtgui_dc_begin_drawing(rtgui_widget_t* owner) -{ - return rtgui_dc_hw_create(owner); -} - -void rtgui_dc_end_drawing(struct rtgui_dc* dc) -{ - rtgui_dc_hw_fini(dc); -} - const struct rtgui_dc_engine dc_hw_engine = { rtgui_dc_hw_draw_point, @@ -64,17 +54,6 @@ const struct rtgui_dc_engine dc_hw_engine = rtgui_dc_hw_fini, }; -void rtgui_dc_hw_init(rtgui_widget_t* owner) -{ - struct rtgui_dc* dc; - - RT_ASSERT(owner != RT_NULL); - - dc = RTGUI_WIDGET_DC(owner); - dc->type = RTGUI_DC_HW; - dc->engine = &dc_hw_engine; -} - extern struct rt_mutex cursor_mutex; extern void rtgui_mouse_show_cursor(void); extern void rtgui_mouse_hide_cursor(void); @@ -233,7 +212,6 @@ static void rtgui_dc_hw_draw_point(struct rtgui_dc* self, int x, int y) owner = RTGUI_CONTAINER_OF(self, struct rtgui_widget, dc_type); if (!RTGUI_WIDGET_IS_DC_VISIBLE(owner)) return; - x = x + owner->extent.x1; y = y + owner->extent.y1; diff --git a/components/rtgui/common/image_hdc.c b/components/rtgui/common/image_hdc.c index 79870b77ba8ab8276145cbcc8dbe5510ad262cea..70b4c0a17870a3ebf3d8bc95bd539e4177fc64aa 100644 --- a/components/rtgui/common/image_hdc.c +++ b/components/rtgui/common/image_hdc.c @@ -155,7 +155,7 @@ static void rtgui_image_hdc_blit(struct rtgui_image* image, struct rtgui_dc* dc, hdc = (struct rtgui_image_hdc*) image->data; RT_ASSERT(hdc != RT_NULL); - if (dc->type != RTGUI_DC_HW) return; + if ((dc->type != RTGUI_DC_HW) || (dc->type != RTGUI_DC_CLIENT)) return; /* the minimum rect */ if (image->w < rtgui_rect_width(*dst_rect)) w = image->w; @@ -172,7 +172,7 @@ static void rtgui_image_hdc_blit(struct rtgui_image* image, struct rtgui_dc* dc, for (y = 0; y < h; y ++) { - rtgui_dc_hw_draw_raw_hline(dc, ptr, dst_rect->x1, dst_rect->x1 + w, dst_rect->y1 + y); + rtgui_dc_client_draw_raw_hline(dc, ptr, dst_rect->x1, dst_rect->x1 + w, dst_rect->y1 + y); ptr += hdc->pitch; } } @@ -191,7 +191,7 @@ static void rtgui_image_hdc_blit(struct rtgui_image* image, struct rtgui_dc* dc, if (rtgui_filerw_read(hdc->filerw, ptr, 1, hdc->pitch) != hdc->pitch) break; /* read data failed */ - rtgui_dc_hw_draw_raw_hline(dc, ptr, dst_rect->x1, dst_rect->x1 + w, dst_rect->y1 + y); + rtgui_dc_client_draw_raw_hline(dc, ptr, dst_rect->x1, dst_rect->x1 + w, dst_rect->y1 + y); } rtgui_free(ptr); @@ -207,7 +207,7 @@ static void rtgui_image_hdcmm_blit(struct rtgui_image* image, struct rtgui_dc* d RT_ASSERT(image != RT_NULL || dc != RT_NULL || dst_rect != RT_NULL); /* this dc is not visible */ - if (rtgui_dc_get_visible(dc) != RT_TRUE || (dc->type != RTGUI_DC_HW)) return; + if (rtgui_dc_get_visible(dc) != RT_TRUE || (dc->type != RTGUI_DC_HW) || (dc->type != RTGUI_DC_CLIENT)) return; hdc = (struct rtgui_image_hdcmm*) image; RT_ASSERT(hdc != RT_NULL); @@ -224,7 +224,7 @@ static void rtgui_image_hdcmm_blit(struct rtgui_image* image, struct rtgui_dc* d for (y = 0; y < h; y ++) { - rtgui_dc_hw_draw_raw_hline(dc, ptr, dst_rect->x1, dst_rect->x1 + w, dst_rect->y1 + y); + rtgui_dc_client_draw_raw_hline(dc, ptr, dst_rect->x1, dst_rect->x1 + w, dst_rect->y1 + y); ptr += hdc->pitch; } } diff --git a/components/rtgui/include/rtgui/dc.h b/components/rtgui/include/rtgui/dc.h index 5f442b27aee933ed455f5adc6d564628fa339116..3b5fe1d36e74c43041d39ffc04f711ea0384a627 100644 --- a/components/rtgui/include/rtgui/dc.h +++ b/components/rtgui/include/rtgui/dc.h @@ -22,6 +22,7 @@ enum rtgui_dc_type { RTGUI_DC_HW, + RTGUI_DC_CLIENT, RTGUI_DC_BUFFER, RTGUI_DC_IMLIB2, }; diff --git a/components/rtgui/include/rtgui/dc_client.h b/components/rtgui/include/rtgui/dc_client.h new file mode 100644 index 0000000000000000000000000000000000000000..b12f59538e9c19af569d71eca371a7d9925dd1f7 --- /dev/null +++ b/components/rtgui/include/rtgui/dc_client.h @@ -0,0 +1,30 @@ +/* + * File : dc_buffer.h + * This file is part of RT-Thread RTOS + * COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rt-thread.org/license/LICENSE + * + * Change Logs: + * Date Author Notes + * 2010-04-10 Bernard first version + * 2010-06-14 Bernard embedded hardware dc to each widget + * 2010-08-09 Bernard rename hardware dc to client dc + */ + +#ifndef __RTGUI_DC_CLIENT_H__ +#define __RTGUI_DC_CLIENT_H__ + +#include + +/* create a hardware dc */ +struct rtgui_dc* rtgui_dc_client_create(rtgui_widget_t* owner); +void rtgui_dc_client_init(rtgui_widget_t* owner); + +/* draw a hline with raw pixel data */ +void rtgui_dc_client_draw_raw_hline(struct rtgui_dc* dc, rt_uint8_t* raw_ptr, int x1, int x2, int y); + +#endif + diff --git a/components/rtgui/include/rtgui/dc_hw.h b/components/rtgui/include/rtgui/dc_hw.h index 7b6e7b5b2020ea28995a28225db2711d3897062c..c313373aecc97ba036e4aa5d9331de6776501b6f 100644 --- a/components/rtgui/include/rtgui/dc_hw.h +++ b/components/rtgui/include/rtgui/dc_hw.h @@ -19,7 +19,6 @@ /* create a hardware dc */ struct rtgui_dc* rtgui_dc_hw_create(rtgui_widget_t* owner); -void rtgui_dc_hw_init(rtgui_widget_t* owner); /* draw a hline with raw pixel data */ void rtgui_dc_hw_draw_raw_hline(struct rtgui_dc* dc, rt_uint8_t* raw_ptr, int x1, int x2, int y); diff --git a/components/rtgui/widgets/widget.c b/components/rtgui/widgets/widget.c index 6f6747ebcf793ed7e7ba23fbe9d599a02086287b..e0460872879805cfe973078d5592336e2563ac2b 100644 --- a/components/rtgui/widgets/widget.c +++ b/components/rtgui/widgets/widget.c @@ -13,7 +13,7 @@ * 2010-06-26 Bernard add user_data to widget structure */ -#include +#include #include #include #include @@ -63,7 +63,7 @@ static void _rtgui_widget_constructor(rtgui_widget_t *widget) rtgui_region_init(&(widget->clip)); /* init hardware dc */ - rtgui_dc_hw_init(widget); + rtgui_dc_client_init(widget); } /* Destroys the widget */