aboutsummaryrefslogtreecommitdiffstats
path: root/src/gfx.c
blob: 00d4e563bad2d81f4ed19a26ababae50fbb16f3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
pre { line-height: 125%; margin: 0; }
td.linenos pre { color: #000000; background-color: #f0f0f0; padding: 0 5px 0 5px; }
span.linenos { color: #000000; background-color: #f0f0f0; padding: 0 5px 0 5px; }
td.linenos pre.special { color: #000000; background-color: #ffffc0; padding: 0 5px 0 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding: 0 5px 0 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight { background: #ffffff; }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt {
/*
 * 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    src/gfx.c
 * @brief   GFX common routines.
 */

/* Display various warnings from gfx_rules.h */
#define GFX_DISPLAY_RULE_WARNINGS	TRUE

#include "../gfx.h"

static bool_t gfxInitDone = FALSE;

/* These init functions are defined by each module but not published */
extern void _gosInit(void);
extern void _gosDeinit(void);
#ifdef GFX_OS_PRE_INIT_FUNCTION
		extern void GFX_OS_PRE_INIT_FUNCTION(void);
#endif
#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
#if GFX_USE_GDRIVER
	extern void _gdriverInit(void);
	extern void _gdriverDeinit(void);
#endif
#if GFX_USE_GFILE
	extern void _gfileInit(void);
	extern void _gfileDeinit(void);
#endif
#if GFX_USE_GDISP
	extern void _gdispInit(void);
	extern void _gdispDeinit(void);
#endif
#if GFX_USE_GWIN
	extern void _gwinInit(void);
	extern void _gwinDeinit(void);
#endif
#if GFX_USE_GEVENT
	extern void _geventInit(void);
	extern void _geventDeinit(void);
#endif
#if GFX_USE_GTIMER
	extern void _gtimerInit(void);
	extern void _gtimerDeinit(void);
#endif
#if GFX_USE_GINPUT
	extern void _ginputInit(void);
	extern void _ginputDeinit(void);
#endif
#if GFX_USE_GADC
	extern void _gadcInit(void);
	extern void _gadcDeinit(void);
#endif
#if GFX_USE_GAUDIO
	extern void _gaudioInit(void);
	extern void _gaudioDeinit(void);
#endif
#if GFX_USE_GQUEUE
	extern void _gqueueInit(void);
	extern void _gqueueDeinit(void);
#endif
#if GFX_USE_GMISC
	extern void _gmiscInit(void);
	extern void _gmiscDeinit(void);
#endif
#if GFX_USE_GTRANS
	extern void _gtransInit(void);
	extern void _gtransDeinit(void);
#endif

void gfxInit(void)
{
	/* Ensure we only initialise once */
	if (gfxInitDone)
		return;
	gfxInitDone = TRUE;

	// These must be initialised in the order of their dependancies

	#ifdef GFX_OS_PRE_INIT_FUNCTION
		GFX_OS_PRE_INIT_FUNCTION();
	#endif
	_gosInit();
	#ifdef GFX_OS_EXTRA_INIT_FUNCTION
		GFX_OS_EXTRA_INIT_FUNCTION();
	#endif
	#if GFX_USE_GQUEUE
		_gqueueInit();
	#endif
	#if GFX_USE_GMISC
		_gmiscInit();
	#endif
	#if GFX_USE_GTRANS
		_gtransInit();
	#endif
	#if GFX_USE_GEVENT
		_geventInit();
	#endif
	#if GFX_USE_GTIMER
		_gtimerInit();
	#endif
	#if GFX_USE_GDRIVER
		_gdriverInit();
	#endif
	#if GFX_USE_GFILE
		_gfileInit();
	#endif
	#if GFX_USE_GDISP
		_gdispInit();
	#endif
	#if GFX_USE_GINPUT
		_ginputInit();
	#endif
	#if GFX_USE_GADC
		_gadcInit();
	#endif
	#if GFX_USE_GAUDIO
		_gaudioInit();
	#endif
	#if GFX_USE_GWIN
		_gwinInit();
	#endif
}

void gfxDeinit(void)
{
	if (!gfxInitDone)
		return;
	gfxInitDone = FALSE;

	// We deinitialise the opposite way as we initialised
	#if GFX_USE_GWIN
		_gwinDeinit();
	#endif
	#if GFX_USE_GAUDIO
		_gaudioDeinit();
	#endif
	#if GFX_USE_GADC
		_gadcDeinit();
	#endif
	#if GFX_USE_GINPUT
		_ginputDeinit();
	#endif
	#if GFX_USE_GDISP
		_gdispDeinit();
	#endif
	#if GFX_USE_GFILE
		_gfileDeinit();
	#endif
	#if GFX_USE_GDRIVER
		_gdriverDeinit();
	#endif
	#if GFX_USE_GTIMER
		_gtimerDeinit();
	#endif
	#if GFX_USE_GEVENT
		_geventDeinit();
	#endif
	#if GFX_USE_GTRANS
		_gtransDeinit();
	#endif
	#if GFX_USE_GMISC
		_gmiscDeinit();
	#endif
	#if GFX_USE_GQUEUE
		_gqueueDeinit();
	#endif
	#ifdef GFX_OS_EXTRA_DEINIT_FUNCTION
		GFX_OS_EXTRA_DEINIT_FUNCTION();
	#endif
	_gosDeinit();
}