summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorscuri <scuri>2009-12-01 18:50:14 +0000
committerscuri <scuri>2009-12-01 18:50:14 +0000
commitdae1bed96c9ad7654f44ec486bd71c04936e7fa7 (patch)
tree195a52db1882a615a3586f960aa7883b2c74b370
parent7dc817d0c129e0b6a37a54b679c42322a659b060 (diff)
# Changed: ANTIALIAS attribute is now respected also by CanvasText in the IMAGERGB driver.
# Changed: WriteMode=XOR is ignored if alpha transparency is used in the IMAGERGB driver.
-rw-r--r--src/drv/cdirgb.c61
1 files changed, 40 insertions, 21 deletions
diff --git a/src/drv/cdirgb.c b/src/drv/cdirgb.c
index ddbcb4d..8baef1e 100644
--- a/src/drv/cdirgb.c
+++ b/src/drv/cdirgb.c
@@ -58,11 +58,33 @@ struct _cdCtxCanvas
#define RGB_COMPOSE_OVER(_SRC, _SRC_ALPHA, _DST, _TMP_MULTI, _TMP_ALPHA) (unsigned char)(((_SRC_ALPHA)*(_SRC) + (_TMP_MULTI)*(_DST)) / (_TMP_ALPHA))
+#define RGBA_WRITE_MODE(_write_mode, _pdst_red, _pdst_green, _pdst_blue, _tmp_red, _tmp_green, _tmp_blue) \
+{ \
+ switch (_write_mode) \
+ { \
+ case CD_REPLACE: \
+ *_pdst_red = _tmp_red; \
+ *_pdst_green = _tmp_green; \
+ *_pdst_blue = _tmp_blue; \
+ break; \
+ case CD_XOR: \
+ *_pdst_red ^= _tmp_red; \
+ *_pdst_green ^= _tmp_green; \
+ *_pdst_blue ^= _tmp_blue; \
+ break; \
+ case CD_NOT_XOR: \
+ *_pdst_red = (unsigned char)~(_tmp_red ^ *_pdst_red); \
+ *_pdst_green = (unsigned char)~(_tmp_green ^ *_pdst_green); \
+ *_pdst_blue = (unsigned char)~(_tmp_blue ^ *_pdst_blue); \
+ break; \
+ } \
+}
+
#define RGBA_COLOR_COMBINE(_ctxcanvas, _pdst_red, _pdst_green, _pdst_blue, _pdst_alpha, _src_red, _src_green, _src_blue, _src_alpha) \
{ \
- unsigned char _tmp_red = 0, _tmp_green = 0, _tmp_blue = 0; \
+ unsigned char _tmp_red = 0, _tmp_green = 0, _tmp_blue = 0; \
\
- if (_pdst_alpha) /* destiny has alpha */ \
+ if (_pdst_alpha) /* destiny has alpha */ \
{ \
if (_src_alpha != 255) /* some transparency */ \
{ \
@@ -74,6 +96,8 @@ struct _cdCtxCanvas
_tmp_green = _src_green; \
_tmp_blue = _src_blue; \
*_pdst_alpha = _src_alpha; \
+ RGBA_WRITE_MODE(CD_REPLACE, _pdst_red, _pdst_green, _pdst_blue, \
+ _tmp_red, _tmp_green, _tmp_blue); \
} \
else if (*_pdst_alpha == 255) /* destiny opaque */ \
{ \
@@ -81,6 +105,8 @@ struct _cdCtxCanvas
_tmp_green = CD_ALPHA_BLEND(_src_green, *_pdst_green, _src_alpha); \
_tmp_blue = CD_ALPHA_BLEND(_src_blue, *_pdst_blue, _src_alpha); \
/* *_pdst_alpha is not changed */ \
+ RGBA_WRITE_MODE(CD_REPLACE, _pdst_red, _pdst_green, _pdst_blue, \
+ _tmp_red, _tmp_green, _tmp_blue); \
} \
else /* (0<*_pdst_alpha<255 && 0<_src_alpha<255) destiny and source are semi-transparent */ \
{ \
@@ -96,6 +122,8 @@ struct _cdCtxCanvas
_tmp_green = RGB_COMPOSE_OVER(_src_green, _tmp_src_alpha, *_pdst_green, _tmp_multi, _tmp_alpha); \
_tmp_blue = RGB_COMPOSE_OVER(_src_blue, _tmp_src_alpha, *_pdst_blue, _tmp_multi, _tmp_alpha); \
*_pdst_alpha = (unsigned char)(_tmp_alpha / 255); \
+ RGBA_WRITE_MODE(CD_REPLACE, _pdst_red, _pdst_green, _pdst_blue, \
+ _tmp_red, _tmp_green, _tmp_blue); \
} \
} \
else /* (_src_alpha == 0) source full transparent */ \
@@ -103,6 +131,8 @@ struct _cdCtxCanvas
_tmp_red = *_pdst_red; \
_tmp_green = *_pdst_green; \
_tmp_blue = *_pdst_blue; \
+ RGBA_WRITE_MODE(CD_REPLACE, _pdst_red, _pdst_green, _pdst_blue, \
+ _tmp_red, _tmp_green, _tmp_blue); \
/* *_pdst_alpha is not changed */ \
} \
} \
@@ -112,6 +142,8 @@ struct _cdCtxCanvas
_tmp_green = _src_green; \
_tmp_blue = _src_blue; \
*_pdst_alpha = (unsigned char)255; /* set destiny as opaque */ \
+ RGBA_WRITE_MODE(_ctxcanvas->canvas->write_mode, _pdst_red, _pdst_green, _pdst_blue, \
+ _tmp_red, _tmp_green, _tmp_blue); \
} \
} \
else /* destiny does NOT have alpha */ \
@@ -123,12 +155,16 @@ struct _cdCtxCanvas
_tmp_red = CD_ALPHA_BLEND(_src_red, *_pdst_red, _src_alpha); \
_tmp_green = CD_ALPHA_BLEND(_src_green, *_pdst_green, _src_alpha); \
_tmp_blue = CD_ALPHA_BLEND(_src_blue, *_pdst_blue, _src_alpha); \
+ RGBA_WRITE_MODE(CD_REPLACE, _pdst_red, _pdst_green, _pdst_blue, \
+ _tmp_red, _tmp_green, _tmp_blue); \
} \
else /* (_src_alpha == 0) source full transparent */ \
{ \
_tmp_red = *_pdst_red; \
_tmp_green = *_pdst_green; \
_tmp_blue = *_pdst_blue; \
+ RGBA_WRITE_MODE(CD_REPLACE, _pdst_red, _pdst_green, _pdst_blue, \
+ _tmp_red, _tmp_green, _tmp_blue); \
} \
} \
else /* (_src_alpha == 255) source has no alpha = opaque */ \
@@ -136,27 +172,10 @@ struct _cdCtxCanvas
_tmp_red = _src_red; \
_tmp_green = _src_green; \
_tmp_blue = _src_blue; \
+ RGBA_WRITE_MODE(_ctxcanvas->canvas->write_mode, _pdst_red, _pdst_green, _pdst_blue, \
+ _tmp_red, _tmp_green, _tmp_blue); \
} \
} \
- \
- switch (_ctxcanvas->canvas->write_mode) \
- { \
- case CD_REPLACE: \
- *_pdst_red = _tmp_red; \
- *_pdst_green = _tmp_green; \
- *_pdst_blue = _tmp_blue; \
- break; \
- case CD_XOR: \
- *_pdst_red ^= _tmp_red; \
- *_pdst_green ^= _tmp_green; \
- *_pdst_blue ^= _tmp_blue; \
- break; \
- case CD_NOT_XOR: \
- *_pdst_red = (unsigned char)~(_tmp_red ^ *_pdst_red); \
- *_pdst_green = (unsigned char)~(_tmp_green ^ *_pdst_green); \
- *_pdst_blue = (unsigned char)~(_tmp_blue ^ *_pdst_blue); \
- break; \
- } \
}
static void sCombineRGBColor(cdCtxCanvas* ctxcanvas, int offset, long color)