driver.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. struct rtgui_graphic_driver_ops
  19. {
  20. /* set and get pixel in (x, y) */
  21. void (*set_pixel) (rtgui_color_t *c, int x, int y);
  22. void (*get_pixel) (rtgui_color_t *c, int x, int y);
  23. void (*draw_hline)(rtgui_color_t *c, int x1, int x2, int y);
  24. void (*draw_vline)(rtgui_color_t *c, int x , int y1, int y2);
  25. /* draw raw hline */
  26. void (*draw_raw_hline)(rt_uint8_t *pixels, int x1, int x2, int y);
  27. };
  28. struct rtgui_graphic_driver
  29. {
  30. /* pixel format and byte per pixel */
  31. rt_uint8_t pixel_format;
  32. rt_uint8_t bits_per_pixel;
  33. rt_uint16_t pitch;
  34. /* screen width and height */
  35. rt_uint16_t width;
  36. rt_uint16_t height;
  37. /* framebuffer address and ops */
  38. volatile rt_uint8_t *framebuffer;
  39. rt_device_t device;
  40. const struct rtgui_graphic_driver_ops *ops;
  41. };
  42. void rtgui_graphic_driver_add(const struct rtgui_graphic_driver* driver);
  43. struct rtgui_graphic_driver* rtgui_graphic_driver_get_default(void);
  44. void rtgui_graphic_driver_get_rect(const struct rtgui_graphic_driver *driver, rtgui_rect_t *rect);
  45. void rtgui_graphic_driver_screen_update(const struct rtgui_graphic_driver* driver, rtgui_rect_t *rect);
  46. rt_uint8_t* rtgui_graphic_driver_get_framebuffer(const struct rtgui_graphic_driver* driver);
  47. rt_uint8_t* rtgui_graphic_driver_get_default_framebuffer(void);
  48. rt_err_t rtgui_graphic_set_device(rt_device_t device);
  49. rt_inline struct rtgui_graphic_driver* rtgui_graphic_get_device()
  50. {
  51. extern struct rtgui_graphic_driver _driver;
  52. return &_driver;
  53. }
  54. #endif