driver.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * File : driver.h
  3. * This file is part of RTGUI in RT-Thread RTOS
  4. * COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://www.rt-thread.org/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2009-10-04 Bernard first version
  13. */
  14. #ifndef __RTGUI_DRIVER_H__
  15. #define __RTGUI_DRIVER_H__
  16. #include <rtgui/list.h>
  17. #include <rtgui/color.h>
  18. /* graphic driver operations */
  19. struct rtgui_graphic_driver_ops
  20. {
  21. /* set and get pixel in (x, y) */
  22. void (*set_pixel)(rtgui_color_t *c, int x, int y);
  23. void (*get_pixel)(rtgui_color_t *c, int x, int y);
  24. void (*draw_hline)(rtgui_color_t *c, int x1, int x2, int y);
  25. void (*draw_vline)(rtgui_color_t *c, int x , int y1, int y2);
  26. /* draw raw hline */
  27. void (*draw_raw_hline)(rt_uint8_t *pixels, int x1, int x2, int y);
  28. };
  29. /* graphic extension operations */
  30. struct rtgui_graphic_ext_ops
  31. {
  32. /* some 2D operations */
  33. void (*draw_line)(rtgui_color_t *c, int x1, int y1, int x2, int y2);
  34. void (*draw_rect)(rtgui_color_t *c, int x1, int y1, int x2, int y2);
  35. void (*fill_rect)(rtgui_color_t *c, int x1, int y1, int x2, int y2);
  36. void (*draw_circle)(rtgui_color_t *c, int x, int y, int r);
  37. void (*fill_circle)(rtgui_color_t *c, int x, int y, int r);
  38. void (*draw_ellipse)(rtgui_color_t *c, int x, int y, int rx, int ry);
  39. void (*fill_ellipse)(rtgui_color_t *c, int x, int y, int rx, int ry);
  40. };
  41. struct rtgui_graphic_driver
  42. {
  43. /* pixel format and byte per pixel */
  44. rt_uint8_t pixel_format;
  45. rt_uint8_t bits_per_pixel;
  46. rt_uint16_t pitch;
  47. /* screen width and height */
  48. rt_uint16_t width;
  49. rt_uint16_t height;
  50. /* framebuffer address and ops */
  51. rt_uint8_t *framebuffer;
  52. struct rt_device* device;
  53. const struct rtgui_graphic_driver_ops *ops;
  54. const struct rtgui_graphic_ext_ops *ext_ops;
  55. };
  56. struct rtgui_graphic_driver *rtgui_graphic_driver_get_default(void);
  57. void rtgui_graphic_driver_get_rect(const struct rtgui_graphic_driver *driver, rtgui_rect_t *rect);
  58. void rtgui_graphic_driver_screen_update(const struct rtgui_graphic_driver *driver, rtgui_rect_t *rect);
  59. rt_uint8_t *rtgui_graphic_driver_get_framebuffer(const struct rtgui_graphic_driver *driver);
  60. rt_err_t rtgui_graphic_set_device(rt_device_t device);
  61. void rtgui_graphic_driver_set_framebuffer(void *fb);
  62. rt_inline struct rtgui_graphic_driver *rtgui_graphic_get_device()
  63. {
  64. return rtgui_graphic_driver_get_default();
  65. }
  66. #ifdef RTGUI_USING_HW_CURSOR
  67. /*
  68. * hardware cursor
  69. */
  70. enum rtgui_cursor_type
  71. {
  72. RTGUI_CURSOR_ARROW,
  73. RTGUI_CURSOR_HAND,
  74. };
  75. void rtgui_cursor_set_device(const char* device_name);
  76. void rtgui_cursor_set_position(rt_uint16_t x, rt_uint16_t y);
  77. void rtgui_cursor_set_image(enum rtgui_cursor_type type);
  78. #endif
  79. #ifdef RTGUI_USING_VFRAMEBUFFER
  80. void rtgui_graphic_driver_vmode_enter(void);
  81. void rtgui_graphic_driver_vmode_exit(void);
  82. struct rtgui_dc* rtgui_graphic_driver_get_rect_buffer(const struct rtgui_graphic_driver *driver, struct rtgui_rect *rect);
  83. #endif
  84. rt_bool_t rtgui_graphic_driver_is_vmode(void);
  85. #endif