summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--css/utils.h27
-rw-r--r--desktop/system_colour.c3
2 files changed, 22 insertions, 8 deletions
diff --git a/css/utils.h b/css/utils.h
index 9d40aba7b..f3131f1bb 100644
--- a/css/utils.h
+++ b/css/utils.h
@@ -27,17 +27,32 @@ extern css_fixed nscss_screen_dpi;
/**
* Convert a CSS color to a NetSurf colour primitive
- *
+ *
* ARGB -> (1-A)BGR
*
* \param color The CSS color to convert
* \return Corresponding NetSurf colour primitive
*/
-#define nscss_color_to_ns(color) \
- (0xff000000 - ((color) & 0xff000000)) | \
- (((color) & 0xff0000) >> 16) | \
- ((color) & 0xff00) | \
- (((color) & 0xff) << 16)
+#define nscss_color_to_ns(c) \
+ ( ((~c) & 0xff000000) | \
+ ((( c) & 0xff0000 ) >> 16) | \
+ (( c) & 0xff00 ) | \
+ ((( c) & 0xff ) << 16))
+
+
+/**
+ * Convert a NetSurf color to a CSS colour primitive
+ *
+ * (1-A)BGR -> ARGB
+ *
+ * \param color The NetSurf color to convert
+ * \return Corresponding CSS colour primitive
+ */
+#define ns_color_to_nscss(c) \
+ ( ((~c) & 0xff000000) | \
+ ((( c) & 0xff0000 ) >> 16) | \
+ (( c) & 0xff00 ) | \
+ ((( c) & 0xff ) << 16))
/**
* Determine if a CSS color primitive is transparent
diff --git a/desktop/system_colour.c b/desktop/system_colour.c
index 7b4fded38..4ef170981 100644
--- a/desktop/system_colour.c
+++ b/desktop/system_colour.c
@@ -23,6 +23,7 @@
#include "utils/utils.h"
#include "utils/log.h"
+#include "css/utils.h"
#include "desktop/gui.h"
#include "utils/nsoption.h"
@@ -82,8 +83,6 @@ colour gui_system_colour_char(const char *name)
return ret;
}
-#define ns_color_to_nscss(c) (((0xff - (((c) >> 24) & 0xff)) << 24) | ((c) & 0xFF00) | (((c) >> 16) & 0xFF) | (((c) & 0xFF) << 16))
-
css_error gui_system_colour(void *pw, lwc_string *name, css_color *colour)
{
unsigned int ccount;