From 3a8d39980b9124fe899605cb5350f42d093b1a10 Mon Sep 17 00:00:00 2001 From: Andrew Hannam Date: Mon, 10 Sep 2012 15:54:22 +1000 Subject: Changes to Console, VMT, BitBlt, Clip & Drivers Console - Fix compile, add GDISP_NEED_CONSOLE for compilation VMT - Fix after directory structure changes BitBlt - Update API to allow a source bitmap position. Clip - Add clipping support into gdisp Arc - Allow hardware accelleration of Arc routines Nokia6610 - Fixes to BitBlt. --- templates/gdispXXXXX/gdisp_lld.c | 152 +++++++++++++++++++++++--------- templates/gdispXXXXX/gdisp_lld_config.h | 3 + 2 files changed, 113 insertions(+), 42 deletions(-) (limited to 'templates/gdispXXXXX') diff --git a/templates/gdispXXXXX/gdisp_lld.c b/templates/gdispXXXXX/gdisp_lld.c index 81e96894..26052e98 100644 --- a/templates/gdispXXXXX/gdisp_lld.c +++ b/templates/gdispXXXXX/gdisp_lld.c @@ -35,23 +35,7 @@ /* Include the emulation code for things we don't support */ #include "gdisp_emulation.c" -/*===========================================================================*/ -/* Driver local definitions. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver exported variables. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver local variables. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver local functions. */ -/*===========================================================================*/ - -#if GDISP_NEED_TEXT +#if GDISP_NEED_TEXT && GDISP_HARDWARE_TEXT #include "gdisp_fonts.h" #endif @@ -95,6 +79,12 @@ bool_t GDISP_LLD(init)(void) { GDISP.Powermode = powerOn; GDISP.Backlight = 100; GDISP.Contrast = 50; + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + GDISP.clipx0 = 0; + GDISP.clipy0 = 0; + GDISP.clipx1 = GDISP.Width-1; + GDISP.clipy1 = GDISP.Height-1; + #endif return TRUE; } @@ -108,8 +98,8 @@ bool_t GDISP_LLD(init)(void) { * @notapi */ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { - #if GDISP_NEED_VALIDATION - if (x >= GDISP.Width || y >= GDISP.Height) return; + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + if (x < GDISP.clipx0 || y < GDISP.clipy0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; #endif /* Code here */ } @@ -157,8 +147,8 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { * @notapi */ void GDISP_LLD(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color) { - #if GDISP_NEED_VALIDATION - /* Need to clip to screen */ + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + /* Code here */ #endif /* Code here */ } @@ -176,10 +166,12 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { * @notapi */ void GDISP_LLD(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { - #if GDISP_NEED_VALIDATION - if (cx < 1 || cy < 1 || x >= GDISP.Width || y >= GDISP.Height) return; - if (x+cx > GDISP.Width) cx = GDISP.Width - x; - if (y+cy > GDISP.Height) cy = GDISP.Height - y; + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; x = GDISP.clipx0; } + if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; y = GDISP.clipy0; } + if (cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; + if (x+cx > GDISP.clipx1) cx -= GDISP.clipx1 - x; + if (y+cy > GDISP.clipy1) cy -= GDISP.clipy1 - y; #endif /* Code here */ } @@ -192,15 +184,20 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { * * @param[in] x, y The start filled area * @param[in] cx, cy The width and height to be filled + * @param[in] srcx, srcy The bitmap position to start the fill from + * @param[in] srccx The width of a line in the bitmap. * @param[in] buffer The pixels to use to fill the area. * * @notapi */ - void GDISP_LLD(blitarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer) { - #if GDISP_NEED_VALIDATION - if (cx < 1 || cy < 1 || x >= GDISP.Width || y >= GDISP.Height) return; - if (x+cx > GDISP.Width) return; - if (y+cy > GDISP.Height) cy = GDISP.Height - y; + void GDISP_LLD(blitareaex)(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) { + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; srcx += GDISP.clipx0 - x; x = GDISP.clipx0; } + if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; srcy += GDISP.clipy0 - y; y = GDISP.clipy0; } + if (srcx+cx > srccx) cx = srccx - srcx; + if (cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; + if (x+cx > GDISP.clipx1) cx -= GDISP.clipx1 - x; + if (y+cy > GDISP.clipy1) cy -= GDISP.clipy1 - y; #endif /* Code here */ } @@ -221,7 +218,7 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { * @notapi */ void GDISP_LLD(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color) { - #if GDISP_NEED_VALIDATION + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP /* Code here */ #endif /* Code here */ @@ -242,7 +239,7 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { * @notapi */ void GDISP_LLD(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color) { - #if GDISP_NEED_VALIDATION + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP /* Code here */ #endif /* Code here */ @@ -263,7 +260,7 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { * @notapi */ void GDISP_LLD(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) { - #if GDISP_NEED_VALIDATION + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP /* Code here */ #endif /* Code here */ @@ -284,7 +281,52 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { * @notapi */ void GDISP_LLD(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) { - #if GDISP_NEED_VALIDATION + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + /* Code here */ + #endif + /* Code here */ + } +#endif + +/* Arc Drawing Functions */ +#if (GDISP_NEED_ARC && GDISP_HARDWARE_ARCS) || defined(__DOXYGEN__) + /** + * @brief Draw an arc. + * @note Optional - The high level driver can emulate using software. + * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave + * correctly if the circle is over the edges of the screen. + * + * @param[in] x, y The centre of the arc circle + * @param[in] radius The radius of the arc circle + * @param[in] startangle, endangle The start and end angles for the arc (0..359) + * @param[in] color The color of the circle + * + * @notapi + */ + void GDISP_LLD(drawarc)(coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle, color_t color) { + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + /* Code here */ + #endif + /* Code here */ + } +#endif + +#if (GDISP_NEED_ARC && GDISP_HARDWARE_ARCFILLS) || defined(__DOXYGEN__) + /** + * @brief Create a filled arc. + * @note Optional - The high level driver can emulate using software. + * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave + * correctly if the circle is over the edges of the screen. + * + * @param[in] x, y The centre of the arc circle + * @param[in] radius The radius of the arc circle + * @param[in] startangle, endangle The start and end angles for the arc (0..359) + * @param[in] color The color of the circle + * + * @notapi + */ + void GDISP_LLD(fillarc)(coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle, color_t color) { + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP /* Code here */ #endif /* Code here */ @@ -303,7 +345,7 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { * @notapi */ void GDISP_LLD(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color) { - #if GDISP_NEED_VALIDATION + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP /* Code here */ #endif /* Code here */ @@ -323,7 +365,7 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { * @notapi */ void GDISP_LLD(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor) { - #if GDISP_NEED_VALIDATION + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP /* Code here */ #endif /* Code here */ @@ -342,8 +384,8 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { * @notapi */ color_t GDISP_LLD(getpixelcolor)(coord_t x, coord_t y) { - #if GDISP_NEED_VALIDATION - if (x >= GDISP.Width || y >= GDISP.Height) return 0; + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + if (x < 0 || x >= GDISP.Width || y < 0 || y >= GDISP.Height) return 0; #endif /* Code here */ } @@ -364,10 +406,12 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { * @notapi */ void GDISP_LLD(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) { - #if GDISP_NEED_VALIDATION - if (cx < 1 || cy < 1 || x >= GDISP.Width || y >= GDISP.Height) return; - if (x+cx > GDISP.Width) cx = GDISP.Width - x; - if (y+cy > GDISP.Height) cy = GDISP.Height - y; + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; x = GDISP.clipx0; } + if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; y = GDISP.clipy0; } + if (!lines || cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; + if (x+cx > GDISP.clipx1) cx -= GDISP.clipx1 - x; + if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; #endif /* Code here */ } @@ -444,6 +488,12 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { default: return; } + #if GDISP_NEED_CLIP || GDISP_NEED_VALIDATION + GDISP.clipx0 = 0; + GDISP.clipy0 = 0; + GDISP.clipx1 = GDISP.Width; + GDISP.clipy1 = GDISP.Height; + #endif GDISP.Orientation = (gdisp_orientation_t)value; return; /* @@ -486,5 +536,23 @@ void *GDISP_LLD(query)(unsigned what) { } #endif +#if GDISP_NEED_CLIP && GDISP_HARDWARE_CLIP + void GDISP_LLD(setclip)(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; + /* Code here to set hardware clipping */ + } +#endif + #endif /* HAL_USE_GDISP */ /** @} */ diff --git a/templates/gdispXXXXX/gdisp_lld_config.h b/templates/gdispXXXXX/gdisp_lld_config.h index 81a6826f..191c4c3e 100644 --- a/templates/gdispXXXXX/gdisp_lld_config.h +++ b/templates/gdispXXXXX/gdisp_lld_config.h @@ -46,12 +46,15 @@ #define GDISP_HARDWARE_CIRCLEFILLS FALSE #define GDISP_HARDWARE_ELLIPSES FALSE #define GDISP_HARDWARE_ELLIPSEFILLS FALSE +#define GDISP_HARDWARE_ARCS FALSE +#define GDISP_HARDWARE_ARCFILLS FALSE #define GDISP_HARDWARE_TEXT FALSE #define GDISP_HARDWARE_TEXTFILLS FALSE #define GDISP_HARDWARE_SCROLL FALSE #define GDISP_HARDWARE_PIXELREAD FALSE #define GDISP_HARDWARE_CONTROL FALSE #define GDISP_HARDWARE_QUERY FALSE +#define GDISP_HARDWARE_CLIP FALSE #define GDISP_SOFTWARE_TEXTFILLDRAW FALSE #define GDISP_SOFTWARE_TEXTBLITCOLUMN FALSE -- cgit v1.2.3