提交 94e758a2 编写于 作者: B bernard.xiong@gmail.com

add rtgui_image_hdcmm from memory HDC image.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@736 bbd45198-f89e-11dd-88c7-29a3b14d5316
上级 e7e1a2a6
......@@ -2,6 +2,7 @@
#include <rtgui/dc_hw.h>
#include <rtgui/image.h>
#include <rtgui/rtgui_system.h>
#include <rtgui/image_hdc.h>
#define HDC_MAGIC_LEN 4
......@@ -9,21 +10,22 @@ struct rtgui_image_hdc
{
rt_bool_t is_loaded;
struct rtgui_filerw* filerw;
struct rtgui_graphic_driver* hw_driver;
/* hdc image information */
rt_uint16_t byte_per_pixel;
rt_uint16_t pitch;
rt_size_t pixel_offset;
rt_uint8_t *pixels;
struct rtgui_filerw* filerw;
struct rtgui_graphic_driver* hw_driver;
};
static rt_bool_t rtgui_image_hdc_check(struct rtgui_filerw* file);
static rt_bool_t rtgui_image_hdc_load(struct rtgui_image* image, struct rtgui_filerw* file, rt_bool_t load);
static void rtgui_image_hdc_unload(struct rtgui_image* image);
static void rtgui_image_hdc_blit(struct rtgui_image* image, struct rtgui_dc* dc, struct rtgui_rect* rect);
static void rtgui_image_hdcmm_blit(struct rtgui_image* image, struct rtgui_dc* dc, struct rtgui_rect* dst_rect);
struct rtgui_image_engine rtgui_image_hdc_engine =
{
......@@ -35,6 +37,16 @@ struct rtgui_image_engine rtgui_image_hdc_engine =
rtgui_image_hdc_blit
};
struct rtgui_image_engine rtgui_image_hdcmm_engine =
{
"hdcmm",
{RT_NULL},
{RT_NULL},
{RT_NULL},
{RT_NULL},
rtgui_image_hdcmm_blit
};
static rt_bool_t rtgui_image_hdc_check(struct rtgui_filerw* file)
{
int start;
......@@ -186,8 +198,40 @@ static void rtgui_image_hdc_blit(struct rtgui_image* image, struct rtgui_dc* dc,
}
}
static void rtgui_image_hdcmm_blit(struct rtgui_image* image, struct rtgui_dc* dc, struct rtgui_rect* dst_rect)
{
rt_uint8_t* ptr;
rt_uint16_t y, w, h;
struct rtgui_image_hdcmm* hdc;
RT_ASSERT(image != RT_NULL || dc != RT_NULL || dst_rect != RT_NULL);
/* this dc is not visible */
if ((dc->get_visible(dc) != RT_TRUE) || (dc->type != RTGUI_DC_HW)) return;
hdc = (struct rtgui_image_hdcmm*) image;
RT_ASSERT(hdc != RT_NULL);
/* the minimum rect */
if (image->w < rtgui_rect_width(*dst_rect)) w = image->w;
else w = rtgui_rect_width(*dst_rect);
if (image->h < rtgui_rect_height(*dst_rect)) h = image->h;
else h = rtgui_rect_height(*dst_rect);
/* get pixel pointer */
ptr = hdc->pixels;
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);
ptr += hdc->pitch;
}
}
void rtgui_image_hdc_init()
{
/* register hdc on image system */
rtgui_image_register_engine(&rtgui_image_hdc_engine);
}
......@@ -16,6 +16,22 @@
#include <rtgui/image.h>
struct rtgui_image_hdcmm
{
struct rtgui_image parent;
/* hdc image information */
rt_uint16_t byte_per_pixel;
rt_uint16_t pitch;
rt_uint8_t *pixels;
};
void rtgui_image_hdc_init(void);
extern struct rtgui_image_engine rtgui_image_hdcmm_engine;
#define HDC_HEADER_SIZE (5 * 4)
#define RTGUI_IMAGE_HDC_DEF(bpp, w, h, pixels) \
{{w, h, &rtgui_image_hdcmm_engine, RT_NULL}, bpp, (bpp * w), ((rt_uint8_t*)pixels + HDC_HEADER_SIZE)}
#endif
......@@ -28,15 +28,18 @@
/** Checks if the object is an rtgui_win */
#define RTGUI_IS_WIN(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_WIN_TYPE))
#define RTGUI_WIN_STYLE_MODAL 0x01 /* modal mode window */
#define RTGUI_WIN_STYLE_CLOSED 0x02 /* window is closed */
#define RTGUI_WIN_STYLE_ACTIVATE 0x04 /* window is activated */
#define RTGUI_WIN_STYLE_NO_FOCUS 0x08 /* non-focused window */
#define RTGUI_WIN_STYLE_MODAL 0x001 /* modal mode window */
#define RTGUI_WIN_STYLE_CLOSED 0x002 /* window is closed */
#define RTGUI_WIN_STYLE_ACTIVATE 0x004 /* window is activated */
#define RTGUI_WIN_STYLE_NO_FOCUS 0x008 /* non-focused window */
#define RTGUI_WIN_STYLE_NO_TITLE 0x10 /* no title window */
#define RTGUI_WIN_STYLE_NO_BORDER 0x20 /* no border window */
#define RTGUI_WIN_STYLE_CLOSEBOX 0x40 /* window has the close button */
#define RTGUI_WIN_STYLE_MINIBOX 0x80 /* window has the mini button */
#define RTGUI_WIN_STYLE_NO_TITLE 0x010 /* no title window */
#define RTGUI_WIN_STYLE_NO_BORDER 0x020 /* no border window */
#define RTGUI_WIN_STYLE_CLOSEBOX 0x040 /* window has the close button */
#define RTGUI_WIN_STYLE_MINIBOX 0x080 /* window has the mini button */
#define RTGUI_WIN_STYLE_UNDER_MODAL 0x100 /* window is under modal show (show
* sub-win as modal window) */
#define RTGUI_WIN_STYLE_DEFAULT (RTGUI_WIN_STYLE_CLOSEBOX | RTGUI_WIN_STYLE_MINIBOX)
......@@ -52,9 +55,8 @@ struct rtgui_win
rtgui_toplevel_t* parent_toplevel;
/* top window style */
rt_uint8_t style;
rt_uint16_t style;
rt_uint8_t flag;
rtgui_modal_code_t modal_code;
rtgui_widget_t* modal_widget;
......
......@@ -221,12 +221,12 @@ rtgui_modal_code_t rtgui_win_show(struct rtgui_win* win, rt_bool_t is_modal)
{
rtgui_win_t* parent_win;
parent_win = RTGUI_WIN(win->parent_toplevel);
parent_win->flag |= RTGUI_WORKBENCH_FLAG_MODAL_MODE;
parent_win->style |= RTGUI_WIN_STYLE_UNDER_MODAL;
parent_win->modal_widget = RTGUI_WIDGET(win);
rtgui_win_event_loop(parent_win);
result = parent_win->modal_code;
parent_win->flag &= ~RTGUI_WORKBENCH_FLAG_MODAL_MODE;
parent_win->style &= ~RTGUI_WIN_STYLE_UNDER_MODAL;
parent_win->modal_widget = RT_NULL;
}
}
......@@ -264,7 +264,7 @@ void rtgui_win_end_modal(struct rtgui_win* win, rtgui_modal_code_t modal_code)
/* which is shown under win */
parent_win = RTGUI_WIN(win->parent_toplevel);
parent_win->modal_code = modal_code;
parent_win->flag &= ~RTGUI_WORKBENCH_FLAG_MODAL_MODE;
parent_win->style &= ~RTGUI_WIN_STYLE_UNDER_MODAL;
}
}
else
......@@ -432,7 +432,7 @@ rt_bool_t rtgui_win_event_handler(struct rtgui_widget* widget, struct rtgui_even
case RTGUI_EVENT_WIN_DEACTIVATE:
if (win->style & RTGUI_WIN_STYLE_MODAL)
{
/* do not deactivate a modal win */
/* do not deactivate a modal win, re-send win-show event */
struct rtgui_event_win_show eshow;
RTGUI_EVENT_WIN_SHOW_INIT(&eshow);
eshow.wid = win;
......@@ -465,7 +465,7 @@ rt_bool_t rtgui_win_event_handler(struct rtgui_widget* widget, struct rtgui_even
break;
case RTGUI_EVENT_MOUSE_BUTTON:
if (win->flag & RTGUI_WIN_STYLE_MODAL)
if (win->style & RTGUI_WIN_STYLE_UNDER_MODAL)
{
if (win->modal_widget != RT_NULL)
return win->modal_widget->event_handler(win->modal_widget, event);
......@@ -500,7 +500,7 @@ rt_bool_t rtgui_win_event_handler(struct rtgui_widget* widget, struct rtgui_even
break;
case RTGUI_EVENT_KBD:
if (win->flag & RTGUI_WIN_STYLE_MODAL)
if (win->style & RTGUI_WIN_STYLE_UNDER_MODAL)
{
if (win->modal_widget != RT_NULL)
return win->modal_widget->event_handler(win->modal_widget, event);
......@@ -527,9 +527,9 @@ void rtgui_win_event_loop(rtgui_win_t* wnd)
struct rtgui_event* event = (struct rtgui_event*)&event_buf[0];
if (wnd->style & RTGUI_WIN_STYLE_MODAL)
if (wnd->style & RTGUI_WIN_STYLE_UNDER_MODAL)
{
while (wnd->style & RTGUI_WIN_STYLE_MODAL)
while (wnd->style & RTGUI_WIN_STYLE_UNDER_MODAL)
{
if (rtgui_thread_recv(event, sizeof(event_buf)) == RT_EOK)
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册