Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * Copyright 2009 Vincent Sanders <vince@simtec.co.uk>
  3.  * Copyright 2010 Michael Drake <tlsa@netsurf-browser.org>
  4.  *
  5.  * This file is part of libnsfb, http://www.netsurf-browser.org/
  6.  * Licenced under the MIT License,
  7.  *                http://www.opensource.org/licenses/mit-license.php
  8.  */
  9.  
  10. #include <stdbool.h>
  11. #include <endian.h>
  12. #include <stdlib.h>
  13.  
  14. #include "libnsfb.h"
  15. #include "libnsfb_plot.h"
  16. #include "libnsfb_plot_util.h"
  17.  
  18. #include "nsfb.h"
  19. #include "plot.h"
  20.  
  21.  
  22. #define UNUSED __attribute__((unused))
  23.  
  24. static inline uint32_t *get_xy_loc(nsfb_t *nsfb, int x, int y)
  25. {
  26.         return (void *)(nsfb->ptr + (y * nsfb->linelen) + (x << 2));
  27. }
  28.  
  29. #if __BYTE_ORDER == __BIG_ENDIAN
  30. static inline nsfb_colour_t pixel_to_colour(UNUSED nsfb_t *nsfb, uint32_t pixel)
  31. {
  32.         /* TODO: FIX */
  33.         return (pixel >> 8) & ~0xFF000000U;
  34. }
  35.  
  36. /* convert a colour value to a 32bpp pixel value ready for screen output */
  37. static inline uint32_t colour_to_pixel(UNUSED nsfb_t *nsfb, nsfb_colour_t c)
  38. {
  39.         /* TODO: FIX */
  40.         return (c << 8);
  41. }
  42. #else /* __BYTE_ORDER == __BIG_ENDIAN */
  43. static inline nsfb_colour_t pixel_to_colour(UNUSED nsfb_t *nsfb, uint32_t pixel)
  44. {
  45.         return pixel | 0xFF000000U;
  46. }
  47.  
  48. /* convert a colour value to a 32bpp pixel value ready for screen output */
  49. static inline uint32_t colour_to_pixel(UNUSED nsfb_t *nsfb, nsfb_colour_t c)
  50. {
  51.         return c;
  52. }
  53. #endif
  54.  
  55. #define PLOT_TYPE uint32_t
  56. #define PLOT_LINELEN(ll) ((ll) >> 2)
  57.  
  58. #include "32bpp-common.c"
  59.  
  60. const nsfb_plotter_fns_t _nsfb_32bpp_xbgr8888_plotters = {
  61.         .line = line,
  62.         .fill = fill,
  63.         .point = point,
  64.         .bitmap = bitmap,
  65.         .glyph8 = glyph8,
  66.         .glyph1 = glyph1,
  67.         .readrect = readrect,
  68. };
  69.  
  70. /*
  71.  * Local Variables:
  72.  * c-basic-offset:8
  73.  * End:
  74.  */
  75.