diff options
| author | [email protected] <[email protected]> | 2010-05-30 22:44:21 +0000 |
|---|---|---|
| committer | [email protected] <[email protected]> | 2010-05-30 22:44:21 +0000 |
| commit | a1ee019309d171f9dc641c7ef09d545a49edc1a1 (patch) | |
| tree | 34f73bfd97dc5ae77372275f28d653a81297a1b2 /components/rtgui/common | |
| parent | ea6e5155ef903c6353d8f317dd73b3838658c971 (diff) | |
move the basic routine of dc to inline; add hdc memory image type; move event buffer from stack to gui thread structure.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@755 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'components/rtgui/common')
| -rw-r--r-- | components/rtgui/common/dc.c | 130 | ||||
| -rw-r--r-- | components/rtgui/common/font_hz_file.c | 2 | ||||
| -rw-r--r-- | components/rtgui/common/image_hdc.c | 2 | ||||
| -rw-r--r-- | components/rtgui/common/region.c | 4 | ||||
| -rw-r--r-- | components/rtgui/common/rtgui_system.c | 31 | ||||
| -rw-r--r-- | components/rtgui/common/rtgui_theme.c | 4 |
6 files changed, 36 insertions, 137 deletions
diff --git a/components/rtgui/common/dc.c b/components/rtgui/common/dc.c index 652e6b7fd7..681d2b242b 100644 --- a/components/rtgui/common/dc.c +++ b/components/rtgui/common/dc.c @@ -31,46 +31,6 @@ void rtgui_dc_destory(struct rtgui_dc* dc) rtgui_free(dc); } -/* - * draw a point on dc - */ -void rtgui_dc_draw_point(struct rtgui_dc* dc, int x, int y) -{ - if (dc == RT_NULL) return; - - dc->draw_point(dc, x, y); -} - -/* - * draw a color point on dc - */ -void rtgui_dc_draw_color_point(struct rtgui_dc* dc, int x, int y, rtgui_color_t color) -{ - if (dc == RT_NULL) return; - - dc->draw_color_point(dc, x, y, color); -} - -/* - * draw a vertical line on dc - */ -void rtgui_dc_draw_vline(struct rtgui_dc* dc, int x, int y1, int y2) -{ - if (dc == RT_NULL) return; - - dc->draw_vline(dc, x, y1, y2); -} - -/* - * draw a horizontal line on dc - */ -void rtgui_dc_draw_hline(struct rtgui_dc* dc, int x1, int x2, int y) -{ - if (dc == RT_NULL) return; - - dc->draw_hline(dc, x1, x2, y); -} - void rtgui_dc_draw_line (struct rtgui_dc* dc, int x1, int y1, int x2, int y2) { if (dc == RT_NULL) return; @@ -163,20 +123,6 @@ void rtgui_dc_draw_round_rect(struct rtgui_dc* dc, struct rtgui_rect* rect) rtgui_dc_draw_vline(dc, rect->x2, rect->y1 + r, rect->y2 - r); } -void rtgui_dc_fill_rect (struct rtgui_dc* dc, struct rtgui_rect* rect) -{ - if (dc == RT_NULL) return; - - dc->fill_rect(dc, rect); -} - -void rtgui_dc_blit(struct rtgui_dc* dc, struct rtgui_point* dc_point, struct rtgui_dc* dest, rtgui_rect_t* rect) -{ - if (dc == RT_NULL || dest == RT_NULL || rect == RT_NULL) return; - - dc->blit(dc, dc_point, dest, rect); -} - void rtgui_dc_draw_text (struct rtgui_dc* dc, const char* text, struct rtgui_rect* rect) { rt_uint32_t len; @@ -236,67 +182,33 @@ void rtgui_dc_draw_text (struct rtgui_dc* dc, const char* text, struct rtgui_rec #endif } -void rtgui_dc_draw_byte(struct rtgui_dc*dc, int x, int y, int h, const rt_uint8_t* data) -{ - int i, k; - - /* draw byte */ - for (i=0; i < h; i ++) - { - for (k=0; k < 8; k++) - { - if (((data[i] >> (7-k)) & 0x01) != 0) - { - rtgui_dc_draw_point(dc, x + k, y + i); - } - } - } -} - -void rtgui_dc_draw_word(struct rtgui_dc*dc, int x, int y, int h, const rt_uint8_t* data) +/* + * draw a monochrome color bitmap data + */ +void rtgui_dc_draw_mono_bmp(struct rtgui_dc* dc, int x, int y, int w, int h, const rt_uint8_t* data) { + int word_bytes; int i, j, k; - /* draw word */ - for (i=0; i < h; i ++) - { - for (j=0; j < 2; j++) - for (k=0; k < 8; k++) - { - if (((data[i * 2 + j] >> (7-k)) & 0x01) != 0) - { - rtgui_dc_draw_point(dc, x + 8*j + k, y + i); - } - } - } -} + /* get word bytes */ + word_bytes = (w + 7)/8; -void rtgui_dc_set_gc(struct rtgui_dc* dc, rtgui_gc_t* gc) -{ - if (dc != RT_NULL) - { - dc->set_gc(dc, gc); - } + /* draw mono bitmap data */ + for (i = 0; i < h; i ++) + for (j = 0; j < word_bytes; j++) + for (k = 0; k < 8; k++) + if ( ((data[i*2 + j] >> (7-k)) & 0x01) != 0) + rtgui_dc_draw_point(dc, x + 8*j + k, y + i); } -rtgui_gc_t *rtgui_dc_get_gc(struct rtgui_dc* dc) +void rtgui_dc_draw_byte(struct rtgui_dc*dc, int x, int y, int h, const rt_uint8_t* data) { - if (dc != RT_NULL) - { - return dc->get_gc(dc); - } - - return RT_NULL; + rtgui_dc_draw_mono_bmp(dc, x, y, 8, h, data); } -rt_bool_t rtgui_dc_get_visible(struct rtgui_dc* dc) +void rtgui_dc_draw_word(struct rtgui_dc*dc, int x, int y, int h, const rt_uint8_t* data) { - if (dc != RT_NULL) - { - return dc->get_visible(dc); - } - - return RT_FALSE; + rtgui_dc_draw_mono_bmp(dc, x, y, 16, h, data); } void rtgui_dc_draw_shaded_rect(struct rtgui_dc* dc, rtgui_rect_t* rect, @@ -1295,11 +1207,3 @@ void rtgui_dc_draw_focus_rect(struct rtgui_dc* dc, rtgui_rect_t* rect) rtgui_dc_draw_point(dc, rect->x2, i); } } - -void rtgui_dc_get_rect(struct rtgui_dc*dc, rtgui_rect_t* rect) -{ - if (dc != RT_NULL && rect != RT_NULL) - { - dc->get_rect(dc, rect); - } -} diff --git a/components/rtgui/common/font_hz_file.c b/components/rtgui/common/font_hz_file.c index 9a4b6380cb..03b41f02a1 100644 --- a/components/rtgui/common/font_hz_file.c +++ b/components/rtgui/common/font_hz_file.c @@ -116,7 +116,7 @@ static void rtgui_hz_file_font_draw_text(struct rtgui_font* font, struct rtgui_d /* draw word */ for (i=0; i < h; i ++) { - for (j=0; j < 2; j++) + for (j=0; j < word_bytes; j++) for (k=0; k < 8; k++) { if ( ((font_ptr[i*2 + j] >> (7-k)) & 0x01) != 0 && diff --git a/components/rtgui/common/image_hdc.c b/components/rtgui/common/image_hdc.c index 56bf614aa5..a9d8bcc744 100644 --- a/components/rtgui/common/image_hdc.c +++ b/components/rtgui/common/image_hdc.c @@ -37,7 +37,7 @@ struct rtgui_image_engine rtgui_image_hdc_engine = rtgui_image_hdc_blit }; -struct rtgui_image_engine rtgui_image_hdcmm_engine = +const struct rtgui_image_engine rtgui_image_hdcmm_engine = { "hdcmm", {RT_NULL}, diff --git a/components/rtgui/common/region.c b/components/rtgui/common/region.c index cb6191a570..42ac6cd121 100644 --- a/components/rtgui/common/region.c +++ b/components/rtgui/common/region.c @@ -2202,14 +2202,14 @@ void rtgui_rect_intersect(rtgui_rect_t *src, rtgui_rect_t *dest) if (dest->y2 > src->y2) dest->y2 = src->y2; } -int rtgui_rect_contains_point(rtgui_rect_t *rect, int x, int y) +int rtgui_rect_contains_point(const rtgui_rect_t *rect, int x, int y) { if (INBOX(rect, x, y)) return RT_EOK; return -RT_ERROR; } -int rtgui_rect_is_intersect(rtgui_rect_t *rect1, rtgui_rect_t *rect2) +int rtgui_rect_is_intersect(const rtgui_rect_t *rect1, const rtgui_rect_t *rect2) { if (INBOX(rect1, rect2->x1, rect2->y1) || INBOX(rect1, rect2->x1, rect2->y2) || diff --git a/components/rtgui/common/rtgui_system.c b/components/rtgui/common/rtgui_system.c index dc5df0c1f2..df438ab5ee 100644 --- a/components/rtgui/common/rtgui_system.c +++ b/components/rtgui/common/rtgui_system.c @@ -29,9 +29,6 @@ void rtgui_system_server_init() { - /* init rtgui_thread */ - rtgui_thread_system_init(); - /* init image */ rtgui_system_image_init(); /* init font */ @@ -276,13 +273,6 @@ static void rtgui_event_dump(rt_thread_t tid, rtgui_event_t* event) #define rtgui_event_dump(tid, event) #endif -struct rt_semaphore _rtgui_thread_hash_semaphore; - -void rtgui_thread_system_init() -{ - rt_sem_init(&_rtgui_thread_hash_semaphore, "rtgui", 1, RT_IPC_FLAG_FIFO); -} - rtgui_thread_t* rtgui_thread_register(rt_thread_t tid, rt_mq_t mq) { rtgui_thread_t* thread = rtgui_malloc(sizeof(struct rtgui_thread)); @@ -296,12 +286,8 @@ rtgui_thread_t* rtgui_thread_register(rt_thread_t tid, rt_mq_t mq) thread->mq = mq; thread->widget = RT_NULL; - /* take semaphore */ - rt_sem_take(&_rtgui_thread_hash_semaphore, RT_WAITING_FOREVER); /* set user thread */ tid->user_data = (rt_uint32_t)thread; - /* release semaphore */ - rt_sem_release(&_rtgui_thread_hash_semaphore); } return thread; @@ -316,18 +302,27 @@ void rtgui_thread_deregister(rt_thread_t tid) if (thread != RT_NULL) { - /* take semaphore */ - rt_sem_take(&_rtgui_thread_hash_semaphore, RT_WAITING_FOREVER); /* remove rtgui_thread */ tid->user_data = 0; - /* release semaphore */ - rt_sem_release(&_rtgui_thread_hash_semaphore); /* free rtgui_thread */ rtgui_free(thread); } } +/* get current gui thread */ +rtgui_thread_t* rtgui_thread_self() +{ + struct rtgui_thread* thread; + rt_thread_t self; + + /* get current thread */ + self = rt_thread_self(); + thread = (struct rtgui_thread*)(self->user_data); + + return thread; +} + extern rt_thread_t rt_thread_find(char* name); rt_thread_t rtgui_thread_get_server() { diff --git a/components/rtgui/common/rtgui_theme.c b/components/rtgui/common/rtgui_theme.c index 1c5a6f1a9d..2cb4628d9c 100644 --- a/components/rtgui/common/rtgui_theme.c +++ b/components/rtgui/common/rtgui_theme.c @@ -488,7 +488,7 @@ void rtgui_theme_draw_radiobutton(struct rtgui_radiobox* radiobox, rt_uint16_t i { struct rtgui_dc* dc; struct rtgui_rect rect, item_rect; - rt_size_t item_size, bord_size; + int item_size, bord_size; /* begin drawing */ dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(radiobox)); @@ -572,7 +572,7 @@ void rtgui_theme_draw_radiobox(struct rtgui_radiobox* radiobox) { struct rtgui_dc* dc; struct rtgui_rect rect, item_rect; - rt_size_t item_size, bord_size, index; + int item_size, bord_size, index; rtgui_color_t fc; /* begin drawing */ |
