summaryrefslogtreecommitdiff
path: root/components/rtgui/include
diff options
context:
space:
mode:
Diffstat (limited to 'components/rtgui/include')
-rw-r--r--components/rtgui/include/rtgui/color.h18
-rw-r--r--components/rtgui/include/rtgui/dc.h1
-rw-r--r--components/rtgui/include/rtgui/driver.h76
-rw-r--r--components/rtgui/include/rtgui/widgets/widget.h1
4 files changed, 73 insertions, 23 deletions
diff --git a/components/rtgui/include/rtgui/color.h b/components/rtgui/include/rtgui/color.h
index e13f461885..0e78bd0fd3 100644
--- a/components/rtgui/include/rtgui/color.h
+++ b/components/rtgui/include/rtgui/color.h
@@ -92,5 +92,23 @@ rt_inline rtgui_color_t rtgui_color_from_565p(rt_uint16_t pixel)
return color;
}
+/* convert rtgui color to RGB */
+rt_inline rt_uint32_t rtgui_color_to_888(rtgui_color_t c)
+{
+ rt_uint32_t pixel;
+
+ pixel = RTGUI_RGB_R(c) << 16 | RTGUI_RGB_G(c) << 8 | RTGUI_RGB_B(c);
+ return pixel;
+}
+
+rt_inline rtgui_color_t rtgui_color_from_888(rt_uint32_t pixel)
+{
+ rtgui_color_t color;
+
+ color = RTGUI_RGB(((pixel >> 16) & 0xff), ((pixel >> 8) & 0xff), pixel & 0xff);
+
+ return color;
+}
+
#endif
diff --git a/components/rtgui/include/rtgui/dc.h b/components/rtgui/include/rtgui/dc.h
index 866192cbb4..bca0a65015 100644
--- a/components/rtgui/include/rtgui/dc.h
+++ b/components/rtgui/include/rtgui/dc.h
@@ -24,7 +24,6 @@ enum rtgui_dc_type
RTGUI_DC_HW,
RTGUI_DC_CLIENT,
RTGUI_DC_BUFFER,
- RTGUI_DC_IMLIB2,
};
struct rtgui_dc_engine
diff --git a/components/rtgui/include/rtgui/driver.h b/components/rtgui/include/rtgui/driver.h
index 79856856ba..4cc187fb2d 100644
--- a/components/rtgui/include/rtgui/driver.h
+++ b/components/rtgui/include/rtgui/driver.h
@@ -17,24 +17,40 @@
#include <rtgui/list.h>
#include <rtgui/color.h>
-struct rtgui_graphic_driver
+#define LCD_RECT_UPDATE 0
+#define LCD_ON 1
+#define LCD_OFF 2
+#define LCD_GET_INFO 3
+#define LCD_MODE_SET 4
+
+enum
{
- /* driver name */
- char* name;
+ PIXEL_FORMAT_MONO = 0,
+ PIXEL_FORMAT_GRAY4,
+ PIXEL_FORMAT_GRAY16,
+ PIXEL_FORMAT_RGB332,
+ PIXEL_FORMAT_RGB444,
+ PIXEL_FORMAT_RGB565,
+ PIXEL_FORMAT_RGB565P,
+ PIXEL_FORMAT_RGB666,
+ PIXEL_FORMAT_RGB888,
+ PIXEL_FORMAT_ARGB888
+};
+#define PIXEL_POSITION(x, y) ((x << 16) | y)
- /* byte per pixel */
- rt_uint16_t byte_per_pixel;
+struct rt_lcd_info
+{
+ rt_uint8_t pixel_format;
+ rt_uint8_t byte_per_pixel;
- /* screen width and height */
rt_uint16_t width;
rt_uint16_t height;
- /* screen update */
- void (*screen_update)(rtgui_rect_t* rect);
-
- /* get video frame buffer */
- rt_uint8_t* (*get_framebuffer)(void);
+ rt_uint8_t *framebuffer;
+};
+struct rtgui_graphic_driver_ops
+{
/* set and get pixel in (x, y) */
void (*set_pixel) (rtgui_color_t *c, rt_base_t x, rt_base_t y);
void (*get_pixel) (rtgui_color_t *c, rt_base_t x, rt_base_t y);
@@ -44,24 +60,40 @@ struct rtgui_graphic_driver
/* draw raw hline */
void (*draw_raw_hline)(rt_uint8_t *pixels, rt_base_t x1, rt_base_t x2, rt_base_t y);
-
- /* the driver list */
- 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
+{
+ /* pixel format and byte per pixel */
+ rt_uint8_t pixel_format;
+ rt_uint8_t byte_per_pixel;
+ rt_uint16_t pitch;
+
+ /* screen width and height */
+ rt_uint16_t width;
+ rt_uint16_t height;
+
+ /* framebuffer address and ops */
+ volatile rt_uint8_t *framebuffer;
+ rt_device_t device;
+ const struct rtgui_graphic_driver_ops *ops;
+};
-struct rtgui_graphic_driver* rtgui_graphic_driver_find(char* name);
-#else
void rtgui_graphic_driver_add(const struct rtgui_graphic_driver* driver);
-#endif
-const struct rtgui_graphic_driver* rtgui_graphic_driver_get_default(void);
+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);
+void rtgui_graphic_driver_screen_update(struct rtgui_graphic_driver* driver, rtgui_rect_t *rect);
+rt_uint8_t* rtgui_graphic_driver_get_framebuffer(struct rtgui_graphic_driver* driver);
+
+rt_err_t rtgui_graphic_set_device(rt_device_t device);
+
+rt_inline struct rtgui_graphic_driver* rtgui_graphic_get_device()
+{
+ extern struct rtgui_graphic_driver _driver;
+ return &_driver;
+}
#endif
diff --git a/components/rtgui/include/rtgui/widgets/widget.h b/components/rtgui/include/rtgui/widgets/widget.h
index 9dfd40f0ae..ab44d23b39 100644
--- a/components/rtgui/include/rtgui/widgets/widget.h
+++ b/components/rtgui/include/rtgui/widgets/widget.h
@@ -152,6 +152,7 @@ void rtgui_widget_set_oncommand(rtgui_widget_t* widget, rtgui_event_handler_ptr
/* get and set rect of widget */
void rtgui_widget_get_rect(rtgui_widget_t* widget, rtgui_rect_t *rect);
void rtgui_widget_set_rect(rtgui_widget_t* widget, const rtgui_rect_t* rect);
+void rtgui_widget_set_rectangle(rtgui_widget_t* widget, int x, int y, int width, int height);
void rtgui_widget_get_extent(rtgui_widget_t* widget, rtgui_rect_t *rect);
#ifndef RTGUI_USING_SMALL_SIZE