diff options
| author | [email protected] <[email protected]> | 2011-06-06 09:10:13 +0000 |
|---|---|---|
| committer | [email protected] <[email protected]> | 2011-06-06 09:10:13 +0000 |
| commit | 80da4b977588119a2e66566fb9a2e7a0c3588a62 (patch) | |
| tree | 6d0f4b18be36779a0f6fdd9bfe83913026064f10 /components/rtgui/common | |
| parent | 5284d6d52e39faefcf96dedad6695bb46d2d5579 (diff) | |
change to graphic device.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1459 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'components/rtgui/common')
| -rw-r--r-- | components/rtgui/common/dc_buffer.c | 15 | ||||
| -rw-r--r-- | components/rtgui/common/dc_client.c | 2 | ||||
| -rw-r--r-- | components/rtgui/common/framebuffer_driver.c | 14 | ||||
| -rw-r--r-- | components/rtgui/common/image_bmp.c | 10 | ||||
| -rw-r--r-- | components/rtgui/common/image_hdc.c | 2 | ||||
| -rw-r--r-- | components/rtgui/common/pixel_driver.c | 22 |
6 files changed, 37 insertions, 28 deletions
diff --git a/components/rtgui/common/dc_buffer.c b/components/rtgui/common/dc_buffer.c index 730156e89c..7677fa9dd5 100644 --- a/components/rtgui/common/dc_buffer.c +++ b/components/rtgui/common/dc_buffer.c @@ -20,6 +20,11 @@ #define hw_driver (rtgui_graphic_driver_get_default()) +#define RTGUI_BLENDMODE_NONE 0x00 +#define RTGUI_BLENDMODE_BLEND 0x01 +#define RTGUI_BLENDMODE_ADD 0x02 +#define RTGUI_BLENDMODE_MOD 0x03 + struct rtgui_dc_buffer { struct rtgui_dc parent; @@ -27,6 +32,10 @@ struct rtgui_dc_buffer /* graphic context */ rtgui_gc_t gc; + /* pixel format */ + rt_uint8_t pixel_format; + rt_uint8_t blend_mode; + /* width and height */ rt_uint16_t width, height; rt_uint16_t pitch; @@ -240,7 +249,7 @@ static void rtgui_dc_buffer_blit(struct rtgui_dc* self, struct rtgui_point* dc_p /* prepare pixel line */ pixels = dc->pixel + dc_point->y * dc->pitch + dc_point->x * sizeof(rtgui_color_t); - if (hw_driver->byte_per_pixel == sizeof(rtgui_color_t)) + if (hw_driver->bits_per_pixel == sizeof(rtgui_color_t) * 8) { /* it's the same byte per pixel, draw it directly */ for (index = rect->y1; index < rect->y1 + rect_height; index++) @@ -252,11 +261,11 @@ static void rtgui_dc_buffer_blit(struct rtgui_dc* self, struct rtgui_point* dc_p else { /* get blit line function */ - blit_line = rtgui_blit_line_get(hw_driver->byte_per_pixel, 4); + blit_line = rtgui_blit_line_get(hw_driver->bits_per_pixel/8, 4); /* calculate pitch */ pitch = rect_width * sizeof(rtgui_color_t); /* create line buffer */ - line_ptr = (rt_uint8_t*) rtgui_malloc(rect_width * hw_driver->byte_per_pixel); + line_ptr = (rt_uint8_t*) rtgui_malloc(rect_width * hw_driver->bits_per_pixel/8); /* draw each line */ for (index = rect->y1; index < rect->y1 + rect_height; index ++) diff --git a/components/rtgui/common/dc_client.c b/components/rtgui/common/dc_client.c index f2db68d8e8..a3559a8842 100644 --- a/components/rtgui/common/dc_client.c +++ b/components/rtgui/common/dc_client.c @@ -474,7 +474,7 @@ static void rtgui_dc_client_blit_line (struct rtgui_dc* self, int x1, int x2, in if (prect->x2 < x2) draw_x2 = prect->x2; /* draw hline */ - hw_driver->ops->draw_raw_hline(line_data + (draw_x1 - x1) * hw_driver->byte_per_pixel, draw_x1, draw_x2, y); + hw_driver->ops->draw_raw_hline(line_data + (draw_x1 - x1) * hw_driver->bits_per_pixel/8, draw_x1, draw_x2, y); } } diff --git a/components/rtgui/common/framebuffer_driver.c b/components/rtgui/common/framebuffer_driver.c index 477e096eed..ed411f23c4 100644 --- a/components/rtgui/common/framebuffer_driver.c +++ b/components/rtgui/common/framebuffer_driver.c @@ -2,7 +2,7 @@ #include <rtgui/driver.h>
#define GET_PIXEL(dst, x, y, type) \
- (type *)((rt_uint8_t*)((dst)->framebuffer) + (y) * (dst)->pitch + (x) * (dst)->byte_per_pixel)
+ (type *)((rt_uint8_t*)((dst)->framebuffer) + (y) * (dst)->pitch + (x) * ((dst)->bits_per_pixel/8))
static void _rgb565_set_pixel(rtgui_color_t *c, rt_base_t x, rt_base_t y)
{
@@ -108,7 +108,7 @@ static void framebuffer_draw_raw_hline(rt_uint8_t *pixels, rt_base_t x1, rt_base rt_uint8_t *dst;
dst = GET_PIXEL(rtgui_graphic_get_device(), x1, y, rt_uint8_t);
- rt_memcpy(dst, pixels, (x2 - x1) * rtgui_graphic_get_device()->byte_per_pixel);
+ rt_memcpy(dst, pixels, (x2 - x1) * (rtgui_graphic_get_device()->bits_per_pixel/8));
}
const struct rtgui_graphic_driver_ops _framebuffer_rgb565_ops =
@@ -208,15 +208,15 @@ const struct rtgui_graphic_driver_ops *rtgui_framebuffer_get_ops(int pixel_forma {
switch (pixel_format)
{
- case PIXEL_FORMAT_MONO:
+ case RTGRAPHIC_PIXEL_FORMAT_MONO:
return &_framebuffer_mono_ops;
- case PIXEL_FORMAT_GRAY4:
+ case RTGRAPHIC_PIXEL_FORMAT_GRAY4:
break;
- case PIXEL_FORMAT_GRAY16:
+ case RTGRAPHIC_PIXEL_FORMAT_GRAY16:
break;
- case PIXEL_FORMAT_RGB565:
+ case RTGRAPHIC_PIXEL_FORMAT_RGB565:
return &_framebuffer_rgb565_ops;
- case PIXEL_FORMAT_RGB565P:
+ case RTGRAPHIC_PIXEL_FORMAT_RGB565P:
return &_framebuffer_rgb565p_ops;
}
diff --git a/components/rtgui/common/image_bmp.c b/components/rtgui/common/image_bmp.c index f68dd507e6..9dd9798675 100644 --- a/components/rtgui/common/image_bmp.c +++ b/components/rtgui/common/image_bmp.c @@ -462,7 +462,7 @@ static void rtgui_image_bmp_blit(struct rtgui_image* image, struct rtgui_dc* dc, /* get pixel pointer */
ptr = bmp->pixels;
- if (bmp->byte_per_pixel == hw_driver->byte_per_pixel)
+ if (bmp->byte_per_pixel == hw_driver->bits_per_pixel/8)
{
for (y = 0; y < h; y ++)
{
@@ -481,8 +481,8 @@ static void rtgui_image_bmp_blit(struct rtgui_image* image, struct rtgui_dc* dc, if (image->palette == RT_NULL)
{
rtgui_blit_line_func blit_line;
- line_ptr = (rt_uint8_t*) rtgui_malloc(hw_driver->byte_per_pixel * w);
- blit_line = rtgui_blit_line_get(hw_driver->byte_per_pixel , bmp->byte_per_pixel);
+ line_ptr = (rt_uint8_t*) rtgui_malloc((hw_driver->bits_per_pixel/8) * w);
+ blit_line = rtgui_blit_line_get(hw_driver->bits_per_pixel/8 , bmp->byte_per_pixel);
pitch = w * bmp->byte_per_pixel;
if (line_ptr != RT_NULL)
{
@@ -585,7 +585,7 @@ static void rtgui_image_bmp_blit(struct rtgui_image* image, struct rtgui_dc* dc, }
else
{
- rt_uint8_t *line_ptr = (rt_uint8_t*) rtgui_malloc(hw_driver->byte_per_pixel * w);
+ rt_uint8_t *line_ptr = (rt_uint8_t*) rtgui_malloc((hw_driver->bits_per_pixel/8) * w);
if (line_ptr == RT_NULL) return;
/* draw each line */
@@ -607,7 +607,7 @@ static void rtgui_image_bmp_blit(struct rtgui_image* image, struct rtgui_dc* dc, {
int pitch;
rtgui_blit_line_func blit_line;
- blit_line = rtgui_blit_line_get(hw_driver->byte_per_pixel , bmp->byte_per_pixel);
+ blit_line = rtgui_blit_line_get(hw_driver->bits_per_pixel/8 , bmp->byte_per_pixel);
pitch = w * bmp->byte_per_pixel;
if (line_ptr != RT_NULL)
{
diff --git a/components/rtgui/common/image_hdc.c b/components/rtgui/common/image_hdc.c index c64db4f3bf..8e19a1c05a 100644 --- a/components/rtgui/common/image_hdc.c +++ b/components/rtgui/common/image_hdc.c @@ -94,7 +94,7 @@ static rt_bool_t rtgui_image_hdc_load(struct rtgui_image* image, struct rtgui_fi image->engine = &rtgui_image_hdc_engine; image->data = hdc; hdc->filerw = file; - hdc->byte_per_pixel = hdc->hw_driver->byte_per_pixel; + hdc->byte_per_pixel = hdc->hw_driver->bits_per_pixel/8; hdc->pitch = image->w * hdc->byte_per_pixel; hdc->pixel_offset = rtgui_filerw_tell(file); diff --git a/components/rtgui/common/pixel_driver.c b/components/rtgui/common/pixel_driver.c index 1140acc66c..3ee321ba66 100644 --- a/components/rtgui/common/pixel_driver.c +++ b/components/rtgui/common/pixel_driver.c @@ -5,20 +5,20 @@ static void _pixeldevice_set_pixel(rtgui_color_t *c, rt_base_t x, rt_base_t y) {
switch (rtgui_graphic_get_device()->pixel_format)
{
- case PIXEL_FORMAT_RGB565:
+ case RTGRAPHIC_PIXEL_FORMAT_RGB565:
{
rt_uint16_t pixel;
pixel = rtgui_color_to_565(*c);
- rt_device_write(rtgui_graphic_get_device()->device, PIXEL_POSITION(x, y), &pixel,
+ rt_device_write(rtgui_graphic_get_device()->device, RTGRAPHIC_PIXEL_POSITION(x, y), &pixel,
sizeof(pixel));
}
break;
- case PIXEL_FORMAT_RGB888:
+ case RTGRAPHIC_PIXEL_FORMAT_RGB888:
{
rt_uint32_t pixel;
pixel = rtgui_color_to_888(*c);
- rt_device_write(rtgui_graphic_get_device()->device, PIXEL_POSITION(x, y), &pixel,
+ rt_device_write(rtgui_graphic_get_device()->device, RTGRAPHIC_PIXEL_POSITION(x, y), &pixel,
3);
}
@@ -30,20 +30,20 @@ static void _pixeldevice_get_pixel(rtgui_color_t *c, rt_base_t x, rt_base_t y) {
switch (rtgui_graphic_get_device()->pixel_format)
{
- case PIXEL_FORMAT_RGB565:
+ case RTGRAPHIC_PIXEL_FORMAT_RGB565:
{
rt_uint16_t pixel;
- rt_device_read(rtgui_graphic_get_device()->device, PIXEL_POSITION(x, y), &pixel,
- rtgui_graphic_get_device()->byte_per_pixel);
+ rt_device_read(rtgui_graphic_get_device()->device, RTGRAPHIC_PIXEL_POSITION(x, y), &pixel,
+ (rtgui_graphic_get_device()->bits_per_pixel/8));
/* get pixel from color */
*c = rtgui_color_from_565(pixel);
}
break;
- case PIXEL_FORMAT_RGB888:
+ case RTGRAPHIC_PIXEL_FORMAT_RGB888:
{
rt_uint32_t pixel;
- rt_device_read(rtgui_graphic_get_device()->device, PIXEL_POSITION(x, y), &pixel,
+ rt_device_read(rtgui_graphic_get_device()->device, RTGRAPHIC_PIXEL_POSITION(x, y), &pixel,
3);
/* get pixel from color */
*c = rtgui_color_from_888(pixel);
@@ -71,8 +71,8 @@ static void _pixeldevice_vline(rtgui_color_t *c, rt_base_t x , rt_base_t y1, rt_ /* draw raw hline */
static void _pixeldevice_draw_raw_hline(rt_uint8_t *pixels, rt_base_t x1, rt_base_t x2, rt_base_t y)
{
- rt_device_write(rtgui_graphic_get_device()->device, PIXEL_POSITION(x1, y), pixels,
- (x2 - x1) * rtgui_graphic_get_device()->byte_per_pixel);
+ rt_device_write(rtgui_graphic_get_device()->device, RTGRAPHIC_PIXEL_POSITION(x1, y), pixels,
+ (x2 - x1) * (rtgui_graphic_get_device()->bits_per_pixel/8));
}
/* pixel device */
|
