Subversion Repositories Kolibri OS

Rev

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

  1. /*
  2.  * Copyright 2009 John-Mark Bell <jmb@netsurf-browser.org>
  3.  *
  4.  * This file is part of NetSurf, http://www.netsurf-browser.org/
  5.  *
  6.  * NetSurf is free software; you can redistribute it and/or modify
  7.  * it under the terms of the GNU General Public License as published by
  8.  * the Free Software Foundation; version 2 of the License.
  9.  *
  10.  * NetSurf 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 this program.  If not, see <http://www.gnu.org/licenses/>.
  17.  */
  18.  
  19. #ifndef NETSURF_CSS_UTILS_H_
  20. #define NETSURF_CSS_UTILS_H_
  21.  
  22. #include "css/css.h"
  23. #include "desktop/plot_style.h"
  24.  
  25. /* DPI of the screen, in fixed point units */
  26. extern css_fixed nscss_screen_dpi;
  27.  
  28. /**
  29.  * Convert a CSS color to a NetSurf colour primitive
  30.  *
  31.  * ARGB -> (1-A)BGR
  32.  *
  33.  * \param color  The CSS color to convert
  34.  * \return Corresponding NetSurf colour primitive
  35.  */
  36. #define nscss_color_to_ns(color) \
  37.                 (0xff000000 - ((color) & 0xff000000)) | \
  38.                 (((color) & 0xff0000) >> 16) | \
  39.                 ((color) & 0xff00) | \
  40.                 (((color) & 0xff) << 16)
  41.  
  42. /**
  43.  * Determine if a CSS color primitive is transparent
  44.  *
  45.  * \param color  The CSS color to consider
  46.  * \return True if the color is transparent, false otherwise
  47.  */
  48. #define nscss_color_is_transparent(color) \
  49.                 (((color) >> 24) == 0)
  50.  
  51. css_fixed nscss_len2pt(css_fixed length, css_unit unit);
  52. css_fixed nscss_len2px(css_fixed length, css_unit unit,
  53.                 const css_computed_style *style);
  54.  
  55. #endif
  56.