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.  *
  4.  * This file is part of libnsfb, http://www.netsurf-browser.org/
  5.  * Licenced under the MIT License,
  6.  *                http://www.opensource.org/licenses/mit-license.php
  7.  *
  8.  * This is the exported interface for the libnsfb graphics library.
  9.  */
  10.  
  11. #ifndef _LIBNSFB_PLOT_UTIL_H
  12. #define _LIBNSFB_PLOT_UTIL_H 1
  13.  
  14.  
  15. /* alpha blend two pixels together */
  16. static inline nsfb_colour_t
  17. nsfb_plot_ablend(nsfb_colour_t pixel, nsfb_colour_t scrpixel)
  18. {
  19.     int opacity = pixel >> 24;
  20.     int transp = 0x100 - opacity;
  21.     uint32_t rb, g;
  22.  
  23.     rb = ((pixel & 0xFF00FF) * opacity +
  24.           (scrpixel & 0xFF00FF) * transp) >> 8;
  25.     g  = ((pixel & 0x00FF00) * opacity +
  26.           (scrpixel & 0x00FF00) * transp) >> 8;
  27.  
  28.     return (rb & 0xFF00FF) | (g & 0xFF00);
  29. }
  30.  
  31.  
  32. bool nsfb_plot_clip(const nsfb_bbox_t *  clip, nsfb_bbox_t *  rect);
  33.  
  34. bool nsfb_plot_clip_ctx(nsfb_t *nsfb, nsfb_bbox_t *  rect);
  35.  
  36. bool nsfb_plot_clip_line(const nsfb_bbox_t *  clip, nsfb_bbox_t *  line);
  37.  
  38. bool nsfb_plot_clip_line_ctx(nsfb_t *nsfb, nsfb_bbox_t *  line);
  39.  
  40. /** Obtain a bounding box which is the superset of two source boxes.
  41.  *
  42.  */
  43. bool nsfb_plot_add_rect(const nsfb_bbox_t *box1, const nsfb_bbox_t *box2, nsfb_bbox_t *result);
  44.  
  45. /** Find if two boxes intersect. */
  46. bool nsfb_plot_bbox_intersect(const nsfb_bbox_t *box1, const nsfb_bbox_t *box2);
  47.  
  48. #endif /* _LIBNSFB_PLOT_UTIL_H */
  49.