aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorinmarket <andrewh@inmarket.com.au>2013-07-29 16:29:25 +1000
committerinmarket <andrewh@inmarket.com.au>2013-07-29 16:29:25 +1000
commit7c303eb72efe8a61383c4914fb940024236b2bdb (patch)
tree743f66a4d68fa9811c8153368018e907370d8dbc /include
parent12085b8014234b10739d5cf22ed6c6d055ce8741 (diff)
downloaduGFX-7c303eb72efe8a61383c4914fb940024236b2bdb.tar.gz
uGFX-7c303eb72efe8a61383c4914fb940024236b2bdb.tar.bz2
uGFX-7c303eb72efe8a61383c4914fb940024236b2bdb.zip
Vastly simplify GDISP mcufont interface code.
Fix boundary cases. Prevent overwriting of defined display area. Improve performance. Remove hardware acceleration for fonts (unlikely anyway unles the hardware understood our software font structures)
Diffstat (limited to 'include')
-rw-r--r--include/gdisp/gdisp.h64
-rw-r--r--include/gdisp/lld/emulation.c137
-rw-r--r--include/gdisp/lld/gdisp_lld.h36
-rw-r--r--include/gdisp/lld/gdisp_lld_msgs.h21
-rw-r--r--include/gdisp/options.h4
5 files changed, 30 insertions, 232 deletions
diff --git a/include/gdisp/gdisp.h b/include/gdisp/gdisp.h
index 25194c4f..aa418cdb 100644
--- a/include/gdisp/gdisp.h
+++ b/include/gdisp/gdisp.h
@@ -37,12 +37,6 @@ typedef int16_t coord_t;
#if GFX_USE_GDISP || defined(__DOXYGEN__)
/*===========================================================================*/
-/* Include the low level driver configuration information */
-/*===========================================================================*/
-
-#include "gdisp_lld_config.h"
-
-/*===========================================================================*/
/* Type definitions */
/*===========================================================================*/
@@ -480,35 +474,6 @@ extern "C" {
void gdispFillArc(coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle, color_t color);
#endif
- /* Basic Text Rendering Functions */
-
- #if GDISP_NEED_TEXT || defined(__DOXYGEN__)
- /**
- * @brief Draw a text character.
- *
- * @param[in] x,y The position for the text
- * @param[in] c The character to draw
- * @param[in] font The font to use
- * @param[in] color The color to use
- *
- * @api
- */
- void gdispDrawChar(coord_t x, coord_t y, uint16_t c, font_t font, color_t color);
-
- /**
- * @brief Draw a text character with a filled background.
- *
- * @param[in] x,y The position for the text
- * @param[in] c The character to draw
- * @param[in] font The font to use
- * @param[in] color The color to use
- * @param[in] bgcolor The background color to use
- *
- * @api
- */
- void gdispFillChar(coord_t x, coord_t y, uint16_t c, font_t font, color_t color, color_t bgcolor);
- #endif
-
/* Read a pixel Function */
#if GDISP_NEED_PIXELREAD || defined(__DOXYGEN__)
@@ -591,8 +556,6 @@ extern "C" {
#define gdispFillArc(x, y, radius, sangle, eangle, color) gdisp_lld_fill_arc(x, y, radius, sangle, eangle, color)
#define gdispDrawEllipse(x, y, a, b, color) gdisp_lld_draw_ellipse(x, y, a, b, color)
#define gdispFillEllipse(x, y, a, b, color) gdisp_lld_fill_ellipse(x, y, a, b, color)
- #define gdispDrawChar(x, y, c, font, color) gdisp_lld_draw_char(x, y, c, font, color)
- #define gdispFillChar(x, y, c, font, color, bgcolor) gdisp_lld_fill_char(x, y, c, font, color, bgcolor)
#define gdispGetPixelColor(x, y) gdisp_lld_get_pixel_color(x, y)
#define gdispVerticalScroll(x, y, cx, cy, lines, bgcolor) gdisp_lld_vertical_scroll(x, y, cx, cy, lines, bgcolor)
#define gdispControl(what, value) gdisp_lld_control(what, value)
@@ -652,10 +615,35 @@ void gdispDrawBox(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color);
void gdispFillConvexPoly(coord_t tx, coord_t ty, const point *pntarray, unsigned cnt, color_t color);
#endif
-/* Extra Text Functions */
+/* Text Functions */
#if GDISP_NEED_TEXT || defined(__DOXYGEN__)
/**
+ * @brief Draw a text character.
+ *
+ * @param[in] x,y The position for the text
+ * @param[in] c The character to draw
+ * @param[in] font The font to use
+ * @param[in] color The color to use
+ *
+ * @api
+ */
+ void gdispDrawChar(coord_t x, coord_t y, uint16_t c, font_t font, color_t color);
+
+ /**
+ * @brief Draw a text character with a filled background.
+ *
+ * @param[in] x,y The position for the text
+ * @param[in] c The character to draw
+ * @param[in] font The font to use
+ * @param[in] color The color to use
+ * @param[in] bgcolor The background color to use
+ *
+ * @api
+ */
+ void gdispFillChar(coord_t x, coord_t y, uint16_t c, font_t font, color_t color, color_t bgcolor);
+
+ /**
* @brief Draw a text string.
*
* @param[in] x,y The position for the text
diff --git a/include/gdisp/lld/emulation.c b/include/gdisp/lld/emulation.c
index 716a3988..cb0c9c4b 100644
--- a/include/gdisp/lld/emulation.c
+++ b/include/gdisp/lld/emulation.c
@@ -461,135 +461,6 @@ GDISPDriver GDISP;
}
#endif
-#if GDISP_NEED_TEXT && !GDISP_HARDWARE_TEXT
- #include "mcufont.h"
-#endif
-
-#if GDISP_NEED_TEXT && !GDISP_HARDWARE_TEXT
- static void gdisp_lld_draw_char_callback(int16_t x, int16_t y, uint8_t count, uint8_t alpha, void *state) {
- color_t color = *(color_t*)state;
- if (alpha == 255)
- {
- if (count == 1)
- gdisp_lld_draw_pixel(x, y, color);
- else
- gdisp_lld_fill_area(x, y, count, 1, color);
- }
-#if GDISP_NEED_ANTIALIAS
- else
- {
- while (count--)
- {
- color_t oldColor;
-
- oldColor = gdisp_lld_get_pixel_color(x, y);
- oldColor = gdispBlendColor(color, oldColor, alpha);
- gdisp_lld_draw_pixel(x, y, oldColor);
-
- x++;
- }
- }
-#endif
- }
-
- void gdisp_lld_draw_char(coord_t x, coord_t y, uint16_t c, font_t font, color_t color) {
- mf_render_character(font, x, y, c, gdisp_lld_draw_char_callback, &color);
- }
-#endif
-
-#if GDISP_NEED_TEXT && !GDISP_HARDWARE_TEXTFILLS
- typedef struct {
- int16_t x0;
- int16_t y0;
- int16_t x1;
- int16_t y1;
- int16_t x;
- int16_t y;
- color_t fg;
- color_t bg;
- } gdisp_lld_fill_char_state_t;
-
- static void gdisp_lld_fill_char_callback(int16_t x, int16_t y, uint8_t count, uint8_t alpha, void *state) {
- gdisp_lld_fill_char_state_t *s = state;
-
- if (y > s->y && s->x != s->x0)
- {
- /* Fill background to the end of current line */
- gdisp_lld_fill_area(s->x, s->y, s->x1 - s->x, 1, s->bg);
- s->y++;
- s->x = s->x0;
- }
-
- if (y > s->y)
- {
- /* Fill background for given number of full lines */
- gdisp_lld_fill_area(s->x0, s->y, s->x1 - s->x0, y - s->y, s->bg);
- s->y = y;
- }
-
- if (x > s->x)
- {
- /* Fill background from previous X position */
- gdisp_lld_fill_area(s->x, s->y, x - s->x, 1, s->bg);
- s->x = x;
- }
-
- if (!count)
- return;
-
- if (y == s->y)
- {
- s->x += count;
-
- if (s->x == s->x1)
- {
- s->x = s->x0;
- s->y++;
- }
- }
-
- /* Draw the foreground */
- if (alpha == 255 || alpha == 0)
- {
- if (count == 1)
- gdisp_lld_draw_pixel(x, y, alpha ? s->fg : s->bg);
- else
- gdisp_lld_fill_area(x, y, count, 1, alpha ? s->fg : s->bg);
- }
-#if GDISP_NEED_ANTIALIAS
- else
- {
- while (count--)
- {
- color_t color;
- color = gdispBlendColor(s->fg, s->bg, alpha);
- gdisp_lld_draw_pixel(x, y, color);
-
- x++;
- }
- }
-#endif
- }
-
- void gdisp_lld_fill_char(coord_t x, coord_t y, uint16_t c, font_t font, color_t color, color_t bgcolor) {
- gdisp_lld_fill_char_state_t state;
-
- state.x0 = x;
- state.y0 = y;
- state.x1 = x + mf_character_width(font, c) + font->baseline_x;
- state.y1 = y + font->height;
- state.x = x;
- state.y = y;
- state.fg = color;
- state.bg = bgcolor;
-
- mf_render_character(font, x, y, c, gdisp_lld_fill_char_callback, &state);
-
- gdisp_lld_fill_char_callback(state.x0, state.y1, 0, 0, &state);
- }
-#endif
-
-
#if GDISP_NEED_CONTROL && !GDISP_HARDWARE_CONTROL
void gdisp_lld_control(unsigned what, void *value) {
(void)what;
@@ -657,14 +528,6 @@ void *gdisp_lld_query(unsigned what) {
gdisp_lld_fill_circle(msg->fillarc.x, msg->fillarc.y, msg->fillarc.radius, msg->fillarc.startangle, msg->fillarc.endangle, msg->fillarc.color);
break;
#endif
- #if GDISP_NEED_TEXT
- case GDISP_LLD_MSG_DRAWCHAR:
- gdisp_lld_draw_char(msg->drawchar.x, msg->drawchar.y, msg->drawchar.c, msg->drawchar.font, msg->drawchar.color);
- break;
- case GDISP_LLD_MSG_FILLCHAR:
- gdisp_lld_fill_char(msg->fillchar.x, msg->fillchar.y, msg->fillchar.c, msg->fillchar.font, msg->fillchar.color, msg->fillchar.bgcolor);
- break;
- #endif
#if GDISP_NEED_PIXELREAD
case GDISP_LLD_MSG_GETPIXELCOLOR:
msg->getpixelcolor.result = gdisp_lld_get_pixel_color(msg->getpixelcolor.x, msg->getpixelcolor.y);
diff --git a/include/gdisp/lld/gdisp_lld.h b/include/gdisp/lld/gdisp_lld.h
index 9c4b3947..98c7569c 100644
--- a/include/gdisp/lld/gdisp_lld.h
+++ b/include/gdisp/lld/gdisp_lld.h
@@ -107,22 +107,6 @@
#endif
/**
- * @brief Hardware accelerated text drawing.
- * @details If set to @p FALSE software emulation is used.
- */
- #ifndef GDISP_HARDWARE_TEXT
- #define GDISP_HARDWARE_TEXT FALSE
- #endif
-
- /**
- * @brief Hardware accelerated text drawing with a filled background.
- * @details If set to @p FALSE software emulation is used.
- */
- #ifndef GDISP_HARDWARE_TEXTFILLS
- #define GDISP_HARDWARE_TEXTFILLS FALSE
- #endif
-
- /**
* @brief Hardware accelerated scrolling.
* @details If set to @p FALSE there is no support for scrolling.
*/
@@ -167,26 +151,6 @@
* @name GDISP software algorithm choices
* @{
*/
- /**
- * @brief For filled text drawing, use a background fill and then draw
- * the text instead of using a blit or direct pixel drawing.
- * @details If set to @p TRUE background fill and then text draw is used.
- * @note This is ignored if hardware accelerated text is supported.
- */
- #ifndef GDISP_SOFTWARE_TEXTFILLDRAW
- #define GDISP_SOFTWARE_TEXTFILLDRAW FALSE
- #endif
-
- /**
- * @brief For filled text drawing, when using a bitmap blit
- * use a column by column buffer rather than a full character
- * buffer to save memory at a small performance cost.
- * @details If set to @p TRUE background fill one character column at a time.
- * @note This is ignored if software text using blit is not being used.
- */
- #ifndef GDISP_SOFTWARE_TEXTBLITCOLUMN
- #define GDISP_SOFTWARE_TEXTBLITCOLUMN FALSE
- #endif
/** @} */
/**
diff --git a/include/gdisp/lld/gdisp_lld_msgs.h b/include/gdisp/lld/gdisp_lld_msgs.h
index 5f4bed9a..2c199cbe 100644
--- a/include/gdisp/lld/gdisp_lld_msgs.h
+++ b/include/gdisp/lld/gdisp_lld_msgs.h
@@ -42,10 +42,6 @@ typedef enum gdisp_msgaction {
GDISP_LLD_MSG_DRAWARC,
GDISP_LLD_MSG_FILLARC,
#endif
- #if GDISP_NEED_TEXT
- GDISP_LLD_MSG_DRAWCHAR,
- GDISP_LLD_MSG_FILLCHAR,
- #endif
#if GDISP_NEED_PIXELREAD
GDISP_LLD_MSG_GETPIXELCOLOR,
#endif
@@ -151,23 +147,6 @@ typedef union gdisp_lld_msg {
coord_t startangle, endangle;
color_t color;
} fillarc;
- struct gdisp_lld_msg_drawchar {
- gfxQueueItem qi;
- gdisp_msgaction_t action; // GDISP_LLD_MSG_DRAWCHAR
- coord_t x, y;
- uint16_t c;
- font_t font;
- color_t color;
- } drawchar;
- struct gdisp_lld_msg_fillchar {
- gfxQueueItem qi;
- gdisp_msgaction_t action; // GDISP_LLD_MSG_FILLCHAR
- coord_t x, y;
- uint16_t c;
- font_t font;
- color_t color;
- color_t bgcolor;
- } fillchar;
struct gdisp_lld_msg_getpixelcolor {
gfxQueueItem qi;
gdisp_msgaction_t action; // GDISP_LLD_MSG_GETPIXELCOLOR
diff --git a/include/gdisp/options.h b/include/gdisp/options.h
index 918c7aea..d5818284 100644
--- a/include/gdisp/options.h
+++ b/include/gdisp/options.h
@@ -296,6 +296,10 @@
/* #define GDISP_USE_GPIO */
/** @} */
+#if GFX_USE_GDISP
+ #include "gdisp_lld_config.h"
+#endif
+
#endif /* _GDISP_OPTIONS_H */
/** @} */