SImplify the options for multiple displays.

This will also be more compatible with newmouse infrastructure
ugfx_release_2.6
inmarket 2014-09-17 08:43:11 +10:00
parent e586459a24
commit ffa03cb570
9 changed files with 155 additions and 193 deletions

View File

@ -46,16 +46,20 @@
#define GDISP_INCLUDE_FONT_UI2 TRUE #define GDISP_INCLUDE_FONT_UI2 TRUE
#define GDISP_TOTAL_DISPLAYS 2 /* You must either define GDISP_TOTAL_DISPLAYS or GDISP_DRIVER_LIST for multiple displays.
* You cannot define both!
/* Uncomment the following lines if you want to use multiple displays on
* different controllers.
* *
* Change the definitions to suit your hardware. * Defining GDISP_TOTAL_DISPLAYS will create multiple instances of the one default driver.
* Currently all controllers must use the same pixel format. * Defining GDISP_DRIVER_LIST allows you to specify multiple different drivers.
* *
* Remember that GDISP_TOTAL_DISPLAYS above must match the **Total** * Extra Notes for GDISP_DRIVER_LIST:
* number of displays in your system across all controllers. *-----------------------------------
*
* The same controller can appear more than once in the list.
*
* You must specify a GDISP_PIXELFORMAT that the application will work in. This
* is translated into each drivers internal pixel format by the driver. You the
* pixel format that is most common accross your drivers (for efficiency).
* *
* Optionally, you can also specify hardware characteristics that are common to * Optionally, you can also specify hardware characteristics that are common to
* all your controllers. This significantly improves code and speed efficiency * all your controllers. This significantly improves code and speed efficiency
@ -72,9 +76,9 @@
* #define GDISP_HARDWARE_DRAWPIXEL TRUE * #define GDISP_HARDWARE_DRAWPIXEL TRUE
* #define GDISP_HARDWARE_FILLS TRUE * #define GDISP_HARDWARE_FILLS TRUE
*/ */
//#define GDISP_TOTAL_CONTROLLERS 2 #define GDISP_TOTAL_DISPLAYS 2
//#define GDISP_CONTROLLER_LIST GDISPVMT_Win32, GDISPVMT_Win32
//#define GDISP_CONTROLLER_DISPLAYS 1, 1 //#define GDISP_DRIVER_LIST GDISPVMT_Win32, GDISPVMT_Win32
//#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB888 //#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB888
#endif /* _GFXCONF_H */ #endif /* _GFXCONF_H */

View File

@ -46,7 +46,7 @@
#if USE_METHOD_1 #if USE_METHOD_1
int main(void) { int main(void) {
coord_t width, height; coord_t width, height;
coord_t display, i, j; coord_t display, i, j, cnt;
font_t f; font_t f;
GDisplay *g; GDisplay *g;
char buf[16]; char buf[16];
@ -58,7 +58,8 @@
f = gdispOpenFont("*"); f = gdispOpenFont("*");
/* Cycle through each display */ /* Cycle through each display */
for(display = 0; display < GDISP_TOTAL_DISPLAYS; display++) { cnt = gdispGetDisplayCount();
for(display = 0; display < cnt; display++) {
// Get the specified display // Get the specified display
g = gdispGetDisplay(display); g = gdispGetDisplay(display);
@ -84,7 +85,7 @@
#else #else
int main(void) { int main(void) {
coord_t width, height; coord_t width, height;
coord_t display, i, j; coord_t display, i, j, cnt;
font_t f; font_t f;
char buf[16]; char buf[16];
@ -95,7 +96,8 @@
f = gdispOpenFont("*"); f = gdispOpenFont("*");
/* Cycle through each display */ /* Cycle through each display */
for(display = 0; display < GDISP_TOTAL_DISPLAYS; display++) { cnt = gdispGetDisplayCount();
for(display = 0; display < cnt; display++) {
// Set the default display to the specified display // Set the default display to the specified display
gdispSetDisplay(gdispGetDisplay(display)); gdispSetDisplay(gdispGetDisplay(display));

View File

@ -205,20 +205,18 @@ static DECLARE_THREAD_FUNCTION(NetThread, param) {
gfxHalt("GDISP: uGFXnet - Accept failed"); gfxHalt("GDISP: uGFXnet - Accept failed");
// Look for a display that isn't connected // Look for a display that isn't connected
for(disp = 0; disp < GDISP_TOTAL_DISPLAYS; disp++) { for(g = 0; (g = (GDisplay *)gdriverGetNext(GDRIVER_TYPE_DISPLAY, (GDriver *)g));) {
if (!(g = gdispGetDisplay(disp))) // Ignore displays for other controllers
continue; #ifdef GDISP_DRIVER_LIST
#if GDISP_TOTAL_CONTROLLERS > 1 if (gvmt(g) != &GDISPVMT_uGFXnet)
// Ignore displays for other controllers continue;
if (g->vmt != &GDISPVMT_uGFXnet) #endif
continue;
#endif
if (!(g->flags & GDISP_FLG_CONNECTED)) if (!(g->flags & GDISP_FLG_CONNECTED))
break; break;
} }
// Was anything found? // Was anything found?
if (disp >= GDISP_TOTAL_DISPLAYS) { if (!g) {
// No Just close the connection // No Just close the connection
closesocket(clientfd); closesocket(clientfd);
gfxHalt("GDISP: uGFXnet - Can't find display for connection"); gfxHalt("GDISP: uGFXnet - Can't find display for connection");
@ -275,21 +273,19 @@ static DECLARE_THREAD_FUNCTION(NetThread, param) {
if((clientfd = accept(listenfd, (struct sockaddr *)&addr, &len)) == (SOCKET_TYPE)-1) if((clientfd = accept(listenfd, (struct sockaddr *)&addr, &len)) == (SOCKET_TYPE)-1)
gfxHalt("GDISP: uGFXnet - Accept failed"); gfxHalt("GDISP: uGFXnet - Accept failed");
// Look for a display that isn't connected // Look for a display that isn't connected
for(disp = 0; disp < GDISP_TOTAL_DISPLAYS; disp++) { for(g = 0; (g = (GDisplay *)gdriverGetNext(GDRIVER_TYPE_DISPLAY, (GDriver *)g));) {
if (!(g = gdispGetDisplay(disp))) // Ignore displays for other controllers
continue; #ifdef GDISP_DRIVER_LIST
#if GDISP_TOTAL_CONTROLLERS > 1 if (gvmt(g) != &GDISPVMT_uGFXnet)
// Ignore displays for other controllers continue;
if (g->vmt != &GDISPVMT_uGFXnet) #endif
continue; if (!(g->flags & GDISP_FLG_CONNECTED))
#endif break;
if (!(g->flags & GDISP_FLG_CONNECTED)) }
break;
}
// Was anything found? // Was anything found?
if (disp >= GDISP_TOTAL_DISPLAYS) { if (!g) {
// No Just close the connection // No Just close the connection
closesocket(clientfd); closesocket(clientfd);
//printf(New connection from %s on socket %d rejected as all displays are already connected\n", inet_ntoa(addr.sin_addr), clientfd); //printf(New connection from %s on socket %d rejected as all displays are already connected\n", inet_ntoa(addr.sin_addr), clientfd);
@ -332,19 +328,17 @@ static DECLARE_THREAD_FUNCTION(NetThread, param) {
// Handle data from a client // Handle data from a client
// Look for a display that is connected and the socket descriptor matches // Look for a display that is connected and the socket descriptor matches
for(disp = 0; disp < GDISP_TOTAL_DISPLAYS; disp++) { for(g = 0; (g = (GDisplay *)gdriverGetNext(GDRIVER_TYPE_DISPLAY, (GDriver *)g));) {
if (!(g = gdispGetDisplay(disp))) // Ignore displays for other controllers
continue; #ifdef GDISP_DRIVER_LIST
#if GDISP_TOTAL_CONTROLLERS > 1 if (gvmt(g) != &GDISPVMT_uGFXnet)
// Ignore displays for other controllers continue;
if (g->vmt != &GDISPVMT_uGFXnet) #endif
continue;
#endif
priv = g->priv; priv = g->priv;
if ((g->flags & GDISP_FLG_CONNECTED) && priv->netfd == i) if ((g->flags & GDISP_FLG_CONNECTED) && priv->netfd == i)
break; break;
} }
if (disp >= GDISP_TOTAL_DISPLAYS) if (!g)
gfxHalt("GDISP: uGFXnet - Got data from unrecognized connection"); gfxHalt("GDISP: uGFXnet - Got data from unrecognized connection");
if ((g->flags & GDISP_FLG_HAVEDATA)) { if ((g->flags & GDISP_FLG_HAVEDATA)) {

View File

@ -108,8 +108,8 @@
//#define GDISP_TOTAL_DISPLAYS 1 //#define GDISP_TOTAL_DISPLAYS 1
//#define GDISP_TOTAL_CONTROLLERS 1 //#define GDISP_DRIVER_LIST GDISPVMT_Win32, GDISPVMT_Win32
// #if GDISP_TOTAL_CONTROLLERS > 1 // #ifdef GDISP_DRIVER_LIST
// // For code and speed optimization define as TRUE or FALSE if all controllers have the same capability // // For code and speed optimization define as TRUE or FALSE if all controllers have the same capability
// #define GDISP_HARDWARE_STREAM_WRITE FALSE // #define GDISP_HARDWARE_STREAM_WRITE FALSE
// #define GDISP_HARDWARE_STREAM_READ FALSE // #define GDISP_HARDWARE_STREAM_READ FALSE
@ -124,8 +124,6 @@
// #define GDISP_HARDWARE_QUERY FALSE // #define GDISP_HARDWARE_QUERY FALSE
// #define GDISP_HARDWARE_CLIP FALSE // #define GDISP_HARDWARE_CLIP FALSE
// #define GDISP_CONTROLLER_LIST GDISPVMT_Win32, GDISPVMT_Win32
// #define GDISP_CONTROLLER_DISPLAYS 1, 1
// #define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB888 // #define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB888
// #endif // #endif

View File

@ -24,7 +24,7 @@
// Our special auto-detect hardware code which uses the VMT. // Our special auto-detect hardware code which uses the VMT.
#define HARDWARE_AUTODETECT 2 #define HARDWARE_AUTODETECT 2
#if GDISP_TOTAL_CONTROLLERS > 1 && !defined(GDISP_DRIVER_VMT) #if defined(GDISP_DRIVER_LIST) && !defined(GDISP_DRIVER_VMT)
// Multiple controllers the default is to hardware detect // Multiple controllers the default is to hardware detect
#define HARDWARE_DEFAULT HARDWARE_AUTODETECT #define HARDWARE_DEFAULT HARDWARE_AUTODETECT
#else #else
@ -40,7 +40,7 @@
* @brief The display hardware can benefit from being de-initialized when usage is complete. * @brief The display hardware can benefit from being de-initialized when usage is complete.
* @details Can be set to TRUE, FALSE or HARDWARE_AUTODETECT * @details Can be set to TRUE, FALSE or HARDWARE_AUTODETECT
* *
* @note HARDWARE_AUTODETECT is only meaningful when GDISP_TOTAL_CONTROLLERS > 1 * @note HARDWARE_AUTODETECT is only meaningful when GDISP_DRIVER_LIST is defined
* @note This is most useful for displays such as remote network displays. * @note This is most useful for displays such as remote network displays.
*/ */
#ifndef GDISP_HARDWARE_DEINIT #ifndef GDISP_HARDWARE_DEINIT
@ -51,7 +51,7 @@
* @brief The display hardware can benefit from being flushed. * @brief The display hardware can benefit from being flushed.
* @details Can be set to TRUE, FALSE or HARDWARE_AUTODETECT * @details Can be set to TRUE, FALSE or HARDWARE_AUTODETECT
* *
* @note HARDWARE_AUTODETECT is only meaningful when GDISP_TOTAL_CONTROLLERS > 1 * @note HARDWARE_AUTODETECT is only meaningful when GDISP_DRIVER_LIST is defined
* @note Some controllers ** require ** the application to flush * @note Some controllers ** require ** the application to flush
*/ */
#ifndef GDISP_HARDWARE_FLUSH #ifndef GDISP_HARDWARE_FLUSH
@ -62,7 +62,7 @@
* @brief Hardware streaming writing is supported. * @brief Hardware streaming writing is supported.
* @details Can be set to TRUE, FALSE or HARDWARE_AUTODETECT * @details Can be set to TRUE, FALSE or HARDWARE_AUTODETECT
* *
* @note HARDWARE_AUTODETECT is only meaningful when GDISP_TOTAL_CONTROLLERS > 1 * @note HARDWARE_AUTODETECT is only meaningful when GDISP_DRIVER_LIST is defined
* @note Either GDISP_HARDWARE_STREAM_WRITE or GDISP_HARDWARE_DRAWPIXEL must be provided by each driver * @note Either GDISP_HARDWARE_STREAM_WRITE or GDISP_HARDWARE_DRAWPIXEL must be provided by each driver
*/ */
#ifndef GDISP_HARDWARE_STREAM_WRITE #ifndef GDISP_HARDWARE_STREAM_WRITE
@ -73,7 +73,7 @@
* @brief Hardware streaming reading of the display surface is supported. * @brief Hardware streaming reading of the display surface is supported.
* @details Can be set to TRUE, FALSE or HARDWARE_AUTODETECT * @details Can be set to TRUE, FALSE or HARDWARE_AUTODETECT
* *
* @note HARDWARE_AUTODETECT is only meaningful when GDISP_TOTAL_CONTROLLERS > 1 * @note HARDWARE_AUTODETECT is only meaningful when GDISP_DRIVER_LIST is defined
* *
*/ */
#ifndef GDISP_HARDWARE_STREAM_READ #ifndef GDISP_HARDWARE_STREAM_READ
@ -84,7 +84,7 @@
* @brief Hardware supports setting the cursor position within the stream window. * @brief Hardware supports setting the cursor position within the stream window.
* @details Can be set to TRUE, FALSE or HARDWARE_AUTODETECT * @details Can be set to TRUE, FALSE or HARDWARE_AUTODETECT
* *
* @note HARDWARE_AUTODETECT is only meaningful when GDISP_TOTAL_CONTROLLERS > 1 * @note HARDWARE_AUTODETECT is only meaningful when GDISP_DRIVER_LIST is defined
* @note This is used to optimise setting of individual pixels within a stream window. * @note This is used to optimise setting of individual pixels within a stream window.
* It should therefore not be implemented unless it is cheaper than just setting * It should therefore not be implemented unless it is cheaper than just setting
* a new window. * a new window.
@ -97,7 +97,7 @@
* @brief Hardware accelerated draw pixel. * @brief Hardware accelerated draw pixel.
* @details Can be set to TRUE, FALSE or HARDWARE_AUTODETECT * @details Can be set to TRUE, FALSE or HARDWARE_AUTODETECT
* *
* @note HARDWARE_AUTODETECT is only meaningful when GDISP_TOTAL_CONTROLLERS > 1 * @note HARDWARE_AUTODETECT is only meaningful when GDISP_DRIVER_LIST is defined
* @note Either GDISP_HARDWARE_STREAM_WRITE or GDISP_HARDWARE_DRAWPIXEL must be provided by the driver * @note Either GDISP_HARDWARE_STREAM_WRITE or GDISP_HARDWARE_DRAWPIXEL must be provided by the driver
*/ */
#ifndef GDISP_HARDWARE_DRAWPIXEL #ifndef GDISP_HARDWARE_DRAWPIXEL
@ -108,7 +108,7 @@
* @brief Hardware accelerated screen clears. * @brief Hardware accelerated screen clears.
* @details Can be set to TRUE, FALSE or HARDWARE_AUTODETECT * @details Can be set to TRUE, FALSE or HARDWARE_AUTODETECT
* *
* @note HARDWARE_AUTODETECT is only meaningful when GDISP_TOTAL_CONTROLLERS > 1 * @note HARDWARE_AUTODETECT is only meaningful when GDISP_DRIVER_LIST is defined
* @note This clears the entire display surface regardless of the clipping area currently set * @note This clears the entire display surface regardless of the clipping area currently set
*/ */
#ifndef GDISP_HARDWARE_CLEARS #ifndef GDISP_HARDWARE_CLEARS
@ -119,7 +119,7 @@
* @brief Hardware accelerated rectangular fills. * @brief Hardware accelerated rectangular fills.
* @details Can be set to TRUE, FALSE or HARDWARE_AUTODETECT * @details Can be set to TRUE, FALSE or HARDWARE_AUTODETECT
* *
* @note HARDWARE_AUTODETECT is only meaningful when GDISP_TOTAL_CONTROLLERS > 1 * @note HARDWARE_AUTODETECT is only meaningful when GDISP_DRIVER_LIST is defined
*/ */
#ifndef GDISP_HARDWARE_FILLS #ifndef GDISP_HARDWARE_FILLS
#define GDISP_HARDWARE_FILLS HARDWARE_DEFAULT #define GDISP_HARDWARE_FILLS HARDWARE_DEFAULT
@ -129,7 +129,7 @@
* @brief Hardware accelerated fills from an image. * @brief Hardware accelerated fills from an image.
* @details Can be set to TRUE, FALSE or HARDWARE_AUTODETECT * @details Can be set to TRUE, FALSE or HARDWARE_AUTODETECT
* *
* @note HARDWARE_AUTODETECT is only meaningful when GDISP_TOTAL_CONTROLLERS > 1 * @note HARDWARE_AUTODETECT is only meaningful when GDISP_DRIVER_LIST is defined
*/ */
#ifndef GDISP_HARDWARE_BITFILLS #ifndef GDISP_HARDWARE_BITFILLS
#define GDISP_HARDWARE_BITFILLS HARDWARE_DEFAULT #define GDISP_HARDWARE_BITFILLS HARDWARE_DEFAULT
@ -139,7 +139,7 @@
* @brief Hardware accelerated scrolling. * @brief Hardware accelerated scrolling.
* @details Can be set to TRUE, FALSE or HARDWARE_AUTODETECT * @details Can be set to TRUE, FALSE or HARDWARE_AUTODETECT
* *
* @note HARDWARE_AUTODETECT is only meaningful when GDISP_TOTAL_CONTROLLERS > 1 * @note HARDWARE_AUTODETECT is only meaningful when GDISP_DRIVER_LIST is defined
*/ */
#ifndef GDISP_HARDWARE_SCROLL #ifndef GDISP_HARDWARE_SCROLL
#define GDISP_HARDWARE_SCROLL HARDWARE_DEFAULT #define GDISP_HARDWARE_SCROLL HARDWARE_DEFAULT
@ -149,7 +149,7 @@
* @brief Reading back of pixel values. * @brief Reading back of pixel values.
* @details Can be set to TRUE, FALSE or HARDWARE_AUTODETECT * @details Can be set to TRUE, FALSE or HARDWARE_AUTODETECT
* *
* @note HARDWARE_AUTODETECT is only meaningful when GDISP_TOTAL_CONTROLLERS > 1 * @note HARDWARE_AUTODETECT is only meaningful when GDISP_DRIVER_LIST is defined
*/ */
#ifndef GDISP_HARDWARE_PIXELREAD #ifndef GDISP_HARDWARE_PIXELREAD
#define GDISP_HARDWARE_PIXELREAD HARDWARE_DEFAULT #define GDISP_HARDWARE_PIXELREAD HARDWARE_DEFAULT
@ -159,7 +159,7 @@
* @brief The driver supports one or more control commands. * @brief The driver supports one or more control commands.
* @details Can be set to TRUE, FALSE or HARDWARE_AUTODETECT * @details Can be set to TRUE, FALSE or HARDWARE_AUTODETECT
* *
* @note HARDWARE_AUTODETECT is only meaningful when GDISP_TOTAL_CONTROLLERS > 1 * @note HARDWARE_AUTODETECT is only meaningful when GDISP_DRIVER_LIST is defined
*/ */
#ifndef GDISP_HARDWARE_CONTROL #ifndef GDISP_HARDWARE_CONTROL
#define GDISP_HARDWARE_CONTROL HARDWARE_DEFAULT #define GDISP_HARDWARE_CONTROL HARDWARE_DEFAULT
@ -169,7 +169,7 @@
* @brief The driver supports a non-standard query. * @brief The driver supports a non-standard query.
* @details Can be set to TRUE, FALSE or HARDWARE_AUTODETECT * @details Can be set to TRUE, FALSE or HARDWARE_AUTODETECT
* *
* @note HARDWARE_AUTODETECT is only meaningful when GDISP_TOTAL_CONTROLLERS > 1 * @note HARDWARE_AUTODETECT is only meaningful when GDISP_DRIVER_LIST is defined
*/ */
#ifndef GDISP_HARDWARE_QUERY #ifndef GDISP_HARDWARE_QUERY
#define GDISP_HARDWARE_QUERY HARDWARE_DEFAULT #define GDISP_HARDWARE_QUERY HARDWARE_DEFAULT
@ -179,7 +179,7 @@
* @brief The driver supports a clipping in hardware. * @brief The driver supports a clipping in hardware.
* @details Can be set to TRUE, FALSE or HARDWARE_AUTODETECT * @details Can be set to TRUE, FALSE or HARDWARE_AUTODETECT
* *
* @note HARDWARE_AUTODETECT is only meaningful when GDISP_TOTAL_CONTROLLERS > 1 * @note HARDWARE_AUTODETECT is only meaningful when GDISP_DRIVER_LIST is defined
* @note If this is defined the driver must perform its own clipping on all calls to * @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. * 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 * @note If this is not defined then the software ensures that all calls to the
@ -310,16 +310,16 @@ typedef struct GDISPVMT {
} GDISPVMT; } GDISPVMT;
// Do we need function definitions or macro's (via the VMT) // Do we need function definitions or macro's (via the VMT)
#if GDISP_TOTAL_CONTROLLERS <= 1 || defined(GDISP_DRIVER_VMT) || defined(__DOXYGEN__) #if !defined(GDISP_DRIVER_LIST) || defined(GDISP_DRIVER_VMT) || defined(__DOXYGEN__)
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
// Should the driver routines should be static or not // Should the driver routines should be static or not
#if GDISP_TOTAL_CONTROLLERS <= 1 #if defined(GDISP_DRIVER_LIST)
#define LLDSPEC #define LLDSPEC static
#else #else
#define LLDSPEC static #define LLDSPEC
#endif #endif
/** /**
@ -611,7 +611,7 @@ typedef struct GDISPVMT {
#endif #endif
// If we are not using multiple displays then hard-code the VMT name // If we are not using multiple displays then hard-code the VMT name
#ifndef GDISP_CONTROLLER_LIST #if !defined(GDISP_DRIVER_LIST)
#undef GDISP_DRIVER_VMT #undef GDISP_DRIVER_VMT
#define GDISP_DRIVER_VMT GDISPVMT_OnlyOne #define GDISP_DRIVER_VMT GDISPVMT_OnlyOne
#endif #endif

View File

@ -566,45 +566,24 @@ static void line_clip(GDisplay *g) {
void _gdispInit(void) void _gdispInit(void)
{ {
// Both GDISP_CONTROLLER_LIST and GDISP_CONTROLLER_DISPLAYS are defined - create the required numbers of each controller // GDISP_DRIVER_LIST is defined - create each driver instance
#if defined(GDISP_CONTROLLER_LIST) && defined(GDISP_CONTROLLER_DISPLAYS) #if defined(GDISP_DRIVER_LIST)
{
int i, cnt;
extern GDriverVMTList GDISP_CONTROLLER_LIST;
static const struct GDriverVMT const * dclist[GDISP_TOTAL_CONTROLLERS] = {GDISP_CONTROLLER_LIST};
static const unsigned dnlist[GDISP_TOTAL_CONTROLLERS] = {GDISP_CONTROLLER_DISPLAYS};
for(i = 0; i < GDISP_TOTAL_CONTROLLERS; i++) {
for(cnt = dnlist[i]; cnt; cnt--)
gdriverRegister(dclist[i]);
}
}
// Only GDISP_CONTROLLER_LIST is defined - create one of each controller
#elif defined(GDISP_CONTROLLER_LIST)
{ {
int i; int i;
extern GDriverVMTList GDISP_CONTROLLER_LIST; extern GDriverVMTList GDISP_DRIVER_LIST;
static const struct GDriverVMT const * dclist[GDISP_TOTAL_CONTROLLERS] = {GDISP_CONTROLLER_LIST}; static const struct GDriverVMT const * dclist[] = {GDISP_DRIVER_LIST};
for(i = 0; i < GDISP_TOTAL_CONTROLLERS; i++) for(i = 0; i < sizeof(dclist)/sizeof(dclist[0]); i++)
gdriverRegister(dclist[i]); gdriverRegister(dclist[i]);
} }
// Only GDISP_TOTAL_DISPLAYS is defined - create the required number of the one controller
#elif GDISP_TOTAL_DISPLAYS > 1 #elif GDISP_TOTAL_DISPLAYS > 1
{ {
int cnt; int i;
extern GDriverVMTList GDISPVMT_OnlyOne; for(i = 0; i < GDISP_TOTAL_DISPLAYS; i++)
for(cnt = 0; cnt < GDISP_TOTAL_DISPLAYS; cnt++)
gdriverRegister(GDISPVMT_OnlyOne); gdriverRegister(GDISPVMT_OnlyOne);
} }
// One and only one display
#else #else
{ {
extern GDriverVMTList GDISPVMT_OnlyOne; extern GDriverVMTList GDISPVMT_OnlyOne;
@ -715,10 +694,6 @@ void _gdispDeInitDriver(GDriver *g) {
#undef gd #undef gd
} }
GDisplay *gdispGetDisplay(unsigned display) {
return (GDisplay *)gdriverGetInstance(GDRIVER_TYPE_DISPLAY, display);
}
void gdispSetDisplay(GDisplay *g) { void gdispSetDisplay(GDisplay *g) {
if (g) GDISP = g; if (g) GDISP = g;
} }

View File

@ -111,7 +111,7 @@ extern GDisplay *GDISP;
/* Defines relating to the display hardware */ /* Defines relating to the display hardware */
/*===========================================================================*/ /*===========================================================================*/
#if GDISP_TOTAL_CONTROLLERS <= 1 #if !defined(GDISP_DRIVER_LIST)
// Pull in the default hardware configuration for a single controller. // Pull in the default hardware configuration for a single controller.
// If we have multiple controllers the settings must be set in the // If we have multiple controllers the settings must be set in the
// users gfxconf.h file. // users gfxconf.h file.
@ -133,7 +133,7 @@ extern GDisplay *GDISP;
* @details It generally defaults to the hardware pixel format. * @details It generally defaults to the hardware pixel format.
* @note This doesn't need to match the hardware pixel format. * @note This doesn't need to match the hardware pixel format.
* It is definitely more efficient when it does. * It is definitely more efficient when it does.
* @note When GDISP_TOTAL_CONTROLLERS > 1, this must * @note When GDISP_DRIVER_LIST is defined, this must
* be explicitly defined and you should ensure the best match * be explicitly defined and you should ensure the best match
* with your hardware across all devices. * with your hardware across all devices.
*/ */
@ -213,13 +213,13 @@ color_t gdispContrastColor(color_t color);
* @note The GDISP variable contains the display used by the gdispXxxx routines * @note The GDISP variable contains the display used by the gdispXxxx routines
* as opposed to the gdispGXxxx routines which take an explicit display * as opposed to the gdispGXxxx routines which take an explicit display
* parameter. * parameter.
* @note Displays are numbered from 0 to GDISP_TOTAL_DISPLAYS - 1 * @note Displays are numbered from 0 to @p gdispGetDisplayCount() - 1
* *
* @param[in] display The display number (0..n) * @param[in] display The display number (0..n)
* *
* @api * @api
*/ */
GDisplay *gdispGetDisplay(unsigned display); #define gdispGetDisplay(display) ((GDisplay *)gdriverGetInstance(GDRIVER_TYPE_DISPLAY, display))
/** /**
* @brief Set the current default display to the specified display * @brief Set the current default display to the specified display
@ -235,6 +235,14 @@ GDisplay *gdispGetDisplay(unsigned display);
*/ */
void gdispSetDisplay(GDisplay *g); void gdispSetDisplay(GDisplay *g);
/**
* @brief Get the count of currently active displays
* @return The count of displays currently in the system
*
* @note Displays are numbered from 0 to @p gdispGetDisplayCount() - 1
*/
#define gdispGetDisplayCount() gdriverInstanceCount(GDRIVER_TYPE_DISPLAY)
/* Property Functions */ /* Property Functions */
/** /**

View File

@ -184,42 +184,26 @@
* @{ * @{
*/ */
/** /**
* @brief The total number of displays. * @brief The total number of displays using the default driver.
* @note This can be on just one type of controller or spread across several different controllers * @note If you want to use multiple displays either set GDISP_TOTAL_DISPLAYS or GDISP_DRIVER_LIST
* but not both.
*/ */
#ifndef GDISP_TOTAL_DISPLAYS #ifndef GDISP_TOTAL_DISPLAYS
#define GDISP_TOTAL_DISPLAYS 1 #define GDISP_TOTAL_DISPLAYS 1
#endif #endif
/**
* @brief The total number of controllers.
* @note If this is greater than one, all the hardware acceleration options below
* and the pixel format must be manually specified in your gfxconf.h along with
* @p GDISP_CONTROLLER_LIST. See the gdisp_lld_config.h in each driver to get a list
* of hardware capabilities for each driver in order to work out the common set across
* all the controllers you want to use.
*/
#ifndef GDISP_TOTAL_CONTROLLERS
#define GDISP_TOTAL_CONTROLLERS 1
#endif
#if defined(__DOXYGEN__) #if defined(__DOXYGEN__)
/** /**
* @brief The list of controllers. * @brief The list of display drivers.
* @note This is required if @p GDISP_TOTAL_CONTROLLERS is greater than one. * @note Replace this example with your own definition in your gfxconf.h file. See the gdisp_lld.c
* @note The number of entries must match @p GDISP_TOTAL_CONTROLLERS. * in each driver (near the top) to get the name of the VMT for a driver.
* @note See the gdisp_lld.c in each driver (near the top) to get the name of the VMT for a driver. * @note The same driver can occur more than once in the list to create an extra instance of that driver.
* @note Replace this example with your own definition in your gfxconf.h file. * @note If defining this you must also define GDISP_PIXELFORMAT for your application to use.
* Choose a value that is most common accross all your drivers for efficiency.
* @note If using this you may optionally define the GDISP_HARDWARE_xxx values as either TRUE or FALSE.
* Doing this causes GDISP to assume that all (TRUE) or none (FALSE) of the listed drivers have that
* capability. This can help improve drawing speed and efficiency.
*/ */
#define GDISP_CONTROLLER_LIST GDISPVMT_Win32, GDISPVMT_SSD1963 #define GDISP_DRIVER_LIST GDISPVMT_Win32, GDISPVMT_SSD1963
/**
* @brief The number of displays for each controller.
* @note This is required if @p GDISP_TOTAL_CONTROLLERS is greater than one.
* @note The number of entries must match @p GDISP_TOTAL_CONTROLLERS.
* @note The sum of all the display counts must equal @p GDISP_TOTAL_DISPLAYS (3 for this example)
* or bad things will happen.
* @note Replace this example with your own definition in your gfxconf.h file.
*/
#define GDISP_CONTROLLER_DISPLAYS 2, 1
#endif #endif
/** /**
* @} * @}

View File

@ -24,15 +24,12 @@
#undef GFX_USE_GDRIVER #undef GFX_USE_GDRIVER
#define GFX_USE_GDRIVER TRUE #define GFX_USE_GDRIVER TRUE
#endif #endif
#if GDISP_TOTAL_CONTROLLERS > 1 #if defined(GDISP_DRIVER_LIST)
#ifndef GDISP_CONTROLLER_LIST #if GDISP_TOTAL_DISPLAYS != 1
#error "GDISP Multiple Controllers: You must specify a value for GDISP_CONTROLLER_LIST" #error "GDISP Multiple Drivers: You can't specify both GDISP_TOTAL_DISPLAYS and GDISP_DRIVER_LIST
#endif #endif
#ifndef GDISP_CONTROLLER_DISPLAYS
#error "GDISP Multiple Controllers: You must specify a value for GDISP_CONTROLLER_DISPLAYS"
#endif
#ifndef GDISP_PIXELFORMAT #ifndef GDISP_PIXELFORMAT
#error "GDISP Multiple Controllers: You must specify a value for GDISP_PIXELFORMAT" #error "GDISP Multiple Drivers: You must specify a value for GDISP_PIXELFORMAT when using GDISP_DRIVER_LIST"
#endif #endif
#endif #endif
#if GDISP_NEED_AUTOFLUSH && GDISP_NEED_TIMERFLUSH #if GDISP_NEED_AUTOFLUSH && GDISP_NEED_TIMERFLUSH