From 3f53804f62dea94758fdbd63748f8d78a7c9162b Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Sun, 31 Mar 2019 15:38:39 +0800 Subject: [PATCH 01/19] fix bugs --- src/font/freetype1.c | 10 ++++---- src/font/freetype2.c | 10 ++++---- src/font/qpf.c | 2 +- src/font/rawbitmap.c | 2 +- src/font/scripteasy.c | 2 +- src/font/upf.c | 2 +- src/font/varbitmap.c | 9 ++++--- src/ial/dummy.c | 56 ++++++++++++++++++++++--------------------- src/include/devfont.h | 4 ++-- 9 files changed, 49 insertions(+), 48 deletions(-) diff --git a/src/font/freetype1.c b/src/font/freetype1.c index 7e3e1ae0..2fbf20fc 100644 --- a/src/font/freetype1.c +++ b/src/font/freetype1.c @@ -294,7 +294,7 @@ static void start_str_output (LOGFONT* logfont, DEVFONT* devfont) /* call this function before getting the bitmap/pixmap of the char * to get the bbox of the char */ static int get_glyph_bbox (LOGFONT* logfont, DEVFONT* devfont, - const Glyph32 glyph_value, + Glyph32 glyph_value, int* px, int* py, int* pwidth, int* pheight) { TT_UShort uni_char; @@ -440,7 +440,7 @@ static int get_glyph_bbox (LOGFONT* logfont, DEVFONT* devfont, /* call this function to get the bitmap/pixmap of the char */ static const void* char_bitmap_pixmap (LOGFONT* logfont, DEVFONT* devfont, - const Glyph32 glyph_value, SIZE* sz, int* pitch, BOOL is_grey) + Glyph32 glyph_value, SIZE* sz, int* pitch, BOOL is_grey) { TT_Raster_Map Raster; TT_Error error; @@ -538,14 +538,14 @@ char_bitmap_pixmap (LOGFONT* logfont, DEVFONT* devfont, } static const void* get_glyph_monobitmap (LOGFONT* logfont, DEVFONT* devfont, - const Glyph32 glyph_value, SIZE* sz, int* pitch, unsigned short* scale) + Glyph32 glyph_value, SIZE* sz, int* pitch, unsigned short* scale) { if (scale) *scale = 1; return char_bitmap_pixmap (logfont, devfont, glyph_value, sz, pitch, FALSE); } static const void* get_glyph_greybitmap (LOGFONT* logfont, DEVFONT* devfont, - const Glyph32 glyph_value, SIZE* sz, int* pitch, unsigned short* scale) + Glyph32 glyph_value, SIZE* sz, int* pitch, unsigned short* scale) { if (scale) *scale = 1; return char_bitmap_pixmap (logfont, devfont, glyph_value, sz, pitch, TRUE); @@ -554,7 +554,7 @@ static const void* get_glyph_greybitmap (LOGFONT* logfont, DEVFONT* devfont, /* call this function after getting the bitmap/pixmap of the char * to get the advance of the char */ static int get_glyph_advance (LOGFONT* logfont, DEVFONT* devfont, - const Glyph32 glyph_value, int* px, int* py) + Glyph32 glyph_value, int* px, int* py) { TT_Pos vec_x, vec_y; TTFINSTANCEINFO* ttf_inst_info = TTF_INST_INFO_P (devfont); diff --git a/src/font/freetype2.c b/src/font/freetype2.c index a05b5832..11f4cc38 100644 --- a/src/font/freetype2.c +++ b/src/font/freetype2.c @@ -324,7 +324,7 @@ load_or_search_glyph (FTINSTANCEINFO* ft_inst_info, FT_Face* face, * to get the bbox of the char */ static int get_glyph_bbox (LOGFONT* logfont, DEVFONT* devfont, - const Glyph32 glyph_value, + Glyph32 glyph_value, int* px, int* py, int* pwidth, int* pheight) { @@ -479,7 +479,7 @@ press_bitmap (void* buffer, int width, int rows, int pitch) /* call this function to get the bitmap/pixmap of the char */ static const void* char_bitmap_pixmap (LOGFONT* logfont, DEVFONT* devfont, - const Glyph32 glyph_value, SIZE* sz, int* pitch, BOOL is_grey) + Glyph32 glyph_value, SIZE* sz, int* pitch, BOOL is_grey) { FT_BitmapGlyph glyph_bitmap; FT_Bitmap* source; @@ -616,14 +616,14 @@ char_bitmap_pixmap (LOGFONT* logfont, DEVFONT* devfont, static const void* get_glyph_monobitmap (LOGFONT* logfont, DEVFONT* devfont, - const Glyph32 glyph_value, SIZE* sz, int* pitch, unsigned short* scale) + Glyph32 glyph_value, SIZE* sz, int* pitch, unsigned short* scale) { if (scale) *scale = 1; return char_bitmap_pixmap (logfont, devfont, glyph_value, sz, pitch, FALSE); } static const void* get_glyph_greybitmap (LOGFONT* logfont, DEVFONT* devfont, - const Glyph32 glyph_value, SIZE* sz, int* pitch, + Glyph32 glyph_value, SIZE* sz, int* pitch, unsigned short* scale) { if (scale) *scale = 1; @@ -648,7 +648,7 @@ start_str_output (LOGFONT* logfont, DEVFONT* devfont) * to get the advance of the char */ static int get_glyph_advance (LOGFONT* logfont, DEVFONT* devfont, - const Glyph32 glyph_value, int* px, int* py) + Glyph32 glyph_value, int* px, int* py) { FT_Fixed advance; FTINSTANCEINFO* ft_inst_info = FT_INST_INFO_P (devfont); diff --git a/src/font/qpf.c b/src/font/qpf.c index 7da0c09d..139f8afc 100644 --- a/src/font/qpf.c +++ b/src/font/qpf.c @@ -329,7 +329,7 @@ static int get_font_descent (LOGFONT* logfont, DEVFONT* devfont) } static const void* get_glyph_monobitmap (LOGFONT* logfont, DEVFONT* devfont, - const Glyph32 glyph_value, SIZE* sz, int* pitch, unsigned short* scale) + Glyph32 glyph_value, SIZE* sz, int* pitch, unsigned short* scale) { unsigned int uc16; QPF_GLYPH* glyph; diff --git a/src/font/rawbitmap.c b/src/font/rawbitmap.c index 1394df0a..f351d08a 100644 --- a/src/font/rawbitmap.c +++ b/src/font/rawbitmap.c @@ -208,7 +208,7 @@ static int get_font_descent (LOGFONT* logfont, DEVFONT* devfont) } static const void* get_glyph_monobitmap (LOGFONT* logfont, DEVFONT* devfont, - const Glyph32 glyph_value, SIZE* sz, int* pitch, unsigned short* scale) + Glyph32 glyph_value, SIZE* sz, int* pitch, unsigned short* scale) { int bitmap_size; Glyph32 glyph_tmp = glyph_value; diff --git a/src/font/scripteasy.c b/src/font/scripteasy.c index 7989f1ab..35637a18 100644 --- a/src/font/scripteasy.c +++ b/src/font/scripteasy.c @@ -466,7 +466,7 @@ static const void* get_glyph_greybitmap (LOGFONT* logfont, DEVFONT* devfont, } static const void* get_glyph_monobitmap (LOGFONT* logfont, DEVFONT* devfont, - const Glyph32 glyph_value, int* pitch, unsigned short* scale) + Glyph32 glyph_value, int* pitch, unsigned short* scale) { seunichar16 wc; SeLogFont selogfont; diff --git a/src/font/upf.c b/src/font/upf.c index 9ab83409..ceb711a1 100644 --- a/src/font/upf.c +++ b/src/font/upf.c @@ -279,7 +279,7 @@ print_bitmap(char* bits, int width, int height, int pitch) #endif static const void* get_glyph_monobitmap (LOGFONT* logfont, DEVFONT* devfont, - const Glyph32 glyph_value, SIZE* sz, int* pitch, unsigned short* scale) + Glyph32 glyph_value, SIZE* sz, int* pitch, unsigned short* scale) { unsigned int uc16; UPFGLYPH* glyph; diff --git a/src/font/varbitmap.c b/src/font/varbitmap.c index b2440e11..3d814da7 100644 --- a/src/font/varbitmap.c +++ b/src/font/varbitmap.c @@ -237,10 +237,9 @@ static int get_glyph_advance (LOGFONT* logfont, DEVFONT* devfont, } static const void* get_glyph_monobitmap (LOGFONT* logfont, DEVFONT* devfont, - const Glyph32 glyph_value, SIZE* sz, int* pitch, unsigned short* scale) + Glyph32 glyph_value, SIZE* sz, int* pitch, unsigned short* scale) { int offset; - Glyph32 eff_value = glyph_value; Glyph32 first_value; Glyph32 last_value; VBFINFO* vbf_info = VARFONT_INFO_P (devfont); @@ -249,13 +248,13 @@ static const void* get_glyph_monobitmap (LOGFONT* logfont, DEVFONT* devfont, last_value = vbf_info->last_glyph; if (glyph_value < first_value || glyph_value > last_value) - eff_value = vbf_info->def_glyph; + glyph_value = vbf_info->def_glyph; if (vbf_info->bits_offset == NULL) offset = (((size_t)vbf_info->max_width + 7) >> 3) * vbf_info->height - * (eff_value - first_value); + * (glyph_value - first_value); else { - offset = vbf_info->bits_offset [eff_value - vbf_info->first_glyph]; + offset = vbf_info->bits_offset [glyph_value - vbf_info->first_glyph]; #if MGUI_BYTEORDER == MGUI_BIG_ENDIAN if (vbf_info->font_size) offset = ArchSwap16 (offset); diff --git a/src/ial/dummy.c b/src/ial/dummy.c index 32cf891d..175c2170 100644 --- a/src/ial/dummy.c +++ b/src/ial/dummy.c @@ -1,39 +1,39 @@ /* - * This file is part of MiniGUI, a mature cross-platform windowing + * This file is part of MiniGUI, a mature cross-platform windowing * and Graphics User Interface (GUI) support system for embedded systems * and smart IoT devices. - * + * * Copyright (C) 2002~2018, Beijing FMSoft Technologies Co., Ltd. * Copyright (C) 1998~2002, WEI Yongming - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * + * * Or, - * + * * As this program is a library, any link to this program must follow * GNU General Public License version 3 (GPLv3). If you cannot accept * GPLv3, you need to be licensed from FMSoft. - * + * * If you have got a commercial license of this program, please use it * under the terms and conditions of the commercial license. - * + * * For more information about the commercial license, please refer to * . */ /* ** dummy.c: The dummy IAL engine. -** +** ** Created by Wei Yongming, 2001/09/13 */ @@ -53,9 +53,9 @@ static int mouse_x, mouse_y, mouse_button; typedef struct tagPOS { - short x; - short y; - short b; + short x; + short y; + short b; } POS; /************************ Low Level Input Operations **********************/ @@ -64,28 +64,28 @@ typedef struct tagPOS */ static int mouse_update(void) { - return 1; + return 1; } static void mouse_getxy (int* x, int* y) { - *x = mouse_x; + *x = mouse_x; *y = mouse_y; } static int mouse_getbutton(void) { - return mouse_button; + return mouse_button; } static int keyboard_update(void) { - return 0; + return 0; } static const char * keyboard_get_state (void) { - return NULL; + return NULL; } static int wait_event (int which, int maxfd, fd_set *in, fd_set *out, fd_set *except, @@ -93,23 +93,25 @@ static int wait_event (int which, int maxfd, fd_set *in, fd_set *out, fd_set *ex { #ifdef _MGRM_THREADS __mg_os_time_delay (300); + timeout->tv_sec = 0; + timeout->tv_usec = 0; #else - fd_set rfds; - int e; + fd_set rfds; + int e; if (!in) { in = &rfds; mg_fd_zero (in); } - e = mg_select (maxfd + 1, in, out, except, timeout) ; + e = mg_select (maxfd + 1, in, out, except, timeout) ; if (e < 0) { - return -1; - } + return -1; + } #endif - return 0; + return 0; } BOOL InitDummyInput (INPUT* input, const char* mdev, const char* mtype) @@ -125,9 +127,9 @@ BOOL InitDummyInput (INPUT* input, const char* mdev, const char* mtype) input->set_leds = NULL; input->wait_event = wait_event; - mouse_x = 0; - mouse_y = 0; - mouse_button= 0; + mouse_x = 0; + mouse_y = 0; + mouse_button= 0; return TRUE; } diff --git a/src/include/devfont.h b/src/include/devfont.h index 44cd8ba8..8bc94b3a 100644 --- a/src/include/devfont.h +++ b/src/include/devfont.h @@ -225,11 +225,11 @@ struct _FONTOPS /** The method to get mono-bitmap function. */ const void* (*get_glyph_monobitmap) (LOGFONT* logfont, DEVFONT* devfont, - const Glyph32 glyph_value, SIZE* sz, int* pitch, unsigned short* scale); + Glyph32 glyph_value, SIZE* sz, int* pitch, unsigned short* scale); /** The method to get grey bitmap, pitch and scale function */ const void* (*get_glyph_greybitmap) (LOGFONT* logfont, DEVFONT* devfont, - const Glyph32 galph_value, SIZE* sz, int* pitch, unsigned short* scale); + Glyph32 galph_value, SIZE* sz, int* pitch, unsigned short* scale); /** The method to get the pre-rendered bitmap of one glyph. */ int (*get_glyph_prbitmap) (LOGFONT* logfont, DEVFONT* devfont, From 61dd46f965ed147bcd8255fe834968021305aeef Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Sat, 6 Apr 2019 13:55:19 +0800 Subject: [PATCH 02/19] handle SIGINT --- src/kernel/init-lite.c | 23 +++++++++-------------- src/kernel/init.c | 13 +++++++++---- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/kernel/init-lite.c b/src/kernel/init-lite.c index 23331ced..580934b9 100644 --- a/src/kernel/init-lite.c +++ b/src/kernel/init-lite.c @@ -248,36 +248,31 @@ failure: static void sig_handler (int v) { if (v == SIGSEGV) { -#ifdef WIN32 - raise(SIGABRT); -#else kill (getpid(), SIGABRT); /* cause core dump */ -#endif - }else if (__mg_quiting_stage > 0) { + } + if (v == SIGINT) { + _exit(1); /* force to quit */ + } + else if (__mg_quiting_stage > 0) { ExitGUISafely(-1); - }else{ + } + else { exit(1); /* force to quit */ } } static BOOL InstallSEGVHandler (void) { -#ifdef WIN32 - signal(SIGSEGV, sig_handler); - signal(SIGTERM, sig_handler); - signal(SIGINT, sig_handler); -#else struct sigaction siga; - + siga.sa_handler = sig_handler; siga.sa_flags = 0; - + memset (&siga.sa_mask, 0, sizeof (sigset_t)); sigaction (SIGSEGV, &siga, NULL); sigaction (SIGTERM, &siga, NULL); sigaction (SIGINT, &siga, NULL); sigaction (SIGPIPE, &siga, NULL); -#endif return TRUE; } diff --git a/src/kernel/init.c b/src/kernel/init.c index e6f7f844..d8987c04 100644 --- a/src/kernel/init.c +++ b/src/kernel/init.c @@ -321,9 +321,14 @@ static void sig_handler (int v) { if (v == SIGSEGV) { kill (getpid(), SIGABRT); /* cause core dump */ - }else if (__mg_quiting_stage > 0) { + } + else if (v == SIGINT) { + _exit(1); + } + else if (__mg_quiting_stage > 0) { ExitGUISafely(-1); - }else{ + } + else { exit(1); /* force to quit */ } } @@ -331,10 +336,10 @@ static void sig_handler (int v) static BOOL InstallSEGVHandler (void) { struct sigaction siga; - + siga.sa_handler = sig_handler; siga.sa_flags = 0; - + memset (&siga.sa_mask, 0, sizeof (sigset_t)); sigaction (SIGSEGV, &siga, NULL); sigaction (SIGTERM, &siga, NULL); From ac6d4019d56248dca40144bf875630e161f11019 Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Sat, 6 Apr 2019 13:58:49 +0800 Subject: [PATCH 03/19] fix typo --- src/kernel/init-lite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kernel/init-lite.c b/src/kernel/init-lite.c index 580934b9..494dad48 100644 --- a/src/kernel/init-lite.c +++ b/src/kernel/init-lite.c @@ -250,7 +250,7 @@ static void sig_handler (int v) if (v == SIGSEGV) { kill (getpid(), SIGABRT); /* cause core dump */ } - if (v == SIGINT) { + else if (v == SIGINT) { _exit(1); /* force to quit */ } else if (__mg_quiting_stage > 0) { From debd8a3fdd1d14d85d6c745e84efc3d98ed4c1da Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Sun, 7 Apr 2019 16:09:39 +0800 Subject: [PATCH 04/19] introduce exstubs.h header file to define the interfaces for commlcd NEWGAL engine, comm IAL engine, and custom IAL engine --- configure.ac | 34 +++--- include/Makefile.am | 4 +- include/customial.h | 56 +-------- include/exstubs.h | 181 ++++++++++++++++++++++++++++ src/ial/comminput.c | 39 ++---- src/newgal/commlcd/axlinux_c33l05.c | 2 +- src/newgal/commlcd/commlcd.c | 104 +++++++++------- src/newgal/commlcd/commlcd.h | 22 +--- src/newgal/commlcd/ecos_generic.c | 2 +- src/newgal/commlcd/ecos_mv6600.c | 2 +- src/newgal/commlcd/extern.c | 38 ++---- src/newgal/commlcd/ose_mx21.c | 4 +- src/newgal/commlcd/vxworks_i386.c | 2 +- src/newgal/commlcd/vxworks_ppc.c | 2 +- 14 files changed, 298 insertions(+), 194 deletions(-) create mode 100644 include/exstubs.h diff --git a/configure.ac b/configure.ac index 00489796..92e9b2c3 100644 --- a/configure.ac +++ b/configure.ac @@ -389,7 +389,7 @@ AC_ARG_ENABLE(netial, build_net_ial_engine=$enableval) AC_ARG_ENABLE(cisco_touchpad_ial, -[ --enable-cisco_touchpad_ial build the IAL engine for Cisco Touchpad ], +[ --enable-cisco_touchpad_ial build the IAL engine for Cisco Touchpad ], build_cisco_touchpad_ial_engine=$enableval) AC_ARG_ENABLE(mstar_ial, @@ -892,21 +892,21 @@ CheckXVFB() [ --enable-videortosxvfb include RTOS Virtual FrameBuffer NEWGAL engine . Please disable pcxvfb to enable rtosxvfb], enable_video_rtos_xvfb=$enableval) - if test "x$enable_video_pc_xvfb" = "xyes"; then -dnl CheckPCXVFB + if test "x$enable_video_pc_xvfb" = "xyes"; then +dnl CheckPCXVFB AC_DEFINE(_MGGAL_PCXVFB, 1, [Define if include PC Virtual FrameBuffer NEWGAL engine]) VIDEO_SUBDIRS="$VIDEO_SUBDIRS pcxvfb" VIDEO_DRIVERS="$VIDEO_DRIVERS pcxvfb/libvideo_pcxvfb.la" - else - if test "x$enable_video_rtos_xvfb" = "xyes"; then -dnl CheckRTOSXVFB + else + if test "x$enable_video_rtos_xvfb" = "xyes"; then +dnl CheckRTOSXVFB AC_DEFINE(_MGGAL_RTOSXVFB, 1, [Define if include RTOS Virtual FrameBuffer NEWGAL engine]) VIDEO_SUBDIRS="$VIDEO_SUBDIRS rtos_xvfb" VIDEO_DRIVERS="$VIDEO_DRIVERS rtos_xvfb/libvideo_rtos_xvfb.la" - fi - fi + fi + fi } @@ -1509,17 +1509,21 @@ dnl ;; dnl esac AC_ARG_WITH(targetname, - [ --with-targetname=unknown/customer/fmsoft/mstudio/stb810/vfanvil/vxi386/qvfb/fbcon/mx21/monaco/c33l05/bfin/vxppc/ + [ --with-targetname=unknown/external/fmsoft/mstudio/stb810/vfanvil/vxi386/qvfb/fbcon/mx21/monaco/c33l05/bfin/vxppc/ S3C6410/S3C2440/S3C2410/hi3560a Define the target board name]) case "$with_targetname" in + external) + AC_DEFINE(__TARGET_EXTERNAL__, 1, + [Define for targets which use GAL and/or IAL engines and define the interfaces externally]) + ;; fmsoft) AC_DEFINE(__TARGET_FMSOFT__, 1, - [Define for FMSoft internal use]) + [Define for FMSoft internal use]) ;; mstudio) AC_DEFINE(__TARGET_MSTUDIO__, 1, - [Define for FMSoft miniStudio]) + [Define for FMSoft miniStudio]) ;; stb810) AC_DEFINE(__TARGET_STB810__, 1, @@ -1547,11 +1551,11 @@ case "$with_targetname" in ;; bfin) AC_DEFINE(__TARGET_BLACKFIN__, 1, - [Define for Blackfin run uClinux]) + [Define for Blackfin run uClinux]) ;; c33l05) AC_DEFINE(__TARGET_C33L05__, 1, - [Define for EPSON C33L05 (axLinux)]) + [Define for EPSON C33L05 (axLinux)]) ;; S3C6410) CFLAGS="$CFLAGS -D_WITH_TARGET_S3C6410" @@ -2430,8 +2434,8 @@ fi if test "x$build_ctrl_textedit_new" = "xyes"; then AC_DEFINE(_MGCTRL_TEXTEDIT, 1, [Define if include TEXTEDIT control]) - AC_DEFINE(_MGCTRL_TEXTEDIT_USE_NEW_IMPL, 1, - [Define if use new implementation of TEXTEDIT control]) + AC_DEFINE(_MGCTRL_TEXTEDIT_USE_NEW_IMPL, 1, + [Define if use new implementation of TEXTEDIT control]) fi if test "x$build_splash" = "xyes"; then diff --git a/include/Makefile.am b/include/Makefile.am index 1a4c323f..2203c585 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -11,8 +11,8 @@ COMM_HDRS = \ common.h endianrw.h fixedmath.h \ minigui.h gdi.h window.h control.h \ own_malloc.h own_stdio.h \ - xvfb.h customial.h \ - dti.c + xvfb.h customial.h exstubs.h \ + dti.c UCOSII_HDRS=ucos2_pthread.h ucos2_semaphore.h THREADX_HDRS=threadx_pthread.h threadx_semaphore.h diff --git a/include/customial.h b/include/customial.h index 5f4b69db..13ad6c6d 100644 --- a/include/customial.h +++ b/include/customial.h @@ -51,61 +51,7 @@ #ifndef GUI_IAL_CUSTOM_H #define GUI_IAL_CUSTOM_H -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - - -#define IAL_MOUSE_LEFTBUTTON 1 -#define IAL_MOUSE_RIGHTBUTTON 2 -#define IAL_MOUSE_MIDDLEBUTTON 4 -#define IAL_MOUSE_FOURTHBUTTON 8 -#define IAL_MOUSE_FIFTHBUTTON 16 -#define IAL_MOUSE_SIXTHBUTTON 32 -#define IAL_MOUSE_RESETBUTTON 64 - -#define IAL_MOUSEEVENT 1 -#define IAL_KEYEVENT 2 - -typedef struct tagINPUT -{ - char* id; - - // Initialization and termination - BOOL (*init_input) (struct tagINPUT *input, const char* mdev, const char* mtype); - void (*term_input) (void); - - // Mouse operations - int (*update_mouse) (void); - void (*get_mouse_xy) (int* x, int* y); - void (*set_mouse_xy) (int x, int y); - int (*get_mouse_button) (void); - void (*set_mouse_range) (int minx, int miny, int maxx, int maxy); - void (*suspend_mouse) (void); - int (*resume_mouse) (void); - - // Keyboard operations - int (*update_keyboard) (void); - const char* (*get_keyboard_state) (void); - void (*suspend_keyboard) (void); - int (*resume_keyboard) (void); - void (*set_leds) (unsigned int leds); - - // Event - int (*wait_event) (int which, int maxfd, fd_set *in, fd_set *out, - fd_set *except, struct timeval *timeout); - - char mdev [MAX_PATH + 1]; -}INPUT; - -#ifdef _MGIAL_CUSTOM -extern BOOL InitCustomInput (INPUT* input, const char* mdev, const char* mtype); -extern void TermCustomInput (void); -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ +#warning "Please use instead." #endif /* GUI_IAL_CUSTOM_H */ diff --git a/include/exstubs.h b/include/exstubs.h new file mode 100644 index 00000000..27342f96 --- /dev/null +++ b/include/exstubs.h @@ -0,0 +1,181 @@ +/** + * \file exstubs.h + * \author Wei Yongming + * \date 2019/04/07 + * + * \brief This file is the header for NEWGAL/IAL engines which should be + * implemented by an external module. + * + \verbatim + + This file is part of MiniGUI, a mature cross-platform windowing + and Graphics User Interface (GUI) support system for embedded systems + and smart IoT devices. + + Copyright (C) 2007~2018, Beijing FMSoft Technologies Co., Ltd. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + Or, + + As this program is a library, any link to this program must follow + GNU General Public License version 3 (GPLv3). If you cannot accept + GPLv3, you need to be licensed from FMSoft. + + If you have got a commercial license of this program, please use it + under the terms and conditions of the commercial license. + + For more information about the commercial license, please refer to + . + + \endverbatim + */ + +/* + * MiniGUI for Linux/uClinux, eCos, uC/OS-II, VxWorks, + * pSOS, ThreadX, NuCleus, OSE, and Win32. + */ + +#ifndef GUI_EXSTUBS_H + #define GUI_EXSTUBS_H + +/* external stubs for COMMLCD NEWGAL engine */ + +#ifdef _MGGAL_COMMLCD + +/* The pixel format defined by depth */ +#define COMMLCD_PSEUDO_RGB332 1 +#define COMMLCD_TRUE_RGB555 2 +#define COMMLCD_TRUE_RGB565 3 +#define COMMLCD_TRUE_RGB888 4 +#define COMMLCD_TRUE_RGB0888 5 +#define COMMLCD_TRUE_ARGB1555 6 +#define COMMLCD_TRUE_ARGB8888 7 +#define COMMLCD_TRUE_ABRG8888 8 + +#define COMMLCD_UPDATE_NONE 0 +#define COMMLCD_UPDATE_SYNC 1 +#define COMMLCD_UPDATE_ASYNC 2 + +struct commlcd_info { + int height; // vertical resolution of the screen + int width; // horinzontal resolution of the screen + int pitch; // Length of one scan line in bytes + int bpp; // Depth (bits-per-pixel) + int type; // Pixel type + int update_method; // Update method: none, asynchronously, or synchronously. + Uint8* fb; // Frame buffer +}; + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +int __commlcd_drv_init (void); +int __commlcd_drv_getinfo (struct commlcd_info *li, + int width, int height, int depth); +int __commlcd_drv_release (void); +int __commlcd_drv_setclut (int firstcolor, int ncolors, GAL_Color *colors); +int __commlcd_drv_update (const RECT* rc_dirty); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _MGGAL_COMMLCD */ + +#ifdef _MGIAL_COMM + +#define COMM_MOUSEINPUT 0x01 +#define COMM_KBINPUT 0x02 + +#define COMM_MOUSELBUTTON 0x01 +#define COMM_MOUSERBUTTON 0x04 + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +int __comminput_init (void); +int __comminput_ts_getdata (short *x, short *y, short *button); +int __comminput_kb_getdata (short *key, short *status); +int __comminput_wait_for_input (struct timeval *timeout); +void __comminput_deinit (void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _MGIAL_COMM */ + +#ifdef _MGIAL_CUSTOM + +#define IAL_MOUSE_LEFTBUTTON 1 +#define IAL_MOUSE_RIGHTBUTTON 2 +#define IAL_MOUSE_MIDDLEBUTTON 4 +#define IAL_MOUSE_FOURTHBUTTON 8 +#define IAL_MOUSE_FIFTHBUTTON 16 +#define IAL_MOUSE_SIXTHBUTTON 32 +#define IAL_MOUSE_RESETBUTTON 64 + +#define IAL_MOUSEEVENT 1 +#define IAL_KEYEVENT 2 + +typedef struct tagINPUT +{ + char* id; + + // Initialization and termination + BOOL (*init_input) (struct tagINPUT *input, const char* mdev, + const char* mtype); + void (*term_input) (void); + + // Mouse operations + int (*update_mouse) (void); + void (*get_mouse_xy) (int* x, int* y); + void (*set_mouse_xy) (int x, int y); + int (*get_mouse_button) (void); + void (*set_mouse_range) (int minx, int miny, int maxx, int maxy); + void (*suspend_mouse) (void); + int (*resume_mouse) (void); + + // Keyboard operations + int (*update_keyboard) (void); + const char* (*get_keyboard_state) (void); + void (*suspend_keyboard) (void); + int (*resume_keyboard) (void); + void (*set_leds) (unsigned int leds); + + // Event + int (*wait_event) (int which, int maxfd, fd_set *in, fd_set *out, + fd_set *except, struct timeval *timeout); + + char mdev [MAX_PATH + 1]; +} INPUT; + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +extern BOOL InitCustomInput (INPUT* input, const char* mdev, const char* mtype); +extern void TermCustomInput (void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _MGIAL_CUSTOM */ + +#endif /* GUI_EXSTUBS_H */ + diff --git a/src/ial/comminput.c b/src/ial/comminput.c index 2ff9d032..8c341c2f 100644 --- a/src/ial/comminput.c +++ b/src/ial/comminput.c @@ -1,39 +1,39 @@ /* - * This file is part of MiniGUI, a mature cross-platform windowing + * This file is part of MiniGUI, a mature cross-platform windowing * and Graphics User Interface (GUI) support system for embedded systems * and smart IoT devices. - * + * * Copyright (C) 2002~2018, Beijing FMSoft Technologies Co., Ltd. * Copyright (C) 1998~2002, WEI Yongming - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * + * * Or, - * + * * As this program is a library, any link to this program must follow * GNU General Public License version 3 (GPLv3). If you cannot accept * GPLv3, you need to be licensed from FMSoft. - * + * * If you have got a commercial license of this program, please use it * under the terms and conditions of the commercial license. - * + * * For more information about the commercial license, please refer to * . */ /* ** comminput.c: Common Input Engine for eCos, uC/OS-II, VxWorks, ... -** +** ** Created by Zhong Shuyi, 2004/02/29 */ @@ -50,24 +50,9 @@ #include "comminput.h" -#define COMM_MOUSEINPUT 0x01 -#define COMM_KBINPUT 0x02 - -#define COMM_MOUSELBUTTON 0x01 -#define COMM_MOUSERBUTTON 0x04 +#include "exstubs.h" /* ----------------------------------------------------------------------- */ -// OS input driver or application must implement these input functions -// hardware must be initialized before this engine can be used. - -extern int __comminput_init (void); -extern int __comminput_ts_getdata (short *x, short *y, short *button); -extern int __comminput_kb_getdata (short *key, short *status); -extern int __comminput_wait_for_input (struct timeval *timeout); -extern void __comminput_deinit (void); - -/* ----------------------------------------------------------------------- */ - static short MOUSEX = 0, MOUSEY = 0, MOUSEBUTTON = 0; static short KEYCODE = 0, KEYSTATUS = 0; @@ -142,7 +127,7 @@ static int wait_event (int which, int maxfd, fd_set *in, fd_set *out, fd_set *ex else if (retvalue < 0) { retvalue = -1; } - + return retvalue; } diff --git a/src/newgal/commlcd/axlinux_c33l05.c b/src/newgal/commlcd/axlinux_c33l05.c index 61716d52..2a3139c5 100644 --- a/src/newgal/commlcd/axlinux_c33l05.c +++ b/src/newgal/commlcd/axlinux_c33l05.c @@ -208,7 +208,7 @@ static int L2F50113T00_getscreeninfo (struct commlcd_info *li, int width, int he li->width = SCREEN_WIDTH; li->fb = (void*)VRAM_ADDR_1; li->bpp = LCD_BPP; - li->rlen = SCREEN_WIDTH * LCD_BPP_UNIT; + li->pitch = SCREEN_WIDTH * LCD_BPP_UNIT; li->async_update = 0; return 0; diff --git a/src/newgal/commlcd/commlcd.c b/src/newgal/commlcd/commlcd.c index 5383a71b..1f126de3 100644 --- a/src/newgal/commlcd/commlcd.c +++ b/src/newgal/commlcd/commlcd.c @@ -1,33 +1,33 @@ /* - * This file is part of MiniGUI, a mature cross-platform windowing + * This file is part of MiniGUI, a mature cross-platform windowing * and Graphics User Interface (GUI) support system for embedded systems * and smart IoT devices. - * + * * Copyright (C) 2002~2018, Beijing FMSoft Technologies Co., Ltd. * Copyright (C) 1998~2002, WEI Yongming - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * + * * Or, - * + * * As this program is a library, any link to this program must follow * GNU General Public License version 3 (GPLv3). If you cannot accept * GPLv3, you need to be licensed from FMSoft. - * + * * If you have got a commercial license of this program, please use it * under the terms and conditions of the commercial license. - * + * * For more information about the commercial license, please refer to * . */ @@ -47,6 +47,7 @@ #include "newgal.h" #include "sysvideo.h" #include "pixels_c.h" +#include "misc.h" #ifdef _MGGAL_COMMLCD @@ -78,6 +79,23 @@ static void COMMLCD_DeleteDevice(GAL_VideoDevice *device) free (device); } +static void COMMLCD_UpdateRects_Sync (_THIS, int numrects, GAL_Rect *rects) +{ + int i; + + /* sync update */ + for (i = 0; i < numrects; i++) { + RECT rc; + SetRect (&rc, rects[i].x, rects[i].y, + rects[i].x + rects[i].w, rects[i].y + rects[i].h); + if (!IsRectEmpty (&rc)) { + __mg_commlcd_ops.update (&rc); + } + } +} + +static BOOL _valid_async_updater = TRUE; + static void* task_do_update (void* data) { _THIS; @@ -92,41 +110,23 @@ static void* task_do_update (void* data) this->hidden->dirty = FALSE; } pthread_mutex_unlock (&this->hidden->update_lock); - usleep (50*1000); /* 50 ms */ - } while (1); + __mg_os_time_delay(50); /* 50 ms */ + } while (_valid_async_updater); return NULL; } -static void COMMLCD_UpdateRects (_THIS, int numrects, GAL_Rect *rects) +static void COMMLCD_UpdateRects_Async (_THIS, int numrects, GAL_Rect *rects) { int i; RECT bound; - if (__mg_commlcd_ops.update == NULL) { - return; - } - - if (this->hidden->update_th == 0) { - /* sync update */ - for (i = 0; i < numrects; i++) { - RECT rc; - SetRect (&rc, rects[i].x, rects[i].y, - rects[i].x + rects[i].w, rects[i].y + rects[i].h); - if (!IsRectEmpty (&rc)) { - __mg_commlcd_ops.update (&rc); - } - } - - return; - } - pthread_mutex_lock (&this->hidden->update_lock); bound = this->hidden->rc_dirty; for (i = 0; i < numrects; i++) { RECT rc; - SetRect (&rc, rects[i].x, rects[i].y, + SetRect (&rc, rects[i].x, rects[i].y, rects[i].x + rects[i].w, rects[i].y + rects[i].h); if (IsRectEmpty (&bound)) bound = rc; @@ -180,8 +180,8 @@ static GAL_VideoDevice *COMMLCD_CreateDevice (int devindex) device->SetHWColorKey = NULL; device->SetHWAlpha = NULL; device->FreeHWSurface = COMMLCD_FreeHWSurface; - device->UpdateRects = COMMLCD_UpdateRects; - + device->UpdateRects = NULL; + device->free = COMMLCD_DeleteDevice; return device; } @@ -214,7 +214,7 @@ static GAL_Surface *COMMLCD_SetVideoMode(_THIS, GAL_Surface *current, int width, int height, int bpp, Uint32 flags) { Uint32 Rmask = 0, Gmask = 0, Bmask = 0, Amask = 0; - struct commlcd_info li; + struct commlcd_info li; memset (&li, 0, sizeof (struct commlcd_info)); if (__mg_commlcd_ops.getinfo (&li, width, height, bpp)) { @@ -225,10 +225,10 @@ static GAL_Surface *COMMLCD_SetVideoMode(_THIS, GAL_Surface *current, this->hidden->w = li.width; this->hidden->h = li.height; - this->hidden->pitch = li.rlen; + this->hidden->pitch = li.pitch; this->hidden->fb = li.fb; - memset (li.fb, 0, li.rlen * height); + memset (li.fb, 0, li.pitch * height); switch (li.type) { case COMMLCD_PSEUDO_RGB332: @@ -264,6 +264,12 @@ static GAL_Surface *COMMLCD_SetVideoMode(_THIS, GAL_Surface *current, Gmask = 0x0000FF00; Bmask = 0x000000FF; break; + case COMMLCD_TRUE_ABRG8888: + Amask = 0xFF000000; + Bmask = 0x00FF0000; + Rmask = 0x0000FF00; + Gmask = 0x000000FF; + break; } /* Allocate the new pixel format for the screen */ @@ -284,17 +290,29 @@ static GAL_Surface *COMMLCD_SetVideoMode(_THIS, GAL_Surface *current, current->pitch = this->hidden->pitch; current->pixels = this->hidden->fb; - if (li.async_update && __mg_commlcd_ops.update) { + if (li.update_method == COMMLCD_UPDATE_NONE) { + this->UpdateRects = NULL; + this->hidden->update_th = 0; + } + else if (li.update_method == COMMLCD_UPDATE_ASYNC) { + this->UpdateRects = COMMLCD_UpdateRects_Async; + +#if 0 pthread_attr_t new_attr; pthread_attr_init (&new_attr); pthread_attr_setdetachstate (&new_attr, PTHREAD_CREATE_DETACHED); - pthread_create (&this->hidden->update_th, &new_attr, + pthread_create (&this->hidden->update_th, &new_attr, task_do_update, this); pthread_attr_destroy (&new_attr); +#else + pthread_create (&this->hidden->update_th, NULL, + task_do_update, this); +#endif pthread_mutex_init (&this->hidden->update_lock, NULL); } else { + this->UpdateRects = COMMLCD_UpdateRects_Sync; this->hidden->update_th = 0; } @@ -308,8 +326,10 @@ static void COMMLCD_VideoQuit (_THIS) this->screen->pixels = NULL; } - if (__mg_commlcd_ops.update) { + if (this->hidden->update_th) { /* quit the update task */ + _valid_async_updater = FALSE; + pthread_join(this->hidden->update_th, NULL); } if (__mg_commlcd_ops.release) @@ -318,7 +338,7 @@ static void COMMLCD_VideoQuit (_THIS) return; } -static GAL_Rect **COMMLCD_ListModes (_THIS, GAL_PixelFormat *format, +static GAL_Rect **COMMLCD_ListModes (_THIS, GAL_PixelFormat *format, Uint32 flags) { return (GAL_Rect **) -1; @@ -335,11 +355,11 @@ static void COMMLCD_FreeHWSurface (_THIS, GAL_Surface *surface) surface->pixels = NULL; } -static int COMMLCD_SetColors (_THIS, int firstcolor, int ncolors, +static int COMMLCD_SetColors (_THIS, int firstcolor, int ncolors, GAL_Color *colors) { if (__mg_commlcd_ops.setclut) - return __mg_commlcd_ops.setclut (firstcolor, ncolors, colors); + return __mg_commlcd_ops.setclut (firstcolor, ncolors, colors); return 0; } diff --git a/src/newgal/commlcd/commlcd.h b/src/newgal/commlcd/commlcd.h index 61147639..1297c7a4 100644 --- a/src/newgal/commlcd/commlcd.h +++ b/src/newgal/commlcd/commlcd.h @@ -37,6 +37,8 @@ #include "sysvideo.h" +#include "exstubs.h" + #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ @@ -56,26 +58,6 @@ struct GAL_PrivateVideoData { pthread_mutex_t update_lock; }; -/* The pixel format defined by depth */ -#define COMMLCD_PSEUDO_RGB332 1 -#define COMMLCD_TRUE_RGB555 2 -#define COMMLCD_TRUE_RGB565 3 -#define COMMLCD_TRUE_RGB888 4 -#define COMMLCD_TRUE_RGB0888 5 -#define COMMLCD_TRUE_ARGB1555 6 -#define COMMLCD_TRUE_ARGB8888 7 - -struct commlcd_info { - short height; // vertical resolution of the screen - short width; // horinzontal resolution of the screen - short bpp; // Depth (bits-per-pixel) - short type; // Pixel type - short rlen; // Length of one scan line in bytes - void *fb; // Frame buffer - - short async_update; // update asynchronously or synchronously. 0 for synchronously; others for asynchronously. -}; - struct commlcd_ops { /* return value: zero for OK */ int (*init) (void); diff --git a/src/newgal/commlcd/ecos_generic.c b/src/newgal/commlcd/ecos_generic.c index c7cd5045..067da214 100644 --- a/src/newgal/commlcd/ecos_generic.c +++ b/src/newgal/commlcd/ecos_generic.c @@ -71,7 +71,7 @@ static int a_getinfo (struct commlcd_info *li, int width, int height, int bpp) li->width = ecos_lcd_info.width; li->fb = ecos_lcd_info.fb; li->bpp = ecos_lcd_info.bpp; - li->rlen = ecos_lcd_info.rlen; + li->pitch = ecos_lcd_info.pitch; li->async_update = 0; return 0; } diff --git a/src/newgal/commlcd/ecos_mv6600.c b/src/newgal/commlcd/ecos_mv6600.c index e5dd3060..0320c32a 100644 --- a/src/newgal/commlcd/ecos_mv6600.c +++ b/src/newgal/commlcd/ecos_mv6600.c @@ -74,7 +74,7 @@ static int a_getinfo (struct commlcd_info *li, int width, int height, int bpp) li->height = 240; li->width = 320; li->bpp = 32; - li->rlen = 320 * 32 / 8; + li->pitch = 320 * 32 / 8; li->fb = 0xe40000; li->type = COMMLCD_TRUE_RGB0888; return 0; diff --git a/src/newgal/commlcd/extern.c b/src/newgal/commlcd/extern.c index 149f55e8..623d2589 100644 --- a/src/newgal/commlcd/extern.c +++ b/src/newgal/commlcd/extern.c @@ -1,50 +1,44 @@ /* - * This file is part of MiniGUI, a mature cross-platform windowing + * This file is part of MiniGUI, a mature cross-platform windowing * and Graphics User Interface (GUI) support system for embedded systems * and smart IoT devices. - * + * * Copyright (C) 2002~2018, Beijing FMSoft Technologies Co., Ltd. * Copyright (C) 1998~2002, WEI Yongming - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * + * * Or, - * + * * As this program is a library, any link to this program must follow * GNU General Public License version 3 (GPLv3). If you cannot accept * GPLv3, you need to be licensed from FMSoft. - * + * * If you have got a commercial license of this program, please use it * under the terms and conditions of the commercial license. - * + * * For more information about the commercial license, please refer to * . */ /* ** extern.c: A subdriver of CommonLCD NEWGAL engine for some targets -** which are defined by the external module. +** which are defined by the external module (__TARGET_EXTERNAL__). */ -#include -#include -#include - #include "common.h" -#ifdef _MGGAL_COMMLCD - -#if defined (__VXWORKS__) || defined (__TARGET_UNKNOWN__) +#if defined(_MGGAL_COMMLCD) && defined(__TARGET_EXTERNAL__) #include "minigui.h" #include "newgal.h" @@ -52,12 +46,6 @@ #include "pixels_c.h" #include "commlcd.h" -extern int __commlcd_drv_init (void); -extern int __commlcd_drv_getinfo (struct commlcd_info *li, int width, int height, int bpp); -extern int __commlcd_drv_release (void); -extern int __commlcd_drv_setclut (int firstcolor, int ncolors, GAL_Color *colors); -extern int __commlcd_drv_update (const RECT* rc_dirty); - struct commlcd_ops __mg_commlcd_ops = { __commlcd_drv_init, __commlcd_drv_getinfo, @@ -66,7 +54,5 @@ struct commlcd_ops __mg_commlcd_ops = { __commlcd_drv_update }; -#endif - -#endif /* _MGGAL_COMMLCD */ +#endif /* _MGGAL_COMMLCD && __TARGET_EXTERNAL__ */ diff --git a/src/newgal/commlcd/ose_mx21.c b/src/newgal/commlcd/ose_mx21.c index 131bec28..78eeff21 100644 --- a/src/newgal/commlcd/ose_mx21.c +++ b/src/newgal/commlcd/ose_mx21.c @@ -101,8 +101,8 @@ static int a_getinfo (struct commlcd_info *li, int width, int height, int bpp) li->width = fbinfo->width; li->fb = fbinfo->fb_ptr; li->bpp = fbinfo->depth; - li->rlen = (li->bpp*li->width + 7) / 8; - /*li->rlen = fbinfo->fb_size;*/ + li->pitch = (li->bpp*li->width + 7) / 8; + /*li->pitch = fbinfo->fb_size;*/ return 0; } diff --git a/src/newgal/commlcd/vxworks_i386.c b/src/newgal/commlcd/vxworks_i386.c index 66f3488a..2b4050d7 100644 --- a/src/newgal/commlcd/vxworks_i386.c +++ b/src/newgal/commlcd/vxworks_i386.c @@ -91,7 +91,7 @@ static int a_getinfo (struct lcd_info *li, int width, int height, int bpp) li->width = modeInfo.width; li->fb = modeInfo.fbAddress; li->bpp = modeInfo.colorDepth; - li->rlen = (li->bpp*li->width + 7) / 8; + li->pitch = (li->bpp*li->width + 7) / 8; return 0; } diff --git a/src/newgal/commlcd/vxworks_ppc.c b/src/newgal/commlcd/vxworks_ppc.c index c6002ce9..e33c9230 100644 --- a/src/newgal/commlcd/vxworks_ppc.c +++ b/src/newgal/commlcd/vxworks_ppc.c @@ -87,7 +87,7 @@ static int a_getinfo (struct lcd_info *li, int width, int height, int bpp) //li->bpp = modeInfo.colorDepth; li->bpp = 32; printf ("Current color depth is %d \n", modeInfo.colorDepth); - li->rlen = (li->bpp*1024 + 7) / 8; + li->pitch = (li->bpp*1024 + 7) / 8; return 0; } From 12106c036c0420c19e0f9bdf3a46d912aded5620 Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Sun, 7 Apr 2019 16:13:17 +0800 Subject: [PATCH 05/19] tune --- include/customial.h | 2 +- include/exstubs.h | 86 ++++++++++++++++++++++----------------------- src/include/ial.h | 2 +- 3 files changed, 45 insertions(+), 45 deletions(-) diff --git a/include/customial.h b/include/customial.h index 13ad6c6d..d3403d3e 100644 --- a/include/customial.h +++ b/include/customial.h @@ -51,7 +51,7 @@ #ifndef GUI_IAL_CUSTOM_H #define GUI_IAL_CUSTOM_H -#warning "Please use instead." +#include "exstubs.h" #endif /* GUI_IAL_CUSTOM_H */ diff --git a/include/exstubs.h b/include/exstubs.h index 27342f96..b66c335e 100644 --- a/include/exstubs.h +++ b/include/exstubs.h @@ -50,6 +50,49 @@ #ifndef GUI_EXSTUBS_H #define GUI_EXSTUBS_H +#define IAL_MOUSE_LEFTBUTTON 1 +#define IAL_MOUSE_RIGHTBUTTON 2 +#define IAL_MOUSE_MIDDLEBUTTON 4 +#define IAL_MOUSE_FOURTHBUTTON 8 +#define IAL_MOUSE_FIFTHBUTTON 16 +#define IAL_MOUSE_SIXTHBUTTON 32 +#define IAL_MOUSE_RESETBUTTON 64 + +#define IAL_MOUSEEVENT 1 +#define IAL_KEYEVENT 2 + +typedef struct tagINPUT +{ + char* id; + + // Initialization and termination + BOOL (*init_input) (struct tagINPUT *input, const char* mdev, + const char* mtype); + void (*term_input) (void); + + // Mouse operations + int (*update_mouse) (void); + void (*get_mouse_xy) (int* x, int* y); + void (*set_mouse_xy) (int x, int y); + int (*get_mouse_button) (void); + void (*set_mouse_range) (int minx, int miny, int maxx, int maxy); + void (*suspend_mouse) (void); + int (*resume_mouse) (void); + + // Keyboard operations + int (*update_keyboard) (void); + const char* (*get_keyboard_state) (void); + void (*suspend_keyboard) (void); + int (*resume_keyboard) (void); + void (*set_leds) (unsigned int leds); + + // Event + int (*wait_event) (int which, int maxfd, fd_set *in, fd_set *out, + fd_set *except, struct timeval *timeout); + + char mdev [MAX_PATH + 1]; +} INPUT; + /* external stubs for COMMLCD NEWGAL engine */ #ifdef _MGGAL_COMMLCD @@ -121,49 +164,6 @@ void __comminput_deinit (void); #ifdef _MGIAL_CUSTOM -#define IAL_MOUSE_LEFTBUTTON 1 -#define IAL_MOUSE_RIGHTBUTTON 2 -#define IAL_MOUSE_MIDDLEBUTTON 4 -#define IAL_MOUSE_FOURTHBUTTON 8 -#define IAL_MOUSE_FIFTHBUTTON 16 -#define IAL_MOUSE_SIXTHBUTTON 32 -#define IAL_MOUSE_RESETBUTTON 64 - -#define IAL_MOUSEEVENT 1 -#define IAL_KEYEVENT 2 - -typedef struct tagINPUT -{ - char* id; - - // Initialization and termination - BOOL (*init_input) (struct tagINPUT *input, const char* mdev, - const char* mtype); - void (*term_input) (void); - - // Mouse operations - int (*update_mouse) (void); - void (*get_mouse_xy) (int* x, int* y); - void (*set_mouse_xy) (int x, int y); - int (*get_mouse_button) (void); - void (*set_mouse_range) (int minx, int miny, int maxx, int maxy); - void (*suspend_mouse) (void); - int (*resume_mouse) (void); - - // Keyboard operations - int (*update_keyboard) (void); - const char* (*get_keyboard_state) (void); - void (*suspend_keyboard) (void); - int (*resume_keyboard) (void); - void (*set_leds) (unsigned int leds); - - // Event - int (*wait_event) (int which, int maxfd, fd_set *in, fd_set *out, - fd_set *except, struct timeval *timeout); - - char mdev [MAX_PATH + 1]; -} INPUT; - #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ diff --git a/src/include/ial.h b/src/include/ial.h index 3e5cbcaa..57c53177 100644 --- a/src/include/ial.h +++ b/src/include/ial.h @@ -60,7 +60,7 @@ #include "mgsock.h" #include "misc.h" #include "gal.h" -#include "customial.h" +#include "exstubs.h" #ifdef __cplusplus extern "C" { From 5a0fc2e74fa592e0cde779460505597cfcad38f6 Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Sun, 7 Apr 2019 16:25:43 +0800 Subject: [PATCH 06/19] tune --- include/customial.h | 58 ++++++++++++- include/exstubs.h | 58 ------------- src/ial/netial/netial.c | 181 ++++++++++++++++++++-------------------- src/ial/netial/netial.h | 36 +------- src/include/ial.h | 68 +++++++-------- 5 files changed, 184 insertions(+), 217 deletions(-) diff --git a/include/customial.h b/include/customial.h index d3403d3e..a6ab8dbc 100644 --- a/include/customial.h +++ b/include/customial.h @@ -51,8 +51,62 @@ #ifndef GUI_IAL_CUSTOM_H #define GUI_IAL_CUSTOM_H -#include "exstubs.h" +#define IAL_MOUSE_LEFTBUTTON 1 +#define IAL_MOUSE_RIGHTBUTTON 2 +#define IAL_MOUSE_MIDDLEBUTTON 4 +#define IAL_MOUSE_FOURTHBUTTON 8 +#define IAL_MOUSE_FIFTHBUTTON 16 +#define IAL_MOUSE_SIXTHBUTTON 32 +#define IAL_MOUSE_RESETBUTTON 64 + +#define IAL_MOUSEEVENT 1 +#define IAL_KEYEVENT 2 + +typedef struct tagINPUT { + char* id; + + // Initialization and termination + BOOL (*init_input) (struct tagINPUT *input, const char* mdev, + const char* mtype); + void (*term_input) (void); + + // Mouse operations + int (*update_mouse) (void); + void (*get_mouse_xy) (int* x, int* y); + void (*set_mouse_xy) (int x, int y); + int (*get_mouse_button) (void); + void (*set_mouse_range) (int minx, int miny, int maxx, int maxy); + void (*suspend_mouse) (void); + int (*resume_mouse) (void); + + // Keyboard operations + int (*update_keyboard) (void); + const char* (*get_keyboard_state) (void); + void (*suspend_keyboard) (void); + int (*resume_keyboard) (void); + void (*set_leds) (unsigned int leds); + + // Event + int (*wait_event) (int which, int maxfd, fd_set *in, fd_set *out, + fd_set *except, struct timeval *timeout); + + char mdev [MAX_PATH + 1]; +} INPUT; + +#ifdef _MGIAL_CUSTOM + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +BOOL InitCustomInput (INPUT* input, const char* mdev, const char* mtype); +void TermCustomInput (void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _MGIAL_CUSTOM */ #endif /* GUI_IAL_CUSTOM_H */ - diff --git a/include/exstubs.h b/include/exstubs.h index b66c335e..c569e731 100644 --- a/include/exstubs.h +++ b/include/exstubs.h @@ -50,49 +50,6 @@ #ifndef GUI_EXSTUBS_H #define GUI_EXSTUBS_H -#define IAL_MOUSE_LEFTBUTTON 1 -#define IAL_MOUSE_RIGHTBUTTON 2 -#define IAL_MOUSE_MIDDLEBUTTON 4 -#define IAL_MOUSE_FOURTHBUTTON 8 -#define IAL_MOUSE_FIFTHBUTTON 16 -#define IAL_MOUSE_SIXTHBUTTON 32 -#define IAL_MOUSE_RESETBUTTON 64 - -#define IAL_MOUSEEVENT 1 -#define IAL_KEYEVENT 2 - -typedef struct tagINPUT -{ - char* id; - - // Initialization and termination - BOOL (*init_input) (struct tagINPUT *input, const char* mdev, - const char* mtype); - void (*term_input) (void); - - // Mouse operations - int (*update_mouse) (void); - void (*get_mouse_xy) (int* x, int* y); - void (*set_mouse_xy) (int x, int y); - int (*get_mouse_button) (void); - void (*set_mouse_range) (int minx, int miny, int maxx, int maxy); - void (*suspend_mouse) (void); - int (*resume_mouse) (void); - - // Keyboard operations - int (*update_keyboard) (void); - const char* (*get_keyboard_state) (void); - void (*suspend_keyboard) (void); - int (*resume_keyboard) (void); - void (*set_leds) (unsigned int leds); - - // Event - int (*wait_event) (int which, int maxfd, fd_set *in, fd_set *out, - fd_set *except, struct timeval *timeout); - - char mdev [MAX_PATH + 1]; -} INPUT; - /* external stubs for COMMLCD NEWGAL engine */ #ifdef _MGGAL_COMMLCD @@ -162,20 +119,5 @@ void __comminput_deinit (void); #endif /* _MGIAL_COMM */ -#ifdef _MGIAL_CUSTOM - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -extern BOOL InitCustomInput (INPUT* input, const char* mdev, const char* mtype); -extern void TermCustomInput (void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _MGIAL_CUSTOM */ - #endif /* GUI_EXSTUBS_H */ diff --git a/src/ial/netial/netial.c b/src/ial/netial/netial.c index 4bbe8eb8..8e01c505 100644 --- a/src/ial/netial/netial.c +++ b/src/ial/netial/netial.c @@ -1,33 +1,33 @@ /* - * This file is part of MiniGUI, a mature cross-platform windowing + * This file is part of MiniGUI, a mature cross-platform windowing * and Graphics User Interface (GUI) support system for embedded systems * and smart IoT devices. - * + * * Copyright (C) 2002~2018, Beijing FMSoft Technologies Co., Ltd. * Copyright (C) 1998~2002, WEI Yongming - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * + * * Or, - * + * * As this program is a library, any link to this program must follow * GNU General Public License version 3 (GPLv3). If you cannot accept * GPLv3, you need to be licensed from FMSoft. - * + * * If you have got a commercial license of this program, please use it * under the terms and conditions of the commercial license. - * + * * For more information about the commercial license, please refer to * . */ @@ -39,11 +39,12 @@ #include #include -#include "mgconfig.h" #include "common.h" + +#ifdef _MGIAL_NET + #include "minigui.h" #include "netial.h" -#ifdef _MGIAL_NET #include #include @@ -74,9 +75,9 @@ typedef struct { typedef struct { - int x; - int y; - int pressure; + int x; + int y; + int pressure; }MOUSE_EVENT; static int mousex = 0; @@ -108,15 +109,15 @@ static int mouse_update(void) static void mouse_getxy(int *x, int* y) { - if (mousex < 0) - mousex = 0; - if (mousex > g_rcScr.right) - mousex = g_rcScr.right; + if (mousex < 0) + mousex = 0; + if (mousex > g_rcScr.right) + mousex = g_rcScr.right; - if (mousey < 0) - mousey = 0; - if (mousey > g_rcScr.bottom) - mousey = g_rcScr.bottom; + if (mousey < 0) + mousey = 0; + if (mousey > g_rcScr.bottom) + mousey = g_rcScr.bottom; *x = mousex; *y = mousey; } @@ -149,98 +150,98 @@ static int wait_event (int which, int maxfd, fd_set *in, fd_set *out, fd_set *ex e = select (FD_SETSIZE, in, out, except, timeout) ; #endif - if (e > 0) - { - if (temp_sock_descriptor >= 0 && FD_ISSET (temp_sock_descriptor, in)) - { - FD_CLR (temp_sock_descriptor, in); - n = recv (temp_sock_descriptor, event_buf, 100, 0); - if (n == 0) - { - printf ("recv == 0\n"); - exit (1); - } - if (n == sizeof (MOUSE_EVENT)/sizeof (char)) - { - mouse_event = (MOUSE_EVENT*)event_buf; - mousex += mouse_event->x * 2; - mousey += mouse_event->y * 2; - switch (mouse_event->pressure) - { - case 1: - ts_event.pressure = IAL_MOUSE_LEFTBUTTON; - break; - case 2: - ts_event.pressure = IAL_MOUSE_RIGHTBUTTON; - break; - case 0: - ts_event.pressure = 0; - break; - } - return IAL_MOUSEEVENT; - } - } - } - else if (e < 0) - { - return -1; - } + if (e > 0) + { + if (temp_sock_descriptor >= 0 && FD_ISSET (temp_sock_descriptor, in)) + { + FD_CLR (temp_sock_descriptor, in); + n = recv (temp_sock_descriptor, event_buf, 100, 0); + if (n == 0) + { + printf ("recv == 0\n"); + exit (1); + } + if (n == sizeof (MOUSE_EVENT)/sizeof (char)) + { + mouse_event = (MOUSE_EVENT*)event_buf; + mousex += mouse_event->x * 2; + mousey += mouse_event->y * 2; + switch (mouse_event->pressure) + { + case 1: + ts_event.pressure = IAL_MOUSE_LEFTBUTTON; + break; + case 2: + ts_event.pressure = IAL_MOUSE_RIGHTBUTTON; + break; + case 0: + ts_event.pressure = 0; + break; + } + return IAL_MOUSEEVENT; + } + } + } + else if (e < 0) + { + return -1; + } - return 0; + return 0; } BOOL InitNetInput (INPUT* input, const char* mdev, const char* mtype) { - sock_descriptor = socket (AF_INET, SOCK_STREAM, 0); - if (sock_descriptor == -1) - { - perror ("call to socket"); - exit (1); - } + sock_descriptor = socket (AF_INET, SOCK_STREAM, 0); + if (sock_descriptor == -1) + { + perror ("call to socket"); + exit (1); + } - bzero (&sin, sizeof (sin)); - sin.sin_family = AF_INET; - sin.sin_addr.s_addr = INADDR_ANY; - sin.sin_port = htons (port); + bzero (&sin, sizeof (sin)); + sin.sin_family = AF_INET; + sin.sin_addr.s_addr = INADDR_ANY; + sin.sin_port = htons (port); - if (bind (sock_descriptor, (struct sockaddr*)&sin, sizeof (sin)) == -1) - { - perror("call to bind"); - exit (1); - } + if (bind (sock_descriptor, (struct sockaddr*)&sin, sizeof (sin)) == -1) + { + perror("call to bind"); + exit (1); + } - if (listen (sock_descriptor, 20) == -1) - { - perror ("call to listen"); - exit (1); - } - printf ("Please start the PC side of the client process.\n"); + if (listen (sock_descriptor, 20) == -1) + { + perror ("call to listen"); + exit (1); + } + printf ("Please start the PC side of the client process.\n"); - temp_sock_descriptor = accept (sock_descriptor, (struct sockaddr *)&pin, &address_size); - if (temp_sock_descriptor == -1) - { - perror ("call to accept"); - exit (1); - } + temp_sock_descriptor = accept (sock_descriptor, (struct sockaddr *)&pin, &address_size); + if (temp_sock_descriptor == -1) + { + perror ("call to accept"); + exit (1); + } input->update_mouse = mouse_update; input->get_mouse_xy = mouse_getxy; input->set_mouse_xy = NULL; input->get_mouse_button = mouse_getbutton; input->set_mouse_range = NULL; - - input->update_keyboard = NULL; + + input->update_keyboard = NULL; input->get_keyboard_state = NULL; input->wait_event = wait_event; - + return TRUE; } void TermNetInput(void) { if (temp_sock_descriptor >= 0) - close(temp_sock_descriptor); + close(temp_sock_descriptor); } #endif /* _MGIAL_NET */ diff --git a/src/ial/netial/netial.h b/src/ial/netial/netial.h index a46791bc..1067fd0e 100644 --- a/src/ial/netial/netial.h +++ b/src/ial/netial/netial.h @@ -35,10 +35,11 @@ #ifndef GUI_IAL_NET_H #define GUI_IAL_NET_H +#include "ial.h" + #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ -#include "customial.h" #define IAL_MOUSE_LEFTBUTTON 1 #define IAL_MOUSE_RIGHTBUTTON 2 @@ -50,42 +51,9 @@ extern "C" { #define IAL_MOUSEEVENT 1 #define IAL_KEYEVENT 2 -/* -typedef struct tagINPUT -{ - char* id; - // Initialization and termination - BOOL (*init_input) (struct tagINPUT *input, const char* mdev, const char* mtype); - void (*term_input) (void); - - // Mouse operations - int (*update_mouse) (void); - void (*get_mouse_xy) (int* x, int* y); - void (*set_mouse_xy) (int x, int y); - int (*get_mouse_button) (void); - void (*set_mouse_range) (int minx, int miny, int maxx, int maxy); - void (*suspend_mouse) (void); - int (*resume_mouse) (void); - - // Keyboard operations - int (*update_keyboard) (void); - const char* (*get_keyboard_state) (void); - void (*suspend_keyboard) (void); - int (*resume_keyboard) (void); - void (*set_leds) (unsigned int leds); - - // Event - int (*wait_event) (int which, int maxfd, fd_set *in, fd_set *out, - fd_set *except, struct timeval *timeout); - - char mdev [MAX_PATH + 1]; -}INPUT; -*/ -#ifdef _MGIAL_NET extern BOOL InitNetInput (INPUT* input, const char* mdev, const char* mtype); extern void TermNetInput (void); -#endif #ifdef __cplusplus } diff --git a/src/include/ial.h b/src/include/ial.h index 57c53177..fb08887b 100644 --- a/src/include/ial.h +++ b/src/include/ial.h @@ -1,33 +1,33 @@ /* - * This file is part of MiniGUI, a mature cross-platform windowing + * This file is part of MiniGUI, a mature cross-platform windowing * and Graphics User Interface (GUI) support system for embedded systems * and smart IoT devices. - * + * * Copyright (C) 2002~2018, Beijing FMSoft Technologies Co., Ltd. * Copyright (C) 1998~2002, WEI Yongming - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * + * * Or, - * + * * As this program is a library, any link to this program must follow * GNU General Public License version 3 (GPLv3). If you cannot accept * GPLv3, you need to be licensed from FMSoft. - * + * * If you have got a commercial license of this program, please use it * under the terms and conditions of the commercial license. - * + * * For more information about the commercial license, please refer to * . */ @@ -60,7 +60,7 @@ #include "mgsock.h" #include "misc.h" #include "gal.h" -#include "exstubs.h" +#include "customial.h" #ifdef __cplusplus extern "C" { @@ -72,6 +72,7 @@ extern "C" { #define _ROT_DIR_HFLIP 0x08 #define _ROT_DIR_VFLIP 0x10 #endif + extern void (*__mg_ial_change_mouse_xy_hook) (int* x, int* y); extern DWORD __mg_shadow_rotate_flags; @@ -89,36 +90,36 @@ extern INPUT* __mg_cur_input; #define IAL_UpdateMouse (*__mg_cur_input->update_mouse) //#define IAL_GetMouseXY (*__mg_cur_input->get_mouse_xy) -static inline void IAL_GetMouseXY(int *x, int* y) { - - if (__mg_cur_input && __mg_cur_input->get_mouse_xy) { - (*__mg_cur_input->get_mouse_xy) (x, y); +static inline void IAL_GetMouseXY(int *x, int* y) +{ + if (__mg_cur_input && __mg_cur_input->get_mouse_xy) { + (*__mg_cur_input->get_mouse_xy) (x, y); #ifdef _MGHAVE_MOUSECALIBRATE - __mg_mouse_org_pos.x = *x; - __mg_mouse_org_pos.y = *y; + __mg_mouse_org_pos.x = *x; + __mg_mouse_org_pos.y = *y; #endif - } + } #ifdef _MGHAVE_MOUSECALIBRATE - if (__mg_do_mouse_calibrate) __mg_do_mouse_calibrate (x, y); + if (__mg_do_mouse_calibrate) __mg_do_mouse_calibrate (x, y); #endif - if (*x < 0) *x = 0; - if (*y < 0) *y = 0; - - if (__mg_ial_change_mouse_xy_hook) - __mg_ial_change_mouse_xy_hook (x, y); - else - { - if (*x > (__gal_screen->w-1)) *x = (__gal_screen->w-1); - if (*y > (__gal_screen->h-1)) *y = (__gal_screen->h-1); - } + if (*x < 0) *x = 0; + if (*y < 0) *y = 0; + + if (__mg_ial_change_mouse_xy_hook) + __mg_ial_change_mouse_xy_hook (x, y); + else + { + if (*x > (__gal_screen->w-1)) *x = (__gal_screen->w-1); + if (*y > (__gal_screen->h-1)) *y = (__gal_screen->h-1); + } } #define IAL_GetMouseButton (*__mg_cur_input->get_mouse_button) -//#define IAL_SetMouseXY if (__mg_cur_input->set_mouse_xy) (*__mg_cur_input->set_mouse_xy) -static inline void IAL_SetMouseXY (int x, int y) { +static inline void IAL_SetMouseXY (int x, int y) +{ if (__mg_cur_input->set_mouse_xy) { #ifdef _MGGAL_SHADOW if (__mg_shadow_rotate_flags & _ROT_DIR_CW){ @@ -140,14 +141,15 @@ static inline void IAL_SetMouseXY (int x, int y) { } } -//#define IAL_SetMouseRange if (__mg_cur_input->set_mouse_range) (*__mg_cur_input->set_mouse_range) -static inline void IAL_SetMouseRange (int minx, int miny, int maxx, int maxy) { +static inline void IAL_SetMouseRange (int minx, int miny, int maxx, int maxy) +{ #ifdef _MGGAL_SHADOW if (__mg_shadow_rotate_flags) return; #endif - if (__mg_cur_input->set_mouse_range) (*__mg_cur_input->set_mouse_range)(minx, miny, maxx, maxy); + if (__mg_cur_input->set_mouse_range) + __mg_cur_input->set_mouse_range(minx, miny, maxx, maxy); } From 736a532b1a6eeaa34ad3b0664c1761fcf9e53e4e Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Sun, 7 Apr 2019 17:16:53 +0800 Subject: [PATCH 07/19] use standard pixel format for alpha_pixel_format --- include/exstubs.h | 41 ++++++++++++++++------------------------- src/newgal/pixels.c | 1 + src/newgdi/attr.c | 24 ++++++++++++------------ 3 files changed, 29 insertions(+), 37 deletions(-) diff --git a/include/exstubs.h b/include/exstubs.h index c569e731..13bc0133 100644 --- a/include/exstubs.h +++ b/include/exstubs.h @@ -50,10 +50,6 @@ #ifndef GUI_EXSTUBS_H #define GUI_EXSTUBS_H -/* external stubs for COMMLCD NEWGAL engine */ - -#ifdef _MGGAL_COMMLCD - /* The pixel format defined by depth */ #define COMMLCD_PSEUDO_RGB332 1 #define COMMLCD_TRUE_RGB555 2 @@ -78,25 +74,6 @@ struct commlcd_info { Uint8* fb; // Frame buffer }; -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -int __commlcd_drv_init (void); -int __commlcd_drv_getinfo (struct commlcd_info *li, - int width, int height, int depth); -int __commlcd_drv_release (void); -int __commlcd_drv_setclut (int firstcolor, int ncolors, GAL_Color *colors); -int __commlcd_drv_update (const RECT* rc_dirty); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _MGGAL_COMMLCD */ - -#ifdef _MGIAL_COMM - #define COMM_MOUSEINPUT 0x01 #define COMM_KBINPUT 0x02 @@ -107,17 +84,31 @@ int __commlcd_drv_update (const RECT* rc_dirty); extern "C" { #endif /* __cplusplus */ +/* external stubs for COMMLCD NEWGAL engine */ +#ifdef _MGGAL_COMMLCD + +int __commlcd_drv_init (void); +int __commlcd_drv_getinfo (struct commlcd_info *li, + int width, int height, int depth); +int __commlcd_drv_release (void); +int __commlcd_drv_setclut (int firstcolor, int ncolors, GAL_Color *colors); +int __commlcd_drv_update (const RECT* rc_dirty); + +#endif /* _MGGAL_COMMLCD */ + +#ifdef _MGIAL_COMM + int __comminput_init (void); int __comminput_ts_getdata (short *x, short *y, short *button); int __comminput_kb_getdata (short *key, short *status); int __comminput_wait_for_input (struct timeval *timeout); void __comminput_deinit (void); +#endif /* _MGIAL_COMM */ + #ifdef __cplusplus } #endif /* __cplusplus */ -#endif /* _MGIAL_COMM */ - #endif /* GUI_EXSTUBS_H */ diff --git a/src/newgal/pixels.c b/src/newgal/pixels.c index d66af920..50c66a74 100644 --- a/src/newgal/pixels.c +++ b/src/newgal/pixels.c @@ -240,6 +240,7 @@ GAL_PixelFormat *GAL_AllocFormat(int bpp, } return(format); } + GAL_PixelFormat *GAL_ReallocFormat(GAL_Surface *surface, int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) { diff --git a/src/newgdi/attr.c b/src/newgdi/attr.c index b101521c..384e63e3 100644 --- a/src/newgdi/attr.c +++ b/src/newgdi/attr.c @@ -75,22 +75,22 @@ static int make_alpha_pixel_format (PDC pdc) if (pdc->alpha_pixel_format == NULL) { switch (pdc->surface->format->BytesPerPixel) { case 2: - Rmask = 0x0000F000; - Gmask = 0x00000F00; - Bmask = 0x000000F0; - Amask = 0x0000000F; + Amask = 0x0000F000; + Rmask = 0x00000F00; + Gmask = 0x000000F0; + Bmask = 0x0000000F; break; case 3: - Rmask = 0x00FC0000; - Gmask = 0x0003F000; - Bmask = 0x00000FC0; - Amask = 0x0000003F; + Amask = 0x00FC0000; + Rmask = 0x0003F000; + Gmask = 0x00000FC0; + Bmask = 0x0000003F; break; case 4: - Rmask = 0xFF000000; - Gmask = 0x00FF0000; - Bmask = 0x0000FF00; - Amask = 0x000000FF; + Amask = 0xFF000000; + Rmask = 0x00FF0000; + Gmask = 0x0000FF00; + Bmask = 0x000000FF; break; default: return -1; From eca15c447d8cb9f380034f74be76e0bdf027e94e Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Mon, 8 Apr 2019 13:48:16 +0800 Subject: [PATCH 08/19] check li.bpp with the requested bpp --- src/newgal/commlcd/commlcd.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/newgal/commlcd/commlcd.c b/src/newgal/commlcd/commlcd.c index 1f126de3..3f5a5bfb 100644 --- a/src/newgal/commlcd/commlcd.c +++ b/src/newgal/commlcd/commlcd.c @@ -193,11 +193,11 @@ VideoBootStrap COMMLCD_bootstrap = { static int COMMLCD_VideoInit(_THIS, GAL_PixelFormat *vformat) { - fprintf (stderr, "NEWGAL>COMMLCD: Calling init method!\n"); + _ERR_PRINTF ("NEWGAL>COMMLCD: Calling init method!\n"); /* Initialize LCD screen */ if (__mg_commlcd_ops.init ()) { - fprintf (stderr, "NEWGAL>COMMLCD: Couldn't initialize LCD\n"); + _ERR_PRINTF ("NEWGAL>COMMLCD: Couldn't initialize LCD\n"); return -1; } @@ -214,22 +214,26 @@ static GAL_Surface *COMMLCD_SetVideoMode(_THIS, GAL_Surface *current, int width, int height, int bpp, Uint32 flags) { Uint32 Rmask = 0, Gmask = 0, Bmask = 0, Amask = 0; - struct commlcd_info li; + struct commlcd_info li; memset (&li, 0, sizeof (struct commlcd_info)); if (__mg_commlcd_ops.getinfo (&li, width, height, bpp)) { - fprintf (stderr, "NEWGAL>COMMLCD: " + _ERR_PRINTF ("NEWGAL>COMMLCD: " "Couldn't get the LCD information\n"); return NULL; } + if (li.bpp != bpp) { + _ERR_PRINTF ("NEWGAL>COMMLCD: " + "Returned color depth (%d) does not matched the requested color depth (%d)\n", + li.bpp, bpp); + } + this->hidden->w = li.width; this->hidden->h = li.height; this->hidden->pitch = li.pitch; this->hidden->fb = li.fb; - memset (li.fb, 0, li.pitch * height); - switch (li.type) { case COMMLCD_PSEUDO_RGB332: Rmask = 0xE0; @@ -278,7 +282,7 @@ static GAL_Surface *COMMLCD_SetVideoMode(_THIS, GAL_Surface *current, __mg_commlcd_ops.release (); this->hidden->fb = NULL; - fprintf (stderr, "NEWGAL>COMMLCD: " + _ERR_PRINTF ("NEWGAL>COMMLCD: " "Couldn't allocate new pixel format for requested mode\n"); return NULL; } From f562661146e04813207a692eec5295616a3bf00d Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Tue, 9 Apr 2019 10:47:38 +0800 Subject: [PATCH 09/19] use 0xff for alpha of RGB2Pixel --- include/gdi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/gdi.h b/include/gdi.h index 068ce12a..a997846f 100644 --- a/include/gdi.h +++ b/include/gdi.h @@ -2769,7 +2769,7 @@ MG_EXPORT void GUIAPI RGB2Pixels (HDC hdc, const RGB* rgbs, */ static inline gal_pixel RGB2Pixel (HDC hdc, Uint8 r, Uint8 g, Uint8 b) { - RGB rgb = {r, g, b, 0}; + RGB rgb = {r, g, b, 0xFF}; gal_pixel pixel; RGB2Pixels (hdc, &rgb, &pixel, 1); From 9475ff227fb0b7161e20dc2cfdc220cc81f9c7b3 Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Tue, 9 Apr 2019 10:57:30 +0800 Subject: [PATCH 10/19] add LoadDevFontFromIncoreData --- include/gdi.h | 21 +++++- src/font/devfont.c | 171 +++++++++++++++++++++++++++++---------------- 2 files changed, 127 insertions(+), 65 deletions(-) diff --git a/include/gdi.h b/include/gdi.h index a997846f..5bc6ec46 100644 --- a/include/gdi.h +++ b/include/gdi.h @@ -6258,7 +6258,6 @@ MG_EXPORT BOOL GUIAPI ft2SetLcdFilter (LOGFONT* logfont, mg_FT_LcdFilter filter) #endif -#if defined(_MGFONT_QPF) || defined(_MGFONT_FT2) || defined(_MGFONT_TTF) || defined(_MGFONT_UPF) /** * \fn DEVFONT* GUIAPI LoadDevFontFromFile (const char* devfont_name, \ * const char* file_name) @@ -6275,9 +6274,26 @@ MG_EXPORT BOOL GUIAPI ft2SetLcdFilter (LOGFONT* logfont, mg_FT_LcdFilter filter) * * \sa GetNextDevFont, DestroyDynamicDevFont */ -MG_EXPORT DEVFONT* GUIAPI LoadDevFontFromFile (const char *devfont_name, +MG_EXPORT DEVFONT* GUIAPI LoadDevFontFromFile (const char *devfont_name, const char *file_name); +/** + * \fn DEVFONT* GUIAPI LoadDevFontFromIncoreData (const char* devfont_name, \ + * const void* data) + * \brief Load device font from incore data. + * + * This function can be used to load device font from incore data. + * + * \param devfont_name The device font name. + * \param data The pointer to the incore font data. + * + * \return the pointer to the new device font on success, NULL on error. + * + * \sa GetNextDevFont, DestroyDynamicDevFont + */ +MG_EXPORT DEVFONT* GUIAPI LoadDevFontFromIncoreData (const char *devfont_name, + const void *data); + /** * \fn void GUIAPI DestroyDynamicDevFont (DEVFONT **devfont) * \brief Destroy device font loaded dynamically from font file. @@ -6288,7 +6304,6 @@ MG_EXPORT DEVFONT* GUIAPI LoadDevFontFromFile (const char *devfont_name, * \sa LoadDevFontFromFile */ MG_EXPORT void GUIAPI DestroyDynamicDevFont (DEVFONT **devfont); -#endif /** @} end of font_fns */ diff --git a/src/font/devfont.c b/src/font/devfont.c index e514e918..64a01137 100644 --- a/src/font/devfont.c +++ b/src/font/devfont.c @@ -1,33 +1,33 @@ /* - * This file is part of MiniGUI, a mature cross-platform windowing + * This file is part of MiniGUI, a mature cross-platform windowing * and Graphics User Interface (GUI) support system for embedded systems * and smart IoT devices. - * + * * Copyright (C) 2002~2018, Beijing FMSoft Technologies Co., Ltd. * Copyright (C) 1998~2002, WEI Yongming - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * + * * Or, - * + * * As this program is a library, any link to this program must follow * GNU General Public License version 3 (GPLv3). If you cannot accept * GPLv3, you need to be licensed from FMSoft. - * + * * If you have got a commercial license of this program, please use it * under the terms and conditions of the commercial license. - * + * * For more information about the commercial license, please refer to * . */ @@ -103,7 +103,7 @@ void font_ResetDevFont (void) #define MATCHED_FAMILY 0x02 #define MATCHED_CHARSET 0x04 -static DEVFONT* get_matched_devfont (LOGFONT* log_font, DEVFONT* list_head, +static DEVFONT* get_matched_devfont (LOGFONT* log_font, DEVFONT* list_head, int list_len, char* req_charset) { int i = 0; @@ -160,8 +160,8 @@ static DEVFONT* get_matched_devfont (LOGFONT* log_font, DEVFONT* list_head, if ((match_bits [i] & MATCHED_TYPE) && (match_bits [i] & MATCHED_FAMILY) && (match_bits [i] & MATCHED_CHARSET)) { - error = log_font->size - - (*dev_font->font_ops->get_font_size) (log_font, dev_font, + error = log_font->size - + (*dev_font->font_ops->get_font_size) (log_font, dev_font, log_font->size); error = ABS (error); if (min_error >= error) { /* use >=, make the later has a higher priority */ @@ -178,7 +178,7 @@ static DEVFONT* get_matched_devfont (LOGFONT* log_font, DEVFONT* list_head, FreeFixStr ((char*)match_bits); #endif - matched_font->font_ops->get_font_size (log_font, matched_font, + matched_font->font_ops->get_font_size (log_font, matched_font, log_font->size); return matched_font; @@ -189,7 +189,7 @@ static DEVFONT* get_matched_devfont (LOGFONT* log_font, DEVFONT* list_head, for (i = 0; i < list_len; i++) { int error; if (match_bits [i] & MATCHED_CHARSET) { - error = log_font->size - + error = log_font->size - (*dev_font->font_ops->get_font_size) (log_font, dev_font, log_font->size); error = ABS (error); if (min_error >= error) { /* use >=, make the later has a higher priority */ @@ -218,12 +218,12 @@ DEVFONT* font_GetMatchedSBDevFont (LOGFONT* log_font) /*mbc logfont --- sbc devfont*/ char sysfont_charset [LEN_FONT_NAME + 1]; fontGetCharsetFromName (g_SysLogFont[0]->sbc_devfont->name, sysfont_charset); - matched_devfont = get_matched_devfont (log_font, sb_dev_font_head, + matched_devfont = get_matched_devfont (log_font, sb_dev_font_head, nr_sb_dev_fonts, sysfont_charset); } else { /*sbc logfont --- sbc devfont*/ - matched_devfont = get_matched_devfont (log_font, sb_dev_font_head, + matched_devfont = get_matched_devfont (log_font, sb_dev_font_head, nr_sb_dev_fonts,log_font->charset); } @@ -240,7 +240,7 @@ DEVFONT* font_GetMatchedMBDevFont (LOGFONT* log_font) return NULL; /*mbc logfont --- mbc devfont*/ else - return get_matched_devfont (log_font, mb_dev_font_head, + return get_matched_devfont (log_font, mb_dev_font_head, nr_mb_dev_fonts, log_font->charset); } @@ -265,7 +265,7 @@ unsigned short font_GetBestScaleFactor (int height, int expect) { int error, min_error; unsigned short scale = 1; - + min_error = height - expect; min_error = ABS (min_error); @@ -322,10 +322,10 @@ void dbg_dumpDevFonts (void) /***** Added in MiniGUI V2.2 for bitmap font *****/ -/* +/* * Removes an element from single-byte devfont linked list. If two elements * contain the same data, only the first is removed. If none of the elements - * contain the data, the single-byte devfont linked list is unchanged + * contain the data, the single-byte devfont linked list is unchanged */ void font_DelSBDevFont (DEVFONT* dev_font) { @@ -334,27 +334,27 @@ void font_DelSBDevFont (DEVFONT* dev_font) tmp = sb_dev_font_head; while (tmp != NULL) { if (tmp == dev_font) { - if (prev != NULL) + if (prev != NULL) prev->next = tmp->next; - else + else sb_dev_font_head = tmp->next; nr_sb_dev_fonts --; - - break; + + break; } - + prev = tmp; tmp = prev->next; } - + return; } -/* +/* * Removes an element from multiple-byte devfont linked list. If two elements * contain the same data, only the first is removed. If none of the elements - * contain the data, the multiple-byte devfont linked list is unchanged + * contain the data, the multiple-byte devfont linked list is unchanged */ void font_DelMBDevFont (DEVFONT* dev_font) { @@ -369,31 +369,55 @@ void font_DelMBDevFont (DEVFONT* dev_font) mb_dev_font_head = tmp->next; nr_mb_dev_fonts --; - - break; + + break; } prev = tmp; tmp = prev->next; } - + return; } ////////////////////////////////////////////////////////////////////// -static DEVFONT* make_devfont (const char* font_name, void* data, BOOL is_filename) +static DEVFONT* find_devfont(const char* font_name, BOOL is_mbc_list) +{ + DEVFONT* head; + DEVFONT* cur; + + if (is_mbc_list) { + head = mb_dev_font_head; + } + else { + head = sb_dev_font_head; + } + + cur = head; + while (cur) { + if (strcasecmp (cur->name, font_name) == 0) { + return cur; + } + + cur = cur->next; + } + + return NULL; +} + +static DEVFONT* make_devfont (const char* font_name, const void* data, BOOL is_filename) { FONTOPS_INFO* fontops_info = __mg_fontops_infos; DEVFONT* devfont; CHARSETOPS* charset_ops; char charset [LEN_FONT_NAME + 1]; - + /*find the FONTOPS and LOADER*/ while (fontops_info->type) { if (strncmp (font_name, fontops_info->type, FONT_TYPE_NAME_LEN) == 0) break; fontops_info++; } - + if (fontops_info->type == NULL) { _MG_PRINTF ("FONT>DevFont: invalid font type: %s.\n", font_name); return NULL; @@ -406,11 +430,17 @@ static DEVFONT* make_devfont (const char* font_name, void* data, BOOL is_filenam } if ((charset_ops = GetCharsetOpsEx (charset)) == NULL) { - _MG_PRINTF ("FONT>DevFont: Invalid charset name %s of font %s.\n", + _MG_PRINTF ("FONT>DevFont: Invalid charset name %s of font %s.\n", charset, font_name); return NULL; } + if (find_devfont(font_name, (charset_ops->bytes_maxlen_char > 1))) { + _MG_PRINTF ("FONT>DevFont: Duplicated devfont name (%s)", + font_name); + return NULL; + } + devfont = calloc (1, sizeof (DEVFONT)); devfont->font_ops = fontops_info->fontops; @@ -421,7 +451,7 @@ static DEVFONT* make_devfont (const char* font_name, void* data, BOOL is_filenam devfont->data = devfont->font_ops->load_font_data (font_name, data); if (devfont->data == NULL) { - _MG_PRINTF ("FONT>DevFont: error in loading font %s from %s file.\n", + _MG_PRINTF ("FONT>DevFont: error in loading font %s from %s file.\n", font_name, (const char*) data); free (devfont); return NULL; @@ -429,7 +459,7 @@ static DEVFONT* make_devfont (const char* font_name, void* data, BOOL is_filenam devfont->need_unload = TRUE; } else { - devfont->data = data; + devfont->data = (void*)data; devfont->need_unload = FALSE; } @@ -562,7 +592,7 @@ static UPFINFO* incore_upfonts [] = { &__mgif_upf_times_12x10, &__mgif_upf_times_17x14, #endif - NULL + NULL }; #define NR_UPFONTS (sizeof (incore_upfonts) / sizeof (UPFINFO*)) @@ -649,7 +679,7 @@ static void del_all_devfonts (void) DEVFONT* cur; DEVFONT* head; - head = sb_dev_font_head; + head = sb_dev_font_head; one_list: cur = head; while (cur) { @@ -674,8 +704,8 @@ one_list: */ -static inline void del_devfont_from_list(const char* font_name, BOOL is_mbc_list) -{ +static inline void del_devfont_from_list(const char* font_name, BOOL is_mbc_list) +{ DEVFONT* head; DEVFONT* cur; DEVFONT* prev; @@ -691,11 +721,11 @@ static inline void del_devfont_from_list(const char* font_name, BOOL is_mbc_list prev = NULL; } - while (cur) { - if (strcmp (cur->name, font_name) == 0) { - /*unload cur->data*/ - if (!cur->relationship && cur->need_unload) - cur->font_ops->unload_font_data (cur->data); + while (cur) { + if (strcmp (cur->name, font_name) == 0) { + /*unload cur->data*/ + if (!cur->relationship && cur->need_unload) + cur->font_ops->unload_font_data (cur->data); if (cur == head) { cur = cur->next; @@ -705,20 +735,20 @@ static inline void del_devfont_from_list(const char* font_name, BOOL is_mbc_list } else { prev->next = cur->next; - free (cur); - cur = prev->next; + free (cur); + cur = prev->next; } if (is_mbc_list) nr_mb_dev_fonts--; else nr_sb_dev_fonts--; - } - else { + } + else { prev = cur; cur = cur->next; - } - } + } + } if (is_mbc_list) mb_dev_font_head = head; @@ -738,10 +768,22 @@ static void font_DelDevFont (const char* font_name) del_devfont_from_list(font_name, FALSE); } -DEVFONT* GUIAPI LoadDevFontFromFile - (const char *devfont_name, const char *file_name) +DEVFONT* GUIAPI LoadDevFontFromIncoreData(const char *devfont_name, + const void *data) { - DEVFONT* devfont = make_devfont (devfont_name, (char*)file_name, TRUE); + DEVFONT* devfont = make_devfont (devfont_name, data, FALSE); + if (devfont == NULL) + return NULL; + + ADD_DEVFONT_TO_LINKLIST (devfont); + add_relating_devfonts_to_list (devfont); + return devfont; +} + +DEVFONT* GUIAPI LoadDevFontFromFile(const char *devfont_name, + const char *file_name) +{ + DEVFONT* devfont = make_devfont (devfont_name, file_name, TRUE); if (devfont == NULL) return NULL; @@ -752,7 +794,12 @@ DEVFONT* GUIAPI LoadDevFontFromFile void GUIAPI DestroyDynamicDevFont (DEVFONT** devfont) { - font_DelDevFont ((*devfont)->name); + char font_name [LEN_UNIDEVFONT_NAME + 1]; + + memset(font_name, 0, LEN_UNIDEVFONT_NAME + 1); + strncpy(font_name, (*devfont)->name, LEN_UNIDEVFONT_NAME); + + font_DelDevFont (font_name); *devfont = NULL; } @@ -763,13 +810,13 @@ static BOOL init_or_term_specifical_fonts (char* etc_section, BOOL is_unload) char font_name [LEN_UNIDEVFONT_NAME + 1]; char font_file [MAX_PATH+1]; char font_path [MAX_PATH+1]; - char *font_file_name = NULL; - MEM_RES* memres = NULL; + char *font_file_name = NULL; + MEM_RES* memres = NULL; char key[12]; int added_num = 0; - font_file_name = font_file; + font_file_name = font_file; /*get font number in minigui etc*/ if (GetMgEtcIntValue (etc_section, "font_number", &font_num) < 0 ) { @@ -782,14 +829,14 @@ static BOOL init_or_term_specifical_fonts (char* etc_section, BOOL is_unload) for (i=0; iDevFont: can't get name of key %s in section %s.\n", + _MG_PRINTF ("FONT>DevFont: can't get name of key %s in section %s.\n", key, etc_section); continue; } snprintf (key, sizeof(key)-1, "fontfile%d", i); if (GetMgEtcValue (etc_section, key, font_file_name, MAX_PATH) < 0) { - _MG_PRINTF ("FONT>DevFont: can't get font_file of key %s in section %s.\n", + _MG_PRINTF ("FONT>DevFont: can't get font_file of key %s in section %s.\n", key, etc_section); continue; } @@ -808,7 +855,7 @@ static BOOL init_or_term_specifical_fonts (char* etc_section, BOOL is_unload) else { /* [DK] Fix Bug #4801, which introduce a absolute path check error in Windows, * first to load from sytem res path, else load it directly(relative or absolute path).*/ - if ((0 == mg_path_joint(font_path, MAX_PATH + 1, sysres_get_system_res_path(), font_file)) + if ((0 == mg_path_joint(font_path, MAX_PATH + 1, sysres_get_system_res_path(), font_file)) && ((AddDevFont (font_name, font_path, TRUE)) == TRUE)) added_num++; else if ((AddDevFont (font_name, font_file, TRUE)) == TRUE) From 79267be62c9c386ea949dab987f46512058ae075 Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Thu, 11 Apr 2019 17:36:02 +0800 Subject: [PATCH 11/19] use sys/sysmacros.h for makedev --- src/ial/native/kbd_event.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ial/native/kbd_event.c b/src/ial/native/kbd_event.c index 3e5b0911..341e511c 100644 --- a/src/ial/native/kbd_event.c +++ b/src/ial/native/kbd_event.c @@ -37,6 +37,7 @@ #include #include +#include // for makedev #include #include #include From 06c497d671ad6c4ef13453767866a9b6ec4a2fad Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Fri, 12 Apr 2019 14:39:02 +0800 Subject: [PATCH 12/19] tune --- src/newgdi/glyph.c | 2 +- src/newgdi/logfont.c | 362 ------------------------------------------- 2 files changed, 1 insertion(+), 363 deletions(-) delete mode 100644 src/newgdi/logfont.c diff --git a/src/newgdi/glyph.c b/src/newgdi/glyph.c index 39ea66a7..91465878 100644 --- a/src/newgdi/glyph.c +++ b/src/newgdi/glyph.c @@ -297,7 +297,7 @@ int GUIAPI GetGlyphInfo (LOGFONT* logfont, Glyph32 glyph_value, return advance; } -void GUIAPI inline GetGlyphBitmap (LOGFONT* logfont, const char* mchar, +void GUIAPI GetGlyphBitmap (LOGFONT* logfont, const char* mchar, int mchar_len, GLYPHBITMAP* glyph_bitmap) { GLYPHINFO glyph_info; diff --git a/src/newgdi/logfont.c b/src/newgdi/logfont.c deleted file mode 100644 index e7fc26c1..00000000 --- a/src/newgdi/logfont.c +++ /dev/null @@ -1,362 +0,0 @@ -/* - * This file is part of MiniGUI, a mature cross-platform windowing - * and Graphics User Interface (GUI) support system for embedded systems - * and smart IoT devices. - * - * Copyright (C) 2002~2018, Beijing FMSoft Technologies Co., Ltd. - * Copyright (C) 1998~2002, WEI Yongming - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * Or, - * - * As this program is a library, any link to this program must follow - * GNU General Public License version 3 (GPLv3). If you cannot accept - * GPLv3, you need to be licensed from FMSoft. - * - * If you have got a commercial license of this program, please use it - * under the terms and conditions of the commercial license. - * - * For more information about the commercial license, please refer to - * . - */ -/* -** logfont.c: Log fonts management. -** -** Current maintainer: Wei Yongming. -** -** Created by Wei Yongming -** -** Create date: 2000/07/07 -*/ - -#include -#include -#include - -#include "common.h" -#include "minigui.h" -#include "gdi.h" -#include "window.h" -#include "cliprect.h" -#include "gal.h" -#include "internals.h" -#include "ctrlclass.h" -#include "dc.h" - -#include "sysfont.h" -#include "devfont.h" -#include "fontname.h" - -CHARSETOPS* GetCharsetOps (const char* charset_name); - -/************************** Exported functions ******************************/ -static PLOGFONT gdiCreateLogFont ( const char* type, const char* family, - const char* charset, DWORD style, int size, int rotation) -{ - PLOGFONT log_font; - int sbc_descent, mbc_descent = 0; - char dev_family [LEN_FONT_NAME + 1]; - DEVFONT* sbc_devfont, *mbc_devfont; - - // is valid style? - if (style == 0xFFFFFFFF) - return INV_LOGFONT; - - // is supported charset? - if (GetCharsetOps (charset) == NULL) { - return INV_LOGFONT; - } - - if ((log_font = malloc (sizeof (LOGFONT))) == NULL) - return INV_LOGFONT; - - log_font->style = style; - -#if 0 - fprintf (stderr, "LogFont: style: %x\n", log_font->style); -#endif - - if (type) { - strncpy (log_font->type, type, LEN_FONT_NAME); - log_font->type [LEN_FONT_NAME] = '\0'; - } - else - strcpy (log_font->type, FONT_TYPE_NAME_ALL); - - strncpy (log_font->family, family, LEN_FONT_NAME); - log_font->family [LEN_FONT_NAME] = '\0'; - - strncpy (log_font->charset, charset, LEN_FONT_NAME); - log_font->charset [LEN_FONT_NAME] = '\0'; - - if (size > FONT_MAX_SIZE) - log_font->size = FONT_MAX_SIZE; - else if (size < FONT_MIN_SIZE) - log_font->size = FONT_MIN_SIZE; - else - log_font->size = size; - - log_font->rotation = rotation; - -#if 0 - fprintf (stderr, "log_font: %s, %s, %s, %d.\n", - log_font->type, log_font->family, log_font->charset, - log_font->size); -#endif - - sbc_devfont = font_GetMatchedSBDevFont (log_font); - if (sbc_devfont->font_ops->new_instance) - sbc_devfont = (*sbc_devfont->font_ops->new_instance) (log_font, sbc_devfont, TRUE); - if (sbc_devfont == NULL) { - free (log_font); - return INV_LOGFONT; - } - - mbc_devfont = font_GetMatchedMBDevFont (log_font); - if (mbc_devfont && mbc_devfont->font_ops->new_instance) - mbc_devfont = (*mbc_devfont->font_ops->new_instance) (log_font, mbc_devfont, FALSE); - - log_font->sbc_devfont = sbc_devfont; - log_font->mbc_devfont = mbc_devfont; - - /* - * Adjust the logical font information - */ - - // family name - if (log_font->mbc_devfont) { - fontGetFamilyFromName (log_font->mbc_devfont->name, dev_family); - strncpy (log_font->family, dev_family, LEN_FONT_NAME); - log_font->family [LEN_FONT_NAME] = '\0'; - } - else { - fontGetFamilyFromName (log_font->sbc_devfont->name, dev_family); - strncpy (log_font->family, dev_family, LEN_FONT_NAME); - log_font->family [LEN_FONT_NAME] = '\0'; - } - - // charset name - if (log_font->mbc_devfont) { - strncpy (log_font->charset, - log_font->mbc_devfont->charset_ops->name, LEN_FONT_NAME); - log_font->charset [LEN_FONT_NAME] = '\0'; - } - else { - strncpy (log_font->charset, - log_font->sbc_devfont->charset_ops->name, LEN_FONT_NAME); - log_font->charset [LEN_FONT_NAME] = '\0'; - } - - // size - log_font->size = (*log_font->sbc_devfont->font_ops->get_font_height) - (log_font, log_font->sbc_devfont); - - if (log_font->mbc_devfont) { - int size = (*log_font->mbc_devfont->font_ops->get_font_height) - (log_font, log_font->mbc_devfont); - - if (size > log_font->size) - log_font->size = size; - } - - sbc_descent = (*log_font->sbc_devfont->font_ops->get_font_descent) - (log_font, log_font->sbc_devfont); - - if (log_font->mbc_devfont) { - mbc_descent = (*log_font->mbc_devfont->font_ops->get_font_descent) - (log_font, log_font->mbc_devfont); - } - else - mbc_descent = sbc_descent; - - log_font->size += ABS (sbc_descent - mbc_descent); - - return log_font; -} - -PLOGFONT GUIAPI CreateLogFontIndirect (LOGFONT *logfont) -{ - return gdiCreateLogFont (logfont->type, logfont->family, - logfont->charset, logfont->style, logfont->size, logfont->rotation); -} - -PLOGFONT GUIAPI CreateLogFont (const char* type, const char* family, - const char* charset, char weight, char slant, char set_width, - char spacing, char underline, char struckout, int size, int rotation) -{ - DWORD style; - char style_name [7]; - style_name[0] = weight; - style_name[1] = slant; - style_name[2] = set_width; - style_name[3] = spacing; - style_name[4] = underline; - style_name[5] = struckout; - style_name[6] = 0; - - if ((style = fontConvertStyle (style_name)) == 0xFFFFFFFF) { - return INV_LOGFONT; - } - - return gdiCreateLogFont (type, family, charset, style, size, rotation); -} - -PLOGFONT GUIAPI CreateLogFontByName (const char* font_name) -{ - char type[LEN_FONT_NAME + 1]; - char family[LEN_FONT_NAME + 1]; - char charset[LEN_FONT_NAME + 1]; - DWORD style; - int height; - - if (!fontGetTypeNameFromName (font_name, type) || - !fontGetFamilyFromName (font_name, family) || - !fontGetCharsetFromName (font_name, charset) || - ((height = fontGetHeightFromName (font_name)) == -1) || - ((style = fontGetStyleFromName (font_name)) == 0xFFFFFFFF)) - return NULL; - - return gdiCreateLogFont (type, family, charset, style, height, 0); -} - -void GUIAPI DestroyLogFont (PLOGFONT log_font) -{ - LOGFONT* logfont = (PLOGFONT)log_font; - - if (log_font == NULL) - return; - - if (logfont->sbc_devfont->font_ops->delete_instance) - (*logfont->sbc_devfont->font_ops->delete_instance) (logfont->sbc_devfont); - if (logfont->mbc_devfont && logfont->mbc_devfont->font_ops->delete_instance) - (*logfont->mbc_devfont->font_ops->delete_instance) (logfont->mbc_devfont); - - free (logfont); -} - -void GUIAPI GetLogFontInfo (HDC hdc, LOGFONT* log_font) -{ - memcpy (log_font, dc_HDC2PDC (hdc)->pLogFont, sizeof (LOGFONT)); -} - -void GUIAPI GetFontMetrics (LOGFONT* log_font, FONTMETRICS* font_metrics) -{ - int sbc_value, mbc_value; - - sbc_value = log_font->sbc_devfont->font_ops->get_font_height (log_font, log_font->sbc_devfont); - if (log_font->mbc_devfont) { - mbc_value = log_font->mbc_devfont->font_ops->get_font_height (log_font, log_font->mbc_devfont); - font_metrics->font_height = MAX (sbc_value, mbc_value); - } - else { - font_metrics->font_height = sbc_value; - } - - sbc_value = log_font->sbc_devfont->font_ops->get_font_ascent (log_font, log_font->sbc_devfont); - if (log_font->mbc_devfont) { - mbc_value = log_font->mbc_devfont->font_ops->get_font_ascent (log_font, log_font->mbc_devfont); - font_metrics->ascent = MAX (sbc_value, mbc_value); - } - else { - font_metrics->ascent = sbc_value; - } - - sbc_value = log_font->sbc_devfont->font_ops->get_font_descent (log_font, log_font->sbc_devfont); - if (log_font->mbc_devfont) { - mbc_value = log_font->mbc_devfont->font_ops->get_font_descent (log_font, log_font->mbc_devfont); - font_metrics->descent = MAX (sbc_value, mbc_value); - } - else { - font_metrics->descent = sbc_value; - } - - sbc_value = log_font->sbc_devfont->font_ops->get_max_width (log_font, log_font->sbc_devfont); - if (log_font->mbc_devfont) { - mbc_value = log_font->mbc_devfont->font_ops->get_max_width (log_font, log_font->mbc_devfont); - font_metrics->max_width = MAX (sbc_value, mbc_value); - } - else { - font_metrics->max_width = sbc_value; - } - - sbc_value = log_font->sbc_devfont->font_ops->get_ave_width (log_font, log_font->sbc_devfont); - if (log_font->mbc_devfont) { - mbc_value = log_font->mbc_devfont->font_ops->get_ave_width (log_font, log_font->mbc_devfont); - font_metrics->ave_width = mbc_value; - } - else { - font_metrics->ave_width = sbc_value; - } -} - -void GUIAPI GetGlyphBitmap (LOGFONT* log_font, const unsigned char* mchar, int mchar_len, - GLYPHBITMAP* glyph_bitmap) -{ - DEVFONT* sbc_devfont = log_font->sbc_devfont; - DEVFONT* mbc_devfont = log_font->mbc_devfont; - DEVFONT* devfont; - - if (mbc_devfont) { - int mbc_pos; - - mbc_pos = mbc_devfont->charset_ops->pos_first_char(mchar, mchar_len); - if (mbc_pos == 0) { - devfont = mbc_devfont; - } - else { - devfont = sbc_devfont; - } - } - else { - devfont = sbc_devfont; - } - - if (devfont->font_ops->get_char_bbox) { - glyph_bitmap->bbox_x = 0; - glyph_bitmap->bbox_y = 0; - devfont->font_ops->get_char_bbox (log_font, devfont, mchar, mchar_len, - &glyph_bitmap->bbox_x, - &glyph_bitmap->bbox_y, - &glyph_bitmap->bbox_w, - &glyph_bitmap->bbox_h); - } - else { - glyph_bitmap->bbox_x = 0; - glyph_bitmap->bbox_y = devfont->font_ops->get_font_descent (log_font, devfont); - glyph_bitmap->bbox_w = devfont->font_ops->get_char_width (log_font, devfont, mchar, mchar_len); - glyph_bitmap->bbox_h = devfont->font_ops->get_font_height (log_font, devfont); - } - - if (devfont->font_ops->get_char_advance) { - devfont->font_ops->get_char_advance (log_font, devfont, mchar, mchar_len, - &glyph_bitmap->advance_x, - &glyph_bitmap->advance_y); - } - else { - glyph_bitmap->advance_x = glyph_bitmap->bbox_w; - glyph_bitmap->advance_y = 0; - } - - devfont->font_ops->get_char_advance (log_font, devfont, mchar, mchar_len, - &glyph_bitmap->advance_x, - &glyph_bitmap->advance_y); - - glyph_bitmap->bmp_size = devfont->font_ops->char_bitmap_size (log_font, devfont, mchar, mchar_len); - - glyph_bitmap->bmp_pitch = (glyph_bitmap->bbox_w + 7) >> 3; - - glyph_bitmap->bits = devfont->font_ops->get_char_bitmap (log_font, devfont, mchar, mchar_len); -} - From 6dc8696c08dc5147808b06fab3725fad02017c12 Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Fri, 12 Apr 2019 15:41:23 +0800 Subject: [PATCH 13/19] Remove char_type and bidi_type from GLYPHINFO --- RELEASE-NOTES.md | 5 +---- include/gdi.h | 16 +++------------- src/newgdi/glyph.c | 14 -------------- 3 files changed, 4 insertions(+), 31 deletions(-) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index b7e5fdd7..e9ff9bf3 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -32,7 +32,7 @@ Please report any bugs and incompatibilities in 1. Enhance commlcd engint to support more pixel type and synchronously update. 1. New USVFB IAL engine and NEWGAL engine for web display server. 1. New type: `QDWORD` for a quauter of DWORD. This type is 16-bit long on -64-bit architecture, and 8-bit long on 32-bit. + 64-bit architecture, and 8-bit long on 32-bit. 1. New macros for QDWORD: * `MAKEDWORD`: Make a DWROD from four QDWORDs. * `FIRST_QDWORD`: get the first (LSB) QDWORD from a DWORD. @@ -51,9 +51,6 @@ Please report any bugs and incompatibilities in 1. Tune cache implementation of FreeType2 font engine. * Enable cache for rotated LOGFONT. -* TUNNING: - 1. Tune GLYPHINFO structure and GetGlyphInfo to return BIDI glyph type. - ## Version 3.2.0 The MiniGUI development team announces the availability of MiniGUI 3.2.0. diff --git a/include/gdi.h b/include/gdi.h index 5bc6ec46..35ea01a4 100644 --- a/include/gdi.h +++ b/include/gdi.h @@ -8775,10 +8775,8 @@ MG_EXPORT int GUIAPI DrawGlyph (HDC hdc, int x, int y, Glyph32 glyph_value, MG_EXPORT int GUIAPI DrawGlyphString (HDC hdc, int x, int y, Glyph32* glyph_string, int len, int* adv_x, int* adv_y); -#define GLYPH_INFO_TYPE 0x01 -#define GLYPH_INFO_BIDI_TYPE 0x02 -#define GLYPH_INFO_METRICS 0x04 -#define GLYPH_INFO_BMP 0x10 +#define GLYPH_INFO_METRICS 0x01 +#define GLYPH_INFO_BMP 0x02 /*the type of glyph bitmap*/ #define GLYPHBMP_TYPE_MONO 0x00 @@ -8795,18 +8793,10 @@ typedef struct _GLYPHINFO /** * The mask indicates if you want to get glyph type info, metrics, * or bitmap infomation you want. Or'ed with the following values: - * - GLYPH_INFO_TYPE - * - GLYPH_INFO_BIDI_TYPE * - GLYPH_INFO_METRICS * - GLYPH_INFO_BMP */ - unsigned char mask; - - /** The basic glyph type */ - unsigned int glyph_type; - - /** The BIDI glyph type */ - unsigned int bidi_glyph_type; + Uint32 mask; /** The height of the glyph */ int height; diff --git a/src/newgdi/glyph.c b/src/newgdi/glyph.c index 91465878..91da77cf 100644 --- a/src/newgdi/glyph.c +++ b/src/newgdi/glyph.c @@ -209,20 +209,6 @@ int GUIAPI GetGlyphInfo (LOGFONT* logfont, Glyph32 glyph_value, DEVFONT* devfont = SELECT_DEVFONT(logfont, glyph_value); glyph_value = REAL_GLYPH (glyph_value); - /*get glyph type*/ - if (glyph_info->mask & GLYPH_INFO_TYPE) - glyph_info->glyph_type = devfont->charset_ops->glyph_type (glyph_value); - - /*get glyph type*/ - if (glyph_info->mask & GLYPH_INFO_BIDI_TYPE) { - if (devfont->charset_ops->bidi_glyph_type) { - glyph_info->bidi_glyph_type = devfont->charset_ops->bidi_glyph_type (glyph_value); - } - else { - glyph_info->bidi_glyph_type = BIDI_TYPE_INVALID; - } - } - glyph_info->advance_x = 0; glyph_info->advance_y = 0; glyph_info->bbox_x = 0; From 4fa002216ef9e5fa6f82a68c9537b952f50ab8f1 Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Fri, 12 Apr 2019 15:49:42 +0800 Subject: [PATCH 14/19] tune release notes --- RELEASE-NOTES.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index e9ff9bf3..92691005 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -39,6 +39,8 @@ Please report any bugs and incompatibilities in * `SECOND_QDWORD`: get the second (LSB) QDWORD from a DWORD. * `THIRD_QDWORD`: get the third (LSB) QDWORD from a DWORD. * `FOURTH_QDWORD`: get the fourth (LSB) QDWORD from a DWORD. + 1. New header for CommLCD NEWGAL engine and COMM IAL engine: + ``. * BUGFIXING: 1. handle `PNG_COLOR_TYPE_GRAY_ALPHA` color type of PNG files. From 4f51baac32f493ab924c0a5865cbe94e66cdcc30 Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Mon, 15 Apr 2019 10:12:25 +0800 Subject: [PATCH 15/19] tune --- README.md | 216 +++++++++++++++++++++++++++--------------------------- 1 file changed, 108 insertions(+), 108 deletions(-) diff --git a/README.md b/README.md index 950fd48e..cd78ea7a 100644 --- a/README.md +++ b/README.md @@ -5,55 +5,55 @@ A mature and proven cross-platform GUI system for embedded and smart IoT devices ## TABLE OF CONTENTS - 1. Introduction - 1. A brief building instruction - 1. New features in version 3.2.x - 1. The runtime modes of MiniGUI - 1. History - 1. About the authors - 1. If you have a problem - 1. A little FAQ - 1. Not free for commercial use + 1. Introduction + 1. A brief building instruction + 1. New features in version 3.2.x + 1. The runtime modes of MiniGUI + 1. History + 1. About the authors + 1. If you have a problem + 1. A little FAQ + 1. Not free for commercial use 1. Copying ## INTRODUCTION - -MiniGUI is a mature cross-platform windowing system and a GUI (Graphics + +MiniGUI is a mature cross-platform windowing system and a GUI (Graphics User Interface) support system for embedded systems and smart IoT devices. -This is the version 3.2.x of MiniGUI maintained by WEI Yongming +This is the version 3.2.x of MiniGUI maintained by WEI Yongming (Vincent Wei, https://github.com/VincentWei). MiniGUI is released under GPLv3 and the dual-licensing applies to commercial use. MiniGUI aims to provide a fast, stable, full-featured, and cross-platform -windowing and GUI support system, which is especially fit for -embedded systems or smart IoT devices based-on Linux/uClinux, eCos, and other -traditional RTOSes, such as VxWorks, ThreadX, Nucleus, pSOS, uC/OS-II, +windowing and GUI support system, which is especially fit for +embedded systems or smart IoT devices based-on Linux/uClinux, eCos, and other +traditional RTOSes, such as VxWorks, ThreadX, Nucleus, pSOS, uC/OS-II, and OSE. -This is the MiniGUI core source tree, which provides windowing -and graphics interfaces as well as a lot of standard controls (tookit). +This is the MiniGUI core source tree, which provides windowing +and graphics interfaces as well as a lot of standard controls (tookit). Besides MiniGUI core, FMSoft also provides some components for the developers to develop app much easier: - * mGUtils: A MiniGUI component which contains miscellaneous utilities - like ColorSelectionDialogBox, FileOpenDialogBox, and so on. + * mGUtils: A MiniGUI component which contains miscellaneous utilities + like ColorSelectionDialogBox, FileOpenDialogBox, and so on. - * mGPlus: A MiniGUI component which provides support for advanced graphics + * mGPlus: A MiniGUI component which provides support for advanced graphics functions like path, gradient, anti-aliase stretch, and color combination. - * mGEff: mGEff provides an animation framework for MiniGUI app. + * mGEff: mGEff provides an animation framework for MiniGUI app. It also provides some popular UI/UE special effects. - * mGNCS: This component provides a new control set for MiniGUI app. - By using mGNCS, you can use miniStudio to develop MiniGUI app in - WYSIWYG way. + * mGNCS: This component provides a new control set for MiniGUI app. + By using mGNCS, you can use miniStudio to develop MiniGUI app in + WYSIWYG way. - * mGNCS4Touch: This component provides some new controls, which are - compliant to the new control API spec of mGNCS, for devices with + * mGNCS4Touch: This component provides some new controls, which are + compliant to the new control API spec of mGNCS, for devices with a touch screen. There are also some legacy MiniGUI components. We will not maintain these @@ -61,7 +61,7 @@ components for MiniGUI core v3.2: * mGi: An input method component for MiniGUI. This component provides some typical input methods (such as softkey, hand-writing, and predict - text input for mobile phone) for MiniGUI apps. + text input for mobile phone) for MiniGUI apps. * mGp: A printing component for MiniGUI. By using mGp, you can print out the graphics created by MiniGUI app to general-purpose printers. @@ -70,11 +70,11 @@ components for MiniGUI core v3.2: provides a simple 3D API for app. You can use mG3d to create simple 3D UI. -MiniGUI is a free software project. In December 1998, the initiator of -FMSoft, Wei Yongming, began to develop MiniGUI under the GNU General Public -License (GPL). In September 2002, the core developers of -MiniGUI founded FMSoft and started the commercial marketing with -the free software. By now, FMSoft still continues to release MiniGUI +MiniGUI is a free software project. In December 1998, the initiator of +FMSoft, Wei Yongming, began to develop MiniGUI under the GNU General Public +License (GPL). In September 2002, the core developers of +MiniGUI founded FMSoft and started the commercial marketing with +the free software. By now, FMSoft still continues to release MiniGUI as a free software project. You can download the source code tarball of MiniGUI and the dependent libraries @@ -82,27 +82,27 @@ from the download zone of the site: http://www.minigui.com -FMSoft also releases some open source apps for MiniGUI on the site above, +FMSoft also releases some open source apps for MiniGUI on the site above, for examples: - * mDolphin, licensed under Apache 2.0, is a full-featured - WEB/WAP browser, which is developed based on the open source browser + * mDolphin, licensed under Apache 2.0, is a full-featured + WEB/WAP browser, which is developed based on the open source browser core WebKit and uses MiniGUI as its underlying graphics support system. - * mGallery, licensed under Apache 2.0, intends to - provide a total solution for PMP (Portable Multimedia Player), + * mGallery, licensed under Apache 2.0, intends to + provide a total solution for PMP (Portable Multimedia Player), which uses MiniGUI as the graphics platform. - * mSpider, licensed under GPL 3.0, intends to provide a + * mSpider, licensed under GPL 3.0, intends to provide a light-weight MiniGUI-based web browser (HTML 3.2 and part JavaScript) - * mEagle, licensed under GPL 3.0, is an embedded GIS development platform + * mEagle, licensed under GPL 3.0, is an embedded GIS development platform which addresses the needs of map browse, query, analysis, etc -FMSoft had created the public repositories for MiniGUI core, MiniGUI +FMSoft had created the public repositories for MiniGUI core, MiniGUI components, and other open source apps on GitHub. You can visit them on: -https://github.com/VincentWei +https://github.com/VincentWei FMSoft also releases miniStudio, which is a WYSIWYG IDE for MiniGUI, as a shareware. You can also download it from the official site of MiniGUI. @@ -154,7 +154,7 @@ We introduce some new features in MiniGUI Version 3.2.x: to support 64-bit platform. For more information, please refer to RELEASE-NOTES.md file. -Because of the changes of some APIs, we recommended strongly that you +Because of the changes of some APIs, we recommended strongly that you use this version for new projects. ## THE RUNTIME MODES OF MINIGUI @@ -164,64 +164,64 @@ You can configure and compile MiniGUI as one of three runtime modes: * 'MiniGUI-Threads': A program running on MiniGUI-Threads can create multiple cascaded windows in different threads, and all the windows belong to a single process. MiniGUI-Threads is fit for some real-time - systems on Linux/uClinux, eCos, uC/OS-II, VxWorks, pSOS, ThreadX, + systems on Linux/uClinux, eCos, uC/OS-II, VxWorks, pSOS, ThreadX, and OSE. - * 'MiniGUI-Processes': A program running on MiniGUI-Processes is - an independent process, which can also create multiple windows. - MiniGUI-Processes is fit for some complex embedded systems, such as - PDAs, Thin-Clients or STBs. This mode is only useful for full-featured + * 'MiniGUI-Processes': A program running on MiniGUI-Processes is + an independent process, which can also create multiple windows. + MiniGUI-Processes is fit for some complex embedded systems, such as + PDAs, Thin-Clients or STBs. This mode is only useful for full-featured UNIX-like operating systems, like Linux. * 'MiniGUI-Standalone': A single process version of MiniGUI. This mode is useful for some small systems, like uClinux or RTOSes. The original MiniGUI (version 1.0) run in MiniGUI-Threads mode. -It is based on POSIX-compliant thread library. And this thread-based -architecture of MiniGUI is very fit for most traditional embedded -operating systems, such as eCos, uC/OS-II, and VxWorks. However, -if you use embedded Linux, the architecture like X Window will have -better stability and scalability, because of the independent memory +It is based on POSIX-compliant thread library. And this thread-based +architecture of MiniGUI is very fit for most traditional embedded +operating systems, such as eCos, uC/OS-II, and VxWorks. However, +if you use embedded Linux, the architecture like X Window will have +better stability and scalability, because of the independent memory address space of every process. Since version 2.0, we provides a new runtime mode called MiniGUI-Processes. -You can use MiniGUI-Processes to run more than one MiniGUI-based -program in the form of UNIX process at the same time. MiniGUI-Processes -is a full-featured multi-process version of original MiniGUI -- You -can run a program based on MiniGUI-Processes from a program called -'mginit'. Just like X Window, the former process is called a client, -and the latter the server. +You can use MiniGUI-Processes to run more than one MiniGUI-based +program in the form of UNIX process at the same time. MiniGUI-Processes +is a full-featured multi-process version of original MiniGUI -- You +can run a program based on MiniGUI-Processes from a program called +'mginit'. Just like X Window, the former process is called a client, +and the latter the server. -Clients connect to the server via UNIX domain socket, and the server -receives and responses requests from clients. The server provides shared -resources for clients, manage window objects, and sends mouse -(or touch screen) and keyboard events to the active top-most client. -If a client exits or dies for some reasons, it will not damage other +Clients connect to the server via UNIX domain socket, and the server +receives and responses requests from clients. The server provides shared +resources for clients, manage window objects, and sends mouse +(or touch screen) and keyboard events to the active top-most client. +If a client exits or dies for some reasons, it will not damage other clients and the server. ## HISTORY -About ten years have pasted since MiniGUI was initially created at -the end of 1998, and now it becomes much reliable and stable. -During the past years, many remarkable changes have taken place in +About ten years have pasted since MiniGUI was initially created at +the end of 1998, and now it becomes much reliable and stable. +During the past years, many remarkable changes have taken place in the MiniGUI project. -At the original, the version 0.2.xx was based on SVGALib and PThread -(LinuxThreads). Then the version 0.3.xx had many enhanced features -including Graphics Abstract Layer (GAL), Input Abstract Layer (IAL), -and the support for multiple charsets and multiple fonts. +At the original, the version 0.2.xx was based on SVGALib and PThread +(LinuxThreads). Then the version 0.3.xx had many enhanced features +including Graphics Abstract Layer (GAL), Input Abstract Layer (IAL), +and the support for multiple charsets and multiple fonts. -In version 1.0.00, we designed MiniGUI-Lite, which was more fit for -some complex embedded systems, such as PDAs, Thin-Clients, or STBs. -MiniGUI-Lite made the embedded systems more stable and efficient. -The version 1.0.00 provided the native fbcon engine based on Linux -frame buffer device directly as well. +In version 1.0.00, we designed MiniGUI-Lite, which was more fit for +some complex embedded systems, such as PDAs, Thin-Clients, or STBs. +MiniGUI-Lite made the embedded systems more stable and efficient. +The version 1.0.00 provided the native fbcon engine based on Linux +frame buffer device directly as well. -In the development of version 1.1.00, we re-wrote the GAL and GDI -interfaces, and provided some advanced video features, such as raster -operation, transparent blitting, alpha blending, and video hardware -acceleration. We also provided some important GDI functions, such as +In the development of version 1.1.00, we re-wrote the GAL and GDI +interfaces, and provided some advanced video features, such as raster +operation, transparent blitting, alpha blending, and video hardware +acceleration. We also provided some important GDI functions, such as Ellipse, Arc, Polygon, and FloodFill. In the development of version 1.6.0, we added advanced 2D graphics @@ -238,7 +238,7 @@ A brief history description of the development progress lay below: 0) 1994 ~ 1996: MiniGUI DOS version. 1) Dec, 1998: Began to write. - 2) Apr, 1999: The skeleton of MiniGUI, windowing sub-system + 2) Apr, 1999: The skeleton of MiniGUI, windowing sub-system and basic graphics device interfaces. 3) May, 1999: Timer, menu, and the skeleton of control sub-system. 4) Jun, 1999: Chinese input method (by Kang Xiaoning). @@ -247,29 +247,29 @@ A brief history description of the development progress lay below: 7) Sep, 1999: Dialog boxes and message boxes. 8) Sep, 1999: Snapshot of screen or window. 9) Jan., 2000: VCOnGUI (Virtual Console on MiniGUI) version 0.2.02. - 10) Mar., 2000: Linux distribution installer based-on MiniGUI for + 10) Mar., 2000: Linux distribution installer based-on MiniGUI for HappyLinux 1.0. 11) Jun., 2000: Began to develop version 1.0.xx. 12) Sep., 2000: MiniGUI version 0.3.06 released. - 13) Oct., 2000: MiniGUI version 0.9.00 released. - 14) Nov., 2000: MiniGUI version 0.9.96 released. - 15) Jan., 2001: MiniGUI version 0.9.98 released. You can build + 13) Oct., 2000: MiniGUI version 0.9.00 released. + 14) Nov., 2000: MiniGUI version 0.9.96 released. + 15) Jan., 2001: MiniGUI version 0.9.98 released. You can build MiniGUI-Lite from this version. 16) Jan., 2001: MiniGUI version 1.0.00Beta1 released. 17) Feb., 2001: MiniGUI version 1.0.00Pre1 released. 18) Apr., 2001: MiniGUI version 1.0.00 released (2001/04/16). 18) Sep., 2001: MiniGUI version 1.1.0Pre1 released (2001/09/12). - 19) Sep., 2001: MiniGUI version 1.0.9 released (2001/09/17), - this will be the last version of source branch 1.0.x. - 20) Oct., 2001: MiniGUI version 1.1.0Pre4 released (2001/10/22). + 19) Sep., 2001: MiniGUI version 1.0.9 released (2001/09/17), + this will be the last version of source branch 1.0.x. + 20) Oct., 2001: MiniGUI version 1.1.0Pre4 released (2001/10/22). This version have new GAL and GDI interfaces. - 21) Mar., 2002: MiniGUI official version 1.1.0 released (2002/03/08). + 21) Mar., 2002: MiniGUI official version 1.1.0 released (2002/03/08). MiniGUI API Reference documentation version 0.9 released. 22) Mar., 2002: MiniGUI API Reference documentation version 1.0 released. - 23) Apr., 2002: MiniGUI the new stable version 1.2.0 released (2002/04/11). - 24) Sep., 2002: The main developers of MiniGUI founded a - new software corporation: Beijing FMSoft Technology Co., Ltd.. - And the development and maintenance of MiniGUI changes from + 23) Apr., 2002: MiniGUI the new stable version 1.2.0 released (2002/04/11). + 24) Sep., 2002: The main developers of MiniGUI founded a + new software corporation: Beijing FMSoft Technology Co., Ltd.. + And the development and maintenance of MiniGUI changes from loosely-knit team to business organization. 25) Mar., 2003: MiniGUI official version 1.2.5 released (2003/03/23). 25) May., 2003: MiniGUI official version 1.2.6 released (2003/05/18). @@ -299,14 +299,14 @@ A brief history description of the development progress lay below: ## ABOUT THE AUTHORS -The original author of MiniGUI is WEI Yongming, and now MiniGUI is -maintained by FMSoft. For more information, please browse +The original author of MiniGUI is WEI Yongming, and now MiniGUI is +maintained by FMSoft. For more information, please browse our home page: http://www.fmsoft.cn. ## IF YOU HAVE A PROBLEM -If you have any technical problem, advice or comment, please send +If you have any technical problem, advice or comment, please send messages to consult@minigui.com. @@ -314,15 +314,15 @@ messages to consult@minigui.com. Q: Is GPL'd MiniGUI free for commercial use? -A: Simply no. FMSoft releases MiniGUI under GPLv3 license. - It is free for those who are 100% GPL and those who never copy, modify - and distribute MiniGUI. But if you want to use these GPL'd versions +A: Simply no. FMSoft releases MiniGUI under GPLv3 license. + It is free for those who are 100% GPL and those who never copy, modify + and distribute MiniGUI. But if you want to use these GPL'd versions for commerce, you should get the commercial license from FMSoft first. Q: Which operating system does MiniGUI support? -A: MiniGUI can run on Linux/uClinux, uC/OS-II, eCos, ThreadX, pSOS, - VxWorks, ThreadX, OSE, and even Win32. Any other real-time OSes can +A: MiniGUI can run on Linux/uClinux, uC/OS-II, eCos, ThreadX, pSOS, + VxWorks, ThreadX, OSE, and even Win32. Any other real-time OSes can be supported theoretically. Q: Which architecture does MiniGUI support? @@ -332,24 +332,24 @@ A: x86 32/64-bit, ARM 32/64-bit (e.g., ARMv7 and ARM Cortex-A7), Q: Does MiniGUI offer the support for grey LCD with 4bpp (bits per pixel)? -A: Yes, it offers. It even offers the support for 1bpp and 2bpp LCD. +A: Yes, it offers. It even offers the support for 1bpp and 2bpp LCD. ## NOT FREE FOR COMMERCIAL USE -MiniGUI and its components are licensed under the GPL license. -So any links about MiniGUI must follow GPL. If you cannot accept GPL, -you need to be licensed from FMSoft. If you wonder that if you need +MiniGUI and its components are licensed under the GPL license. +So any links about MiniGUI must follow GPL. If you cannot accept GPL, +you need to be licensed from FMSoft. If you wonder that if you need the commercial license of MiniGUI, please refer to the LICENSE-POLICY file. -We provide you the commercial license of MiniGUI according to the number -of the run-time binary copies of MiniGUI. If you are interested in -the commercial license of MiniGUI, please write to sales@minigui.com. +We provide you the commercial license of MiniGUI according to the number +of the run-time binary copies of MiniGUI. If you are interested in +the commercial license of MiniGUI, please write to sales@minigui.com. ## COPYING - Copyright (C) 2002~2018, Beijing FMSoft Technologies Co., Ltd. + Copyright (C) 2002~2019, Beijing FMSoft Technologies Co., Ltd. Copyright (C) 1998~2002, WEI Yongming This program is free software: you can redistribute it and/or modify From 76f4bf3661f1f86ac9b9bcb2cc67b99b632b9b1c Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Mon, 15 Apr 2019 15:54:39 +0800 Subject: [PATCH 16/19] add const to INNER_RES --- include/window.h | 11 +++++------ src/sysres/resmgr.c | 7 ++++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/window.h b/include/window.h index 8c2dae99..d1f3577b 100644 --- a/include/window.h +++ b/include/window.h @@ -4584,17 +4584,16 @@ typedef unsigned long RES_KEY; /* define the incore res type */ typedef struct _INNER_RES { RES_KEY key; - Uint8* data; + const Uint8* data; int data_len; - /* special param recognized by the TYPE_OPS - * normal is null. - * is the data is a mem of raw png, jpeg, bmp + /* The special param recognized by the TYPE_OPS normally it is NULL. + * If data is the data is a mem of raw png, jpeg, bmp * and so on, it should be the extention name - * of the filename. eg. + * of the filename. eg. * INNER_RES res[]= { ... { ..., ... ,.., "png" } .. }; * */ - void* additional; + const void* additional; } INNER_RES; /* the type of resource */ diff --git a/src/sysres/resmgr.c b/src/sysres/resmgr.c index a442f154..dc3de550 100644 --- a/src/sysres/resmgr.c +++ b/src/sysres/resmgr.c @@ -928,11 +928,12 @@ static void* img_get_res_data(RESOURCE* res, int src_type, DWORD usr_param) INNER_RES* inner = res->source.inner; if(inner->additional == NULL) //raw bitmap { - res->data = inner->data; + res->data = (void*)inner->data; } else { BITMAP *pbmp = NEW(BITMAP); - if(LoadBitmapFromMem((HDC)usr_param, pbmp, inner->data, inner->data_len, (const char*)inner->additional) != 0) + if(LoadBitmapFromMem((HDC)usr_param, pbmp, inner->data, + inner->data_len, (const char*)inner->additional) != 0) { DELETE(pbmp); return NULL; @@ -1177,7 +1178,7 @@ static void* etc_get_res_data(RESOURCE* res, int src_type, DWORD usr_param) break; } case REF_SRC_INNER: - res->data = res->source.inner->data; + res->data = (void*)res->source.inner->data; break; default: return NULL; From 7d671c831851ef57a7ef2611be3fd6e170aa8abb Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Mon, 15 Apr 2019 15:57:58 +0800 Subject: [PATCH 17/19] tune release notes for LoadDevFontFromFile --- RELEASE-NOTES.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 92691005..89b1f177 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -16,8 +16,10 @@ Please report any bugs and incompatibilities in represents the shadow frame buffer of the screen. * configure option: `--enable-syncupdate` * macro: `_MGUSE_SYNC_UPDATE` - 1. New API: `UpdateInvalidClient`. You can use this function to update + 1. New API `UpdateInvalidClient`. You can use this function to update the invalid client region of a window instantly. + 1. New API `LoadDevFontFromFile`. You can use this function to load + a device font from incore data. 1. Use different colors for the output of `_DBG_PRINTF` and `_ERR_PRINTF`. 1. Add `__mg_save_jpg` function for storing MYBITMAP as JPEG file (10km). 1. Modified logic for checking JPEG format (10km). From a7eaab6d3828162f33eb0b1746001109e2507a56 Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Mon, 15 Apr 2019 16:26:22 +0800 Subject: [PATCH 18/19] use inline functions for --disable-cursor instead of macros --- include/minigui.h | 84 ++++++++++++++++++++++++++++++---------------- src/kernel/timer.c | 2 ++ 2 files changed, 57 insertions(+), 29 deletions(-) diff --git a/include/minigui.h b/include/minigui.h index 3e0bcfe1..95641665 100644 --- a/include/minigui.h +++ b/include/minigui.h @@ -2565,10 +2565,6 @@ MG_EXPORT void GUIAPI FreeFixStr (char* str); * @{ */ -#ifndef _MGHAVE_CURSOR -static inline void do_nothing (void) { return; } -#endif - #ifdef _MGHAVE_CURSOR /** @@ -2731,11 +2727,32 @@ MG_EXPORT HCURSOR GUIAPI GetSystemCursor (int csrid); */ MG_EXPORT HCURSOR GUIAPI GetCurrentCursor (void); #else - #define LoadCursorFromFile(filename) (do_nothing(), 0) - #define CreateCursor(x, y, w, h, ANDbs, XORbs, cr) (do_nothing(), 0) - #define DestroyCursor(hcsr) (do_nothing(), 0) - #define GetSystemCursor(csrid) (do_nothing(), 0) - #define GetCurrentCursor() (do_nothing(), 0) + +static inline HCURSOR LoadCursorFromFile(const char* filename) { + return (HCURSOR)0; +} + +static inline HCURSOR CreateCursor(int xhotspot, int yhotspot, int w, int h, + const BYTE* pANDBits, const BYTE* pXORBits, int colornum) { + return (HCURSOR)0; +} + +static inline HCURSOR GUIAPI CopyCursor (HCURSOR hcsr) { + return (HCURSOR)0; +} + +static inline BOOL DestroyCursor (HCURSOR hcsr) { + return TRUE; +} + +static inline HCURSOR GetSystemCursor (int csrid) { + return (HCURSOR)0; +} + +static inline HCURSOR GUIAPI GetCurrentCursor (void) { + return (HCURSOR)0; +} + #endif /* _MGHAVE_CURSOR */ #define MAX_SYSCURSORINDEX 22 @@ -2863,6 +2880,29 @@ MG_EXPORT void GUIAPI SetCursorPos (int x, int y); */ MG_EXPORT HCURSOR GUIAPI SetCursorEx (HCURSOR hcsr, BOOL set_def); +/** + * \fn HCURSOR GUIAPI GetDefaultCursor (void) + * \brief Gets the default cursor. + * + * This function gets the current default cursor. + * + * \return The current default cursor handle. + * + * \sa SetCursorEx, SetDefaultCursor + */ +MG_EXPORT HCURSOR GUIAPI GetDefaultCursor (void); + +#else +static inline HCURSOR SetCursorEx(HCURSOR hcsr, BOOL set_def) { + return (HCURSOR)0; +} + +static inline HCURSOR GetDefaultCursor(void) { + return (HCURSOR)0; +} + +#endif /* _MGHAVE_CURSOR */ + /** * \def SetCursor(hcsr) * \brief Changes the current cursor. @@ -2896,25 +2936,6 @@ MG_EXPORT void GUIAPI SetCursorPos (int x, int y); */ #define SetDefaultCursor(hcsr) SetCursorEx (hcsr, TRUE) -/** - * \fn HCURSOR GUIAPI GetDefaultCursor (void) - * \brief Gets the default cursor. - * - * This function gets the current default cursor. - * - * \return The current default cursor handle. - * - * \sa SetCursorEx, SetDefaultCursor - */ -MG_EXPORT HCURSOR GUIAPI GetDefaultCursor (void); - -#else - #define SetCursorEx(hcsr, set_def) (do_nothing(), 0) - #define SetCursor(hcsr) (do_nothing(), 0) - #define SetDefaultCursor(hcsr) (do_nothing(), 0) - #define GetDefaultCursor() (do_nothing(), 0) -#endif /* _MGHAVE_CURSOR */ - #ifdef _MGHAVE_CURSOR /** @@ -2932,8 +2953,13 @@ MG_EXPORT HCURSOR GUIAPI GetDefaultCursor (void); * \return Cursor showing count value. */ MG_EXPORT int GUIAPI ShowCursor (BOOL fShow); + #else - #define ShowCursor(fShow) (do_nothing(), 0) + +static inline int GUIAPI ShowCursor (BOOL fShow) { + return 0; +} + #endif /* _MGHAVE_CURSOR */ /** @} end of cursor_fns */ diff --git a/src/kernel/timer.c b/src/kernel/timer.c index 389e236d..9ca71720 100644 --- a/src/kernel/timer.c +++ b/src/kernel/timer.c @@ -83,8 +83,10 @@ static pthread_mutex_t timerLock; #endif /* __LINUX__ */ #ifdef _MG_USE_BETTER_TIMER +#ifdef _MGRM_THREADS #include static clock_t g_timer_started; +#endif static clock_t g_last_tick; #endif From 1d211ed8559a613fdb9a2eb083eb886e6bdabc20 Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Mon, 15 Apr 2019 16:28:50 +0800 Subject: [PATCH 19/19] cleanup --- src/kernel/timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kernel/timer.c b/src/kernel/timer.c index 9ca71720..61c559dc 100644 --- a/src/kernel/timer.c +++ b/src/kernel/timer.c @@ -97,7 +97,7 @@ static void __mg_timer_action (void *data) SHAREDRES_TIMER_COUNTER += 1; #else -#if defined(__uClinux__) && defined(_MGRM_STANDALONE) +#if defined(_MGRM_STANDALONE) __mg_timer_counter += 10; #else # ifdef _MG_USE_BETTER_TIMER