mirror of
https://github.com/VincentWei/MiniGUI.git
synced 2026-09-25 11:07:54 +08:00
Compare commits
11
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
40f53732ff | ||
|
|
e2d2544ce6 | ||
|
|
7cefc7d5ab | ||
|
|
b59ed4b7d1 | ||
|
|
5e43b76753 | ||
|
|
894d0f64a2 | ||
|
|
c18e0f3479 | ||
|
|
8756b5de9f | ||
|
|
54a51ab02f | ||
|
|
741a93aebd | ||
|
|
aeb6642aad |
+2
-2
@@ -1,6 +1,6 @@
|
||||
Version 5.0.7 (2021/06/30)
|
||||
Version 5.0.8 (2021/10/25)
|
||||
|
||||
This is a bugfix release of MiniGUI 5.0.x, the stable version.
|
||||
This is a minor enhancement and bugfix release of MiniGUI 5.0.x, the stable version.
|
||||
|
||||
Other packages for MiniGUI resource, tools, components, and samples:
|
||||
|
||||
|
||||
+37
-7
@@ -1,6 +1,6 @@
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
AC_PREREQ(2.60)
|
||||
AC_INIT(libminigui, 5.0.7)
|
||||
AC_INIT(libminigui, 5.0.8)
|
||||
AC_CONFIG_SRCDIR(src/main/main.c)
|
||||
|
||||
dnl Set various version strings - taken gratefully from the SDL sources
|
||||
@@ -16,9 +16,9 @@ dnl Set various version strings - taken gratefully from the SDL sources
|
||||
#
|
||||
MINIGUI_MAJOR_VERSION=5
|
||||
MINIGUI_MINOR_VERSION=0
|
||||
MINIGUI_MICRO_VERSION=7
|
||||
MINIGUI_INTERFACE_AGE=1
|
||||
MINIGUI_BINARY_AGE=1
|
||||
MINIGUI_MICRO_VERSION=8
|
||||
MINIGUI_INTERFACE_AGE=2
|
||||
MINIGUI_BINARY_AGE=2
|
||||
MINIGUI_VERSION=$MINIGUI_MAJOR_VERSION.$MINIGUI_MINOR_VERSION.$MINIGUI_MICRO_VERSION
|
||||
|
||||
AC_SUBST(MINIGUI_MAJOR_VERSION)
|
||||
@@ -222,6 +222,7 @@ build_save_bitmap="yes"
|
||||
build_gif_support="yes"
|
||||
build_jpg_support="yes"
|
||||
build_png_support="yes"
|
||||
build_webp_support="yes"
|
||||
build_pcx_support="no"
|
||||
build_lbm_support="no"
|
||||
build_tga_support="no"
|
||||
@@ -727,6 +728,10 @@ AC_ARG_ENABLE(pngsupport,
|
||||
[ --enable-pngsupport include PNG file support <default=yes>],
|
||||
build_png_support=$enableval)
|
||||
|
||||
AC_ARG_ENABLE(webpsupport,
|
||||
[ --enable-webpsupport include WebP file support <default=yes>],
|
||||
build_webp_support=$enableval)
|
||||
|
||||
AC_ARG_ENABLE(menu,
|
||||
[ --enable-menu include menu support <default=yes>],
|
||||
build_menu=$enableval)
|
||||
@@ -1438,6 +1443,12 @@ case "$libpng_version" in
|
||||
;;
|
||||
esac
|
||||
|
||||
dnl Check for WebP library.
|
||||
if test "x$build_webp_support" = "xyes"; then
|
||||
PKG_CHECK_MODULES([WEBP], [libwebp >= 0.6.0], [foo=bar],
|
||||
[build_webp_support="no; support WebP file requires libwebp 0.6.0 or later."])
|
||||
fi
|
||||
|
||||
AC_DEFINE_UNQUOTED(MINIGUI_MAJOR_VERSION, $MINIGUI_MAJOR_VERSION,
|
||||
[Major version of MiniGUI])
|
||||
AC_DEFINE_UNQUOTED(MINIGUI_MINOR_VERSION, $MINIGUI_MINOR_VERSION,
|
||||
@@ -1636,7 +1647,7 @@ dnl ;;
|
||||
dnl esac
|
||||
|
||||
AC_ARG_WITH(targetname,
|
||||
[ --with-targetname=TARGET the target name <unknown, external, fmsoft, mstudio, r818, or vxi386>])
|
||||
[ --with-targetname=TARGET the target name <unknown, external, fmsoft, mstudio, r818, px30, or vxi386>])
|
||||
|
||||
case "$with_targetname" in
|
||||
external)
|
||||
@@ -1652,6 +1663,9 @@ case "$with_targetname" in
|
||||
r818)
|
||||
AC_DEFINE(__TARGET_R818__, 1, [Define for Allwinner R818 target])
|
||||
;;
|
||||
px30)
|
||||
AC_DEFINE(__TARGET_PX30__, 1, [Define for Rockchip PX30 target])
|
||||
;;
|
||||
vxi386)
|
||||
AC_DEFINE(__TARGET_VXI386__, 1, [Define for VxWorks on i386])
|
||||
;;
|
||||
@@ -2433,16 +2447,30 @@ fi
|
||||
|
||||
if test "x$build_jpg_support" = "xyes"; then
|
||||
AC_DEFINE(_MGIMAGE_JPG, 1,
|
||||
[Define if support JPEG bmp file format])
|
||||
[Define if support JPEG file format])
|
||||
fi
|
||||
|
||||
if test "x$build_png_support" = "xyes"; then
|
||||
AC_DEFINE(_MGIMAGE_PNG, 1,
|
||||
[Define if support PNG bmp file format])
|
||||
[Define if support PNG file format])
|
||||
AC_DEFINE_UNQUOTED(_MGLIBPNG_VER, $libpng_version,
|
||||
[Define version of libpng])
|
||||
fi
|
||||
|
||||
if test "x$build_webp_support" = "xyes"; then
|
||||
AC_DEFINE(_MGIMAGE_WEBP, 1,
|
||||
[Define if support WebP file format])
|
||||
AC_ARG_WITH(webp_includes,
|
||||
[ --with-webp-includes=DIR where the libwebp includes are])
|
||||
|
||||
if test "x$with_webp_includes" != "x"; then
|
||||
WEBP_CFLAGS="-I$with_webp_includes"
|
||||
fi
|
||||
|
||||
DEP_LIBS="$DEP_LIBS $WEBP_LIBS"
|
||||
AC_SUBST(WEBP_CFLAGS)
|
||||
fi
|
||||
|
||||
if test "x$build_menu" = "xyes"; then
|
||||
AC_DEFINE(_MGHAVE_MENU, 1,
|
||||
[Define if support menu])
|
||||
@@ -2771,6 +2799,7 @@ AC_MSG_NOTICE([
|
||||
## Other Features:
|
||||
* JPEG: ${build_jpg_support}
|
||||
* PNG: ${build_png_support}
|
||||
* WebP: ${build_webp_support}
|
||||
* Unicode: ${build_unicode_support}
|
||||
* Complex Scripts: ${build_complex_scripts}
|
||||
|
||||
@@ -2779,6 +2808,7 @@ AC_MSG_NOTICE([
|
||||
* CPP flags: ${CPPFLAGS}
|
||||
* CC flags: ${CFLAGS}
|
||||
* CXX flags: ${CXXFLAGS}
|
||||
* LibWebP includes: ${WEBP_CFLAGS}
|
||||
* Pixman includes: ${PIXMAN_CFLAGS}
|
||||
* FreeType2 includes: ${FT2_INC_DIR}
|
||||
* HarfBuzz includes: ${HB_INC_DIR}
|
||||
|
||||
@@ -138,6 +138,14 @@ int __mg_save_png (MG_RWops* fp, MYBITMAP* bmp, RGB* pal);
|
||||
BOOL __mg_check_png (MG_RWops* fp);
|
||||
#endif
|
||||
|
||||
#ifdef _MGIMAGE_WEBP
|
||||
void* __mg_init_webp (MG_RWops* fp, MYBITMAP *png, RGB *pal);
|
||||
int __mg_load_webp (MG_RWops* fp, void* init_info, MYBITMAP *png, CB_ONE_SCANLINE cb, void* context);
|
||||
void __mg_cleanup_webp (void* init_info);
|
||||
int __mg_save_webp (MG_RWops* fp, MYBITMAP* bmp, RGB* pal);
|
||||
BOOL __mg_check_webp (MG_RWops* fp);
|
||||
#endif
|
||||
|
||||
int __mg_bmp_compute_pitch (int bpp, Uint32 width, Uint32 *pitch, BOOL does_round);
|
||||
|
||||
#define fp_getc(fp) MGUI_RWgetc(fp)
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
AM_CPPFLAGS = -I$(abs_top_srcdir)/src/include -I$(abs_top_srcdir)/include
|
||||
AM_CPPFLAGS = $(WEBP_CFLAGS)
|
||||
AM_CPPFLAGS += -I$(abs_top_srcdir)/src/include -I$(abs_top_srcdir)/include
|
||||
|
||||
noinst_LTLIBRARIES = libmybmp.la
|
||||
|
||||
SRC_FILES = mybmp.c winbmp.c gif.c jpeg.c png12.c png16.c lbm.c pcx.c tga.c
|
||||
SRC_FILES = mybmp.c winbmp.c gif.c jpeg.c png12.c png16.c webp.c lbm.c pcx.c tga.c
|
||||
|
||||
libmybmp_la_SOURCES = $(SRC_FILES)
|
||||
|
||||
|
||||
+3
-2
@@ -309,7 +309,7 @@ void* __mg_init_jpg (MG_RWops *fp, MYBITMAP* mybmp, RGB* pal)
|
||||
struct my_error_mgr *jerr;
|
||||
jpeg_init_info_t* init_info;
|
||||
|
||||
if (!read_be16(fp,&soi_marker) || JMK_SOI != soi_marker)
|
||||
if (!read_be16(fp, &soi_marker) || JMK_SOI != soi_marker)
|
||||
goto err; /* not JPEG image*/
|
||||
|
||||
MGUI_RWseek (fp, 0, SEEK_SET);
|
||||
@@ -353,7 +353,8 @@ void* __mg_init_jpg (MG_RWops *fp, MYBITMAP* mybmp, RGB* pal)
|
||||
}
|
||||
|
||||
/* Step 4: set parameters for decompression */
|
||||
cinfo->out_color_space = (mybmp->flags & MYBMP_LOAD_GRAYSCALE) ? JCS_GRAYSCALE: JCS_RGB;
|
||||
cinfo->out_color_space =
|
||||
(mybmp->flags & MYBMP_LOAD_GRAYSCALE) ? JCS_GRAYSCALE: JCS_RGB;
|
||||
cinfo->quantize_colors = FALSE;
|
||||
|
||||
if (!(mybmp->flags & MYBMP_LOAD_GRAYSCALE)) {
|
||||
|
||||
@@ -98,6 +98,9 @@ static BITMAP_TYPE_INFO bitmap_types [MAX_BITMAP_TYPES] =
|
||||
#ifdef _MGIMAGE_PNG
|
||||
{ "png", __mg_init_png, __mg_load_png, __mg_cleanup_png, NULL, __mg_check_png },
|
||||
#endif
|
||||
#ifdef _MGIMAGE_WEBP
|
||||
{ "webp", __mg_init_webp, __mg_load_webp, __mg_cleanup_webp, NULL, __mg_check_webp },
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
@@ -0,0 +1,273 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT NOTICE
|
||||
//
|
||||
// The following open source license statement does not apply to any
|
||||
// entity in the Exception List published by FMSoft.
|
||||
//
|
||||
// For more information, please visit:
|
||||
//
|
||||
// https://www.fmsoft.cn/exception-list
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/*
|
||||
* 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~2021, 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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
|
||||
* <http://www.minigui.com/blog/minigui-licensing-policy/>.
|
||||
*/
|
||||
/*
|
||||
** webp.c: Low-level WebP file read routines (based on LibWebP 0.6)
|
||||
**
|
||||
** Current maintainer: Wei Yongming
|
||||
**
|
||||
** Create date: 2021/10/19
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#ifdef _MGIMAGE_WEBP
|
||||
#include "gdi.h"
|
||||
#include "constants.h"
|
||||
|
||||
#include <webp/decode.h>
|
||||
|
||||
#define RIFF_HEADER_SIZE 12
|
||||
|
||||
#define HEADER_CHUNK_SIZE 32
|
||||
#define READ_BUFF_SIZE 1024
|
||||
|
||||
struct webp_decode_info {
|
||||
WebPDecoderConfig config;
|
||||
size_t sz_data;
|
||||
char data[READ_BUFF_SIZE];
|
||||
};
|
||||
|
||||
void* __mg_init_webp(MG_RWops *fp, MYBITMAP *mybmp, RGB *pal)
|
||||
{
|
||||
int n;
|
||||
size_t pitch;
|
||||
struct webp_decode_info *info = NULL;
|
||||
|
||||
if ((info = malloc(sizeof(struct webp_decode_info))) == NULL) {
|
||||
_ERR_PRINTF ("__mg_init_webp: failed to allocate memory\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!WebPInitDecoderConfig(&info->config)) {
|
||||
_ERR_PRINTF ("__mg_init_webp: WebPInitDecoderConfig failed\n");
|
||||
goto error;
|
||||
}
|
||||
|
||||
info->sz_data = 0;
|
||||
do {
|
||||
VP8StatusCode sc;
|
||||
|
||||
if (info->sz_data + HEADER_CHUNK_SIZE > READ_BUFF_SIZE) {
|
||||
_ERR_PRINTF ("__mg_init_webp: two small buffer\n");
|
||||
goto error;
|
||||
}
|
||||
|
||||
n = MGUI_RWread(fp, info->data + info->sz_data, 1, HEADER_CHUNK_SIZE);
|
||||
if (n > 0) {
|
||||
info->sz_data += n;
|
||||
}
|
||||
else
|
||||
goto error;
|
||||
|
||||
sc = WebPGetFeatures(info->data, info->sz_data, &info->config.input);
|
||||
if (sc == VP8_STATUS_OK) {
|
||||
break;
|
||||
}
|
||||
else if (sc == VP8_STATUS_NOT_ENOUGH_DATA) {
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
_ERR_PRINTF ("__mg_init_webp: WebPGetFeatures failed: %d\n", sc);
|
||||
goto error;
|
||||
}
|
||||
} while (1);
|
||||
|
||||
if (info->config.input.has_animation) {
|
||||
_ERR_PRINTF ("__mg_init_webp: animation not supported\n");
|
||||
goto error;
|
||||
}
|
||||
|
||||
#if SIZEOF_PTR == 8
|
||||
info->config.options.no_fancy_upsampling = 0;
|
||||
/* use default
|
||||
info->config.options.dithering_strength = 100; */
|
||||
/* use default
|
||||
info->config.options.alpha_dithering_strength = 100; */
|
||||
#else
|
||||
info->config.options.no_fancy_upsampling = 1;
|
||||
info->config.options.dithering_strength = 67;
|
||||
info->config.options.alpha_dithering_strength = 33;
|
||||
#endif
|
||||
|
||||
mybmp->w = info->config.input.width;
|
||||
mybmp->h = info->config.input.height;
|
||||
mybmp->frames = 1;
|
||||
if (info->config.input.has_alpha) {
|
||||
info->config.output.colorspace = MODE_RGBA;
|
||||
|
||||
mybmp->depth = 32;
|
||||
mybmp->flags |= MYBMP_FLOW_DOWN | MYBMP_ALPHA | MYBMP_TYPE_RGBA;
|
||||
mybmp->flags |= MYBMP_RGBSIZE_4;
|
||||
|
||||
pitch = (size_t)info->config.input.width * 4;
|
||||
}
|
||||
else {
|
||||
info->config.output.colorspace = MODE_RGB;
|
||||
|
||||
mybmp->depth = 24;
|
||||
mybmp->flags |= MYBMP_FLOW_DOWN | MYBMP_TYPE_RGB;
|
||||
mybmp->flags |= MYBMP_RGBSIZE_3;
|
||||
|
||||
pitch = (size_t)info->config.input.width * 3;
|
||||
}
|
||||
|
||||
pitch = ROUND_TO_MULTIPLE(pitch, 8);
|
||||
mybmp->pitch = pitch;
|
||||
|
||||
info->config.output.width = info->config.input.width;
|
||||
info->config.output.height = info->config.input.height;
|
||||
return info;
|
||||
|
||||
error:
|
||||
if (info)
|
||||
free(info);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void __mg_cleanup_webp(void *init_info)
|
||||
{
|
||||
struct webp_decode_info *info = init_info;
|
||||
|
||||
if (info) {
|
||||
free(info);
|
||||
}
|
||||
}
|
||||
|
||||
int __mg_load_webp(MG_RWops *fp, void *init_info, MYBITMAP *mybmp,
|
||||
CB_ONE_SCANLINE cb, void *context)
|
||||
{
|
||||
int rc = ERR_BMP_OK;
|
||||
struct webp_decode_info *info = init_info;
|
||||
WebPIDecoder* idec = NULL;
|
||||
int last_last_y = -1, last_y;
|
||||
|
||||
// Have config.output point to an external buffer:
|
||||
info->config.output.is_external_memory = 1;
|
||||
if (mybmp->flags & MYBMP_LOAD_ALLOCATE_ONE) {
|
||||
info->config.output.u.RGBA.stride = mybmp->pitch;
|
||||
info->config.output.u.RGBA.size = mybmp->pitch * mybmp->h;
|
||||
mybmp->bits = realloc(mybmp->bits, info->config.output.u.RGBA.size);
|
||||
}
|
||||
else {
|
||||
info->config.output.u.RGBA.stride = mybmp->pitch;
|
||||
info->config.output.u.RGBA.size = mybmp->pitch * mybmp->h;
|
||||
}
|
||||
info->config.output.u.RGBA.rgba = (uint8_t*)mybmp->bits;
|
||||
|
||||
idec = WebPINewDecoder(&info->config.output);
|
||||
if (idec == NULL) {
|
||||
rc = ERR_BMP_MEM;
|
||||
goto ret;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
int n;
|
||||
|
||||
VP8StatusCode status = WebPIAppend(idec, info->data, info->sz_data);
|
||||
if (status != VP8_STATUS_OK && status != VP8_STATUS_SUSPENDED) {
|
||||
_ERR_PRINTF ("__mg_load_webp: WebPIAppend failed: %d\n", status);
|
||||
rc = ERR_BMP_LOAD;
|
||||
break;
|
||||
}
|
||||
|
||||
if (WebPIDecGetRGB(idec, &last_y, NULL, NULL, NULL) &&
|
||||
(--last_y > last_last_y)) {
|
||||
|
||||
int y;
|
||||
for (y = last_last_y + 1; y <= last_y; y++) {
|
||||
if (mybmp->flags & MYBMP_LOAD_ALLOCATE_ONE) {
|
||||
mybmp->bits = info->config.output.u.RGBA.rgba;
|
||||
mybmp->bits += mybmp->pitch * y;
|
||||
}
|
||||
|
||||
if (cb)
|
||||
cb(context, mybmp, y);
|
||||
}
|
||||
|
||||
last_last_y = last_y;
|
||||
}
|
||||
|
||||
/* read more data */
|
||||
n = MGUI_RWread(fp, info->data, 1, sizeof(info->data));
|
||||
if (n > 0) {
|
||||
info->sz_data = n;
|
||||
}
|
||||
else if (n == 0) {
|
||||
break;
|
||||
}
|
||||
else {
|
||||
_ERR_PRINTF ("__mg_load_webp: MGUI_RWread failed: %d\n", n);
|
||||
rc = ERR_BMP_LOAD;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
mybmp->bits = info->config.output.u.RGBA.rgba;
|
||||
|
||||
ret:
|
||||
if (idec)
|
||||
WebPIDelete(idec);
|
||||
WebPFreeDecBuffer(&info->config.output);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
BOOL __mg_check_webp(MG_RWops* fp)
|
||||
{
|
||||
unsigned char header[RIFF_HEADER_SIZE];
|
||||
|
||||
if (MGUI_RWread(fp, header, 1, RIFF_HEADER_SIZE) != RIFF_HEADER_SIZE)
|
||||
return FALSE;
|
||||
|
||||
return WebPGetInfo(header, RIFF_HEADER_SIZE, NULL, NULL);
|
||||
}
|
||||
|
||||
#endif /* _MGIMAGE_WEBP */
|
||||
|
||||
@@ -952,6 +952,11 @@ static void DRM_DeleteDevice(GAL_VideoDevice *device)
|
||||
free(device);
|
||||
}
|
||||
|
||||
#ifdef __TARGET_PX30__
|
||||
static inline char* find_driver_for_device (const char *dev_name) {
|
||||
return strdup ("rockchip");
|
||||
}
|
||||
#else /* __TARGET_PX30__ */
|
||||
static char* find_driver_for_device (const char *dev_name)
|
||||
{
|
||||
char *driver;
|
||||
@@ -996,6 +1001,7 @@ static char* find_driver_for_device (const char *dev_name)
|
||||
|
||||
return strdup (driver + strlen ("/"));
|
||||
}
|
||||
#endif /* not defined __TARGET_PX30__ */
|
||||
|
||||
static DrmDriverOps* load_external_driver (DrmVideoData* vdata,
|
||||
const char* driver_name, int device_fd)
|
||||
@@ -1095,6 +1101,7 @@ static int open_drm_device(GAL_VideoDevice *device)
|
||||
_DBG_PRINTF("Try to load DRM driver: %s\n", driver_name);
|
||||
|
||||
fd = drmOpen(driver_name, NULL);
|
||||
|
||||
if (fd < 0) {
|
||||
_ERR_PRINTF("NEWGAL>DRM: drmOpen failed\n");
|
||||
free(driver_name);
|
||||
|
||||
Reference in New Issue
Block a user