mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-11-09 20:45:41 +08:00
implement hardware DC in each widget.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@787 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
1 parent
e76cd77c56
commit
b25f307b9b
15 files changed
+244
-144
No files matched your search
@@ -250,7 +250,7 @@ rt_inline void rtgui_blit_line_4(rtgui_color_t* color, rt_uint8_t* dest, int lin
|
||||
static void rtgui_dc_buffer_blit(struct rtgui_dc* self, struct rtgui_point* dc_point, struct rtgui_dc* dest, rtgui_rect_t* rect)
|
||||
{
|
||||
struct rtgui_dc_buffer* dc = (struct rtgui_dc_buffer*)self;
|
||||
struct rtgui_dc_hw* hw = (struct rtgui_dc_hw*)dest;
|
||||
struct rtgui_dc* hw = dest;
|
||||
|
||||
if (dc_point == RT_NULL) dc_point = &rtgui_empty_point;
|
||||
|
||||
@@ -273,7 +273,7 @@ static void rtgui_dc_buffer_blit(struct rtgui_dc* self, struct rtgui_point* dc_p
|
||||
rect_height = rtgui_rect_height(*rect);
|
||||
|
||||
/* get blit line function */
|
||||
switch (hw->device->byte_per_pixel)
|
||||
switch (rtgui_graphic_driver_get_default()->byte_per_pixel)
|
||||
{
|
||||
case 1:
|
||||
blit_line = rtgui_blit_line_1;
|
||||
@@ -292,7 +292,7 @@ static void rtgui_dc_buffer_blit(struct rtgui_dc* self, struct rtgui_point* dc_p
|
||||
}
|
||||
|
||||
/* create line buffer */
|
||||
line_ptr = (rt_uint8_t*) rtgui_malloc(rect_width * hw->device->byte_per_pixel);
|
||||
line_ptr = (rt_uint8_t*) rtgui_malloc(rect_width * rtgui_graphic_driver_get_default()->byte_per_pixel);
|
||||
|
||||
/* prepare pixel line */
|
||||
pixel = (rtgui_color_t*)(dc->pixel + dc_point->y * dc->pitch + dc_point->x * sizeof(rtgui_color_t));
|
||||
|
||||
+154
-102
File diff suppressed because it is too large.
Load diff
@@ -18,7 +18,7 @@ struct rtgui_image_hdc
|
||||
rt_uint8_t *pixels;
|
||||
|
||||
struct rtgui_filerw* filerw;
|
||||
struct rtgui_graphic_driver* hw_driver;
|
||||
const struct rtgui_graphic_driver* hw_driver;
|
||||
};
|
||||
|
||||
static rt_bool_t rtgui_image_hdc_check(struct rtgui_filerw* file);
|
||||
@@ -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((struct rtgui_dc_hw*)dc, ptr, dst_rect->x1, dst_rect->x1 + w, dst_rect->y1 + y);
|
||||
rtgui_dc_hw_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((struct rtgui_dc_hw*)dc, ptr, dst_rect->x1, dst_rect->x1 + w, dst_rect->y1 + y);
|
||||
rtgui_dc_hw_draw_raw_hline(dc, ptr, dst_rect->x1, dst_rect->x1 + w, dst_rect->y1 + y);
|
||||
}
|
||||
|
||||
rtgui_free(ptr);
|
||||
@@ -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((struct rtgui_dc_hw*)dc, ptr, dst_rect->x1, dst_rect->x1 + w, dst_rect->y1 + y);
|
||||
rtgui_dc_hw_draw_raw_hline(dc, ptr, dst_rect->x1, dst_rect->x1 + w, dst_rect->y1 + y);
|
||||
ptr += hdc->pitch;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,31 +10,19 @@
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2010-04-10 Bernard first version
|
||||
* 2010-06-14 Bernard embedded hardware dc to each widget
|
||||
*/
|
||||
#ifndef __RTGUI_DC_HW_H__
|
||||
#define __RTGUI_DC_HW_H__
|
||||
|
||||
#include <rtgui/dc.h>
|
||||
|
||||
/* hardware device context */
|
||||
struct rtgui_dc_hw
|
||||
{
|
||||
struct rtgui_dc parent;
|
||||
|
||||
/* widget owner */
|
||||
rtgui_widget_t* owner;
|
||||
|
||||
/* visible */
|
||||
rt_bool_t visible;
|
||||
|
||||
/* display driver */
|
||||
struct rtgui_graphic_driver* device;
|
||||
};
|
||||
|
||||
/* 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_hw* dc, rt_uint8_t* raw_ptr, int x1, int x2, int y);
|
||||
void rtgui_dc_hw_draw_raw_hline(struct rtgui_dc* dc, rt_uint8_t* raw_ptr, int x1, int x2, int y);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -49,13 +49,19 @@ struct rtgui_graphic_driver
|
||||
rtgui_list_t list;
|
||||
};
|
||||
|
||||
#ifdef RTGUI_USING_GRAPHIC_DRIVER_LIST
|
||||
void rtgui_graphic_driver_add(struct rtgui_graphic_driver* driver);
|
||||
void rtgui_graphic_driver_remove(struct rtgui_graphic_driver* driver);
|
||||
|
||||
struct rtgui_graphic_driver* rtgui_graphic_driver_find(char* name);
|
||||
struct rtgui_graphic_driver* rtgui_graphic_driver_get_default(void);
|
||||
#else
|
||||
void rtgui_graphic_driver_add(const struct rtgui_graphic_driver* driver);
|
||||
#endif
|
||||
|
||||
void rtgui_graphic_driver_get_rect(struct rtgui_graphic_driver *driver, rtgui_rect_t *rect);
|
||||
const struct rtgui_graphic_driver* rtgui_graphic_driver_get_default(void);
|
||||
|
||||
void rtgui_graphic_driver_get_rect(const struct rtgui_graphic_driver *driver, rtgui_rect_t *rect);
|
||||
void rtgui_graphic_driver_get_default_rect(rtgui_rect_t *rect);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -25,7 +25,7 @@ struct rtgui_event;
|
||||
|
||||
struct rtgui_widget;
|
||||
struct rtgui_win;
|
||||
struct rtgui_font;
|
||||
struct rtgui_font;
|
||||
|
||||
typedef struct rtgui_panel rtgui_panel_t;
|
||||
typedef struct rtgui_win rtgui_win_t;
|
||||
@@ -47,7 +47,7 @@ typedef struct rtgui_rect rtgui_rect_t;
|
||||
#define rtgui_rect_width(r) ((r).x2 - (r).x1)
|
||||
#define rtgui_rect_height(r) ((r).y2 - (r).y1)
|
||||
|
||||
typedef unsigned long rtgui_color_t;
|
||||
typedef unsigned long rtgui_color_t;
|
||||
|
||||
struct rtgui_gc
|
||||
{
|
||||
@@ -129,3 +129,4 @@ typedef enum RTGUI_MODAL_CODE rtgui_modal_code_t;
|
||||
#include <rtgui/rtgui_object.h>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -22,6 +22,8 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/* rtgui object type */
|
||||
#define RTGUI_CONTAINER_OF(obj, type, member) \
|
||||
((type *)((char *)(obj) - (unsigned long)(&((type *)0)->member)))
|
||||
|
||||
/** Casts the function pointer to an rtgui_constructor */
|
||||
#define RTGUI_CONSTRUCTOR(constructor) ((rtgui_constructor_t)(constructor))
|
||||
|
||||
@@ -72,7 +72,9 @@ void rtgui_server_post_event(struct rtgui_event* event, rt_size_t size);
|
||||
/* register or deregister panel in server */
|
||||
void rtgui_panel_register(char* name, rtgui_rect_t* extent);
|
||||
void rtgui_panel_deregister(char* name);
|
||||
|
||||
void rtgui_panel_set_default_focused(char* name);
|
||||
void rtgui_panel_set_nofocused(char* name);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -25,12 +25,13 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define RTGUI_WIDGET_FLAG_HIDE 0x01
|
||||
#define RTGUI_WIDGET_FLAG_DISABLE 0x02
|
||||
#define RTGUI_WIDGET_FLAG_FOCUS 0x04
|
||||
#define RTGUI_WIDGET_FLAG_TRANSPARENT 0x08
|
||||
#define RTGUI_WIDGET_FLAG_FOCUSABLE 0x10
|
||||
#define RTGUI_WIDGET_FLAG_DEFAULT 0x00
|
||||
#define RTGUI_WIDGET_FLAG_DEFAULT 0x0000
|
||||
#define RTGUI_WIDGET_FLAG_HIDE 0x0001
|
||||
#define RTGUI_WIDGET_FLAG_DISABLE 0x0002
|
||||
#define RTGUI_WIDGET_FLAG_FOCUS 0x0004
|
||||
#define RTGUI_WIDGET_FLAG_TRANSPARENT 0x0008
|
||||
#define RTGUI_WIDGET_FLAG_FOCUSABLE 0x0010
|
||||
#define RTGUI_WIDGET_FLAG_DC_VISIBLE 0x0100
|
||||
|
||||
#define RTGUI_WIDGET_UNHIDE(w) (w)->flag &= ~RTGUI_WIDGET_FLAG_HIDE
|
||||
#define RTGUI_WIDGET_HIDE(w) (w)->flag |= RTGUI_WIDGET_FLAG_HIDE
|
||||
@@ -46,6 +47,11 @@ extern "C" {
|
||||
|
||||
#define RTGUI_WIDGET_IS_FOCUSABLE(w) ((w)->flag & RTGUI_WIDGET_FLAG_FOCUSABLE)
|
||||
|
||||
#define RTGUI_WIDGET_IS_DC_VISIBLE(w) ((w)->flag & RTGUI_WIDGET_FLAG_DC_VISIBLE)
|
||||
#define RTGUI_WIDGET_DC_SET_VISIBLE(w) (w)->flag |= RTGUI_WIDGET_FLAG_DC_VISIBLE
|
||||
#define RTGUI_WIDGET_DC_SET_UNVISIBLE(w) (w)->flag &= ~RTGUI_WIDGET_FLAG_DC_VISIBLE
|
||||
#define RTGUI_WIDGET_DC(w) ((struct rtgui_dc*)&((w)->dc_type))
|
||||
|
||||
/* get rtgui widget object */
|
||||
#define RTGUI_WIDGET_FOREGROUND(w) ((w)->gc.foreground)
|
||||
#define RTGUI_WIDGET_BACKGROUND(w) ((w)->gc.background)
|
||||
@@ -75,19 +81,24 @@ struct rtgui_widget
|
||||
|
||||
/* widget flag */
|
||||
rt_int32_t flag;
|
||||
#ifndef RTGUI_USING_SMALL_SIZE
|
||||
/* widget align */
|
||||
rt_int32_t align;
|
||||
#endif
|
||||
|
||||
/* hardware device context */
|
||||
rt_uint32_t dc_type;
|
||||
const struct rtgui_dc_engine* dc_engine;
|
||||
|
||||
/* the graphic context of widget */
|
||||
rtgui_gc_t gc;
|
||||
|
||||
/* the widget extent */
|
||||
rtgui_rect_t extent;
|
||||
|
||||
#ifndef RTGUI_USING_SMALL_SIZE
|
||||
/* minimal width and height of widget */
|
||||
rt_int16_t mini_width, mini_height;
|
||||
rt_int16_t margin, margin_style;
|
||||
|
||||
/* widget align */
|
||||
rt_int32_t align;
|
||||
#endif
|
||||
|
||||
/* the rect clip */
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
*/
|
||||
#include <rtgui/driver.h>
|
||||
|
||||
#ifdef RTGUI_USING_GRAPHIC_DRIVER_LIST
|
||||
struct rtgui_list_node _rtgui_graphic_driver_list = {RT_NULL};
|
||||
|
||||
void rtgui_graphic_driver_add(struct rtgui_graphic_driver* driver)
|
||||
@@ -50,10 +51,25 @@ struct rtgui_graphic_driver* rtgui_graphic_driver_get_default()
|
||||
return rtgui_list_entry(_rtgui_graphic_driver_list.next,
|
||||
struct rtgui_graphic_driver, list);
|
||||
}
|
||||
#else
|
||||
static const struct rtgui_graphic_driver* _default_graphic_driver = RT_NULL;
|
||||
|
||||
void rtgui_graphic_driver_get_rect(struct rtgui_graphic_driver *driver, rtgui_rect_t *rect)
|
||||
void rtgui_graphic_driver_add(const struct rtgui_graphic_driver* driver)
|
||||
{
|
||||
if (rect == RT_NULL || driver == RT_NULL) return;
|
||||
_default_graphic_driver = driver;
|
||||
}
|
||||
|
||||
const struct rtgui_graphic_driver* rtgui_graphic_driver_get_default()
|
||||
{
|
||||
return _default_graphic_driver;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void rtgui_graphic_driver_get_rect(const struct rtgui_graphic_driver *driver, rtgui_rect_t *rect)
|
||||
{
|
||||
RT_ASSERT(rect != RT_NULL);
|
||||
RT_ASSERT(driver != RT_NULL);
|
||||
|
||||
rect->x1 = rect->y1 = 0;
|
||||
rect->x2 = driver->width;
|
||||
@@ -65,3 +81,4 @@ void rtgui_graphic_driver_get_default_rect(rtgui_rect_t *rect)
|
||||
/* return default the extent of default driver */
|
||||
rtgui_graphic_driver_get_rect(rtgui_graphic_driver_get_default(), rect);
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ static void rtgui_winrect_show (void);
|
||||
#define WIN_MOVE_BORDER 4
|
||||
void rtgui_mouse_init()
|
||||
{
|
||||
struct rtgui_graphic_driver* gd = rtgui_graphic_driver_get_default();
|
||||
const struct rtgui_graphic_driver* gd = rtgui_graphic_driver_get_default();
|
||||
|
||||
_rtgui_cursor = (struct rtgui_cursor*) rtgui_malloc(sizeof(struct rtgui_cursor));
|
||||
rt_memset(_rtgui_cursor, 0, sizeof(struct rtgui_cursor));
|
||||
|
||||
@@ -54,6 +54,7 @@ void rtgui_panel_register(char* name, rtgui_rect_t* extent)
|
||||
panel->extent = *extent;
|
||||
|
||||
panel->wm_thread = RT_NULL;
|
||||
panel->is_focusable = RT_TRUE;
|
||||
|
||||
/* init list */
|
||||
rtgui_list_init(&(panel->sibling));
|
||||
@@ -90,6 +91,18 @@ void rtgui_panel_set_default_focused(char* name)
|
||||
}
|
||||
}
|
||||
|
||||
void rtgui_panel_set_nofocused(char* name)
|
||||
{
|
||||
extern struct rtgui_panel* rtgui_server_focus_panel;
|
||||
struct rtgui_panel* panel;
|
||||
|
||||
panel = rtgui_panel_find(name);
|
||||
if (panel != RT_NULL)
|
||||
{
|
||||
panel->is_focusable = RT_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
struct rtgui_panel* rtgui_panel_find(char* name)
|
||||
{
|
||||
struct rtgui_list_node* node;
|
||||
@@ -304,3 +317,4 @@ void rtgui_panel_set_wm(rtgui_panel_t* panel, rt_thread_t wm)
|
||||
|
||||
panel->wm_thread = wm;
|
||||
}
|
||||
|
||||
@@ -47,6 +47,9 @@ struct rtgui_panel
|
||||
|
||||
/* the workbench manager thread */
|
||||
rt_thread_t wm_thread;
|
||||
|
||||
/* is focusable */
|
||||
rt_bool_t is_focusable;
|
||||
};
|
||||
|
||||
/* find panel by name */
|
||||
@@ -66,3 +69,4 @@ void rtgui_panel_append_monitor_rect(rtgui_panel_t* panel, rt_thread_t tid, rtgu
|
||||
void rtgui_panel_remove_monitor_rect(rtgui_panel_t* panel, rt_thread_t tid, rtgui_rect_t* rect);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -182,7 +182,7 @@ void rtgui_server_handle_set_wm(struct rtgui_event_set_wm *event)
|
||||
|
||||
void rtgui_server_handle_update(struct rtgui_event_update_end* event)
|
||||
{
|
||||
struct rtgui_graphic_driver* driver = rtgui_graphic_driver_get_default();
|
||||
const struct rtgui_graphic_driver* driver = rtgui_graphic_driver_get_default();
|
||||
if (driver != RT_NULL)
|
||||
{
|
||||
driver->screen_update(&(event->rect));
|
||||
@@ -290,7 +290,7 @@ void rtgui_server_handle_mouse_btn(struct rtgui_event_mouse* event)
|
||||
|
||||
/* get the panel which contains the mouse */
|
||||
panel = rtgui_panel_get_contain(event->x, event->y);
|
||||
if (panel != RT_NULL)
|
||||
if ((panel != RT_NULL) && (panel->is_focusable == RT_TRUE))
|
||||
{
|
||||
/* deactivate old window */
|
||||
if (rtgui_server_focus_topwin != RT_NULL)
|
||||
|
||||
@@ -60,6 +60,9 @@ static void _rtgui_widget_constructor(rtgui_widget_t *widget)
|
||||
|
||||
/* init clip information */
|
||||
rtgui_region_init(&(widget->clip));
|
||||
|
||||
/* init hardware dc */
|
||||
rtgui_dc_hw_init(widget);
|
||||
}
|
||||
|
||||
/* Destroys the widget */
|
||||
|
||||
Reference in new issue
Block a user