driver.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * File : driver.h
  3. * This file is part of RT-Thread GUI Engine
  4. * COPYRIGHT (C) 2006 - 2017, RT-Thread Development Team
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. * 2009-10-04 Bernard first version
  23. */
  24. #ifndef __RTGUI_DRIVER_H__
  25. #define __RTGUI_DRIVER_H__
  26. #include <rtgui/list.h>
  27. #include <rtgui/color.h>
  28. /* graphic driver operations */
  29. struct rtgui_graphic_driver_ops
  30. {
  31. /* set and get pixel in (x, y) */
  32. void (*set_pixel)(rtgui_color_t *c, int x, int y);
  33. void (*get_pixel)(rtgui_color_t *c, int x, int y);
  34. void (*draw_hline)(rtgui_color_t *c, int x1, int x2, int y);
  35. void (*draw_vline)(rtgui_color_t *c, int x , int y1, int y2);
  36. /* draw raw hline */
  37. void (*draw_raw_hline)(rt_uint8_t *pixels, int x1, int x2, int y);
  38. };
  39. /* graphic extension operations */
  40. struct rtgui_graphic_ext_ops
  41. {
  42. /* some 2D operations */
  43. void (*draw_line)(rtgui_color_t *c, int x1, int y1, int x2, int y2);
  44. void (*draw_rect)(rtgui_color_t *c, int x1, int y1, int x2, int y2);
  45. void (*fill_rect)(rtgui_color_t *c, int x1, int y1, int x2, int y2);
  46. void (*draw_circle)(rtgui_color_t *c, int x, int y, int r);
  47. void (*fill_circle)(rtgui_color_t *c, int x, int y, int r);
  48. void (*draw_ellipse)(rtgui_color_t *c, int x, int y, int rx, int ry);
  49. void (*fill_ellipse)(rtgui_color_t *c, int x, int y, int rx, int ry);
  50. };
  51. struct rtgui_graphic_driver
  52. {
  53. /* pixel format and byte per pixel */
  54. rt_uint8_t pixel_format;
  55. rt_uint8_t bits_per_pixel;
  56. rt_uint16_t pitch;
  57. /* screen width and height */
  58. rt_uint16_t width;
  59. rt_uint16_t height;
  60. /* framebuffer address and ops */
  61. rt_uint8_t *framebuffer;
  62. struct rt_device* device;
  63. const struct rtgui_graphic_driver_ops *ops;
  64. const struct rtgui_graphic_ext_ops *ext_ops;
  65. };
  66. struct rtgui_graphic_driver *rtgui_graphic_driver_get_default(void);
  67. void rtgui_graphic_driver_get_rect(const struct rtgui_graphic_driver *driver, rtgui_rect_t *rect);
  68. void rtgui_graphic_driver_screen_update(const struct rtgui_graphic_driver *driver, rtgui_rect_t *rect);
  69. rt_uint8_t *rtgui_graphic_driver_get_framebuffer(const struct rtgui_graphic_driver *driver);
  70. rt_err_t rtgui_graphic_set_device(rt_device_t device);
  71. void rtgui_graphic_driver_set_framebuffer(void *fb);
  72. rt_inline struct rtgui_graphic_driver *rtgui_graphic_get_device()
  73. {
  74. return rtgui_graphic_driver_get_default();
  75. }
  76. #ifdef RTGUI_USING_HW_CURSOR
  77. /*
  78. * hardware cursor
  79. */
  80. enum rtgui_cursor_type
  81. {
  82. RTGUI_CURSOR_ARROW,
  83. RTGUI_CURSOR_HAND,
  84. };
  85. void rtgui_cursor_set_device(const char* device_name);
  86. void rtgui_cursor_set_position(rt_uint16_t x, rt_uint16_t y);
  87. void rtgui_cursor_set_image(enum rtgui_cursor_type type);
  88. #endif
  89. #ifdef RTGUI_USING_VFRAMEBUFFER
  90. void rtgui_graphic_driver_vmode_enter(void);
  91. void rtgui_graphic_driver_vmode_exit(void);
  92. struct rtgui_dc* rtgui_graphic_driver_get_rect_buffer(const struct rtgui_graphic_driver *driver, struct rtgui_rect *rect);
  93. #endif
  94. rt_bool_t rtgui_graphic_driver_is_vmode(void);
  95. #endif