Merge branch 'master' into freertos
This commit is contained in:
commit
f26581dc7e
29 changed files with 272 additions and 184 deletions
4
demos/3rdparty/doom/i_system.c
vendored
4
demos/3rdparty/doom/i_system.c
vendored
|
@ -66,7 +66,7 @@ int I_GetHeapSize (void)
|
|||
byte* I_ZoneBase (int* size)
|
||||
{
|
||||
*size = mb_used*1024*1024;
|
||||
return (byte *) gfxAlloc (*size);
|
||||
return gfxAlloc (*size);
|
||||
}
|
||||
|
||||
|
||||
|
@ -124,7 +124,7 @@ byte* I_Malloc(int length)
|
|||
{
|
||||
byte* mem;
|
||||
|
||||
mem = (byte *)gfxAlloc (length);
|
||||
mem = gfxAlloc (length);
|
||||
memset (mem,0,length);
|
||||
return mem;
|
||||
}
|
||||
|
|
|
@ -70,9 +70,9 @@ GHandle gwinGScopeCreate(GDisplay *g, GScopeObject *gs, GWindowInit *pInit, uint
|
|||
return 0;
|
||||
gfxSemInit(&gs->bsem, 0, 1);
|
||||
gs->nextx = 0;
|
||||
if (!(gs->lastscopetrace = (coord_t *)gfxAlloc(gs->g.width * sizeof(coord_t))))
|
||||
if (!(gs->lastscopetrace = gfxAlloc(gs->g.width * sizeof(coord_t))))
|
||||
return 0;
|
||||
if (!(gs->audiobuf = (adcsample_t *)gfxAlloc(AUDIOBUFSZ * sizeof(adcsample_t))))
|
||||
if (!(gs->audiobuf = gfxAlloc(AUDIOBUFSZ * sizeof(adcsample_t))))
|
||||
return 0;
|
||||
#if TRIGGER_METHOD == TRIGGER_POSITIVERAMP
|
||||
gs->lasty = gs->g.height/2;
|
||||
|
|
|
@ -28,161 +28,45 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
#define GFX_USE_GDISP TRUE
|
||||
|
||||
#define GDISP_NEED_AUTOFLUSH FALSE
|
||||
#define GDISP_NEED_TIMERFLUSH FALSE
|
||||
#define GDISP_NEED_VALIDATION TRUE
|
||||
#define GDISP_NEED_CLIP TRUE
|
||||
#define GDISP_NEED_CIRCLE FALSE
|
||||
#define GDISP_NEED_ELLIPSE FALSE
|
||||
#define GDISP_NEED_ARC FALSE
|
||||
#define GDISP_NEED_CONVEX_POLYGON TRUE
|
||||
#define GDISP_NEED_SCROLL FALSE
|
||||
#define GDISP_NEED_PIXELREAD FALSE
|
||||
#define GDISP_NEED_CONTROL FALSE
|
||||
#define GDISP_NEED_QUERY FALSE
|
||||
#define GDISP_NEED_MULTITHREAD FALSE
|
||||
#define GDISP_NEED_STREAMING FALSE
|
||||
#define GDISP_NEED_TEXT TRUE
|
||||
#define GDISP_NEED_ANTIALIAS FALSE
|
||||
#define GDISP_NEED_UTF8 FALSE
|
||||
#define GDISP_NEED_TEXT_KERNING FALSE
|
||||
#define GDISP_INCLUDE_FONT_UI1 FALSE
|
||||
#define GDISP_INCLUDE_FONT_UI2 FALSE
|
||||
#define GDISP_INCLUDE_FONT_LARGENUMBERS FALSE
|
||||
#define GDISP_INCLUDE_FONT_DEJAVUSANS10 FALSE
|
||||
#define GDISP_INCLUDE_FONT_DEJAVUSANS12 FALSE
|
||||
#define GDISP_INCLUDE_FONT_DEJAVUSANS16 FALSE
|
||||
#define GDISP_INCLUDE_FONT_DEJAVUSANS24 FALSE
|
||||
#define GDISP_INCLUDE_FONT_DEJAVUSANS32 FALSE
|
||||
#define GDISP_INCLUDE_FONT_DEJAVUSANSBOLD12 FALSE
|
||||
#define GDISP_INCLUDE_FONT_FIXED_10x20 FALSE
|
||||
#define GDISP_INCLUDE_FONT_FIXED_7x14 FALSE
|
||||
#define GDISP_INCLUDE_FONT_FIXED_5x8 FALSE
|
||||
#define GDISP_INCLUDE_FONT_DEJAVUSANS12_AA TRUE
|
||||
#define GDISP_INCLUDE_FONT_DEJAVUSANS16_AA FALSE
|
||||
#define GDISP_INCLUDE_FONT_DEJAVUSANS24_AA FALSE
|
||||
#define GDISP_INCLUDE_FONT_DEJAVUSANS32_AA FALSE
|
||||
#define GDISP_INCLUDE_FONT_DEJAVUSANSBOLD12_AA FALSE
|
||||
#define GDISP_INCLUDE_USER_FONTS FALSE
|
||||
|
||||
#define GDISP_INCLUDE_FONT_UI2 TRUE
|
||||
#define GDISP_NEED_IMAGE TRUE
|
||||
#define GDISP_NEED_IMAGE_NATIVE FALSE
|
||||
#define GDISP_NEED_IMAGE_GIF TRUE
|
||||
#define GDISP_NEED_IMAGE_BMP FALSE
|
||||
#define GDISP_NEED_IMAGE_BMP_1 FALSE
|
||||
#define GDISP_NEED_IMAGE_BMP_4 FALSE
|
||||
#define GDISP_NEED_IMAGE_BMP_4_RLE FALSE
|
||||
#define GDISP_NEED_IMAGE_BMP_8 FALSE
|
||||
#define GDISP_NEED_IMAGE_BMP_8_RLE FALSE
|
||||
#define GDISP_NEED_IMAGE_BMP_16 FALSE
|
||||
#define GDISP_NEED_IMAGE_BMP_24 FALSE
|
||||
#define GDISP_NEED_IMAGE_BMP_32 FALSE
|
||||
#define GDISP_NEED_IMAGE_JPG FALSE
|
||||
#define GDISP_NEED_IMAGE_PNG FALSE
|
||||
#define GDISP_NEED_IMAGE_ACCOUNTING FALSE
|
||||
|
||||
#define GDISP_NEED_STARTUP_LOGO FALSE
|
||||
|
||||
#define GDISP_DEFAULT_ORIENTATION GDISP_ROTATE_LANDSCAPE
|
||||
#define GDISP_LINEBUF_SIZE 128
|
||||
|
||||
#define GDISP_TOTAL_DISPLAYS 1
|
||||
#if GDISP_TOTAL_DISPLAYS > 1
|
||||
#define GDISP_HARDWARE_STREAM_WRITE FALSE
|
||||
#define GDISP_HARDWARE_STREAM_READ FALSE
|
||||
#define GDISP_HARDWARE_STREAM_POS FALSE
|
||||
#define GDISP_HARDWARE_DRAWPIXEL FALSE
|
||||
#define GDISP_HARDWARE_CLEARS FALSE
|
||||
#define GDISP_HARDWARE_FILLS FALSE
|
||||
#define GDISP_HARDWARE_BITFILLS 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
|
||||
#endif
|
||||
|
||||
#define GDISP_TOTAL_CONTROLLERS 1
|
||||
#if GDISP_TOTAL_CONTROLLERS > 1
|
||||
#define GDISP_CONTROLLER_LIST GDISPVMT_Win32, GDISPVMT_Win32
|
||||
#define GDISP_CONTROLLER_DISPLAYS 1, 1
|
||||
#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB888
|
||||
#endif
|
||||
|
||||
#define GDISP_USE_GFXNET FALSE
|
||||
#define GDISP_GFXNET_PORT 13001
|
||||
#define GDISP_GFXNET_CUSTOM_LWIP_STARTUP FALSE
|
||||
#define GDISP_DONT_WAIT_FOR_NET_DISPLAY FALSE
|
||||
#define GDISP_GFXNET_UNSAFE_SOCKETS FALSE
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// GWIN //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
#define GFX_USE_GWIN TRUE
|
||||
|
||||
#define GWIN_NEED_WINDOWMANAGER FALSE
|
||||
|
||||
#define GWIN_NEED_CONSOLE FALSE
|
||||
#define GWIN_CONSOLE_USE_HISTORY FALSE
|
||||
#define GWIN_CONSOLE_HISTORY_AVERAGING FALSE
|
||||
#define GWIN_CONSOLE_HISTORY_ATCREATE FALSE
|
||||
#define GWIN_CONSOLE_USE_BASESTREAM FALSE
|
||||
#define GWIN_CONSOLE_USE_FLOAT FALSE
|
||||
#define GWIN_NEED_GRAPH FALSE
|
||||
|
||||
#define GWIN_NEED_WINDOWMANAGER TRUE
|
||||
#define GWIN_NEED_WIDGET TRUE
|
||||
#define GWIN_NEED_LABEL TRUE
|
||||
#define GWIN_NEED_BUTTON FALSE
|
||||
#define GWIN_BUTTON_LAZY_RELEASE FALSE
|
||||
#define GWIN_NEED_SLIDER FALSE
|
||||
#define GWIN_NEED_CHECKBOX FALSE
|
||||
#define GWIN_NEED_IMAGE FALSE
|
||||
#define GWIN_NEED_IMAGE_ANIMATION FALSE
|
||||
#define GWIN_NEED_RADIO FALSE
|
||||
#define GWIN_NEED_LIST TRUE
|
||||
#define GWIN_NEED_LIST_IMAGES TRUE
|
||||
#define GWIN_NEED_PROGRESSBAR FALSE
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// GEVENT //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
#define GFX_USE_GEVENT FALSE
|
||||
|
||||
#define GEVENT_ASSERT_NO_RESOURCE FALSE
|
||||
#define GEVENT_MAXIMUM_SIZE 32
|
||||
#define GEVENT_MAX_SOURCE_LISTENERS 32
|
||||
|
||||
#define GFX_USE_GEVENT TRUE
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// GTIMER //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
#define GFX_USE_GTIMER FALSE
|
||||
|
||||
#define GTIMER_THREAD_PRIORITY HIGH_PRIORITY
|
||||
#define GTIMER_THREAD_WORKAREA_SIZE 2048
|
||||
|
||||
#define GFX_USE_GTIMER TRUE
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// GQUEUE //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
#define GFX_USE_GQUEUE FALSE
|
||||
|
||||
#define GQUEUE_NEED_ASYNC FALSE
|
||||
#define GQUEUE_NEED_GSYNC FALSE
|
||||
#define GQUEUE_NEED_FSYNC FALSE
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// GINPUT //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
#define GFX_USE_GINPUT TRUE
|
||||
|
||||
#define GINPUT_NEED_MOUSE TRUE
|
||||
#define GINPUT_NEED_KEYBOARD FALSE
|
||||
#define GINPUT_NEED_TOGGLE FALSE
|
||||
#define GINPUT_NEED_DIAL FALSE
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
@ -190,33 +74,20 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
#define GFX_USE_GADC FALSE
|
||||
|
||||
#define GADC_MAX_LOWSPEED_DEVICES 4
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// GAUDIN //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
#define GFX_USE_GAUDIN FALSE
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// GAUDOUT //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
#define GFX_USE_GAUDOUT FALSE
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// GMISC //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
#define GFX_USE_GMISC FALSE
|
||||
|
||||
#define GMISC_NEED_ARRAYOPS FALSE
|
||||
#define GMISC_NEED_FASTTRIG FALSE
|
||||
#define GMISC_NEED_FIXEDTRIG FALSE
|
||||
#define GMISC_NEED_INVSQRT FALSE
|
||||
#define GMISC_INVSQRT_MIXED_ENDIAN FALSE
|
||||
#define GMISC_INVSQRT_REAL_SLOW FALSE
|
||||
|
||||
|
||||
#endif /* _GFXCONF_H */
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ int main(void) {
|
|||
gfxInit();
|
||||
|
||||
// Set the widget defaults
|
||||
gwinSetDefaultFont(gdispOpenFont("DejaVuSans12_AA"));
|
||||
gwinSetDefaultFont(gdispOpenFont("UI2"));
|
||||
gwinSetDefaultStyle(&WhiteWidgetStyle, FALSE);
|
||||
gdispClear(White);
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@ void gaudin_lld_init(const gaudin_params *paud) {
|
|||
|
||||
/* We need to allocate a wave header for each buffer */
|
||||
nBuffers = (paud->bufcount + paud->samplesPerEvent - 1) / paud->samplesPerEvent;
|
||||
if (!(pWaveHdrs = (WAVEHDR *)gfxAlloc(nBuffers * sizeof(WAVEHDR)))) {
|
||||
if (!(pWaveHdrs = gfxAlloc(nBuffers * sizeof(WAVEHDR)))) {
|
||||
fprintf(stderr, "GAUDIN: Buffer header allocation failed\n");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -458,7 +458,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
|
|||
#endif
|
||||
|
||||
// Create a private area for this window
|
||||
priv = (winPriv *)gfxAlloc(sizeof(winPriv));
|
||||
priv = gfxAlloc(sizeof(winPriv));
|
||||
assert(priv != 0);
|
||||
memset(priv, 0, sizeof(winPriv));
|
||||
g->priv = priv;
|
||||
|
|
|
@ -433,7 +433,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
|
|||
#endif
|
||||
|
||||
// Create a private area for this window
|
||||
if (!(priv = (netPriv *)gfxAlloc(sizeof(netPriv))))
|
||||
if (!(priv = gfxAlloc(sizeof(netPriv))))
|
||||
gfxHalt("GDISP: uGFXnet - Memory allocation failed");
|
||||
memset(priv, 0, sizeof(netPriv));
|
||||
g->priv = priv;
|
||||
|
|
|
@ -204,8 +204,15 @@ extern "C" {
|
|||
*/
|
||||
void gfxInit(void);
|
||||
|
||||
/* Compatibility for old programs */
|
||||
void DEPRECATED("Use gfxInit() instead") gdispInit(void);
|
||||
/**
|
||||
* @brief The one call to end it all
|
||||
*
|
||||
* @note This will deinitialise each sub-system that has been turned on.
|
||||
* @note Do not call this without a previous @p gfxInit();
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
void gfxDeinit(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -68,13 +68,22 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
/**
|
||||
* @brief Initialise a timer.
|
||||
* @brief Initialise a timer
|
||||
*
|
||||
* @param[in] pt pointer to a GTimer structure
|
||||
* @param[in] pt Pointer to a GTimer structure
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
void gtimerInit(GTimer *pt);
|
||||
void gtimerInit(GTimer* pt);
|
||||
|
||||
/**
|
||||
* @brief Deinitialise a timer
|
||||
*
|
||||
* @param[in] pt Pointer to a GTimer structure
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
void gtimerDeinit(GTimer* pt);
|
||||
|
||||
/**
|
||||
* @brief Set a timer going or alter its properties if it is already going.
|
||||
|
|
|
@ -12,7 +12,9 @@ FIX: Console does not execute gwinPrintf() anymore if not visible
|
|||
FEATURE: Added gwinGetColor() and gwinGetBgColor()
|
||||
FEATURE: Console does now have an optional buffer (GWIN_CONSOLE_USE_HISTORY)
|
||||
FEATURE: Added smooth scrolling to list widget
|
||||
FEATURE: Increased performance of gwinListAddItem()
|
||||
FEATURE: Added FreeRTOS port
|
||||
FEATURE: Added gfxDeinit()
|
||||
|
||||
|
||||
*** changes after 1.9 ***
|
||||
|
|
|
@ -236,7 +236,8 @@ void GADC_ISR_ErrorI(ADCDriver *adcp, adcerror_t err) {
|
|||
}
|
||||
|
||||
/* Our module initialiser */
|
||||
void _gadcInit(void) {
|
||||
void _gadcInit(void)
|
||||
{
|
||||
gadc_lld_init();
|
||||
gfxSemInit(&gadcsem, GADC_MAX_LOWSPEED_DEVICES, GADC_MAX_LOWSPEED_DEVICES);
|
||||
gfxMutexInit(&gadcmutex);
|
||||
|
@ -246,6 +247,19 @@ void _gadcInit(void) {
|
|||
#endif
|
||||
}
|
||||
|
||||
void _gadcDeinit(void)
|
||||
{
|
||||
/* commented stuff is ToDo */
|
||||
|
||||
// gadc_lld_deinit();
|
||||
gfxSemDestroy(&gadcsem);
|
||||
gfxMutexDestroy(&gadcmutex);
|
||||
gtimerDeinit(&LowSpeedGTimer);
|
||||
#if GFX_USE_GEVENT
|
||||
gtimerDeinit(&HighSpeedGTimer);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void StartADC(bool_t onNoHS) {
|
||||
gfxSystemLock();
|
||||
if (!(gflags & GADC_GFLG_ISACTIVE) || (onNoHS && !curlsdev))
|
||||
|
|
|
@ -85,13 +85,21 @@ void GAUDIN_ISR_ErrorI(void) {
|
|||
/* Ignore any errors for now */
|
||||
}
|
||||
|
||||
/* The module initialiser */
|
||||
void _gaudinInit(void) {
|
||||
void _gaudinInit(void)
|
||||
{
|
||||
#if GFX_USE_GEVENT
|
||||
gtimerInit(&AudGTimer);
|
||||
#endif
|
||||
}
|
||||
|
||||
void _gaudinDeinit(void)
|
||||
{
|
||||
// Commented stuff still ToDo
|
||||
#if GFX_USE_GEVENT
|
||||
gtimerDeinit(&AudGTimer);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool_t gaudinInit(uint16_t channel, uint32_t frequency, audin_sample_t *buffer, size_t bufcount, size_t samplesPerEvent) {
|
||||
/* Check the channel is valid */
|
||||
if (channel >= GAUDIN_NUM_CHANNELS || frequency > GAUDIN_MAX_SAMPLE_FREQUENCY)
|
||||
|
|
|
@ -18,6 +18,16 @@
|
|||
|
||||
#error "GAUDOUT: Not implemented yet"
|
||||
|
||||
void _gaudoutInit(void)
|
||||
{
|
||||
/* ToDo */
|
||||
}
|
||||
|
||||
void _gaudoutDeinit(void)
|
||||
{
|
||||
/* ToDo */
|
||||
}
|
||||
|
||||
#endif /* GFX_USE_GAUDOUT */
|
||||
/** @} */
|
||||
|
||||
|
|
|
@ -566,8 +566,8 @@ static void line_clip(GDisplay *g) {
|
|||
/* Driver exported functions. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/* Our module initialiser */
|
||||
void _gdispInit(void) {
|
||||
void _gdispInit(void)
|
||||
{
|
||||
GDisplay *g;
|
||||
uint16_t i;
|
||||
|
||||
|
@ -627,6 +627,11 @@ void _gdispInit(void) {
|
|||
#endif
|
||||
}
|
||||
|
||||
void _gdispDeinit(void)
|
||||
{
|
||||
/* ToDo */
|
||||
}
|
||||
|
||||
GDisplay *gdispGetDisplay(unsigned display) {
|
||||
if (display >= GDISP_TOTAL_DISPLAYS)
|
||||
return 0;
|
||||
|
@ -2764,8 +2769,14 @@ void gdispGDrawBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, co
|
|||
#if GDISP_NEED_ANTIALIAS && GDISP_HARDWARE_PIXELREAD
|
||||
static void drawcharline(int16_t x, int16_t y, uint8_t count, uint8_t alpha, void *state) {
|
||||
#define GD ((GDisplay *)state)
|
||||
if (y < GD->t.clipy0 || y >= GD->t.clipy1)
|
||||
if (y < GD->t.clipy0 || y >= GD->t.clipy1 || x+count <= GD->t.clipx0 || x >= GD->t.clipx1)
|
||||
return;
|
||||
if (x < GD->t.clipx0) {
|
||||
count -= GD->t.clipx0 - x;
|
||||
x = GD->t.clipx0;
|
||||
}
|
||||
if (x+count > GD->t.clipx1)
|
||||
count = GD->t.clipx1 - x;
|
||||
if (alpha == 255) {
|
||||
GD->p.x = x; GD->p.y = y; GD->p.x1 = x+count-1; GD->p.color = GD->t.color;
|
||||
hline_clip(GD);
|
||||
|
@ -2781,8 +2792,14 @@ void gdispGDrawBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, co
|
|||
#else
|
||||
static void drawcharline(int16_t x, int16_t y, uint8_t count, uint8_t alpha, void *state) {
|
||||
#define GD ((GDisplay *)state)
|
||||
if (y < GD->t.clipy0 || y >= GD->t.clipy1)
|
||||
if (y < GD->t.clipy0 || y >= GD->t.clipy1 || x+count <= GD->t.clipx0 || x >= GD->t.clipx1)
|
||||
return;
|
||||
if (x < GD->t.clipx0) {
|
||||
count -= GD->t.clipx0 - x;
|
||||
x = GD->t.clipx0;
|
||||
}
|
||||
if (x+count > GD->t.clipx1)
|
||||
count = GD->t.clipx1 - x;
|
||||
if (alpha > 0x80) { // A best approximation when using anti-aliased fonts but we can't actually draw them anti-aliased
|
||||
GD->p.x = x; GD->p.y = y; GD->p.x1 = x+count-1; GD->p.color = GD->t.color;
|
||||
hline_clip(GD);
|
||||
|
@ -2794,8 +2811,14 @@ void gdispGDrawBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, co
|
|||
#if GDISP_NEED_ANTIALIAS
|
||||
static void fillcharline(int16_t x, int16_t y, uint8_t count, uint8_t alpha, void *state) {
|
||||
#define GD ((GDisplay *)state)
|
||||
if (y < GD->t.clipy0 || y >= GD->t.clipy1)
|
||||
if (y < GD->t.clipy0 || y >= GD->t.clipy1 || x+count <= GD->t.clipx0 || x >= GD->t.clipx1)
|
||||
return;
|
||||
if (x < GD->t.clipx0) {
|
||||
count -= GD->t.clipx0 - x;
|
||||
x = GD->t.clipx0;
|
||||
}
|
||||
if (x+count > GD->t.clipx1)
|
||||
count = GD->t.clipx1 - x;
|
||||
if (alpha == 255) {
|
||||
GD->p.color = GD->t.color;
|
||||
} else {
|
||||
|
|
|
@ -46,10 +46,16 @@ static void deleteAssignments(GListener *pl, GSourceHandle gsh) {
|
|||
}
|
||||
}
|
||||
|
||||
void _geventInit(void) {
|
||||
void _geventInit(void)
|
||||
{
|
||||
gfxMutexInit(&geventMutex);
|
||||
}
|
||||
|
||||
void _geventDeinit(void)
|
||||
{
|
||||
gfxMutexDestroy(&geventMutex);
|
||||
}
|
||||
|
||||
void geventListenerInit(GListener *pl) {
|
||||
gfxSemInit(&pl->waitqueue, 0, MAX_SEMAPHORE_COUNT); // Next wait'er will block
|
||||
gfxSemInit(&pl->eventlock, 1, 1); // Only one thread at a time looking at the event buffer
|
||||
|
|
58
src/gfx.c
58
src/gfx.c
|
@ -15,47 +15,57 @@
|
|||
|
||||
#include "gfx.h"
|
||||
|
||||
void DEPRECATED("Use gfxInit() instead") gdispInit() { gfxInit(); }
|
||||
static bool_t initDone = FALSE;
|
||||
|
||||
/* These init functions are defined by each module but not published */
|
||||
extern void _gosInit(void);
|
||||
extern void _gosDeinit(void);
|
||||
#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_GAUDIN
|
||||
extern void _gaudinInit(void);
|
||||
extern void _gaudinDeinit(void);
|
||||
#endif
|
||||
#if GFX_USE_GAUDOUT
|
||||
extern void _gaudoutInit(void);
|
||||
extern void _gaudoutDeinit(void);
|
||||
#endif
|
||||
#if GFX_USE_GMISC
|
||||
extern void _gmiscInit(void);
|
||||
extern void _gmiscDeinit(void);
|
||||
#endif
|
||||
|
||||
void gfxInit(void) {
|
||||
static bool_t initDone = FALSE;
|
||||
|
||||
void gfxInit(void)
|
||||
{
|
||||
/* Ensure we only initialise once */
|
||||
if (initDone)
|
||||
return;
|
||||
initDone = TRUE;
|
||||
|
||||
/* These must be initialised in the order of their dependancies */
|
||||
// These must be initialised in the order of their dependancies
|
||||
|
||||
_gosInit();
|
||||
#if GFX_USE_GMISC
|
||||
_gmiscInit();
|
||||
|
@ -85,3 +95,41 @@ void gfxInit(void) {
|
|||
_gaudoutInit();
|
||||
#endif
|
||||
}
|
||||
|
||||
void gfxDeinit(void)
|
||||
{
|
||||
if (!initDone)
|
||||
return;
|
||||
initDone = FALSE;
|
||||
|
||||
// We deinitialise the opposite way as we initialised
|
||||
#if GFX_USE_GAUDOUT
|
||||
_gaudoutDeinit();
|
||||
#endif
|
||||
#if GFX_USE_GAUDIN
|
||||
_gaoudinDeinit();
|
||||
#endif
|
||||
#if GFX_USE_GADC
|
||||
_gadcDeinit();
|
||||
#endif
|
||||
#if GFX_USE_GINPUT
|
||||
_ginputDeinit();
|
||||
#endif
|
||||
#if GFX_USE_GWIN
|
||||
_gwinDeinit();
|
||||
#endif
|
||||
#if GFX_USE_GDISP
|
||||
_gdispDeinit();
|
||||
#endif
|
||||
#if GFX_USE_GTIMER
|
||||
_gtimerDeinit();
|
||||
#endif
|
||||
#if GFX_USE_GEVENT
|
||||
_geventDeinit();
|
||||
#endif
|
||||
#if GFX_USE_GMISC
|
||||
_gmiscInit();
|
||||
#endif
|
||||
_gosDeinit();
|
||||
}
|
||||
|
||||
|
|
|
@ -16,11 +16,21 @@
|
|||
|
||||
#if GFX_USE_GINPUT
|
||||
|
||||
/**
|
||||
* This should really call an init routine for each ginput sub-system.
|
||||
* Maybe we'll do this later.
|
||||
*/
|
||||
void _ginputInit(void) {}
|
||||
void _ginputInit(void)
|
||||
{
|
||||
/* ToDo */
|
||||
|
||||
/**
|
||||
* This should really call an init routine for each ginput sub-system.
|
||||
* Maybe we'll do this later.
|
||||
*/
|
||||
}
|
||||
|
||||
void _ginputDeinit(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endif /* GFX_USE_GINPUT */
|
||||
/** @} */
|
||||
|
||||
|
|
|
@ -14,7 +14,14 @@
|
|||
|
||||
#if GFX_USE_GMISC
|
||||
|
||||
void _gmiscInit(void) {
|
||||
void _gmiscInit(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void _gmiscDeinit(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endif /* GFX_USE_GMISC */
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
#error "GOS: CH_USE_SEMAPHORES must be defined in chconf.h"
|
||||
#endif
|
||||
|
||||
/* Our module initialiser */
|
||||
void _gosInit(void) {
|
||||
void _gosInit(void)
|
||||
{
|
||||
/* Don't initialise if the user already has */
|
||||
if (!chThdSelf()) {
|
||||
halInit();
|
||||
|
@ -31,6 +31,11 @@ void _gosInit(void) {
|
|||
}
|
||||
}
|
||||
|
||||
void _gosDeinit(void)
|
||||
{
|
||||
/* ToDo */
|
||||
}
|
||||
|
||||
void *gfxRealloc(void *ptr, size_t oldsz, size_t newsz) {
|
||||
void *np;
|
||||
|
||||
|
|
|
@ -20,10 +20,16 @@
|
|||
|
||||
static gfxMutex SystemMutex;
|
||||
|
||||
void _gosInit(void) {
|
||||
void _gosInit(void)
|
||||
{
|
||||
gfxMutexInit(&SystemMutex);
|
||||
}
|
||||
|
||||
void _gosDeinit(void)
|
||||
{
|
||||
/* ToDo */
|
||||
}
|
||||
|
||||
void gfxSystemLock(void) {
|
||||
gfxMutexEnter(&SystemMutex);
|
||||
}
|
||||
|
|
|
@ -37,10 +37,16 @@ void get_ticks(mach_timespec_t *mts){
|
|||
|
||||
}
|
||||
|
||||
void _gosInit(void) {
|
||||
void _gosInit(void)
|
||||
{
|
||||
gfxMutexInit(&SystemMutex);
|
||||
}
|
||||
|
||||
void _gosDeinit(void)
|
||||
{
|
||||
/* ToDo */
|
||||
}
|
||||
|
||||
void gfxSystemLock(void) {
|
||||
gfxMutexEnter(&SystemMutex);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,8 @@ static void _gosThreadsInit(void);
|
|||
* Initialise
|
||||
*********************************************************/
|
||||
|
||||
void _gosInit(void) {
|
||||
void _gosInit(void)
|
||||
{
|
||||
// Set up the heap allocator
|
||||
_gosHeapInit();
|
||||
|
||||
|
@ -34,6 +35,11 @@ void _gosInit(void) {
|
|||
_gosThreadsInit();
|
||||
}
|
||||
|
||||
void _gosDeinit(void)
|
||||
{
|
||||
/* ToDo */
|
||||
}
|
||||
|
||||
/*********************************************************
|
||||
* For WIn32 emulation - automatically add the tick functions
|
||||
* the user would normally have to provide for bare metal.
|
||||
|
@ -542,7 +548,7 @@ static void _gosThreadsInit(void) {
|
|||
char * framebase;
|
||||
|
||||
// Allocate a buffer to store our test data
|
||||
pframeinfo = (saveloc *)gfxAlloc(sizeof(saveloc)*2);
|
||||
pframeinfo = gfxAlloc(sizeof(saveloc)*2);
|
||||
|
||||
// Get details of the stack frame from within a function
|
||||
get_stack_state_in_fn();
|
||||
|
|
|
@ -17,7 +17,13 @@
|
|||
|
||||
static HANDLE SystemMutex;
|
||||
|
||||
void _gosInit(void) {
|
||||
void _gosInit(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void _gosDeinit(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -118,15 +118,29 @@ static DECLARE_THREAD_FUNCTION(GTimerThreadHandler, arg) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void _gtimerInit(void) {
|
||||
void _gtimerInit(void)
|
||||
{
|
||||
gfxSemInit(&waitsem, 0, 1);
|
||||
gfxMutexInit(&mutex);
|
||||
}
|
||||
|
||||
void gtimerInit(GTimer *pt) {
|
||||
void _gtimerDeinit(void)
|
||||
{
|
||||
gfxSemDestroy(&waitsem);
|
||||
gfxMutexDestroy(&mutex);
|
||||
// Need to destroy GTimer thread here
|
||||
}
|
||||
|
||||
void gtimerInit(GTimer* pt)
|
||||
{
|
||||
pt->flags = 0;
|
||||
}
|
||||
|
||||
void gtimerDeinit(GTimer* pt)
|
||||
{
|
||||
gtimerStop(pt);
|
||||
}
|
||||
|
||||
void gtimerStart(GTimer *pt, GTimerFunction fn, void *param, bool_t periodic, delaytime_t millisec) {
|
||||
gfxMutexEnter(&mutex);
|
||||
|
||||
|
|
|
@ -285,7 +285,7 @@ GHandle gwinGConsoleCreate(GDisplay *g, GConsoleObject *gc, const GWindowInit *p
|
|||
gcw->bufsize *= gh->height / gdispGetFontMetric(gh->font, fontHeight);
|
||||
|
||||
// Allocate the buffer
|
||||
if (!(gcw->buffer = (char*)gfxAlloc(gcw->bufsize)))
|
||||
if (!(gcw->buffer = gfxAlloc(gcw->bufsize)))
|
||||
return FALSE;
|
||||
|
||||
// All good!
|
||||
|
|
|
@ -224,11 +224,17 @@ static void gwidgetEvent(void *param, GEvent *pe) {
|
|||
}
|
||||
#endif
|
||||
|
||||
void _gwidgetInit(void) {
|
||||
void _gwidgetInit(void)
|
||||
{
|
||||
geventListenerInit(&gl);
|
||||
geventRegisterCallback(&gl, gwidgetEvent, 0);
|
||||
}
|
||||
|
||||
void _gwidgetDeinit(void)
|
||||
{
|
||||
/* ToDo */
|
||||
}
|
||||
|
||||
GHandle _gwidgetCreate(GDisplay *g, GWidgetObject *pgw, const GWidgetInit *pInit, const gwidgetVMT *vmt) {
|
||||
if (!(pgw = (GWidgetObject *)_gwindowCreate(g, &pgw->g, &pInit->g, &vmt->g, GWIN_FLG_WIDGET|GWIN_FLG_ENABLED)))
|
||||
return 0;
|
||||
|
@ -338,7 +344,7 @@ void gwinSetText(GHandle gh, const char *text, bool_t useAlloc) {
|
|||
else if (useAlloc) {
|
||||
char *str;
|
||||
|
||||
if ((str = (char *)gfxAlloc(strlen(text)+1))) {
|
||||
if ((str = gfxAlloc(strlen(text)+1))) {
|
||||
gh->flags |= GWIN_FLG_ALLOCTXT;
|
||||
strcpy(str, text);
|
||||
}
|
||||
|
|
|
@ -84,7 +84,8 @@ static color_t defaultBgColor = Black;
|
|||
* Class Routines
|
||||
*-----------------------------------------------*/
|
||||
|
||||
void _gwinInit(void) {
|
||||
void _gwinInit(void)
|
||||
{
|
||||
#if GWIN_NEED_WIDGET
|
||||
extern void _gwidgetInit(void);
|
||||
|
||||
|
@ -97,12 +98,26 @@ void _gwinInit(void) {
|
|||
#endif
|
||||
}
|
||||
|
||||
void _gwinDeinit(void)
|
||||
{
|
||||
#if GWIN_NEED_WIDGET
|
||||
extern void _gwidgetDeinit(void);
|
||||
|
||||
_gwidgetDeinit();
|
||||
#endif
|
||||
#if GWIN_NEED_WINDOWMANAGER
|
||||
extern void _gwmDeinit(void);
|
||||
|
||||
_gwmDeinit();
|
||||
#endif
|
||||
}
|
||||
|
||||
// Internal routine for use by GWIN components only
|
||||
// Initialise a window creating it dynamically if required.
|
||||
GHandle _gwindowCreate(GDisplay *g, GWindowObject *pgw, const GWindowInit *pInit, const gwinVMT *vmt, uint16_t flags) {
|
||||
// Allocate the structure if necessary
|
||||
if (!pgw) {
|
||||
if (!(pgw = (GWindowObject *)gfxAlloc(vmt->size)))
|
||||
if (!(pgw = gfxAlloc(vmt->size)))
|
||||
return 0;
|
||||
pgw->flags = flags|GWIN_FLG_DYNAMIC;
|
||||
} else
|
||||
|
@ -167,7 +182,9 @@ color_t gwinGetDefaultBgColor(void) {
|
|||
GHandle gwinGWindowCreate(GDisplay *g, GWindowObject *pgw, const GWindowInit *pInit) {
|
||||
if (!(pgw = _gwindowCreate(g, pgw, pInit, &basegwinVMT, 0)))
|
||||
return 0;
|
||||
|
||||
gwinSetVisible(pgw, pInit->show);
|
||||
|
||||
return pgw;
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,8 @@ GWindowManager * _GWINwm;
|
|||
* Window Routines
|
||||
*-----------------------------------------------*/
|
||||
|
||||
void _gwmInit(void) {
|
||||
void _gwmInit(void)
|
||||
{
|
||||
gfxQueueASyncInit(&_GWINList);
|
||||
_GWINwm = (GWindowManager *)&GNullWindowManager;
|
||||
_GWINwm->vmt->Init();
|
||||
|
@ -70,6 +71,11 @@ void _gwmInit(void) {
|
|||
#endif
|
||||
}
|
||||
|
||||
void _gwmDeinit(void)
|
||||
{
|
||||
/* ToDo */
|
||||
}
|
||||
|
||||
void gwinSetWindowManager(struct GWindowManager *gwm) {
|
||||
if (!gwm)
|
||||
gwm = (GWindowManager *)&GNullWindowManager;
|
||||
|
|
|
@ -431,13 +431,14 @@ int gwinListAddItem(GHandle gh, const char* item_name, bool_t useAlloc) {
|
|||
ListItem *newItem;
|
||||
|
||||
if (useAlloc) {
|
||||
if (!(newItem = (ListItem *)gfxAlloc(sizeof(ListItem)+strlen(item_name)+1)))
|
||||
size_t len = strlen(item_name)+1;
|
||||
if (!(newItem = gfxAlloc(sizeof(ListItem) + len)))
|
||||
return -1;
|
||||
|
||||
strcpy((char *)(newItem+1), item_name);
|
||||
memcpy((char *)(newItem+1), item_name, len);
|
||||
item_name = (const char *)(newItem+1);
|
||||
} else {
|
||||
if (!(newItem = (ListItem *)gfxAlloc(sizeof(ListItem))))
|
||||
if (!(newItem = gfxAlloc(sizeof(ListItem))))
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue