aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorinmarket <andrewh@inmarket.com.au>2013-09-06 12:29:06 +1000
committerinmarket <andrewh@inmarket.com.au>2013-09-06 12:29:06 +1000
commit6e4437255b603b5b25360481507099dd9b92f942 (patch)
treee31ce6c06f5f155dd26ce41b9cc76cff945b2f40 /include
parent439426667990b90f76f759ae8f993215c16770cd (diff)
downloaduGFX-6e4437255b603b5b25360481507099dd9b92f942.tar.gz
uGFX-6e4437255b603b5b25360481507099dd9b92f942.tar.bz2
uGFX-6e4437255b603b5b25360481507099dd9b92f942.zip
GDISP revamp - stage 1
New low level driver interface: Only Win32 ported currently Significant reduction in GDISP stack usage Improved performance particularly for native streaming drivers New circle, ellipse, arc routines (draw and fill) that are significantly more efficient and don't overdraw New arc draw algorithm that measures angles correctly. New arc fill algorithm for that actually works without overdrawing or gaps. Much more to come...
Diffstat (limited to 'include')
-rw-r--r--include/gdisp/gdisp.h494
-rw-r--r--include/gdisp/lld/emulation.c558
-rw-r--r--include/gdisp/lld/gdisp_lld.h202
-rw-r--r--include/gmisc/gmisc.h1
4 files changed, 321 insertions, 934 deletions
diff --git a/include/gdisp/gdisp.h b/include/gdisp/gdisp.h
index b82c9f3c..3a1968ed 100644
--- a/include/gdisp/gdisp.h
+++ b/include/gdisp/gdisp.h
@@ -76,20 +76,16 @@ typedef enum powermode {powerOff, powerSleep, powerDeepSleep, powerOn} gdisp_pow
* Applications should always use the routines and macros defined
* below to access it in case the implementation ever changed.
*/
-typedef struct GDISPDriver_t {
+typedef struct GDISPControl {
coord_t Width;
coord_t Height;
gdisp_orientation_t Orientation;
gdisp_powermode_t Powermode;
uint8_t Backlight;
uint8_t Contrast;
- #if GDISP_NEED_CLIP || GDISP_NEED_VALIDATION
- coord_t clipx0, clipy0;
- coord_t clipx1, clipy1; /* not inclusive */
- #endif
- } GDISPDriver;
+ } GDISPControl;
-extern GDISPDriver GDISP;
+extern GDISPControl *GDISP;
/*===========================================================================*/
/* Constants. */
@@ -129,6 +125,7 @@ extern GDISPDriver GDISP;
*/
#define GDISP_PIXELFORMAT_MONO 1
#define GDISP_PIXELFORMAT_RGB565 565
+#define GDISP_PIXELFORMAT_BGR565 9565
#define GDISP_PIXELFORMAT_RGB888 888
#define GDISP_PIXELFORMAT_RGB444 444
#define GDISP_PIXELFORMAT_RGB332 332
@@ -219,10 +216,20 @@ extern GDISPDriver GDISP;
#define MASKCOLOR FALSE
#define RGB2COLOR(r,g,b) ((color_t)((((r) & 0xF8)<<8) | (((g) & 0xFC)<<3) | (((b) & 0xF8)>>3)))
#define HTML2COLOR(h) ((color_t)((((h) & 0xF80000)>>8) | (((h) & 0x00FC00)>>5) | (((h) & 0x0000F8)>>3)))
- #define RED_OF(c) (((c) & 0xF800)>>8)
+ #define RED_OF(c) (((c)&0xF800)>>8)
#define GREEN_OF(c) (((c)&0x07E0)>>3)
#define BLUE_OF(c) (((c)&0x001F)<<3)
+#elif GDISP_PIXELFORMAT == GDISP_PIXELFORMAT_BGR565
+ typedef uint16_t color_t;
+ #define COLOR(c) ((color_t)(c))
+ #define MASKCOLOR FALSE
+ #define RGB2COLOR(r,g,b) ((color_t)((((r) & 0xF8)>>3) | (((g) & 0xFC)<<3) | (((b) & 0xF8)<<8)))
+ #define HTML2COLOR(h) ((color_t)((((h) & 0x0000F8)>>3) | (((h) & 0x00FC00)>>5) | (((h) & 0xF80000)>>8)))
+ #define RED_OF(c) (((c)&0x001F)<<3)
+ #define GREEN_OF(c) (((c)&0x07E0)>>3)
+ #define BLUE_OF(c) (((c)& 0xF800)>>8)
+
#elif GDISP_PIXELFORMAT == GDISP_PIXELFORMAT_RGB888
typedef uint32_t color_t;
#define COLOR(c) ((color_t)(((c) & 0xFFFFFF)))
@@ -296,289 +303,254 @@ typedef color_t pixel_t;
extern "C" {
#endif
-#if GDISP_NEED_MULTITHREAD || GDISP_NEED_ASYNC || defined(__DOXYGEN__)
- /* These routines can be hardware accelerated
- * - Do not add a routine here unless it has also been added to the hardware acceleration layer
- */
+/* Base Functions */
- /* Base Functions */
+/**
+ * @brief Blend 2 colors according to the alpha
+ * @return The combined color
+ *
+ * @param[in] fg The foreground color
+ * @param[in] bg The background color
+ * @param[in] alpha The alpha value (0-255). 0 is all background, 255 is all foreground.
+ *
+ * @api
+ */
+color_t gdispBlendColor(color_t fg, color_t bg, uint8_t alpha);
+/* Drawing Functions */
+
+/**
+ * @brief Clear the display to the specified color.
+ *
+ * @param[in] color The color to use when clearing the screen
+ *
+ * @api
+ */
+void gdispClear(color_t color);
+
+/**
+ * @brief Set a pixel in the specified color.
+ *
+ * @param[in] x,y The position to set the pixel.
+ * @param[in] color The color to use
+ *
+ * @api
+ */
+void gdispDrawPixel(coord_t x, coord_t y, color_t color);
+
+/**
+ * @brief Draw a line.
+ *
+ * @param[in] x0,y0 The start position
+ * @param[in] x1,y1 The end position
+ * @param[in] color The color to use
+ *
+ * @api
+ */
+void gdispDrawLine(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color);
+
+/**
+ * @brief Fill an area with a color.
+ *
+ * @param[in] x,y The start position
+ * @param[in] cx,cy The size of the box (outside dimensions)
+ * @param[in] color The color to use
+ *
+ * @api
+ */
+void gdispFillArea(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color);
+
+/**
+ * @brief Fill an area using the supplied bitmap.
+ * @details The bitmap is in the pixel format specified by the low level driver
+ * @note If a packed pixel format is used and the width doesn't
+ * match a whole number of bytes, the next line will start on a
+ * non-byte boundary (no end-of-line padding).
+ * @note If GDISP_NEED_ASYNC is defined then the buffer must be static
+ * or at least retained until this call has finished the blit. You can
+ * tell when all graphics drawing is finished by @p gdispIsBusy() going FALSE.
+ *
+ * @param[in] x,y The start position
+ * @param[in] cx,cy The size of the filled area
+ * @param[in] srcx,srcy The bitmap position to start the fill form
+ * @param[in] srccx The width of a line in the bitmap
+ * @param[in] buffer The bitmap in the driver's pixel format
+ *
+ * @api
+ */
+void gdispBlitAreaEx(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer);
+
+/**
+ * @brief Draw a rectangular box.
+ *
+ * @param[in] x,y The start position
+ * @param[in] cx,cy The size of the box (outside dimensions)
+ * @param[in] color The color to use
+ *
+ * @api
+ */
+void gdispDrawBox(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color);
+
+/* Clipping Functions */
+
+#if GDISP_NEED_CLIP || defined(__DOXYGEN__)
/**
- * @brief Test if the GDISP engine is currently drawing.
- * @note This function will always return FALSE if
- * GDISP_NEED_ASYNC is not defined.
+ * @brief Clip all drawing to the defined area.
*
- * @return TRUE if gdisp is busy, FALSE otherwise
+ * @param[in] x,y The start position
+ * @param[in] cx,cy The size of the clip area
*
* @api
*/
- bool_t gdispIsBusy(void);
+ void gdispSetClip(coord_t x, coord_t y, coord_t cx, coord_t cy);
+#endif
- /* Drawing Functions */
+/* Circle Functions */
+#if GDISP_NEED_CIRCLE || defined(__DOXYGEN__)
/**
- * @brief Clear the display to the specified color.
+ * @brief Draw a circle.
*
- * @param[in] color The color to use when clearing the screen
+ * @param[in] x,y The center of the circle
+ * @param[in] radius The radius of the circle
+ * @param[in] color The color to use
*
* @api
*/
- void gdispClear(color_t color);
+ void gdispDrawCircle(coord_t x, coord_t y, coord_t radius, color_t color);
/**
- * @brief Set a pixel in the specified color.
+ * @brief Draw a filled circle.
*
- * @param[in] x,y The position to set the pixel.
- * @param[in] color The color to use
+ * @param[in] x,y The center of the circle
+ * @param[in] radius The radius of the circle
+ * @param[in] color The color to use
*
* @api
*/
- void gdispDrawPixel(coord_t x, coord_t y, color_t color);
+ void gdispFillCircle(coord_t x, coord_t y, coord_t radius, color_t color);
+#endif
+
+/* Ellipse Functions */
+#if GDISP_NEED_ELLIPSE || defined(__DOXYGEN__)
/**
- * @brief Draw a line.
+ * @brief Draw an ellipse.
*
- * @param[in] x0,y0 The start position
- * @param[in] x1,y1 The end position
- * @param[in] color The color to use
+ * @param[in] x,y The center of the ellipse
+ * @param[in] a,b The dimensions of the ellipse
+ * @param[in] color The color to use
*
* @api
*/
- void gdispDrawLine(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color);
+ void gdispDrawEllipse(coord_t x, coord_t y, coord_t a, coord_t b, color_t color);
/**
- * @brief Fill an area with a color.
+ * @brief Draw a filled ellipse.
*
- * @param[in] x,y The start position
- * @param[in] cx,cy The size of the box (outside dimensions)
- * @param[in] color The color to use
+ * @param[in] x,y The center of the ellipse
+ * @param[in] a,b The dimensions of the ellipse
+ * @param[in] color The color to use
+ *
+ * @api
+ */
+ void gdispFillEllipse(coord_t x, coord_t y, coord_t a, coord_t b, color_t color);
+#endif
+
+/* Arc Functions */
+
+#if GDISP_NEED_ARC || defined(__DOXYGEN__)
+ /*
+ * @brief Draw an arc.
+ *
+ * @param[in] x0,y0 The center point
+ * @param[in] radius The radius of the arc
+ * @param[in] start The start angle (0 to 360)
+ * @param[in] end The end angle (0 to 360)
+ * @param[in] color The color of the arc
+ *
+ * @api
+ */
+ void gdispDrawArc(coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle, color_t color);
+
+ /*
+ * @brief Draw a filled arc.
+ * @note Not very efficient currently - does lots of overdrawing
+ *
+ * @param[in] x0,y0 The center point
+ * @param[in] radius The radius of the arc
+ * @param[in] start The start angle (0 to 360)
+ * @param[in] end The end angle (0 to 360)
+ * @param[in] color The color of the arc
*
* @api
*/
- void gdispFillArea(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color);
+ void gdispFillArc(coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle, color_t color);
+#endif
+/* Read a pixel Function */
+
+#if GDISP_NEED_PIXELREAD || defined(__DOXYGEN__)
/**
- * @brief Fill an area using the supplied bitmap.
- * @details The bitmap is in the pixel format specified by the low level driver
- * @note If a packed pixel format is used and the width doesn't
- * match a whole number of bytes, the next line will start on a
- * non-byte boundary (no end-of-line padding).
- * @note If GDISP_NEED_ASYNC is defined then the buffer must be static
- * or at least retained until this call has finished the blit. You can
- * tell when all graphics drawing is finished by @p gdispIsBusy() going FALSE.
+ * @brief Get the color of a pixel.
+ * @return The color of the pixel.
*
- * @param[in] x,y The start position
- * @param[in] cx,cy The size of the filled area
- * @param[in] srcx,srcy The bitmap position to start the fill form
- * @param[in] srccx The width of a line in the bitmap
- * @param[in] buffer The bitmap in the driver's pixel format
+ * @param[in] x,y The position of the pixel
*
* @api
*/
- void gdispBlitAreaEx(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer);
-
- /* Clipping Functions */
-
- #if GDISP_NEED_CLIP || defined(__DOXYGEN__)
- /**
- * @brief Clip all drawing to the defined area.
- *
- * @param[in] x,y The start position
- * @param[in] cx,cy The size of the clip area
- *
- * @api
- */
- void gdispSetClip(coord_t x, coord_t y, coord_t cx, coord_t cy);
- #endif
-
- /* Circle Functions */
-
- #if GDISP_NEED_CIRCLE || defined(__DOXYGEN__)
- /**
- * @brief Draw a circle.
- *
- * @param[in] x,y The center of the circle
- * @param[in] radius The radius of the circle
- * @param[in] color The color to use
- *
- * @api
- */
- void gdispDrawCircle(coord_t x, coord_t y, coord_t radius, color_t color);
-
- /**
- * @brief Draw a filled circle.
- *
- * @param[in] x,y The center of the circle
- * @param[in] radius The radius of the circle
- * @param[in] color The color to use
- *
- * @api
- */
- void gdispFillCircle(coord_t x, coord_t y, coord_t radius, color_t color);
- #endif
-
- /* Ellipse Functions */
-
- #if GDISP_NEED_ELLIPSE || defined(__DOXYGEN__)
- /**
- * @brief Draw an ellipse.
- *
- * @param[in] x,y The center of the ellipse
- * @param[in] a,b The dimensions of the ellipse
- * @param[in] color The color to use
- *
- * @api
- */
- void gdispDrawEllipse(coord_t x, coord_t y, coord_t a, coord_t b, color_t color);
-
- /**
- * @brief Draw a filled ellipse.
- *
- * @param[in] x,y The center of the ellipse
- * @param[in] a,b The dimensions of the ellipse
- * @param[in] color The color to use
- *
- * @api
- */
- void gdispFillEllipse(coord_t x, coord_t y, coord_t a, coord_t b, color_t color);
- #endif
-
- /* Arc Functions */
-
- #if GDISP_NEED_ARC || defined(__DOXYGEN__)
- /*
- * @brief Draw an arc.
- *
- * @param[in] x0,y0 The center point
- * @param[in] radius The radius of the arc
- * @param[in] start The start angle (0 to 360)
- * @param[in] end The end angle (0 to 360)
- * @param[in] color The color of the arc
- *
- * @api
- */
- void gdispDrawArc(coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle, color_t color);
-
- /*
- * @brief Draw a filled arc.
- * @note Not very efficient currently - does lots of overdrawing
- *
- * @param[in] x0,y0 The center point
- * @param[in] radius The radius of the arc
- * @param[in] start The start angle (0 to 360)
- * @param[in] end The end angle (0 to 360)
- * @param[in] color The color of the arc
- *
- * @api
- */
- void gdispFillArc(coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle, color_t color);
- #endif
-
- /* Read a pixel Function */
-
- #if GDISP_NEED_PIXELREAD || defined(__DOXYGEN__)
- /**
- * @brief Get the color of a pixel.
- * @return The color of the pixel.
- *
- * @param[in] x,y The position of the pixel
- *
- * @api
- */
- color_t gdispGetPixelColor(coord_t x, coord_t y);
- #endif
-
- /* Scrolling Function - clears the area scrolled out */
-
- #if GDISP_NEED_SCROLL || defined(__DOXYGEN__)
- /**
- * @brief Scroll vertically a section of the screen.
- * @pre GDISP_NEED_SCROLL must be set to TRUE in gfxconf.h
- * @note Optional.
- * @note If lines is >= cy, it is equivelent to a area fill with bgcolor.
- *
- * @param[in] x, y The start of the area to be scrolled
- * @param[in] cx, cy The size of the area to be scrolled
- * @param[in] lines The number of lines to scroll (Can be positive or negative)
- * @param[in] bgcolor The color to fill the newly exposed area.
- *
- * @api
- */
- void gdispVerticalScroll(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor);
- #endif
-
- /* Set driver specific control */
-
- #if GDISP_NEED_CONTROL || defined(__DOXYGEN__)
- /**
- * @brief Control hardware specific parts of the display. eg powermodes, backlight etc
- * @note Depending on the hardware implementation this function may not
- * support some codes. They will be ignored.
- *
- * @param[in] what what you want to control
- * @param[in] value The value to be assigned
- *
- * @api
- */
- void gdispControl(unsigned what, void *value);
- #endif
-
- /* Query driver specific data */
-
- #if GDISP_NEED_QUERY || defined(__DOXYGEN__)
- /**
- * @brief Query a property of the display.
- * @note The result must be typecast to the correct type.
- * @note An unsupported query will return (void *)-1.
- *
- * @param[in] what What to query
- *
- * @api
- */
- void *gdispQuery(unsigned what);
- #endif
-
-#else
- /* Include the low level driver information */
- #include "gdisp/lld/gdisp_lld.h"
-
- /* The same as above but use the low level driver directly if no multi-thread support is needed */
- #define gdispIsBusy() FALSE
- #define gdispClear(color) gdisp_lld_clear(color)
- #define gdispDrawPixel(x, y, color) gdisp_lld_draw_pixel(x, y, color)
- #define gdispDrawLine(x0, y0, x1, y1, color) gdisp_lld_draw_line(x0, y0, x1, y1, color)
- #define gdispFillArea(x, y, cx, cy, color) gdisp_lld_fill_area(x, y, cx, cy, color)
- #define gdispBlitAreaEx(x, y, cx, cy, sx, sy, scx, buf) gdisp_lld_blit_area_ex(x, y, cx, cy, sx, sy, scx, buf)
- #define gdispSetClip(x, y, cx, cy) gdisp_lld_set_clip(x, y, cx, cy)
- #define gdispDrawCircle(x, y, radius, color) gdisp_lld_draw_circle(x, y, radius, color)
- #define gdispFillCircle(x, y, radius, color) gdisp_lld_fill_circle(x, y, radius, color)
- #define gdispDrawArc(x, y, radius, sangle, eangle, color) gdisp_lld_draw_arc(x, y, radius, sangle, eangle, color)
- #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 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)
- #define gdispQuery(what) gdisp_lld_query(what)
+ color_t gdispGetPixelColor(coord_t x, coord_t y);
+#endif
+/* Scrolling Function - clears the area scrolled out */
+
+#if GDISP_NEED_SCROLL || defined(__DOXYGEN__)
+ /**
+ * @brief Scroll vertically a section of the screen.
+ * @pre GDISP_NEED_SCROLL must be set to TRUE in gfxconf.h
+ * @note Optional.
+ * @note If lines is >= cy, it is equivelent to a area fill with bgcolor.
+ *
+ * @param[in] x, y The start of the area to be scrolled
+ * @param[in] cx, cy The size of the area to be scrolled
+ * @param[in] lines The number of lines to scroll (Can be positive or negative)
+ * @param[in] bgcolor The color to fill the newly exposed area.
+ *
+ * @api
+ */
+ void gdispVerticalScroll(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor);
#endif
-/* These routines are not hardware accelerated
- * - Do not add a hardware accelerated routines here.
- */
+/* Set driver specific control */
+
+#if GDISP_NEED_CONTROL || defined(__DOXYGEN__)
+ /**
+ * @brief Control hardware specific parts of the display. eg powermodes, backlight etc
+ * @note Depending on the hardware implementation this function may not
+ * support some codes. They will be ignored.
+ *
+ * @param[in] what what you want to control
+ * @param[in] value The value to be assigned
+ *
+ * @api
+ */
+ void gdispControl(unsigned what, void *value);
+#endif
-/* Extra drawing functions */
+/* Query driver specific data */
-/**
- * @brief Draw a rectangular box.
- *
- * @param[in] x,y The start position
- * @param[in] cx,cy The size of the box (outside dimensions)
- * @param[in] color The color to use
- *
- * @api
- */
-void gdispDrawBox(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color);
+#if GDISP_NEED_QUERY || defined(__DOXYGEN__)
+ /**
+ * @brief Query a property of the display.
+ * @note The result must be typecast to the correct type.
+ * @note An unsupported query will return (void *)-1.
+ *
+ * @param[in] what What to query
+ *
+ * @api
+ */
+ void *gdispQuery(unsigned what);
+#endif
#if GDISP_NEED_CONVEX_POLYGON || defined(__DOXYGEN__)
/**
@@ -803,19 +775,6 @@ void gdispDrawBox(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color);
void gdispFillRoundedBox(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t radius, color_t color);
#endif
-
-/**
- * @brief Blend 2 colors according to the alpha
- * @return The combined color
- *
- * @param[in] fg The foreground color
- * @param[in] bg The background color
- * @param[in] alpha The alpha value (0-255). 0 is all background, 255 is all foreground.
- *
- * @api
- */
-color_t gdispBlendColor(color_t fg, color_t bg, uint8_t alpha);
-
/* Support routine for packed pixel formats */
#if !defined(gdispPackPixels) || defined(__DOXYGEN__)
/**
@@ -890,42 +849,42 @@ color_t gdispBlendColor(color_t fg, color_t bg, uint8_t alpha);
*
* @api
*/
-#define gdispGetWidth() (GDISP.Width)
+#define gdispGetWidth() (GDISP->Width)
/**
* @brief Get the display height in pixels.
*
* @api
*/
-#define gdispGetHeight() (GDISP.Height)
+#define gdispGetHeight() (GDISP->Height)
/**
* @brief Get the current display power mode.
*
* @api
*/
-#define gdispGetPowerMode() (GDISP.Powermode)
+#define gdispGetPowerMode() (GDISP->Powermode)
/**
* @brief Get the current display orientation.
*
* @api
*/
-#define gdispGetOrientation() (GDISP.Orientation)
+#define gdispGetOrientation() (GDISP->Orientation)
/**
* @brief Get the current display backlight brightness.
*
* @api
*/
-#define gdispGetBacklight() (GDISP.Backlight)
+#define gdispGetBacklight() (GDISP->Backlight)
/**
* @brief Get the current display contrast.
*
* @api
*/
-#define gdispGetContrast() (GDISP.Contrast)
+#define gdispGetContrast() (GDISP->Contrast)
/* More interesting macro's */
@@ -936,7 +895,6 @@ color_t gdispBlendColor(color_t fg, color_t bg, uint8_t alpha);
*/
#define gdispUnsetClip() gdispSetClip(0,0,gdispGetWidth(),gdispGetHeight())
-
#ifdef __cplusplus
}
#endif
diff --git a/include/gdisp/lld/emulation.c b/include/gdisp/lld/emulation.c
deleted file mode 100644
index cb0c9c4b..00000000
--- a/include/gdisp/lld/emulation.c
+++ /dev/null
@@ -1,558 +0,0 @@
-/*
- * This file is subject to the terms of the GFX License. If a copy of
- * the license was not distributed with this file, you can obtain one at:
- *
- * http://ugfx.org/license.html
- */
-
-/**
- * @file include/gdisp/lld/emulation.c
- * @brief GDISP emulation routines for stuff the driver dosen't support
- *
- * @addtogroup GDISP
- *
- * @details Even though this is a software emulation of a low level driver
- * most validation doesn't need to happen here as eventually
- * we call a real low level driver routine and if validation is
- * required - it will do it.
- *
- * @{
- */
-#ifndef GDISP_EMULATION_C
-#define GDISP_EMULATION_C
-
-#if GFX_USE_GDISP
-
-/* Include the low level driver information */
-#include "gdisp/lld/gdisp_lld.h"
-
-/* Declare the GDISP structure */
-GDISPDriver GDISP;
-
-#if !GDISP_HARDWARE_CLEARS
- void gdisp_lld_clear(color_t color) {
- gdisp_lld_fill_area(0, 0, GDISP.Width, GDISP.Height, color);
- }
-#endif
-
-#if !GDISP_HARDWARE_LINES
- void gdisp_lld_draw_line(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color) {
- int16_t dy, dx;
- int16_t addx, addy;
- int16_t P, diff, i;
-
- #if GDISP_HARDWARE_FILLS || GDISP_HARDWARE_SCROLL
- // speed improvement if vertical or horizontal
- if (x0 == x1) {
- if (y1 > y0)
- gdisp_lld_fill_area(x0, y0, 1, y1-y0+1, color);
- else
- gdisp_lld_fill_area(x0, y1, 1, y0-y1+1, color);
- return;
- }
- if (y0 == y1) {
- if (x1 > x0)
- gdisp_lld_fill_area(x0, y0, x1-x0+1, 1, color);
- else
- gdisp_lld_fill_area(x1, y0, x0-x1+1, 1, color);
- return;
- }
- #endif
-
- if (x1 >= x0) {
- dx = x1 - x0;
- addx = 1;
- } else {
- dx = x0 - x1;
- addx = -1;
- }
- if (y1 >= y0) {
- dy = y1 - y0;
- addy = 1;
- } else {
- dy = y0 - y1;
- addy = -1;
- }
-
- if (dx >= dy) {
- dy *= 2;
- P = dy - dx;
- diff = P - dx;
-
- for(i=0; i<=dx; ++i) {
- gdisp_lld_draw_pixel(x0, y0, color);
- if (P < 0) {
- P += dy;
- x0 += addx;
- } else {
- P += diff;
- x0 += addx;
- y0 += addy;
- }
- }
- } else {
- dx *= 2;
- P = dx - dy;
- diff = P - dy;
-
- for(i=0; i<=dy; ++i) {
- gdisp_lld_draw_pixel(x0, y0, color);
- if (P < 0) {
- P += dx;
- y0 += addy;
- } else {
- P += diff;
- x0 += addx;
- y0 += addy;
- }
- }
- }
- }
-#endif
-
-#if !GDISP_HARDWARE_FILLS
- void gdisp_lld_fill_area(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) {
- #if GDISP_HARDWARE_SCROLL
- gdisp_lld_vertical_scroll(x, y, cx, cy, cy, color);
- #elif GDISP_HARDWARE_LINES
- coord_t x1, y1;
-
- x1 = x + cx - 1;
- y1 = y + cy;
- for(; y < y1; y++)
- gdisp_lld_draw_line(x, y, x1, y, color);
- #else
- coord_t x0, x1, y1;
-
- x0 = x;
- x1 = x + cx;
- y1 = y + cy;
- for(; y < y1; y++)
- for(x = x0; x < x1; x++)
- gdisp_lld_draw_pixel(x, y, color);
- #endif
- }
-#endif
-
-#if !GDISP_HARDWARE_BITFILLS
- void gdisp_lld_blit_area_ex(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer) {
- coord_t x0, x1, y1;
-
- x0 = x;
- x1 = x + cx;
- y1 = y + cy;
- buffer += srcy*srccx+srcx;
- srccx -= cx;
- for(; y < y1; y++, buffer += srccx)
- for(x=x0; x < x1; x++)
- gdisp_lld_draw_pixel(x, y, *buffer++);
- }
-#endif
-
-#if GDISP_NEED_CLIP && !GDISP_HARDWARE_CLIP
- void gdisp_lld_set_clip(coord_t x, coord_t y, coord_t cx, coord_t cy) {
- #if GDISP_NEED_VALIDATION
- if (x >= GDISP.Width || y >= GDISP.Height || cx < 0 || cy < 0)
- return;
- if (x < 0) x = 0;
- if (y < 0) y = 0;
- if (x+cx > GDISP.Width) cx = GDISP.Width - x;
- if (y+cy > GDISP.Height) cy = GDISP.Height - y;
- #endif
- GDISP.clipx0 = x;
- GDISP.clipy0 = y;
- GDISP.clipx1 = x+cx;
- GDISP.clipy1 = y+cy;
- }
-#endif
-
-#if GDISP_NEED_CIRCLE && !GDISP_HARDWARE_CIRCLES
- void gdisp_lld_draw_circle(coord_t x, coord_t y, coord_t radius, color_t color) {
- coord_t a, b, P;
-
- a = 0;
- b = radius;
- P = 1 - radius;
-
- do {
- gdisp_lld_draw_pixel(x+a, y+b, color);
- gdisp_lld_draw_pixel(x+b, y+a, color);
- gdisp_lld_draw_pixel(x-a, y+b, color);
- gdisp_lld_draw_pixel(x-b, y+a, color);
- gdisp_lld_draw_pixel(x+b, y-a, color);
- gdisp_lld_draw_pixel(x+a, y-b, color);
- gdisp_lld_draw_pixel(x-a, y-b, color);
- gdisp_lld_draw_pixel(x-b, y-a, color);
- if (P < 0)
- P += 3 + 2*a++;
- else
- P += 5 + 2*(a++ - b--);
- } while(a <= b);
- }
-#endif
-
-#if GDISP_NEED_CIRCLE && !GDISP_HARDWARE_CIRCLEFILLS
- void gdisp_lld_fill_circle(coord_t x, coord_t y, coord_t radius, color_t color) {
- coord_t a, b, P;
-
- a = 0;
- b = radius;
- P = 1 - radius;
-
- do {
- gdisp_lld_draw_line(x-a, y+b, x+a, y+b, color);
- gdisp_lld_draw_line(x-a, y-b, x+a, y-b, color);
- gdisp_lld_draw_line(x-b, y+a, x+b, y+a, color);
- gdisp_lld_draw_line(x-b, y-a, x+b, y-a, color);
- if (P < 0)
- P += 3 + 2*a++;
- else
- P += 5 + 2*(a++ - b--);
- } while(a <= b);
- }
-#endif
-
-#if GDISP_NEED_ELLIPSE && !GDISP_HARDWARE_ELLIPSES
- void gdisp_lld_draw_ellipse(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) {
- int dx = 0, dy = b; /* im I. Quadranten von links oben nach rechts unten */
- long a2 = a*a, b2 = b*b;
- long err = b2-(2*b-1)*a2, e2; /* Fehler im 1. Schritt */
-
- do {
- gdisp_lld_draw_pixel(x+dx, y+dy, color); /* I. Quadrant */
- gdisp_lld_draw_pixel(x-dx, y+dy, color); /* II. Quadrant */
- gdisp_lld_draw_pixel(x-dx, y-dy, color); /* III. Quadrant */
- gdisp_lld_draw_pixel(x+dx, y-dy, color); /* IV. Quadrant */
-
- e2 = 2*err;
- if(e2 < (2*dx+1)*b2) {
- dx++;
- err += (2*dx+1)*b2;
- }
- if(e2 > -(2*dy-1)*a2) {
- dy--;
- err -= (2*dy-1)*a2;
- }
- } while(dy >= 0);
-
- while(dx++ < a) { /* fehlerhafter Abbruch bei flachen Ellipsen (b=1) */
- gdisp_lld_draw_pixel(x+dx, y, color); /* -> Spitze der Ellipse vollenden */
- gdisp_lld_draw_pixel(x-dx, y, color);
- }
- }
-#endif
-
-#if GDISP_NEED_ELLIPSE && !GDISP_HARDWARE_ELLIPSEFILLS
- void gdisp_lld_fill_ellipse(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) {
- int dx = 0, dy = b; /* im I. Quadranten von links oben nach rechts unten */
- long a2 = a*a, b2 = b*b;
- long err = b2-(2*b-1)*a2, e2; /* Fehler im 1. Schritt */
-
- do {
- gdisp_lld_draw_line(x-dx,y+dy,x+dx,y+dy, color);
- gdisp_lld_draw_line(x-dx,y-dy,x+dx,y-dy, color);
-
- e2 = 2*err;
- if(e2 < (2*dx+1)*b2) {
- dx++;
- err += (2*dx+1)*b2;
- }
- if(e2 > -(2*dy-1)*a2) {
- dy--;
- err -= (2*dy-1)*a2;
- }
- } while(dy >= 0);
-
- while(dx++ < a) { /* fehlerhafter Abbruch bei flachen Ellipsen (b=1) */
- gdisp_lld_draw_pixel(x+dx, y, color); /* -> Spitze der Ellipse vollenden */
- gdisp_lld_draw_pixel(x-dx, y, color);
- }
- }
-#endif
-
-#if GDISP_NEED_ARC && !GDISP_HARDWARE_ARCS
-
- #include <math.h>
-
- /*
- * @brief Internal helper function for gdispDrawArc()
- *
- * @note DO NOT USE DIRECTLY!
- *
- * @param[in] x, y The middle point of the arc
- * @param[in] start The start angle of the arc
- * @param[in] end The end angle of the arc
- * @param[in] radius The radius of the arc
- * @param[in] color The color in which the arc will be drawn
- *
- * @notapi
- */
- static void _draw_arc(coord_t x, coord_t y, uint16_t start, uint16_t end, uint16_t radius, color_t color) {
- if (/*start >= 0 && */start <= 180) {
- float x_maxI = x + radius*cos(start*M_PI/180);
- float x_minI;
-
- if (end > 180)
- x_minI = x - radius;
- else
- x_minI = x + radius*cos(end*M_PI/180);
-
- int a = 0;
- int b = radius;
- int P = 1 - radius;
-
- do {
- if(x-a <= x_maxI && x-a >= x_minI)
- gdisp_lld_draw_pixel(x-a, y-b, color);
- if(x+a <= x_maxI && x+a >= x_minI)
- gdisp_lld_draw_pixel(x+a, y-b, color);
- if(x-b <= x_maxI && x-b >= x_minI)
- gdisp_lld_draw_pixel(x-b, y-a, color);
- if(x+b <= x_maxI && x+b >= x_minI)
- gdisp_lld_draw_pixel(x+b, y-a, color);
-
- if (P < 0) {
- P = P + 3 + 2*a;
- a = a + 1;
- } else {
- P = P + 5 + 2*(a - b);
- a = a + 1;
- b = b - 1;
- }
- } while(a <= b);
- }
-
- if (end > 180 && end <= 360) {
- float x_maxII = x+radius*cos(end*M_PI/180);
- float x_minII;
-
- if(start <= 180)
- x_minII = x - radius;
- else
- x_minII = x+radius*cos(start*M_PI/180);
-
- int a = 0;
- int b = radius;
- int P = 1 - radius;
-
- do {
- if(x-a <= x_maxII && x-a >= x_minII)
- gdisp_lld_draw_pixel(x-a, y+b, color);
- if(x+a <= x_maxII && x+a >= x_minII)
- gdisp_lld_draw_pixel(x+a, y+b, color);
- if(x-b <= x_maxII && x-b >= x_minII)
- gdisp_lld_draw_pixel(x-b, y+a, color);
- if(x+b <= x_maxII && x+b >= x_minII)
- gdisp_lld_draw_pixel(x+b, y+a, color);
-
- if (P < 0) {
- P = P + 3 + 2*a;
- a = a + 1;
- } else {
- P = P + 5 + 2*(a - b);
- a = a + 1;
- b = b - 1;
- }
- } while (a <= b);
- }
- }
-
- void gdisp_lld_draw_arc(coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle, color_t color) {
- if(endangle < startangle) {
- _draw_arc(x, y, startangle, 360, radius, color);
- _draw_arc(x, y, 0, endangle, radius, color);
- } else {
- _draw_arc(x, y, startangle, endangle, radius, color);
- }
- }
-#endif
-
-#if GDISP_NEED_ARC && !GDISP_HARDWARE_ARCFILLS
- /*
- * @brief Internal helper function for gdispDrawArc()
- *
- * @note DO NOT USE DIRECTLY!
- *
- * @param[in] x, y The middle point of the arc
- * @param[in] start The start angle of the arc
- * @param[in] end The end angle of the arc
- * @param[in] radius The radius of the arc
- * @param[in] color The color in which the arc will be drawn
- *
- * @notapi
- */
- static void _fill_arc(coord_t x, coord_t y, uint16_t start, uint16_t end, uint16_t radius, color_t color) {
- if (/*start >= 0 && */start <= 180) {
- float x_maxI = x + radius*cos(start*M_PI/180);
- float x_minI;
-
- if (end > 180)
- x_minI = x - radius;
- else
- x_minI = x + radius*cos(end*M_PI/180);
-
- int a = 0;
- int b = radius;
- int P = 1 - radius;
-
- do {
- if(x-a <= x_maxI && x-a >= x_minI)
- gdisp_lld_draw_line(x, y, x-a, y-b, color);
- if(x+a <= x_maxI && x+a >= x_minI)
- gdisp_lld_draw_line(x, y, x+a, y-b, color);
- if(x-b <= x_maxI && x-b >= x_minI)
- gdisp_lld_draw_line(x, y, x-b, y-a, color);
- if(x+b <= x_maxI && x+b >= x_minI)
- gdisp_lld_draw_line(x, y, x+b, y-a, color);
-
- if (P < 0) {
- P = P + 3 + 2*a;
- a = a + 1;
- } else {
- P = P + 5 + 2*(a - b);
- a = a + 1;
- b = b - 1;
- }
- } while(a <= b);
- }
-
- if (end > 180 && end <= 360) {
- float x_maxII = x+radius*cos(end*M_PI/180);
- float x_minII;
-
- if(start <= 180)
- x_minII = x - radius;
- else
- x_minII = x+radius*cos(start*M_PI/180);
-
- int a = 0;
- int b = radius;
- int P = 1 - radius;
-
- do {
- if(x-a <= x_maxII && x-a >= x_minII)
- gdisp_lld_draw_line(x, y, x-a, y+b, color);
- if(x+a <= x_maxII && x+a >= x_minII)
- gdisp_lld_draw_line(x, y, x+a, y+b, color);
- if(x-b <= x_maxII && x-b >= x_minII)
- gdisp_lld_draw_line(x, y, x-b, y+a, color);
- if(x+b <= x_maxII && x+b >= x_minII)
- gdisp_lld_draw_line(x, y, x+b, y+a, color);
-
- if (P < 0) {
- P = P + 3 + 2*a;
- a = a + 1;
- } else {
- P = P + 5 + 2*(a - b);
- a = a + 1;
- b = b - 1;
- }
- } while (a <= b);
- }
- }
-
- void gdisp_lld_fill_arc(coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle, color_t color) {
- if(endangle < startangle) {
- _fill_arc(x, y, startangle, 360, radius, color);
- _fill_arc(x, y, 0, endangle, radius, color);
- } else {
- _fill_arc(x, y, startangle, endangle, radius, color);
- }
- }
-#endif
-
-#if GDISP_NEED_CONTROL && !GDISP_HARDWARE_CONTROL
- void gdisp_lld_control(unsigned what, void *value) {
- (void)what;
- (void)value;
- /* Ignore everything */
- }
-#endif
-
-#if GDISP_NEED_QUERY && !GDISP_HARDWARE_QUERY
-void *gdisp_lld_query(unsigned what) {
- (void) what;
- return (void *)-1;
-}
-#endif
-
-#if GDISP_NEED_MSGAPI
- void gdisp_lld_msg_dispatch(gdisp_lld_msg_t *msg) {
- switch(msg->action) {
- case GDISP_LLD_MSG_NOP:
- break;
- case GDISP_LLD_MSG_INIT:
- gdisp_lld_init();
- break;
- case GDISP_LLD_MSG_CLEAR:
- gdisp_lld_clear(msg->clear.color);
- break;
- case GDISP_LLD_MSG_DRAWPIXEL:
- gdisp_lld_draw_pixel(msg->drawpixel.x, msg->drawpixel.y, msg->drawpixel.color);
- break;
- case GDISP_LLD_MSG_FILLAREA:
- gdisp_lld_fill_area(msg->fillarea.x, msg->fillarea.y, msg->fillarea.cx, msg->fillarea.cy, msg->fillarea.color);
- break;
- case GDISP_LLD_MSG_BLITAREA:
- gdisp_lld_blit_area_ex(msg->blitarea.x, msg->blitarea.y, msg->blitarea.cx, msg->blitarea.cy, msg->blitarea.srcx, msg->blitarea.srcy, msg->blitarea.srccx, msg->blitarea.buffer);
- break;
- case GDISP_LLD_MSG_DRAWLINE:
- gdisp_lld_draw_line(msg->drawline.x0, msg->drawline.y0, msg->drawline.x1, msg->drawline.y1, msg->drawline.color);
- break;
- #if GDISP_NEED_CLIP
- case GDISP_LLD_MSG_SETCLIP:
- gdisp_lld_set_clip(msg->setclip.x, msg->setclip.y, msg->setclip.cx, msg->setclip.cy);
- break;
- #endif
- #if GDISP_NEED_CIRCLE
- case GDISP_LLD_MSG_DRAWCIRCLE:
- gdisp_lld_draw_circle(msg->drawcircle.x, msg->drawcircle.y, msg->drawcircle.radius, msg->drawcircle.color);
- break;
- case GDISP_LLD_MSG_FILLCIRCLE:
- gdisp_lld_fill_circle(msg->fillcircle.x, msg->fillcircle.y, msg->fillcircle.radius, msg->fillcircle.color);
- break;
- #endif
- #if GDISP_NEED_ELLIPSE
- case GDISP_LLD_MSG_DRAWELLIPSE:
- gdisp_lld_draw_ellipse(msg->drawellipse.x, msg->drawellipse.y, msg->drawellipse.a, msg->drawellipse.b, msg->drawellipse.color);
- break;
- case GDISP_LLD_MSG_FILLELLIPSE:
- gdisp_lld_fill_ellipse(msg->fillellipse.x, msg->fillellipse.y, msg->fillellipse.a, msg->fillellipse.b, msg->fillellipse.color);
- break;
- #endif
- #if GDISP_NEED_ARC
- case GDISP_LLD_MSG_DRAWARC:
- gdisp_lld_draw_circle(msg->drawarc.x, msg->drawarc.y, msg->drawarc.radius, msg->drawarc.startangle, msg->drawarc.endangle, msg->drawarc.color);
- break;
- case GDISP_LLD_MSG_FILLARC:
- 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_PIXELREAD
- case GDISP_LLD_MSG_GETPIXELCOLOR:
- msg->getpixelcolor.result = gdisp_lld_get_pixel_color(msg->getpixelcolor.x, msg->getpixelcolor.y);
- break;
- #endif
- #if GDISP_NEED_SCROLL
- case GDISP_LLD_MSG_VERTICALSCROLL:
- gdisp_lld_vertical_scroll(msg->verticalscroll.x, msg->verticalscroll.y, msg->verticalscroll.cx, msg->verticalscroll.cy, msg->verticalscroll.lines, msg->verticalscroll.bgcolor);
- break;
- #endif
- #if GDISP_NEED_CONTROL
- case GDISP_LLD_MSG_CONTROL:
- gdisp_lld_control(msg->control.what, msg->control.value);
- break;
- #endif
- #if GDISP_NEED_QUERY
- case GDISP_LLD_MSG_QUERY:
- msg->query.result = gdisp_lld_query(msg->query.what);
- break;
- #endif
- }
- }
-#endif
-
-#endif /* GFX_USE_GDISP */
-#endif /* GDISP_EMULATION_C */
-/** @} */
-
diff --git a/include/gdisp/lld/gdisp_lld.h b/include/gdisp/lld/gdisp_lld.h
index 98c7569c..46d5488a 100644
--- a/include/gdisp/lld/gdisp_lld.h
+++ b/include/gdisp/lld/gdisp_lld.h
@@ -27,83 +27,54 @@
* @{
*/
/**
- * @brief Hardware accelerated line drawing.
+ * @brief Hardware streaming interface is supported.
* @details If set to @p FALSE software emulation is used.
+ * @note Either GDISP_HARDWARE_STREAM or GDISP_HARDWARE_DRAWPIXEL must be provided by the driver
*/
- #ifndef GDISP_HARDWARE_LINES
- #define GDISP_HARDWARE_LINES FALSE
+ #ifndef GDISP_HARDWARE_STREAM
+ #define GDISP_HARDWARE_STREAM FALSE
#endif
/**
- * @brief Hardware accelerated screen clears.
- * @details If set to @p FALSE software emulation is used.
- */
- #ifndef GDISP_HARDWARE_CLEARS
- #define GDISP_HARDWARE_CLEARS FALSE
- #endif
-
- /**
- * @brief Hardware accelerated rectangular fills.
- * @details If set to @p FALSE software emulation is used.
- */
- #ifndef GDISP_HARDWARE_FILLS
- #define GDISP_HARDWARE_FILLS FALSE
- #endif
-
- /**
- * @brief Hardware accelerated fills from an image.
- * @details If set to @p FALSE software emulation is used.
- */
- #ifndef GDISP_HARDWARE_BITFILLS
- #define GDISP_HARDWARE_BITFILLS FALSE
- #endif
-
- /**
- * @brief Hardware accelerated circles.
- * @details If set to @p FALSE software emulation is used.
- */
- #ifndef GDISP_HARDWARE_CIRCLES
- #define GDISP_HARDWARE_CIRCLES FALSE
- #endif
-
- /**
- * @brief Hardware accelerated filled circles.
- * @details If set to @p FALSE software emulation is used.
+ * @brief Hardware streaming requires an explicit end call.
+ * @details If set to @p FALSE if an explicit stream end call is not required.
*/
- #ifndef GDISP_HARDWARE_CIRCLEFILLS
- #define GDISP_HARDWARE_CIRCLEFILLS FALSE
+ #ifndef GDISP_HARDWARE_STREAM_END
+ #define GDISP_HARDWARE_STREAM_END FALSE
#endif
/**
- * @brief Hardware accelerated ellipses.
+ * @brief Hardware accelerated draw pixel.
* @details If set to @p FALSE software emulation is used.
+ * @note Either GDISP_HARDWARE_STREAM or GDISP_HARDWARE_DRAWPIXEL must be provided by the driver
*/
- #ifndef GDISP_HARDWARE_ELLIPSES
- #define GDISP_HARDWARE_ELLIPSES FALSE
+ #ifndef GDISP_HARDWARE_DRAWPIXEL
+ #define GDISP_HARDWARE_DRAWPIXEL FALSE
#endif
/**
- * @brief Hardware accelerated filled ellipses.
+ * @brief Hardware accelerated screen clears.
* @details If set to @p FALSE software emulation is used.
+ * @note This clears the entire display surface regardless of the clipping area currently set
*/
- #ifndef GDISP_HARDWARE_ELLIPSEFILLS
- #define GDISP_HARDWARE_ELLIPSEFILLS FALSE
+ #ifndef GDISP_HARDWARE_CLEARS
+ #define GDISP_HARDWARE_CLEARS FALSE
#endif
/**
- * @brief Hardware accelerated arc's.
+ * @brief Hardware accelerated rectangular fills.
* @details If set to @p FALSE software emulation is used.
*/
- #ifndef GDISP_HARDWARE_ARCS
- #define GDISP_HARDWARE_ARCS FALSE
+ #ifndef GDISP_HARDWARE_FILLS
+ #define GDISP_HARDWARE_FILLS FALSE
#endif
/**
- * @brief Hardware accelerated filled arcs.
+ * @brief Hardware accelerated fills from an image.
* @details If set to @p FALSE software emulation is used.
*/
- #ifndef GDISP_HARDWARE_ARCFILLS
- #define GDISP_HARDWARE_ARCFILLS FALSE
+ #ifndef GDISP_HARDWARE_BITFILLS
+ #define GDISP_HARDWARE_BITFILLS FALSE
#endif
/**
@@ -141,9 +112,14 @@
/**
* @brief The driver supports a clipping in hardware.
* @details If set to @p FALSE there is no support for non-standard queries.
+ * @note If this is defined the driver must perform its own clipping on all calls to
+ * the driver and respond appropriately if a parameter is outside the display area.
+ * @note If this is not defined then the software ensures that all calls to the
+ * driver do not exceed the display area (provided GDISP_NEED_CLIP or GDISP_NEED_VALIDATION
+ * has been set).
*/
#ifndef GDISP_HARDWARE_CLIP
- #define GDISP_HARDWARE_CLIP FALSE
+ #define GDISP_HARDWARE_CLIP FALSE
#endif
/** @} */
@@ -161,6 +137,7 @@
* @brief The native pixel format for this device
* @note Should be set to one of the following:
* GDISP_PIXELFORMAT_RGB565
+ * GDISP_PIXELFORMAT_BGR565
* GDISP_PIXELFORMAT_RGB888
* GDISP_PIXELFORMAT_RGB444
* GDISP_PIXELFORMAT_RGB332
@@ -208,76 +185,85 @@
/* External declarations. */
/*===========================================================================*/
-#ifdef __cplusplus
-extern "C" {
-#endif
-
- /* Core functions */
- extern bool_t gdisp_lld_init(void);
-
- /* Some of these functions will be implemented in software by the high level driver
- depending on the GDISP_HARDWARE_XXX macros defined in gdisp_lld_config.h.
- */
+typedef struct GDISPDriver {
+ GDISPControl g;
- /* Drawing functions */
- extern void gdisp_lld_clear(color_t color);
- extern void gdisp_lld_draw_pixel(coord_t x, coord_t y, color_t color);
- extern void gdisp_lld_fill_area(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color);
- extern void gdisp_lld_blit_area_ex(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer);
- extern void gdisp_lld_draw_line(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color);
-
- /* Circular Drawing Functions */
- #if GDISP_NEED_CIRCLE
- extern void gdisp_lld_draw_circle(coord_t x, coord_t y, coord_t radius, color_t color);
- extern void gdisp_lld_fill_circle(coord_t x, coord_t y, coord_t radius, color_t color);
- #endif
+ uint16_t flags;
+ #define GDISP_FLG_INSTREAM 0x0001
- #if GDISP_NEED_ELLIPSE
- extern void gdisp_lld_draw_ellipse(coord_t x, coord_t y, coord_t a, coord_t b, color_t color);
- extern void gdisp_lld_fill_ellipse(coord_t x, coord_t y, coord_t a, coord_t b, color_t color);
+ // Multithread Mutex
+ #if GDISP_NEED_MULTITHREAD
+ gfxMutex mutex;
#endif
- /* Arc Drawing Functions */
- #if GDISP_NEED_ARC
- extern void gdisp_lld_draw_arc(coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle, color_t color);
- extern void gdisp_lld_fill_arc(coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle, color_t color);
+ // Software clipping
+ #if !GDISP_HARDWARE_CLIP && (GDISP_NEED_CLIP || GDISP_NEED_VALIDATION)
+ coord_t clipx0, clipy0;
+ coord_t clipx1, clipy1; /* not inclusive */
#endif
- /* Text Rendering Functions */
+ // Driver call parameters
+ struct {
+ coord_t x, y;
+ coord_t cx, cy;
+ coord_t x1, y1;
+ coord_t x2, y2;
+ color_t color;
+ void *ptr;
+ } p;
+
+ // Text rendering parameters
#if GDISP_NEED_TEXT
- extern void gdisp_lld_draw_char(coord_t x, coord_t y, uint16_t c, font_t font, color_t color);
- extern void gdisp_lld_fill_char(coord_t x, coord_t y, uint16_t c, font_t font, color_t color, color_t bgcolor);
+ struct {
+ font_t font;
+ color_t color;
+ color_t bgcolor;
+ coord_t clipx0, clipy0;
+ coord_t clipx1, clipy1;
+ } t;
#endif
+} GDISPDriver;
- /* Pixel readback */
- #if GDISP_NEED_PIXELREAD
- extern color_t gdisp_lld_get_pixel_color(coord_t x, coord_t y);
- #endif
+extern GDISPDriver GDISP_DRIVER_STRUCT;
- /* Scrolling Function - clears the area scrolled out */
- #if GDISP_NEED_SCROLL
- extern void gdisp_lld_vertical_scroll(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor);
- #endif
+#ifdef __cplusplus
+extern "C" {
+#endif
- /* Set driver specific control */
- #if GDISP_NEED_CONTROL
- extern void gdisp_lld_control(unsigned what, void *value);
+ bool_t gdisp_lld_init(void);
+ #if GDISP_HARDWARE_STREAM
+ void gdisp_lld_stream_start(void); // Uses p.x,p.y p.cx,p.cy
+ void gdisp_lld_stream_color(void); // Uses p.color
+ #if GDISP_HARDWARE_STREAM_END
+ void gdisp_lld_stream_stop(void); // Uses no parameters
+ #endif
#endif
-
- /* Query driver specific data */
- #if GDISP_NEED_QUERY
- extern void *gdisp_lld_query(unsigned what);
+ #if GDISP_HARDWARE_DRAWPIXEL
+ void gdisp_lld_draw_pixel(void); // Uses p.x,p.y p.color
#endif
-
- /* Clipping Functions */
- #if GDISP_NEED_CLIP
- extern void gdisp_lld_set_clip(coord_t x, coord_t y, coord_t cx, coord_t cy);
+ #if GDISP_HARDWARE_CLEARS
+ void gdisp_lld_clear(void); // Uses p.color
#endif
-
- /* Messaging API */
- #if GDISP_NEED_MSGAPI
- #include "gdisp_lld_msgs.h"
- extern void gdisp_lld_msg_dispatch(gdisp_lld_msg_t *msg);
+ #if GDISP_HARDWARE_FILLS
+ void gdisp_lld_fill_area(void); // Uses p.x,p.y p.cx,p.cy p.color
+ #endif
+ #if GDISP_HARDWARE_BITFILLS
+ void gdisp_lld_blit_area_ex(void); // Uses p.x,p.y p.cx,p.cy p.x1,p.y1 (=srcx,srcy) p.x2 (=srccx), p.ptr (=buffer)
+ #endif
+ #if GDISP_HARDWARE_PIXELREAD && GDISP_NEED_PIXELREAD
+ color_t gdisp_lld_get_pixel_color(void); // Uses p.x,p.y
+ #endif
+ #if GDISP_HARDWARE_SCROLL && GDISP_NEED_SCROLL
+ void gdisp_lld_vertical_scroll(void); // Uses p.x,p.y p.cx,p.cy, p.y1 (=lines) p.color
+ #endif
+ #if GDISP_HARDWARE_CONTROL && GDISP_NEED_CONTROL
+ void gdisp_lld_control(void); // Uses p.x (=what) p.ptr (=value)
+ #endif
+ #if GDISP_HARDWARE_QUERY && GDISP_NEED_QUERY
+ void *gdisp_lld_query(void); // Uses p.x (=what);
+ #endif
+ #if GDISP_HARDWARE_CLIP && (GDISP_NEED_CLIP || GDISP_NEED_VALIDATION)
+ void gdisp_lld_set_clip(void); // Uses p.x,p.y p.cx,p.cy
#endif
#ifdef __cplusplus
diff --git a/include/gmisc/gmisc.h b/include/gmisc/gmisc.h
index 998dda50..5943e642 100644
--- a/include/gmisc/gmisc.h
+++ b/include/gmisc/gmisc.h
@@ -51,6 +51,7 @@ typedef int32_t fixed;
*/
#define FIXED(x) ((fixed)(x)<<16) /* @< integer to fixed */
#define NONFIXED(x) ((x)>>16) /* @< fixed to integer */
+#define FIXED0_5 32768 /* @< 0.5 as a fixed (used for rounding) */
#define FP2FIXED(x) ((fixed)((x)*65536.0)) /* @< floating point to fixed */
#define FIXED2FP(x) ((double)(x)/65536.0) /* @< fixed to floating point */
/* @} */