fbutil.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * GRUB -- GRand Unified Bootloader
  3. * Copyright (C) 2006,2007 Free Software Foundation, Inc.
  4. *
  5. * GRUB is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * GRUB is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /* NOTE: This header is private header for vbe driver and should not be used
  19. in other parts of the code. */
  20. #ifndef GRUB_VBEUTIL_MACHINE_HEADER
  21. #define GRUB_VBEUTIL_MACHINE_HEADER 1
  22. #include <grub/types.h>
  23. #include <grub/video.h>
  24. struct grub_video_fbblit_info
  25. {
  26. struct grub_video_mode_info *mode_info;
  27. grub_uint8_t *data;
  28. };
  29. /*
  30. * Don't use for 1-bit bitmaps, addressing needs to be done at the bit level
  31. * and it doesn't make sense, in general, to ask for a pointer
  32. * to a particular pixel's data.
  33. *
  34. * This function assumes that bounds checking has been done in previous phase
  35. * and they are opted out in here.
  36. */
  37. static inline void *
  38. grub_video_fb_get_video_ptr (struct grub_video_fbblit_info *source,
  39. unsigned int x, unsigned int y)
  40. {
  41. return source->data + (grub_addr_t) y * source->mode_info->pitch + (grub_addr_t) x * source->mode_info->bytes_per_pixel;
  42. }
  43. /* Advance pointer by VAL bytes. If there is no unaligned access available,
  44. VAL has to be divisible by size of pointed type.
  45. */
  46. #ifdef GRUB_HAVE_UNALIGNED_ACCESS
  47. #define GRUB_VIDEO_FB_ADVANCE_POINTER(ptr, val) ((ptr) = (typeof (ptr)) ((char *) ptr + val))
  48. #else
  49. #define GRUB_VIDEO_FB_ADVANCE_POINTER(ptr, val) ((ptr) += (val) / sizeof (*(ptr)))
  50. #endif
  51. grub_video_color_t get_pixel (struct grub_video_fbblit_info *source,
  52. unsigned int x, unsigned int y);
  53. void set_pixel (struct grub_video_fbblit_info *source,
  54. unsigned int x, unsigned int y, grub_video_color_t color);
  55. #endif /* ! GRUB_VBEUTIL_MACHINE_HEADER */