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.         return (pixel >> 8) & ~0xFF000000U;
  33. }
  34. */
  35.  
  36. /* convert a colour value to a 32bpp pixel value ready for screen output */
  37. /*
  38. static inline uint32_t colour_to_pixel(UNUSED nsfb_t *nsfb, nsfb_colour_t c)
  39. {
  40.         return (c << 8);
  41. }
  42. */
  43. //#else /* __BYTE_ORDER == __BIG_ENDIAN */
  44.  
  45.  
  46. static inline nsfb_colour_t pixel_to_colour(UNUSED nsfb_t *nsfb, uint32_t pixel)
  47. {
  48.         return ((pixel & 0xFF) << 16) |
  49.                 ((pixel & 0xFF00)) |
  50.                 ((pixel & 0xFF0000) >> 16);
  51. }
  52.  
  53. /* convert a colour value to a 32bpp pixel value ready for screen output */
  54. static inline uint32_t colour_to_pixel(UNUSED nsfb_t *nsfb, nsfb_colour_t c)
  55. {
  56.         return ((c & 0xff0000) >> 16) | (c & 0xff00) | ((c & 0xff) << 16);
  57. }
  58. //#endif
  59.  
  60. #define PLOT_TYPE uint32_t
  61. #define PLOT_LINELEN(ll) ((ll) >> 2)
  62.  
  63. #include "32bpp-common.c"
  64.  
  65. const nsfb_plotter_fns_t _nsfb_32bpp_xrgb8888_plotters = {
  66.         .line = line,
  67.         .fill = fill,
  68.         .point = point,
  69.         .bitmap = bitmap,
  70.         .glyph8 = glyph8,
  71.         .glyph1 = glyph1,
  72.         .readrect = readrect,
  73. };
  74.  
  75. /*
  76.  * Local Variables:
  77.  * c-basic-offset:8
  78.  * End:
  79.  */
  80.