aboutsummaryrefslogtreecommitdiffstats
path: root/src/gdisp
diff options
context:
space:
mode:
authorinmarket <andrewh@inmarket.com.au>2013-11-17 23:32:19 +1000
committerinmarket <andrewh@inmarket.com.au>2013-11-17 23:32:19 +1000
commit7f1b78a067e11c2394d83dbbc9b0fc78f78af493 (patch)
treecd49bed0ef2fb5469282f525c77e707620e7fbfb /src/gdisp
parent643670ecd1c4dc631b4073d2384ff7fa56cb564d (diff)
downloaduGFX-7f1b78a067e11c2394d83dbbc9b0fc78f78af493.tar.gz
uGFX-7f1b78a067e11c2394d83dbbc9b0fc78f78af493.tar.bz2
uGFX-7f1b78a067e11c2394d83dbbc9b0fc78f78af493.zip
Replace color format conversion macros with proper routines to prevent side effects with using the macro.
Also fix a number of compiler warnings.
Diffstat (limited to 'src/gdisp')
-rw-r--r--src/gdisp/gdisp.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/gdisp/gdisp.c b/src/gdisp/gdisp.c
index 99af5afa..1eb5a41b 100644
--- a/src/gdisp/gdisp.c
+++ b/src/gdisp/gdisp.c
@@ -2825,6 +2825,45 @@ color_t gdispBlendColor(color_t fg, color_t bg, uint8_t alpha)
}
#endif
+#if GDISP_PIXELFORMAT != GDISP_LLD_PIXELFORMAT
+ LLDCOLOR_TYPE gdispColor2Native(color_t c) {
+ #if COLOR_SYSTEM == GDISP_COLORSYSTEM_GRAYSCALE || LLDCOLOR_SYSTEM == GDISP_COLORSYSTEM_GRAYSCALE
+ #if GDISP_HARDWARE_USE_EXACT_COLOR
+ return LLDLUMA2COLOR(EXACT_LUMA_OF(c));
+ #else
+ return LLDLUMA2COLOR(LUMA_OF(c));
+ #endif
+ #elif COLOR_SYSTEM == GDISP_COLORSYSTEM_TRUECOLOR && LLDCOLOR_SYSTEM == GDISP_COLORSYSTEM_TRUECOLOR
+ #if GDISP_HARDWARE_USE_EXACT_COLOR
+ return LLDRGB2COLOR(EXACT_RED_OF(c), EXACT_GREEN_OF(c), EXACT_BLUE_OF(c));
+ #else
+ return LLDRGB2COLOR(RED_OF(c), GREEN_OF(c), BLUE_OF(c));
+ #endif
+ #else
+ #error "GDISP: This pixel format conversion is not supported yet"
+ #endif
+ }
+#endif
+
+#if GDISP_PIXELFORMAT != GDISP_LLD_PIXELFORMAT
+ color_t gdispNative2Color(LLDCOLOR_TYPE c) {
+ #if COLOR_SYSTEM == GDISP_COLORSYSTEM_GRAYSCALE || LLDCOLOR_SYSTEM == GDISP_COLORSYSTEM_GRAYSCALE
+ #if GDISP_HARDWARE_USE_EXACT_COLOR
+ return LUMA2COLOR(LLDEXACT_LUMA_OF(c));
+ #else
+ return LUMA2COLOR(LLDLUMA_OF(c));
+ #endif
+ #elif COLOR_SYSTEM == GDISP_COLORSYSTEM_TRUECOLOR && LLDCOLOR_SYSTEM == GDISP_COLORSYSTEM_TRUECOLOR
+ #if GDISP_HARDWARE_USE_EXACT_COLOR
+ return RGB2COLOR(LLDEXACT_RED_OF(c), LLDEXACT_GREEN_OF(c), LLDEXACT_BLUE_OF(c));
+ #else
+ return RGB2COLOR(LLDRED_OF(c), LLDGREEN_OF(c), LLDBLUE_OF(c));
+ #endif
+ #else
+ #error "GDISP: This pixel format conversion is not supported yet"
+ #endif
+ }
+#endif
#endif /* GFX_USE_GDISP */
/** @} */