diff options
author | inmarket <andrewh@inmarket.com.au> | 2013-10-21 13:34:55 +1000 |
---|---|---|
committer | inmarket <andrewh@inmarket.com.au> | 2013-10-21 13:34:55 +1000 |
commit | 0b9db701a1d52c8a6d63ca692619b0dde47805d1 (patch) | |
tree | 0a7feae21974b21d0b15918aa438615f6bf1579b /include/gdisp | |
parent | 51f4435cd10cdf4b629d524c425923b293263268 (diff) | |
download | uGFX-0b9db701a1d52c8a6d63ca692619b0dde47805d1.tar.gz uGFX-0b9db701a1d52c8a6d63ca692619b0dde47805d1.tar.bz2 uGFX-0b9db701a1d52c8a6d63ca692619b0dde47805d1.zip |
Fix missing case in gdispStreamStop().
Add support for controllers that need flushing.
Add both automatic and manual flushing (via the gdispFlush() method)
Diffstat (limited to 'include/gdisp')
-rw-r--r-- | include/gdisp/gdisp.h | 21 | ||||
-rw-r--r-- | include/gdisp/lld/gdisp_lld.h | 84 | ||||
-rw-r--r-- | include/gdisp/options.h | 14 |
3 files changed, 92 insertions, 27 deletions
diff --git a/include/gdisp/gdisp.h b/include/gdisp/gdisp.h index 0c8310bb..006fa08b 100644 --- a/include/gdisp/gdisp.h +++ b/include/gdisp/gdisp.h @@ -396,6 +396,27 @@ void gdispSetDisplay(GDisplay *g); /* Drawing Functions */ /** + * @brief Flush current drawing operations to the display + * @note Some low level drivers do not update the display until + * the display is flushed. For others it is optional but can + * help prevent tearing effects. For some it is ignored. + * Calling it at the end of a logic set of drawing operations + * in your application will ensure controller portability. If you + * know your controller does not need to be flushed there is no + * need to call it (which is in reality most controllers). + * @note Even for displays that require flushing, there is no need to + * call this function if GDISP_NEED_AUTOFLUSH is TRUE. + * Calling it again won't hurt though. + * + * + * @param[in] display The display number (0..n) + * + * @api + */ +void gdispGFlush(GDisplay *g); +#define gdispFlush() gdispGFlush(GDISP) + +/** * @brief Clear the display to the specified color. * * @param[in] g The display to use diff --git a/include/gdisp/lld/gdisp_lld.h b/include/gdisp/lld/gdisp_lld.h index 442e9b6d..b5d9c699 100644 --- a/include/gdisp/lld/gdisp_lld.h +++ b/include/gdisp/lld/gdisp_lld.h @@ -35,6 +35,17 @@ * @{ */ /** + * @brief The display hardware can benefit from being flushed. + * @details Can be set to TRUE, FALSE or HARDWARE_AUTODETECT + * + * @note HARDWARE_AUTODETECT is only meaningful when GDISP_TOTAL_CONTROLLERS > 1 + * @note Some controllers ** require ** the application to flush + */ + #ifndef GDISP_HARDWARE_FLUSH + #define GDISP_HARDWARE_FLUSH HARDWARE_DEFAULT + #endif + + /** * @brief Hardware streaming writing is supported. * @details Can be set to TRUE, FALSE or HARDWARE_AUTODETECT * @@ -247,6 +258,18 @@ struct GDisplay { */ LLDSPEC bool_t gdisp_lld_init(GDisplay *g); + #if GDISP_HARDWARE_FLUSH || defined(__DOXYGEN__) + /** + * @brief Flush the current drawing operations to the display + * @pre GDISP_HARDWARE_FLUSH is TRUE + * + * @param[in] g The driver structure + * + * @note The parameter variables must not be altered by the driver. + */ + LLDSPEC void gdisp_lld_flush(GDisplay *g); + #endif + #if GDISP_HARDWARE_STREAM_WRITE || defined(__DOXYGEN__) /** * @brief Start a streamed write operation @@ -495,6 +518,7 @@ struct GDisplay { void (*control)(GDisplay *g); // Uses p.x (=what) p.ptr (=value) void *(*query)(GDisplay *g); // Uses p.x (=what); void (*setclip)(GDisplay *g); // Uses p.x,p.y p.cx,p.cy + void (*flush)(GDisplay *g); // Uses no parameters } GDISPVMT; #if defined(GDISP_DRIVER_VMT) @@ -503,6 +527,11 @@ struct GDisplay { #endif const GDISPVMT const GDISP_DRIVER_VMT[1] = {{ gdisp_lld_init, + #if GDISP_HARDWARE_FLUSH + gdisp_lld_flush, + #else + 0, + #endif #if GDISP_HARDWARE_STREAM_WRITE gdisp_lld_write_start, #if GDISP_HARDWARE_STREAM_POS @@ -571,6 +600,7 @@ struct GDisplay { #else #define gdisp_lld_init(g) g->vmt->init(g) + #define gdisp_lld_flush(g) g->vmt->flush(g) #define gdisp_lld_write_start(g) g->vmt->writestart(g) #define gdisp_lld_write_pos(g) g->vmt->writepos(g) #define gdisp_lld_write_color(g) g->vmt->writecolor(g) @@ -591,34 +621,34 @@ struct GDisplay { #endif // GDISP_TOTAL_CONTROLLERS > 1 - /* Verify information for packed pixels and define a non-packed pixel macro */ - #if !GDISP_PACKED_PIXELS - #define gdispPackPixels(buf,cx,x,y,c) { ((color_t *)(buf))[(y)*(cx)+(x)] = (c); } - #elif !GDISP_HARDWARE_BITFILLS - #error "GDISP: packed pixel formats are only supported for hardware accelerated drivers." - #elif GDISP_PIXELFORMAT != GDISP_PIXELFORMAT_RGB888 \ - && GDISP_PIXELFORMAT != GDISP_PIXELFORMAT_RGB444 \ - && GDISP_PIXELFORMAT != GDISP_PIXELFORMAT_RGB666 \ - && GDISP_PIXELFORMAT != GDISP_PIXELFORMAT_CUSTOM - #error "GDISP: A packed pixel format has been specified for an unsupported pixel format." - #endif +/* Verify information for packed pixels and define a non-packed pixel macro */ +#if !GDISP_PACKED_PIXELS + #define gdispPackPixels(buf,cx,x,y,c) { ((color_t *)(buf))[(y)*(cx)+(x)] = (c); } +#elif !GDISP_HARDWARE_BITFILLS + #error "GDISP: packed pixel formats are only supported for hardware accelerated drivers." +#elif GDISP_PIXELFORMAT != GDISP_PIXELFORMAT_RGB888 \ + && GDISP_PIXELFORMAT != GDISP_PIXELFORMAT_RGB444 \ + && GDISP_PIXELFORMAT != GDISP_PIXELFORMAT_RGB666 \ + && GDISP_PIXELFORMAT != GDISP_PIXELFORMAT_CUSTOM + #error "GDISP: A packed pixel format has been specified for an unsupported pixel format." +#endif - /* Support routine for packed pixel formats */ - #if !defined(gdispPackPixels) || defined(__DOXYGEN__) - /** - * @brief Pack a pixel into a pixel buffer. - * @note This function performs no buffer boundary checking - * regardless of whether GDISP_NEED_CLIP has been specified. - * - * @param[in] buf The buffer to put the pixel in - * @param[in] cx The width of a pixel line - * @param[in] x, y The location of the pixel to place - * @param[in] color The color to put into the buffer - * - * @api - */ - void gdispPackPixels(const pixel_t *buf, coord_t cx, coord_t x, coord_t y, color_t color); - #endif +/* Support routine for packed pixel formats */ +#if !defined(gdispPackPixels) || defined(__DOXYGEN__) + /** + * @brief Pack a pixel into a pixel buffer. + * @note This function performs no buffer boundary checking + * regardless of whether GDISP_NEED_CLIP has been specified. + * + * @param[in] buf The buffer to put the pixel in + * @param[in] cx The width of a pixel line + * @param[in] x, y The location of the pixel to place + * @param[in] color The color to put into the buffer + * + * @api + */ + void gdispPackPixels(const pixel_t *buf, coord_t cx, coord_t x, coord_t y, color_t color); +#endif #endif /* GFX_USE_GDISP */ diff --git a/include/gdisp/options.h b/include/gdisp/options.h index 9af7788f..72fe2038 100644 --- a/include/gdisp/options.h +++ b/include/gdisp/options.h @@ -21,6 +21,20 @@ * @{ */ /** + * @brief Should drawing operations be automatically flushed. + * @details Defaults to FALSE + * @note If set to FALSE and the controller requires flushing + * then the application must manually call @p gdispGFlush(). + * Setting this to TRUE causes GDISP to automatically flush + * after each drawing operation. Note this may be slow but enables + * an application to avoid having to manually call the flush routine. + * @note Most controllers don't need flushing which is why this is set to + * FALSE by default. + */ + #ifndef GDISP_NEED_AUTOFLUSH + #define GDISP_NEED_AUTOFLUSH FALSE + #endif + /** * @brief Should all operations be clipped to the screen and colors validated. * @details Defaults to TRUE. * @note If this is FALSE, any operations that extend beyond the |