2013-05-24 15:26:52 +00:00
|
|
|
/*
|
2013-06-15 11:09:02 +00:00
|
|
|
* 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:
|
|
|
|
*
|
2018-10-01 15:32:39 +00:00
|
|
|
* http://ugfx.io/license.html
|
2013-06-15 11:09:02 +00:00
|
|
|
*/
|
2013-05-24 15:26:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @file src/gfx.c
|
|
|
|
* @brief GFX common routines.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Display various warnings from gfx_rules.h */
|
2018-02-27 07:44:21 +00:00
|
|
|
#define GFX_DISPLAY_RULE_WARNINGS GFXON
|
2013-05-24 15:26:52 +00:00
|
|
|
|
2015-11-21 09:27:08 +00:00
|
|
|
#include "../gfx.h"
|
2013-05-24 15:26:52 +00:00
|
|
|
|
2018-06-23 03:02:07 +00:00
|
|
|
static gBool gfxInitDone = gFalse;
|
2014-02-03 08:00:46 +00:00
|
|
|
|
2013-05-24 15:26:52 +00:00
|
|
|
/* These init functions are defined by each module but not published */
|
|
|
|
extern void _gosInit(void);
|
2017-03-04 05:02:55 +00:00
|
|
|
extern void _gosPostInit(void);
|
2014-02-02 18:24:43 +00:00
|
|
|
extern void _gosDeinit(void);
|
2015-11-05 07:07:23 +00:00
|
|
|
#ifdef GFX_OS_PRE_INIT_FUNCTION
|
|
|
|
extern void GFX_OS_PRE_INIT_FUNCTION(void);
|
|
|
|
#endif
|
2015-02-28 03:06:15 +00:00
|
|
|
#ifdef GFX_OS_EXTRA_INIT_FUNCTION
|
|
|
|
extern void GFX_OS_EXTRA_INIT_FUNCTION(void);
|
|
|
|
#endif
|
|
|
|
#ifdef GFX_OS_EXTRA_DEINIT_FUNCTION
|
|
|
|
extern void GFX_OS_EXTRA_DEINIT_FUNCTION(void);
|
|
|
|
#endif
|
2014-08-23 07:55:42 +00:00
|
|
|
#if GFX_USE_GDRIVER
|
|
|
|
extern void _gdriverInit(void);
|
|
|
|
extern void _gdriverDeinit(void);
|
|
|
|
#endif
|
2015-02-28 03:06:15 +00:00
|
|
|
#if GFX_USE_GFILE
|
|
|
|
extern void _gfileInit(void);
|
|
|
|
extern void _gfileDeinit(void);
|
|
|
|
#endif
|
2013-06-07 16:27:59 +00:00
|
|
|
#if GFX_USE_GDISP
|
2013-05-24 15:26:52 +00:00
|
|
|
extern void _gdispInit(void);
|
2014-02-02 18:24:43 +00:00
|
|
|
extern void _gdispDeinit(void);
|
2013-05-24 15:26:52 +00:00
|
|
|
#endif
|
|
|
|
#if GFX_USE_GWIN
|
|
|
|
extern void _gwinInit(void);
|
2014-02-02 18:24:43 +00:00
|
|
|
extern void _gwinDeinit(void);
|
2013-05-24 15:26:52 +00:00
|
|
|
#endif
|
|
|
|
#if GFX_USE_GEVENT
|
|
|
|
extern void _geventInit(void);
|
2014-02-02 18:24:43 +00:00
|
|
|
extern void _geventDeinit(void);
|
2013-05-24 15:26:52 +00:00
|
|
|
#endif
|
|
|
|
#if GFX_USE_GTIMER
|
|
|
|
extern void _gtimerInit(void);
|
2014-02-02 18:24:43 +00:00
|
|
|
extern void _gtimerDeinit(void);
|
2013-05-24 15:26:52 +00:00
|
|
|
#endif
|
|
|
|
#if GFX_USE_GINPUT
|
|
|
|
extern void _ginputInit(void);
|
2014-02-02 18:24:43 +00:00
|
|
|
extern void _ginputDeinit(void);
|
2013-05-24 15:26:52 +00:00
|
|
|
#endif
|
|
|
|
#if GFX_USE_GADC
|
|
|
|
extern void _gadcInit(void);
|
2014-02-02 18:24:43 +00:00
|
|
|
extern void _gadcDeinit(void);
|
2013-05-24 15:26:52 +00:00
|
|
|
#endif
|
2014-03-11 07:13:31 +00:00
|
|
|
#if GFX_USE_GAUDIO
|
|
|
|
extern void _gaudioInit(void);
|
|
|
|
extern void _gaudioDeinit(void);
|
2013-05-24 15:26:52 +00:00
|
|
|
#endif
|
2014-03-20 13:33:32 +00:00
|
|
|
#if GFX_USE_GQUEUE
|
|
|
|
extern void _gqueueInit(void);
|
|
|
|
extern void _gqueueDeinit(void);
|
|
|
|
#endif
|
2013-05-24 15:26:52 +00:00
|
|
|
#if GFX_USE_GMISC
|
|
|
|
extern void _gmiscInit(void);
|
2014-02-02 18:24:43 +00:00
|
|
|
extern void _gmiscDeinit(void);
|
2013-05-24 15:26:52 +00:00
|
|
|
#endif
|
2016-02-07 20:57:03 +00:00
|
|
|
#if GFX_USE_GTRANS
|
|
|
|
extern void _gtransInit(void);
|
|
|
|
extern void _gtransDeinit(void);
|
|
|
|
#endif
|
2013-05-24 15:26:52 +00:00
|
|
|
|
2014-02-02 18:24:43 +00:00
|
|
|
void gfxInit(void)
|
|
|
|
{
|
2014-02-03 08:00:46 +00:00
|
|
|
/* Ensure we only initialise once */
|
2015-06-08 04:14:40 +00:00
|
|
|
if (gfxInitDone)
|
2014-02-03 08:00:46 +00:00
|
|
|
return;
|
2018-06-23 03:02:07 +00:00
|
|
|
gfxInitDone = gTrue;
|
2014-02-03 08:00:46 +00:00
|
|
|
|
2014-02-02 18:24:43 +00:00
|
|
|
// These must be initialised in the order of their dependancies
|
2013-05-24 15:26:52 +00:00
|
|
|
|
2015-11-05 07:07:23 +00:00
|
|
|
#ifdef GFX_OS_PRE_INIT_FUNCTION
|
|
|
|
GFX_OS_PRE_INIT_FUNCTION();
|
|
|
|
#endif
|
2013-05-24 15:26:52 +00:00
|
|
|
_gosInit();
|
2015-02-28 03:06:15 +00:00
|
|
|
#ifdef GFX_OS_EXTRA_INIT_FUNCTION
|
|
|
|
GFX_OS_EXTRA_INIT_FUNCTION();
|
|
|
|
#endif
|
2014-03-20 13:33:32 +00:00
|
|
|
#if GFX_USE_GQUEUE
|
|
|
|
_gqueueInit();
|
|
|
|
#endif
|
2013-05-24 15:26:52 +00:00
|
|
|
#if GFX_USE_GMISC
|
|
|
|
_gmiscInit();
|
|
|
|
#endif
|
2016-02-07 20:57:03 +00:00
|
|
|
#if GFX_USE_GTRANS
|
|
|
|
_gtransInit();
|
|
|
|
#endif
|
2013-05-24 15:26:52 +00:00
|
|
|
#if GFX_USE_GEVENT
|
|
|
|
_geventInit();
|
|
|
|
#endif
|
|
|
|
#if GFX_USE_GTIMER
|
|
|
|
_gtimerInit();
|
|
|
|
#endif
|
2014-08-23 07:55:42 +00:00
|
|
|
#if GFX_USE_GDRIVER
|
|
|
|
_gdriverInit();
|
|
|
|
#endif
|
2015-02-28 03:06:15 +00:00
|
|
|
#if GFX_USE_GFILE
|
|
|
|
_gfileInit();
|
|
|
|
#endif
|
2013-05-24 15:26:52 +00:00
|
|
|
#if GFX_USE_GDISP
|
|
|
|
_gdispInit();
|
|
|
|
#endif
|
|
|
|
#if GFX_USE_GINPUT
|
|
|
|
_ginputInit();
|
|
|
|
#endif
|
|
|
|
#if GFX_USE_GADC
|
|
|
|
_gadcInit();
|
|
|
|
#endif
|
2014-03-11 07:13:31 +00:00
|
|
|
#if GFX_USE_GAUDIO
|
|
|
|
_gaudioInit();
|
2013-05-24 15:26:52 +00:00
|
|
|
#endif
|
2014-09-26 06:28:26 +00:00
|
|
|
#if GFX_USE_GWIN
|
|
|
|
_gwinInit();
|
|
|
|
#endif
|
2017-03-04 05:02:55 +00:00
|
|
|
_gosPostInit();
|
|
|
|
#if GFX_OS_CALL_UGFXMAIN
|
|
|
|
uGFXMain(0);
|
|
|
|
#endif
|
2013-05-24 15:26:52 +00:00
|
|
|
}
|
2014-02-02 18:24:43 +00:00
|
|
|
|
|
|
|
void gfxDeinit(void)
|
|
|
|
{
|
2015-06-08 04:14:40 +00:00
|
|
|
if (!gfxInitDone)
|
2014-02-03 08:00:46 +00:00
|
|
|
return;
|
2018-06-23 03:02:07 +00:00
|
|
|
gfxInitDone = gFalse;
|
2014-02-02 18:24:43 +00:00
|
|
|
|
2014-02-03 08:00:46 +00:00
|
|
|
// We deinitialise the opposite way as we initialised
|
2014-09-26 06:28:26 +00:00
|
|
|
#if GFX_USE_GWIN
|
|
|
|
_gwinDeinit();
|
|
|
|
#endif
|
2016-02-24 21:20:36 +00:00
|
|
|
#if GFX_USE_GAUDIO
|
2014-03-11 07:13:31 +00:00
|
|
|
_gaudioDeinit();
|
2014-02-02 18:24:43 +00:00
|
|
|
#endif
|
|
|
|
#if GFX_USE_GADC
|
|
|
|
_gadcDeinit();
|
|
|
|
#endif
|
|
|
|
#if GFX_USE_GINPUT
|
|
|
|
_ginputDeinit();
|
|
|
|
#endif
|
|
|
|
#if GFX_USE_GDISP
|
|
|
|
_gdispDeinit();
|
|
|
|
#endif
|
2015-02-28 03:06:15 +00:00
|
|
|
#if GFX_USE_GFILE
|
|
|
|
_gfileDeinit();
|
|
|
|
#endif
|
2014-08-23 07:55:42 +00:00
|
|
|
#if GFX_USE_GDRIVER
|
|
|
|
_gdriverDeinit();
|
|
|
|
#endif
|
2014-02-02 18:24:43 +00:00
|
|
|
#if GFX_USE_GTIMER
|
|
|
|
_gtimerDeinit();
|
|
|
|
#endif
|
|
|
|
#if GFX_USE_GEVENT
|
|
|
|
_geventDeinit();
|
|
|
|
#endif
|
2016-02-07 20:57:03 +00:00
|
|
|
#if GFX_USE_GTRANS
|
|
|
|
_gtransDeinit();
|
|
|
|
#endif
|
2014-02-02 18:24:43 +00:00
|
|
|
#if GFX_USE_GMISC
|
2014-03-20 13:33:32 +00:00
|
|
|
_gmiscDeinit();
|
|
|
|
#endif
|
|
|
|
#if GFX_USE_GQUEUE
|
|
|
|
_gqueueDeinit();
|
2014-02-02 18:24:43 +00:00
|
|
|
#endif
|
2015-02-28 03:06:15 +00:00
|
|
|
#ifdef GFX_OS_EXTRA_DEINIT_FUNCTION
|
|
|
|
GFX_OS_EXTRA_DEINIT_FUNCTION();
|
|
|
|
#endif
|
2014-02-02 18:24:43 +00:00
|
|
|
_gosDeinit();
|
|
|
|
}
|