Compare commits

..
108 changed files with 3447 additions and 4476 deletions
+13 -16
View File
@@ -72,7 +72,7 @@ It greatly reduces the size and resource consumption of the entire solution, imp
[HybridOS] is another large open source project initiated by FMSoft.
It is an open source operating system designed for embedded/AIoT devices and cloud computing environment.
HybridOS provides the complete software stack and the app framework based on [HVML] for embedded systems.
HybridOS provides the complete software stack and the app framework based on HVML for embedded systems.
You can easily develop your products which has rich functions and excellent expressiveness by using HybridOS.
In practice, MiniGUI and the software which are used to integrated with GPU constitute the graphics stack of HybridOS.
@@ -86,11 +86,11 @@ The following chart shows the graphics stack of HybridOS:
| MiniGUI/HVML Apps |
|-----------------------------------------------|
| | (Graphics Stack) |
| | --------------------|
| | | Mesa-HBD |
| | Cairo-HBD | ------------------|
| | ---------------------|
| | | hiMesa |
| | hiCairo | ------------------|
| | MiniGUI | | EGL for MiniGUI |
| C++ libs | HBDDRMDrivers | | GL, GLES, VG |
| C++ libs | hiDRMDrivers | | GL, GLES, VG |
| C libs | libDRM | | GPU drivers |
|-----------------------------------------------|
| Linux Kernel |
@@ -102,10 +102,10 @@ The following chart shows the graphics stack of HybridOS:
As shown in the chart above, the HybridOS graphics stack consists of the following software:
- `libDRM` provides some user land APIs for Linux Direct Rendering Infrastructure.
- `HBDDRMDrivers` contains the drivers (user land drivers, not kernel drivers) for
- `hiDRMDrivers` contains the drivers (user land drivers, not kernel drivers) for
MiniGUI DRM engine. The drivers implement the basic hardware accelerated
2D graphics operations of various GPUs for MiniGUI.
- `Mesa-HBD` is the Mesa derivative for HybridOS, while Mesa is the open source
- `hiMesa` is the Mesa derivative for HybridOS, while Mesa is the open source
implementation of OpenGL and other graphics APIs, including OpenGL ES
(versions 1, 2, 3), OpenCL, OpenMAX, and Vulkan. It contains the following
components:
@@ -113,17 +113,13 @@ As shown in the chart above, the HybridOS graphics stack consists of the followi
graphics APIs.
+ The EGL implementation for MiniGUI platform.
+ The graphics drivers for various GPUs and a software driver called `swrast`.
- `Cairo-HBD` is the Cairo derivative for HybridOS. Cairo is a 2D vector graphics
- `hiCairo` is the Cairo derivative for HybridOS. Cairo is a 2D vector graphics
library for Gtk. We provide support for MiniGUI backend in `hiCairo`.
For more information about HybridOS, please refer to:
<https://hybridos.fmsoft.cn/>
For more information about HVML, please refer to:
<https://hvml.fmsoft.cn/> or <https://www.hvml.org>
### Source Code Repositories
FMSoft had created the public repositories for MiniGUI Core, MiniGUI
@@ -572,7 +568,7 @@ A brief history description of the development progress is listed as follow:
The original author of MiniGUI is Vincent Wei, and now MiniGUI is maintained by FMSoft.
For more information, please refer to <http://www.fmsoft.cn>.
Copyright (C) 2002 ~ 2023, Beijing FMSoft Technologies Co., Ltd.
Copyright (C) 2002 ~ 2022, Beijing FMSoft Technologies Co., Ltd.
Copyright (C) 1998 ~ 2002, Vincent Wei
This program is free software: you can redistribute it and/or modify
@@ -650,12 +646,13 @@ A: Yes, FMSoft can provide you with guaranteed commercial technical
[FMSoft Technologies]: https://www.fmsoft.cn
[FMSoft]: https://www.fmsoft.cn
[HybridOS Official Site]: https://hybridos.fmsoft.cn
[MiniGUI Official Site]: https://minigui.fmsoft.cn
[MiniGUI Official Site]: https://hvml.fmsoft.cn
[HVML Official Site]: https://hvml.fmsoft.cn
[Vincent Wei]: https://github.com/VincentWei
[MiniGUI]: https://github.com/VincentWei
[HybridOS]: https://github.com/HybridOS2
[MiniGUI]: https://github.com/VincentWei/MiniGUI
[HybridOS]: https://github.com/FMSoftCN/HybridOS
[HVML]: https://github.com/HVML
[PurC]: https://github.com/HVML/PurC
[xGUI Pro]: https://github.com/HVML/xGUI-Pro
-13
View File
@@ -1,7 +1,5 @@
# Release Notes
- [Version 5.2.0](#version-520)
+ [What's new in version 5.2.0](#whats-new-in-version-520)
- [Version 5.0.13](#version-5013)
+ [What's new in version 5.0.13](#whats-new-in-version-5013)
- [Version 5.0.12](#version-5012)
@@ -34,17 +32,6 @@
+ [Changes leading to incompatibility](#changes-leading-to-incompatibility)
+ [Deprecated APIs](#deprecated-apis)
## Version 5.2.0
On Nov. 30, 2023, FMSoft announces the availability of MiniGUI 5.2.0,
which is an mainline release with some major enhancements:
* ENHANCEMENTS:
- Optimize NEWGAL engines: `shadow`, `drm`, and `fbcon` for large resolution.
- New APIs: `GetWindowSharedSurfaceFD()` and `CreateMemDCFromSharedSurfaceFD()` for compositing schema.
* CHANGES:
- The operations for DRM userland driver changed.
## Version 5.0.13
On Aug. 31, 2023, FMSoft announces the availability of MiniGUI 5.0.13,
+2 -2
View File
@@ -1,6 +1,6 @@
Version 5.2.0 (2023/09/30)
Version 5.0.13 (2023/08/31)
This is a minor enhancement and bugfix release of MiniGUI 5.2.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:
+11 -12
View File
@@ -1,6 +1,6 @@
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.60)
AC_INIT(libminigui, 5.2.0)
AC_INIT(libminigui, 5.0.13)
AC_CONFIG_SRCDIR(src/main/main.c)
dnl Set various version strings - taken gratefully from the SDL sources
@@ -15,10 +15,10 @@ dnl Set various version strings - taken gratefully from the SDL sources
# set MINIGUI_BINARY_AGE and MINIGUI_INTERFACE_AGE to 0.
#
MINIGUI_MAJOR_VERSION=5
MINIGUI_MINOR_VERSION=2
MINIGUI_MICRO_VERSION=0
MINIGUI_INTERFACE_AGE=0
MINIGUI_BINARY_AGE=0
MINIGUI_MINOR_VERSION=0
MINIGUI_MICRO_VERSION=13
MINIGUI_INTERFACE_AGE=1
MINIGUI_BINARY_AGE=3
MINIGUI_VERSION=$MINIGUI_MAJOR_VERSION.$MINIGUI_MINOR_VERSION.$MINIGUI_MICRO_VERSION
AC_SUBST(MINIGUI_MAJOR_VERSION)
@@ -62,7 +62,7 @@ dnl ========================================================================
dnl Checks for header files.
AC_HEADER_STDC
AC_HEADER_DIRENT
AC_CHECK_HEADERS(limits.h math.h stdatomic.h locale.h unistd.h termio.h sys/types.h sys/time.h sys/select.h sys/memfd.h)
AC_CHECK_HEADERS(limits.h math.h locale.h unistd.h termio.h sys/types.h sys/time.h sys/select.h sys/memfd.h)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
@@ -95,7 +95,7 @@ message_string="no"
osname="unspecified"
runtime_mode="procs"
compositing_schema="yes"
virtual_window="yes"
virtual_window="no"
use_shmopen="no"
mgslice_use_fallback="no"
@@ -1704,12 +1704,12 @@ fi
CPPFLAGS="$CPPFLAGS -D__MINIGUI_LIB__"
surface_schema="shared"
surface_schema="shared frame buffer"
case "$runtime_mode" in
sa)
AC_DEFINE(_MGRM_STANDALONE, 1,
[Define if build MiniGUI-Standalone])
MINIGUI_RUNMODE="standalone"
MINIGUI_RUNMODE="sa"
RUNMODE_LADD="standalone/libstandalone.la"
RUNMODE_SUBDIRS="standalone"
;;
@@ -1717,13 +1717,13 @@ case "$runtime_mode" in
AC_DEFINE(_MGRM_THREADS, 1,
[Define if build MiniGUI-Threads])
CPPFLAGS="$CPPFLAGS -D_REENTRANT"
MINIGUI_RUNMODE="threads"
MINIGUI_RUNMODE="ths"
virtual_window="yes"
;;
*)
AC_DEFINE(_MGRM_PROCESSES, 1,
[Define if build MiniGUI-Processes])
MINIGUI_RUNMODE="processes"
MINIGUI_RUNMODE="procs"
RUNMODE_LADD="server/libserver.la client/libclient.la"
RUNMODE_SUBDIRS="server client"
if test "x$compositing_schema" = "xyes"; then
@@ -2664,7 +2664,6 @@ if test "x$no_math" = "xno"; then
fi
DEP_LIBS="$DEP_LIBS -lpthread"
MINIGUI_RUNMODE="$MINIGUI_RUNMODE-${surface_schema}"
AC_SUBST(VIDEO_SUBDIRS)
AC_SUBST(VIDEO_DRIVERS)
+8 -53
View File
@@ -55,36 +55,6 @@ wallpaper_pattern_size=full
# def_compositor_so=
#}}
#{{ifdef _MGGAL_SHADOW
[shadow]
real_engine=pc_xvfb
defaultmode=800x600-16bpp
# `cw`: rotating screen clock-wise.
# `ccw`: rotating screen counter clock-wise.
# `hflip`: flipping screen horizontally.
# `vflip`: flipping screen vertically.
rotate_screen=ccw
# Whether the async. update is enabled.
# Use `true` or `yes` for enabled, anything else for disabled.
# Since 5.0.13.
async_update=yes
# The synchronization interval for the asyn. updater (milli-seconds).
# This setting is only valid when `async_update` is enabled and
# the real engine does not provide WaitWBlank method.
# Since 5.0.13.
update_interval=15
# The minimal pixels to use the hardware accelerator.
# If the number of pixels to copy is less than this value,
# MiniGUI will use the software copy routine to update the real screen,
# even if the real device provides a hardware accelerator.
# Since 5.0.13.
min_pixels_using_hwaccl=4096
#}}
#{{ifdef _MGGAL_DRM
[drm]
defaultmode=1024x768-32bpp
@@ -108,21 +78,9 @@ dpi=96
# Since 5.0.0.
double_buffering=true
# The update interval for the asyn. updater (milli-seconds).
# This setting is only valid when drmWaitVBlank doesn't work correctly.
# Since 5.0.13.
update_interval=15
# The minimal pixels to use the hardware accelerator.
# If the number of pixels to copy is less than this value,
# MiniGUI will use the software copy routine to update the real screen,
# even if the device provides a hardware accelerator.
# Since 5.0.13.
min_pixels_using_hwaccl=4096
# The filename of the shared library for the external driver.
# The equivalent environment variable: MG_GAL_DRM_DRIVER
exdriver=libdrmdrivers.so
exdriver=libhidrmdrivers-0.2.so.0
#}}
#{{ifdef _MGIAL_SINGLETOUCHKEY
@@ -153,16 +111,6 @@ dpi=96
# Note that under compositing schema, double buffering is always enabled.
# Since 5.0.10.
double_buffering=true
# Whether the async. update is enabled.
# Use `true` or `yes` for enabled, anything else for disabled.
# Since 5.0.13.
async_update=yes
# The update interval for the asyn. updater (milli-seconds).
# This setting is only valid when drmWaitVBlank doesn't work correctly.
# Since 5.0.13.
update_interval=15
#}}
#{{ifdef _MGGAL_PCXVFB
@@ -175,6 +123,13 @@ exec_file=/usr/local/bin/gvfb
[rtos_xvfb]
defaultmode=800x600-16bpp
#{{ifdef _MGGAL_SHADOW
[shadow]
real_engine=pc_xvfb
defaultmode=800x600-16bpp
rotate_screen=ccw
#}}
#{{ifdef _MGGAL_MLSHADOW
[mlshadow]
real_engine=qvfb
-3
View File
@@ -268,8 +268,6 @@ MGUI_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8);
#define MG_UNLIKELY(expr) (expr)
#endif
#define HAVE(FEATURE) (defined HAVE_##FEATURE && HAVE_##FEATURE)
/**
* \defgroup endian_info Endianness information
* @{
@@ -2349,7 +2347,6 @@ int init_minigui_printf (int (*output_char) (int ch),
#define _ERR_PRINTF(fmt, ...) \
do { \
TCS_RED (stderr); \
fprintf (stderr, "%s: ", __FUNCTION__); \
fprintf (stderr, fmt, ##__VA_ARGS__); \
TCS_NONE (stderr); \
} while (0)
+82 -62
View File
@@ -84,14 +84,6 @@ extern "C" {
* @{
*/
/** The current version of DRM driver. */
#define DRM_DRIVER_VERSION 2
#define DRM_SURBUF_TYPE_OFFSCREEN 0x0000
#define DRM_SURBUF_TYPE_SHADOW 0x0001
#define DRM_SURBUF_TYPE_SCANOUT 0x0002
#define DRM_SURBUF_TYPE_MASK 0x000F
/**
* The struct type represents the DRI sub driver.
* The concrete struct should be defined by the driver.
@@ -137,8 +129,6 @@ typedef struct _DrmSurfaceBuffer {
uint32_t dumb:1;
/** Is it a scanout buffer. Since 5.0.0. */
uint32_t scanout:1;
/** The buffer is also a dma-buf. Since 5.0.13. */
uint32_t dma_buf:1;
/** The width of the buffer. */
uint32_t width;
@@ -164,23 +154,11 @@ typedef struct _DrmSurfaceBuffer {
* The address of the pixel data:
* uint8_t* pixels = this->buff + this->offset;
*/
uint8_t* vaddr;
uint8_t* buff;
} DrmSurfaceBuffer;
typedef struct _DrmBlitOperations {
BlitCopyOperation cpy;
BlitKeyOperation key;
BlitAlphaOperation alf;
ColorBlendMethod bld;
ColorLogicalOp rop;
ScalingFilter scl;
uint32_t key_min, key_max;
uint8_t alpha;
} DrmBlitOperations;
/**
* The structure type defines the operations for a userland DRM driver.
* The structure type defines the operations for a DRM driver.
*/
typedef struct _DrmDriverOps {
/**
@@ -198,13 +176,12 @@ typedef struct _DrmDriverOps {
void (*destroy_driver) (DrmDriver *driver);
/**
* This operation flushes the batch buffer of the driver and/or
* the specified buffer.
* This operation flushes the batch buffer of the driver or
* the hardware cache.
*
* \note This operation can be NULL.
*/
void (* flush) (DrmDriver *driver, DrmSurfaceBuffer* buff,
const GAL_Rect *dirty_rect);
void (* flush_driver) (DrmDriver *driver);
/**
* This operation creates a surface buffer with the specified pixel format,
@@ -217,7 +194,7 @@ typedef struct _DrmDriverOps {
*/
DrmSurfaceBuffer* (* create_buffer) (DrmDriver *driver,
uint32_t drm_format, uint32_t hdr_size,
uint32_t width, uint32_t height, unsigned flags);
uint32_t width, uint32_t height);
/**
* This operation creates a buffer from a given and possibly foreign handle
@@ -230,9 +207,7 @@ typedef struct _DrmDriverOps {
* DrmSurfaceBuffer object.
*/
DrmSurfaceBuffer* (* create_buffer_from_handle) (DrmDriver *driver,
uint32_t handle, size_t size,
uint32_t drm_format, uint32_t hdr_size,
uint32_t width, uint32_t height, uint32_t pitch);
uint32_t handle, size_t size);
/**
* This operation creates a buffer for the given system global name
@@ -244,9 +219,7 @@ typedef struct _DrmDriverOps {
* DrmSurfaceBuffer object.
*/
DrmSurfaceBuffer* (* create_buffer_from_name) (DrmDriver *driver,
uint32_t name,
uint32_t drm_format, uint32_t hdr_size,
uint32_t width, uint32_t height, uint32_t pitch);
uint32_t name);
/**
* This operation creates a buffer for the given PRIME file descriptor
@@ -258,19 +231,21 @@ typedef struct _DrmDriverOps {
* DrmSurfaceBuffer object.
*/
DrmSurfaceBuffer* (* create_buffer_from_prime_fd) (DrmDriver *driver,
int prime_fd, size_t size,
uint32_t drm_format, uint32_t hdr_size,
uint32_t width, uint32_t height, uint32_t pitch);
int prime_fd, size_t size);
/**
* This operation maps the buffer into the current process's virtual memory
* space, and returns the virtual address. If failed, it returns NULL.
*
* When \a for_scanout is not zero, the buffer will be used for scan out
* frame buffer.
*
* \note The driver must implement this operation. The driver must
* set a valid value for buff field of the DrmSurfaceBuffer object
* on success.
*/
uint8_t* (* map_buffer) (DrmDriver *driver, DrmSurfaceBuffer* buffer);
uint8_t* (* map_buffer) (DrmDriver *driver, DrmSurfaceBuffer* buffer,
int for_scanout);
/**
* This operation un-maps a buffer.
@@ -289,51 +264,96 @@ typedef struct _DrmDriverOps {
void (* destroy_buffer) (DrmDriver *driver, DrmSurfaceBuffer* buffer);
/**
* This operation fills the specific rectangle area of a buffer
* This operation clears the specific rectangle area of a buffer
* with the specific pixel value. If succeed, it returns 0.
*
* \note If this operation is set as NULL, the driver does not support
* hardware accelerated filling operation.
* hardware accelerated clear operation.
*/
int (* fill_rect) (DrmDriver *driver,
int (* clear_buffer) (DrmDriver *driver,
DrmSurfaceBuffer* dst_buf, const GAL_Rect* rc, uint32_t pixel_value);
/**
* This operation checks whether a specified hardware accelerated blit
* This operation checks whether a hardware accelerated blit
* can be done between the source buffer and the destination buffer.
* If succeed, it returns zero, otherwise for failure.
* If succeed, it is safe to call do_blit operation.
* If succeed, it returns 0.
*
* \note If this operation is set as NULL, it will be supposed that
* the driver does not support any hardware accelerated blitting operation.
*/
int (* check_blit) (DrmDriver *driver,
DrmSurfaceBuffer* src_buf, const GAL_Rect* src_rc,
DrmSurfaceBuffer* dst_buf, const GAL_Rect* dst_rc,
const DrmBlitOperations *ops);
DrmSurfaceBuffer* src_buf, DrmSurfaceBuffer* dst_buf);
/**
* This operation does the real blit. It should not be NULL if check_blit
* is not NULL.
*/
int (* do_blit) (DrmDriver *driver,
DrmSurfaceBuffer *src_buf, const GAL_Rect *src_rc,
DrmSurfaceBuffer *dst_buf, const GAL_Rect *dst_rc,
const DrmBlitOperations *blit_ops);
/**
* This operation copies the pixels from the source buffer to
* the destination buffer, with or without scaling, rotation, and flip.
* This operation copies bits from a source buffer to a destination buffer.
*
* \note If this operation is set as NULL, the driver does not support
* hardware accelerated copy operation between buffers.
* hardware accelerated copy blitting.
*
* \note Currently, the logical operation is ignored.
*/
int (* copy_buff) (DrmDriver *driver,
int (* copy_blit) (DrmDriver *driver,
DrmSurfaceBuffer* src_buf, const GAL_Rect* src_rc,
DrmSurfaceBuffer* dst_buf, const GAL_Rect* dst_rc,
BlitCopyOperation op);
ColorLogicalOp logic_op);
/**
* This operation blits pixels from a source buffer with the source alpha
* value specified to a destination buffer.
*
* \note If this operation is set as NULL, the driver does not support
* hardware accelerated blitting with alpha.
*/
int (* alpha_blit) (DrmDriver *driver,
DrmSurfaceBuffer* src_buf, const GAL_Rect* src_rc,
DrmSurfaceBuffer* dst_buf, const GAL_Rect* dst_rc,
uint8_t alpha);
/**
* This operation blits pixels from a source buffer to a destination buffer,
* but skipping the pixel value specified by \a color_key.
*
* \note If this operation is set as NULL, the driver does not support
* hardware accelerated blitting with color key.
*/
int (* key_blit) (DrmDriver *driver,
DrmSurfaceBuffer* src_buf, const GAL_Rect* src_rc,
DrmSurfaceBuffer* dst_buf, const GAL_Rect* dst_rc,
uint32_t color_key);
/**
* This operation blits pixels from a source buffer with the source alpha
* value specified to a destination buffer, but skipping the pixel value
* specified.
*
* \note If this operation is set as NULL, the driver does not support
* hardware accelerated blitting with alpha and color key.
*/
int (* alpha_key_blit) (DrmDriver *driver,
DrmSurfaceBuffer* src_buf, const GAL_Rect* src_rc,
DrmSurfaceBuffer* dst_buf, const GAL_Rect* dst_rc,
uint8_t alpha, uint32_t color_key);
/**
* This operation blits pixels from a source buffer with the source alpha
* value of pixels to the destination buffer, and with the specified color
* compositing/blending method (\a ColorBlendMethod).
*
* \note If this operation is set as NULL, the driver does not support
* hardware accelerated blitting with alpha on basis per pixel.
*
* \note Currently, the color compositing/blending method is ignored.
*/
int (* alpha_pixel_blit) (DrmDriver *driver,
DrmSurfaceBuffer* src_buf, const GAL_Rect* src_rc,
DrmSurfaceBuffer* dst_buf, const GAL_Rect* dst_rc,
ColorBlendMethod blend_method);
} DrmDriverOps;
/** The current version of DRM driver. */
#define DRM_DRIVER_VERSION 1
/**
* Implement this stub to return the DRI driver operations
*
+28 -358
View File
@@ -1704,304 +1704,6 @@ MG_EXPORT BOOL GUIAPI IsScreenDC (HDC hdc);
*/
MG_EXPORT BOOL GUIAPI IsWindowDC (HDC hdc);
struct GAL_Surface;
typedef struct GAL_Surface *HSURF;
#ifdef _MGSCHEMA_COMPOSITING
/**
* \fn HSURF GUIAPI CreateSharedSurface (GHANDLE video,
* const char *name, DWORD flags,
* int width, int height, int depth,
* Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
* \brief Creates a shared surface for specified size and pixel format.
*
* This function creates a shared surface on the current video device with
* the specified size and pixel format. This function also registers
* the shared surface by using the specified name \a name to the server
* if \a name is not NULL. Another client can use the name to get
* the shared surface by calling \a GetSharedSurfaceFDByName().
* \param video The handle to the video; NULL for the current default video.
* \param name The gobal unique name for the shared surface.
* \param flags The flags, can be one of the following values:
* - MEMDC_FLAG_SWSURFACE\n
* Creates the surface in the system memory.
* - MEMDC_FLAG_HWSURFACE\n
* Creates the surface in the video memory.
* \param width The expected width of the result surface.
* \param height The expected height of the result surface.
* \param depth The expected color depth of the surface.
* \param Rmask The bit-masks of the red components in a pixel value.
* \param Gmask The bit-masks of the green components in a pixel value.
* \param Bmask The bit-masks of the blue components in a pixel value.
* \param Amask The bit-masks of the alpha components in a pixel value.
*
* \return The file descriptor which represents the new shared surface buffer;
* a value less than 0 indicates an error.
*
* \note This function only available when _MGSCHEMA_COMPOSITING is defined.
*
* \sa DestroySharedSurface, GetSharedSurfaceFDByName
*
* Since 5.2.0
*/
MG_EXPORT HSURF GUIAPI CreateSharedSurface (GHANDLE video,
const char *name, DWORD flags,
int width, int height, int depth,
Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
/**
* \fn BOOL GUIAPI GUIAPI DestroySharedSurface (HSURF surf, const char *name)
* \brief Destroies a shared surface.
*
* This function destroies the specified shared surface \a surf,
* and/or revoke the global unique name \a name from the server if \a name
* is not NULL.
* \param surf The handle to the shared surface.
* \param name The gobal unique name for the shared surface.
*
* \return TRUE on success, otherwise failure.
*
* \note This function only available when _MGSCHEMA_COMPOSITING is defined.
*
* \sa CreateSharedSurface
*
* Since 5.2.0
*/
MG_EXPORT BOOL GUIAPI DestroySharedSurface (HSURF surf);
/**
* \fn int GUIAPI GetSharedSurfaceFDByClientWindow (int client,
* HWND hwnd, size_t *map_size, DWORD *flags)
* \brief Gets the file descriptor of the shared surface of a window created
* by another client.
*
* This function gets the file descriptor of the shared surface of the window
* \a hwnd, which is created by another client. If there is one such window
* in the system, the server will return a file descriptor which represents
* the shared surface of the window to the caller.
*
* \param client The client identifier.
* \param hwnd The handle to the window created by the client.
* \param map_size The pointer to a buffer of size_t to receive the whole size
* of the shared surface in bytes; nullable.
* \param flags The pointer to a buffer of DWORD to receive the flags of
* the shared surface; nullable.
*
* \return The file descriptor which represents the shared surface on success;
* a value less than 0 for failure.
*
* \note This function only available when _MGSCHEMA_COMPOSITING is defined.
*
* \sa AttachToSharedSurface, GetWindowSharedSurfaceFD
*
* Since 5.2.0
*/
MG_EXPORT int GUIAPI GetSharedSurfaceFDByClientWindow (int client,
HWND hwnd, size_t *map_size, DWORD *flags);
/**
* \fn int GUIAPI GetSharedSurfaceFDByName (const char *name,
* size_t *map_size, DWORD *flags)
* \brief Gets the file descriptor of a shared surface by name.
*
* This function gets the file descriptor of the shared surface created
* by \a CreateSharedSurface by another client. If there is one such window
* in the system, the server will return a file descriptor which represents
* the shared surface.
*
* \param name The gobal unique name for the shared surface.
* \param map_size The pointer to a buffer of size_t to receive the whole size
* of the shared surface in bytes; nullable.
* \param flags The pointer to a buffer of DWORD to receive the flags of
* the shared surface; nullable.
*
* \return The file descriptor which represents the shared surface on success;
* a value less than 0 for failure.
*
* \note This function only available when _MGSCHEMA_COMPOSITING is defined.
*
* \sa CreateSharedSurface, AttachToSharedSurface
*
* Since 5.2.0
*/
MG_EXPORT int GUIAPI GetSharedSurfaceFDByName (const char *name,
size_t *map_size, DWORD *flags);
/**
* \fn HSURF GUIAPI AttachToSharedSurface (GHANDLE video, int fd,
* size_t map_size, DWORD flags)
* \brief Attaches to a shared surface.
*
* This function attaches to the shared surface which is represents by
* the given file descriptor \a fd.
*
* \param video The handle to the video; NULL for the current default video.
* \param fd The file descriptor of the shared surface.
*
* \return The handle to the shared surface on success; NULL for failure.
*
* \note This function only available when _MGSCHEMA_COMPOSITING is defined.
*
* \sa GetSharedSurfaceFDByName, DetachFromSharedSurface
*
* Since 5.2.0
*/
MG_EXPORT HSURF GUIAPI AttachToSharedSurface (GHANDLE video, int fd,
size_t map_size, DWORD flags);
/**
* \fn const char *GUIAPI GetSharedSurfaceInfo (HSURF surf, int *fd,
* SIZE *size, int *pitch, size_t *map_size, off_t *pixels_off)
* \brief Gets the basic information of a shared surface.
*
* This function gets the name and other information of
* the given shared surface \a surf. It also returns the file descriptor,
* the size, or the pitch of the surface if \a fd, \a size or \a pitch
* is not NULL.
*
* \param surf The handle to the shared surface.
* \param fd The pointer to a buffer of int to return the file descriptor of
* the shared surface; nullable.
* \param size The pointer to a buffer of SIZE to return the size of
* the shared surface; nullable.
* \param pitch The pointer to a buffer of int for value of pitch; nullable.
* \param file_size The pointer to a buffer of size_t for the whole file size;
* nullable.
* \param pixel_off The pointer to a buffer of size_t for the offset of
* pixel data; nullable.
*
* \return The name of the shared surface on success; NULL for failure.
* Note that if the name is an empty string, it is an anonymous surface.
*
* \note This function only available when _MGSCHEMA_COMPOSITING is defined.
*
* \sa GetSharedSurfaceFDByName, DetachFromSharedSurface
*
* Since 5.2.0
*/
MG_EXPORT const char *GUIAPI GetSharedSurfaceInfo (HSURF surf, int *fd,
SIZE *size, int *pitch, size_t *map_size, off_t *pixels_off);
/**
* \fn BOOL GUIAPI TestIfSharedSurfaceChanged (HSURF surf,
* unsigned dirty_age)
* \brief Tests if a shared surface changed.
*
* This function tests if the given shared surface \a surf had changed, i.e.,
* it has a different dirty age value against the specified value \a dirty_age.
*
* \param surf The handle to the shared surface.
* \param dirty_age The dirty age to compare.
*
* \return TRUE for changed; FALSE for no change or failure.
*
* \note This function only available when _MGSCHEMA_COMPOSITING is defined.
*
* \sa LockSharedSurface
*
* Since 5.2.0
*/
MG_EXPORT BOOL GUIAPI TestIfSharedSurfaceChanged (HSURF surf,
unsigned dirty_age);
/**
* \fn BOOL GUIAPI LockSharedSurface (HSURF surf,
* unsigned *dirty_age, int *nr_dirty_rects, const RECT **dirty_rects)
* \brief Locks the shared surface for read.
*
* This function locks the given shared surface \a surf and returns
* the dirty information.
*
* \param surf The handle to the shared surface.
* \param dirty_age The pointer to a buffer of unsigned integer to
* return the latest dirty age of the shared surface; nullable.
* \param nr_dirty_rects The pointer to a buffer of integer to return the valid
* dirty rectangles; nullable.
* \param dirty_rects The pointer to a buffer of (const RECT *) for the array
* of dirty rectangles; nullable.
*
* \return TRUE for locked; FALSE for failure.
*
* \note This function only available when _MGSCHEMA_COMPOSITING is defined.
*
* \sa UnlockSharedSurface
*
* Since 5.2.0
*/
MG_EXPORT BOOL GUIAPI LockSharedSurface (HSURF surf,
unsigned *dirty_age, int *nr_dirty_rects, const RECT **dirty_rects);
/**
* \fn BOOL GUIAPI UnlockSharedSurface (HSURF surf)
* \brief Unlocks the shared surface.
*
* This function unlocks the given shared surface \a surf.
*
* \param surf The handle to the shared surface.
*
* \return TRUE on success; otherwise failure.
*
* \note This function only available when _MGSCHEMA_COMPOSITING is defined.
*
* \sa LockSharedSurface
*
* Since 5.2.0
*/
MG_EXPORT BOOL GUIAPI UnlockSharedSurface (HSURF surf);
/**
* \fn BOOL GUIAPI DetachFromSharedSurface (HSURF surf)
* \brief Detaches from a shared surface.
*
* This function detaches from the shared surface \a surf and delete the memory
* used by the surface.
*
* \param surf The handle to the shared surface.
*
* \return TRUE on success; otherwise failure.
*
* \note This function only available when _MGSCHEMA_COMPOSITING is defined.
*
* \sa AttachToSharedSurface
*
* Since 5.2.0
*/
MG_EXPORT BOOL GUIAPI DetachFromSharedSurface (HSURF surf);
#endif /* _MGSCHEMA_COMPOSITING */
/**
* \fn HDC GUIAPI CreateMemDCFromSurface (HSURF surf);
* \brief Creates a memory DC from a surface.
*
* This function creates a memory DC on the specified surface \a surf.
*
* \param surf The handle to the shared surface.
*
* \return The handle to a new memory DC, HDC_INVALID indicates an error.
*
* \sa DeleteMemDC
*
* Since 5.2.0
*/
MG_EXPORT HDC GUIAPI CreateMemDCFromSurface(HSURF surf);
/**
* \fn HSURF GUIAPI GetSurfaceFromDC(HDC hdc);
* \brief Gets surface handle from a DC.
*
* This function returns the handle to the surface of the given DC \a hdc.
*
* \param hdc The handle to the DC.
*
* \return The handle to the surface, NULL for failure.
*
* \sa CreateMemDCFromSurface
*
* Since 5.2.0
*/
MG_EXPORT HSURF GUIAPI GetSurfaceFromDC(HDC hdc);
/**
* \fn HDC GUIAPI CreateMemDCEx (int width, int height, int depth, DWORD flags, \
Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask,
@@ -5460,27 +5162,6 @@ MG_EXPORT BOOL GUIAPI FillBitmapPartInBox (HDC hdc, int box_x, int box_y,
int box_w, int box_h, const BITMAP* pbmp, int bmp_x, int bmp_y,
int bmp_w, int bmp_h);
typedef enum {
BLIT_COPY_TRANSLATE = 0,
BLIT_COPY_ROT_90,
BLIT_COPY_ROT_180,
BLIT_COPY_ROT_270,
BLIT_COPY_FLIP_H,
BLIT_COPY_FLIP_V,
BLIT_COPY_FLIP_H_V
} BlitCopyOperation;
typedef enum {
BLIT_COLORKEY_NONE = 0,
BLIT_COLORKEY_NORMAL,
BLIT_COLORKEY_INVERTED,
} BlitKeyOperation;
typedef enum {
BLIT_ALPHA_NONE = 0,
BLIT_ALPHA_SET,
} BlitAlphaOperation;
/**
* The color blend mothed.
*
@@ -5489,8 +5170,7 @@ typedef enum {
*/
typedef enum {
COLOR_BLEND_LEGACY = 0,
COLOR_BLEND_MASK = 0xFFFF,
COLOR_BLEND_PIXMAN_MASK = 0x00FF,
COLOR_BLEND_FLAGS_MASK = 0x00FF,
/** Porter Duff rule: clear */
COLOR_BLEND_PD_CLEAR = 0x0100, // PIXMAN_OP_CLEAR = 0x00
@@ -5629,24 +5309,21 @@ typedef enum {
*/
typedef enum {
COLOR_LOGICOP_CLEAR = 0,
COLOR_LOGICOP_NOR = 0x01 << 24,
COLOR_LOGICOP_AND_INVERTED = 0x02 << 24,
COLOR_LOGICOP_COPY_INVERTED = 0x03 << 24,
COLOR_LOGICOP_AND_REVERSE = 0x04 << 24,
COLOR_LOGICOP_INVERT = 0x05 << 24,
COLOR_LOGICOP_XOR = 0x06 << 24,
COLOR_LOGICOP_NAND = 0x07 << 24,
COLOR_LOGICOP_AND = 0x08 << 24,
COLOR_LOGICOP_EQUIV = 0x09 << 24,
COLOR_LOGICOP_NOOP0 = 0x0A << 24,
COLOR_LOGICOP_OR_INVERTED1 = 0x0B << 24,
COLOR_LOGICOP_COPY = 0x0C << 24,
COLOR_LOGICOP_OR_REVERSE = 0x0D << 24,
COLOR_LOGICOP_OR = 0x0E << 24,
COLOR_LOGICOP_SET = 0x0F << 24,
COLOR_LOGICOP_MASK = 0x0F << 24,
COLOR_LOGICOP_SHIFT = 24,
COLOR_LOGICOP_NOR,
COLOR_LOGICOP_AND_INVERTED,
COLOR_LOGICOP_COPY_INVERTED,
COLOR_LOGICOP_AND_REVERSE,
COLOR_LOGICOP_INVERT,
COLOR_LOGICOP_XOR,
COLOR_LOGICOP_NAND,
COLOR_LOGICOP_AND,
COLOR_LOGICOP_EQUIV,
COLOR_LOGICOP_NOOP0,
COLOR_LOGICOP_OR_INVERTED1,
COLOR_LOGICOP_COPY,
COLOR_LOGICOP_OR_REVERSE,
COLOR_LOGICOP_OR,
COLOR_LOGICOP_SET,
} ColorLogicalOp;
/**
@@ -5676,18 +5353,15 @@ typedef enum {
* in the destination DC.
* \param dy The y coordinate of the upper-left corner of the rectangle
* in the destination DC.
* \param dwRop The color blending method, see \a ColorBlendMethod, OR'd
* with a color logical operation, see \a ColorLogicalOp.
* This argument is only valid when Pixman is used, or the hardware
* provides a proper accelerator.
* \param dwRop The color blending method, see \a ColorBlendMethod.
* This argument is only valid when Pixman is used.
*
* \note When the source color key is specified for the blitting operation,
* or the formats of the device contexts are not supported by Pixman,
* this function will use the legacy implementation. In this situation,
* the color blending method will be ignored.
*
* \sa StretchBlt, SetMemDCAlpha, SetMemDCColorKey, ColorBlendMethod,
* ColorLogicalOp
* \sa StretchBlt, SetMemDCAlpha, SetMemDCColorKey, ColorBlendMethod
*/
MG_EXPORT void GUIAPI BitBlt (HDC hsdc, int sx, int sy, int sw, int sh,
HDC hddc, int dx, int dy, DWORD dwRop);
@@ -5697,19 +5371,17 @@ MG_EXPORT void GUIAPI BitBlt (HDC hsdc, int sx, int sy, int sw, int sh,
*/
typedef enum {
/** The fast filter (DDA scaler) */
SCALING_FILTER_FAST = 0x0000 << 16,
SCALING_FILTER_FAST = 0x00000000,
/** The good filter */
SCALING_FILTER_GOOD = 0x0001 << 16,
SCALING_FILTER_GOOD = 0x00010000,
/** The best filter */
SCALING_FILTER_BEST = 0x0002 << 16,
SCALING_FILTER_BEST = 0x00020000,
/** The filter using nearest algorithm */
SCALING_FILTER_NEAREST = 0x0003 << 16,
SCALING_FILTER_NEAREST = 0x00020000,
/** The filter using bi-linear algorithm */
SCALING_FILTER_BILINEAR = 0x0004 << 16,
SCALING_FILTER_BILINEAR = 0x00040000,
/** The filter using convolution algorithm */
SCALING_FILTER_CONVOLUTION = 0x0005 << 16,
SCALING_FILTER_MASK = (0x0F << 16),
SCALING_FILTER_CONVOLUTION = 0x00050000,
SCALING_FILTER_SHIFT = 16,
} ScalingFilter;
@@ -5763,10 +5435,8 @@ typedef struct _STRETCH_EXTRA_INFO {
* \param sei The pointer to a stretch extra information strucure;
* can be NULL. Note this only works when Pixman is used.
* \param dwRop The color blending method, see \a ColorBlendMethod, OR'd
* with a fiter of the scaling, see \a ScalingFilter, and OR'd
* with a color logical operation, see \a ColorLogicalOp.
* This argument only works when Pixman is used or the hardware
* provides a proper accelerator.
* with a fiter of the scaling, see \a ScalingFilter.
* This argument only works when Pixman is used.
*
* \return TRUE for success, FALSE for bad arguments and there is no any
* drawing occurred.
@@ -5778,7 +5448,7 @@ typedef struct _STRETCH_EXTRA_INFO {
* will be ignored.
*
* \sa BitBlt, SetMemDCAlpha, SetMemDCColorKey, STRETCH_EXTRA_INFO,
* ColorBlendMethod, ScalingFilter, ColorLogicalOp
* ColorBlendMethod, ScalingFilter
*/
MG_EXPORT BOOL GUIAPI StretchBltEx (HDC hsdc, int sx, int sy, int sw, int sh,
HDC hddc, int dx, int dy, int dw, int dh,
+4 -85
View File
@@ -456,45 +456,6 @@ MG_EXPORT void GUIAPI MiniGUIPanic (int exitcode);
* @{
*/
/**
* \fn GHANDLE GUIAPI JoinLayerEx (const char* layer_name,
const char* client_name,
int max_nr_highers, int max_nr_normals, int *cli_id)
* \brief Joins to a layer and returns the client identifier if success.
*
* This function should be called by clients before calling any other MiniGUI
* functions. You can call \a GetLayerInfo to get the layer information.
* If the layer to be joined does not exist, the server, i.e. \a mginit, will
* try to create a new one. If you passed a NULL pointer or a null string for
* \a layer_name, the client will join to the default layer.
*
* If the client want to create a new layer, you should specify the maximal
* number of z-nodes in the higher level (max_nr_highers) and the maximal
* number of z-nodes in the normal level (max_nr_normals) of the new layer.
* Passing zero to \a max_nr_highers and max_nr_normals will use the default
* values, and the default values are specified by ServerStartup.
*
* Note that the server will create a default layer named "mginit".
*
* \param layer_name The name of the layer. You can use NAME_TOPMOST_LAYER to
* specify the current topmost layer.
* \param client_name The name of the client.
* \param max_nr_highers The maximal number of z-nodes in the higher level of
* the new layer.
* \param max_nr_normals The maximal number of z-nodes in the normal level of
* the new layer.
* \param cli_id The pointer to a buffer of int to return the client identifier.
*
* \return The handle to the layer on success, INV_LAYER_HANDLE on error.
*
* \note Only call this function in clients of MiniGUI-Processes.
*
* \sa GetLayerInfo, ServerStartup, ServerCreateLayer
*/
MG_EXPORT GHANDLE GUIAPI JoinLayerEx (const char* layer_name,
const char* client_name,
int max_nr_highers, int max_nr_normals, int *cli_id);
/**
* \fn GHANDLE GUIAPI JoinLayer (const char* layer_name,
const char* client_name,
@@ -529,30 +490,9 @@ MG_EXPORT GHANDLE GUIAPI JoinLayerEx (const char* layer_name,
*
* \sa GetLayerInfo, ServerStartup, ServerCreateLayer
*/
static inline GHANDLE GUIAPI JoinLayer (const char* layer_name,
MG_EXPORT GHANDLE GUIAPI JoinLayer (const char* layer_name,
const char* client_name,
int max_nr_highers, int max_nr_normals)
{
return JoinLayerEx (layer_name, client_name,
max_nr_highers, max_nr_normals, NULL);
}
/**
* \fn int GUIAPI GetClientId (void)
* \brief Gets the client identifier.
*
* You can get the information of a layer through this function.
* The information will be returned through the pointer arguments
* if the specific pointer is not NULL.
*
* \return Returns the client identifier of the current process.
* Note that the server always returns 0.
*
* \sa JoinLayerEx
*
* Since 5.2.0
*/
MG_EXPORT int GUIAPI GetClientId (void);
int max_nr_highers, int max_nr_normals);
/**
* \fn GHANDLE GUIAPI GetLayerInfo (const char* layer_name,
@@ -2185,7 +2125,7 @@ MG_EXPORT int GUIAPI ServerSendReplyEx (int clifd,
* \fn int GUIAPI ServerSendReply (int clifd, const void* reply, int len)
* \brief Sends the reply to the client.
*
* This function sends a reply pointed to by \a reply which is
* This function sends a replay pointed to by \a reply which is
* \a len bytes long to the client.
*
* \note Only used by the server to send the reply to the client.
@@ -2733,26 +2673,6 @@ MG_EXPORT void GUIAPI DesktopUpdateAllWindow (void);
#define DUMMY_LAYER_HANDLE (GHANDLE)(-1)
/**
* \fn GHANDLE GUIAPI JoinLayerEx (const char* layer_name,
const char* client_name,
int max_nr_highers, int max_nr_normals, int *cli_fd)
* \brief The dummy replacement of the same function for MiniGUI-Processes.
*
* This function is a replacment of the same function for MiniGUI-Processes
* runtime mode. We provide this function for MiniGUI-Threads and
* MiniGUI-Standalone runtime modes, in order to avoid using the
* conditional compilation instructions in your source code.
*
* \return Always returns DUMMY_LAYER_HANDLE to indicate success.
*/
static inline GHANDLE GUIAPI JoinLayerEx (const char* layer_name,
const char* client_name,
int max_nr_highers, int max_nr_normals, int *cli_fd)
{
return DUMMY_LAYER_HANDLE;
}
/**
* \fn GHANDLE GUIAPI JoinLayer (const char* layer_name,
const char* client_name,
@@ -2767,8 +2687,7 @@ static inline GHANDLE GUIAPI JoinLayerEx (const char* layer_name,
* \return Always returns DUMMY_LAYER_HANDLE to indicate success.
*/
static inline GHANDLE GUIAPI JoinLayer (const char* layer_name,
const char* client_name,
int max_nr_highers, int max_nr_normals)
const char* client_name, int max_nr_highers, int max_nr_normals)
{
return DUMMY_LAYER_HANDLE;
}
+3 -32
View File
@@ -2990,22 +2990,18 @@ typedef struct _WINMASKINFO {
if the client moved to a new layer */
#define MSG_LAYERCHANGED 0x0149
/* Since 5.2.0; the server send this message to the client
if a window has been composited to the screen. */
#define MSG_WINCOMPOSITED 0x014A
#endif /* defined _MGRM_PROCESSES */
/* Since 5.0.0: for managing message thread */
#define MSG_MANAGE_MSGTHREAD 0x014B
#define MSG_MANAGE_MSGTHREAD 0x014A
#define MSGTHREAD_SIGNIN 0x00
#define MSGTHREAD_SIGNOUT 0x01
/* Since 5.0.0: for calculating the default position */
#define MSG_CALC_POSITION 0x014C
#define MSG_CALC_POSITION 0x014B
/* Since 5.0.6: for waking up the client */
#define MSG_WAKEUP_CLIENT 0x014D
#define MSG_WAKEUP_CLIENT 0x014C
/**
* \def MSG_DOESNEEDIME
@@ -7241,31 +7237,6 @@ MG_EXPORT BOOL GUIAPI SetMainWindowGestureFlags (HWND hWnd, DWORD dwFlags);
#ifdef _MGSCHEMA_COMPOSITING
/**
* \fn int GUIAPI GetWindowSharedSurfaceFD (HWND hwnd, size_t *map_size,
* DWORD *flags)
* \brief Gets the file descriptor of the surface buffer for a window or
* the main window it locates.
*
* This function gets the file descriptor of the surface buffer for
* the specified window if it is a main window or the main window it locates.
* Note that if the window is a control that has the style `WS_EX_CTRLASMAINWIN`,
* the window will have a separate surface buffer.
*
* \param hwnd The handle to the window.
*
* \return An integer larger than or equal to 0 for a valid file descriptor,
* otherwise a negative value.
*
* \note This function only available when _MGSCHEMA_COMPOSITING is defined.
*
* \sa CreateMemDCFromSharedSurfaceFD
*
* Since 5.0.13
*/
MG_EXPORT int GUIAPI GetWindowSharedSurfaceFD (HWND hWnd, size_t *map_size,
DWORD *flags);
/**
* \fn BOOL GUIAPI SetMainWindowCompositing (HWND hWnd,
int type, DWORD arg)
+1 -2
View File
@@ -2,12 +2,11 @@ prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
runmode=@MINIGUI_RUNMODE@
libsuffix=@MGLIB_SUFFIX@
Name: MiniGUI
Description: A mature cross-platform windowing and GUI system for embedded systems and IoT smart devices.
Version: @MINIGUI_VERSION@
Runmode: @MINIGUI_RUNMODE@
Requires:
Libs: -L${libdir} -lminigui_@MGLIB_SUFFIX@ @DEP_LIBS@
Libs.private:
+3 -32
View File
@@ -184,23 +184,6 @@ static void process_socket_message (MSG *msg)
LOSWORD(msg->wParam), HISWORD(msg->wParam),
LOSWORD(msg->lParam), HISWORD(msg->lParam));
}
#ifdef _MGSCHEMA_COMPOSITING
else if (msg->message == MSG_WINCOMPOSITED) {
/* Since 5.2.0 */
int slot = (int)msg->wParam;
HWND hwnd = (HWND)msg->lParam;
unsigned dirty_age = (unsigned)msg->time;
if (__mg_client_check_znode_hwnd(slot, hwnd, __mg_client_id)) {
GAL_Surface *ssurf = ((PMAINWIN)hwnd)->surf;
assert(ssurf->shared_header);
__mg_lock_file_for_write(ssurf->fd);
if (ssurf->dirty_info->dirty_age == dirty_age) {
ssurf->dirty_info->nr_dirty_rcs = 0;
}
__mg_unlock_file_for_write(ssurf->fd);
}
}
#endif
else {
if (msg->hwnd == HWND_NULL) {
msg->hwnd = HWND_DESKTOP;
@@ -535,8 +518,8 @@ BOOL client_IdleHandler4Client (PMSGQUEUE msg_queue, BOOL wait)
return (n > 0);
}
GHANDLE GUIAPI JoinLayerEx (const char* layer_name, const char* client_name,
int max_nr_topmosts, int max_nr_normals, int *cli_id)
GHANDLE GUIAPI JoinLayer (const char* layer_name, const char* client_name,
int max_nr_topmosts, int max_nr_normals)
{
GHANDLE layer_handle = INV_LAYER_HANDLE;
REQUEST req;
@@ -546,12 +529,8 @@ GHANDLE GUIAPI JoinLayerEx (const char* layer_name, const char* client_name,
if (mgIsServer)
return layer_handle;
if (__mg_client_id != 0) {
/* Already joined, return the handle */
if (cli_id)
*cli_id = __mg_client_id;
if (__mg_client_id != 0) /* Already joined, return the handle */
return GetLayerInfo (NAME_SELF_LAYER, NULL, NULL, NULL);
}
if (layer_name) {
strncpy (info.layer_name, layer_name, LEN_LAYER_NAME);
@@ -614,18 +593,10 @@ GHANDLE GUIAPI JoinLayerEx (const char* layer_name, const char* client_name,
__mg_start_client_desktop ();
if (cli_id)
*cli_id = __mg_client_id;
ret:
return layer_handle;
}
int GUIAPI GetClientId (void)
{
return __mg_client_id;
}
GHANDLE GUIAPI GetLayerInfo (const char* layer_name,
int* nr_clients, BOOL* is_topmost, int* cli_active)
{
+2 -7
View File
@@ -226,7 +226,7 @@ static int iso8859_6_conv_from_uc32 (Uchar32 wc, unsigned char* mchar)
}
#endif
#if 0
/* must attetion the para s is arabic chv value.*/
static int is_arabic_char_vowel(Uint8 c)
{
@@ -240,7 +240,6 @@ static int is_arabic_char_vowel(Uint8 c)
*/
return 0;
}
#endif
/* ISO8859-6 charset vowel relative define and judge */
#define ISARABIC_VOWEL(s) ((s >= FATHATAN) && (s <= SUKUN))
@@ -470,12 +469,9 @@ static int iso8859_6_len_first_char (const unsigned char* mstr, int len)
static unsigned int iso8859_6_char_type (Achar32 chv)
{
chv = REAL_ACHAR(chv);
#if 1
return sb_char_type(chv);
#else
unsigned int ch_type = ACHAR_BASIC_UNKNOWN;
chv = REAL_ACHAR(chv);
if (is_arabic_char_vowel (chv)) { /* is vowel */
ch_type = ACHAR_BASIC_VOWEL;
}
@@ -484,7 +480,6 @@ static unsigned int iso8859_6_char_type (Achar32 chv)
}
return ch_type;
#endif
}
static BidiType __mg_iso8859_6_bidi_char_type_map[] = {
+1 -1
View File
@@ -2185,7 +2185,7 @@ static int create_memdc_for_menu (TRACKMENUINFO* ptmi)
return -1;
}
ptmi->dc = __mg_create_memdc_for_surface (surf);
ptmi->dc = CreateMemDCFromSurface (surf);
if (ptmi->dc == HDC_INVALID) {
GAL_FreeSurface (surf);
return -1;
+9 -33
View File
@@ -4476,10 +4476,10 @@ HWND GUIAPI CreateMainWindowEx2 (PMAINWINCREATE pCreateInfo, LINT id,
#endif
#ifdef _MGSCHEMA_COMPOSITING
/* Since 5.2.0: keep fd available. */
if (0 && pWin->surf->shared_header) {
close (pWin->surf->fd);
pWin->surf->fd = -1;
// Close file descriptor to free kernel memory?
if (pWin->surf->shared_header) {
close (pWin->surf->shared_header->fd);
pWin->surf->shared_header->fd = -1;
}
#endif
@@ -5585,13 +5585,11 @@ BOOL GUIAPI ValidateRegion (HWND hWnd, const CLIPRGN* pRgn)
BOOL GUIAPI GetUpdateRect (HWND hWnd, RECT* update_rect)
{
PMAINWIN pWin;
RECT rcClient;
MG_CHECK_RET (MG_IS_NORMAL_WINDOW(hWnd), FALSE);
pWin = MG_GET_WINDOW_PTR (hWnd);
GetClientRect(hWnd, &rcClient);
IntersectRect(update_rect, &pWin->InvRgn.rgn.rcBound, &rcClient);
*update_rect = pWin->InvRgn.rgn.rcBound;
return TRUE;
}
@@ -6038,10 +6036,10 @@ HWND GUIAPI CreateWindowEx2 (const char* spClassName,
}
#ifdef _MGSCHEMA_COMPOSITING
/* Since 5.2.0: keep fd available. */
if (0 && dwExStyle & WS_EX_CTRLASMAINWIN && pNewCtrl->surf->shared_header) {
close (pNewCtrl->surf->fd);
pNewCtrl->surf->fd = -1;
// Close file descriptor to free kernel memory?
if (dwExStyle & WS_EX_CTRLASMAINWIN && pNewCtrl->surf->shared_header) {
close (pNewCtrl->surf->shared_header->fd);
pNewCtrl->surf->shared_header->fd = -1;
}
#endif
@@ -6068,28 +6066,6 @@ error:
return HWND_INVALID;
}
#ifdef _MGSCHEMA_COMPOSITING
int GUIAPI GetWindowSharedSurfaceFD (HWND hWnd, size_t *map_size, DWORD *flags)
{
MG_CHECK_RET (MG_IS_NORMAL_WINDOW (hWnd), -1);
PMAINWIN pWin = (PMAINWIN)hWnd;
if (pWin->surf->shared_header) {
if (map_size)
*map_size = pWin->surf->shared_header->map_size;
if (flags) {
*flags = MEMDC_FLAG_SWSURFACE;
if (pWin->surf->shared_header->byhw)
*flags |= MEMDC_FLAG_HWSURFACE;
}
return pWin->surf->fd;
}
return -1;
}
#endif /* _MGSCHEMA_COMPOSITING */
BOOL GUIAPI DestroyWindow (HWND hWnd)
{
PCONTROL pCtrl;
+2 -27
View File
@@ -105,10 +105,6 @@
#define REQID_GETSHAREDSURFACE 0x001C
// for compositing schema
#define SYSSF_WALLPAPER_PATTER "syssf-wallpaper-pattern"
#define APPSF_NAME_PREFIX "appsf-name-"
#define APPSF_NAME_PATTER "appsf-name-%s"
#define APPSF_HWND_PREFIX "appsf-hwnd-"
#define APPSF_HWND_PATTER "appsf-hwnd-%d-%p"
// for sharedfb schema
#define SYSSF_REAL_SCREEN "syssf-real-screen"
#define SYSSF_SHADOW_SCREEN "syssf-shadow-screen"
@@ -117,22 +113,10 @@
#define REQID_LOADCURSOR_PNG 0x001D
// Load cursor from in-memory PNG
#define REQID_LOADCURSOR_PNG_MEM 0x001E
#if 0 // Deprecated since 5.2.0
// allocate semaphore for shared surface
#define REQID_ALLOC_SURF_SEM 0x001F
// free semaphore of shared surface
#define REQID_FREE_SURF_SEM 0x0020
#endif
/* Since 5.2.0 */
// Operate a shared surface to register/revoke the name and set the fd
#define REQID_OPERATENAMEDSSURF 0x001F
#define ID_NAMEDSSURFOP_REGISTER 1
#define ID_NAMEDSSURFOP_SET 2
#define ID_NAMEDSSURFOP_REVOKE 3
#define REQID_RESERVED 0x0020
// Move the current client to another layer
#define REQID_MOVETOLAYER 0x0021
@@ -158,23 +142,15 @@ MGUI_COMPILE_TIME_ASSERT(sys_request_id, MAX_SYS_REQID >= REQID_SYS_LAST);
#undef MGUI_COMPILE_TIME_ASSERT
/* Since 5.2.0 */
typedef struct OperateNSSurfInfo
{
int id_op;
char name[NAME_MAX + 1];
size_t map_size;
} OPERATENSSURFINFO;
/* Since 5.0.0 */
typedef struct _SharedSurfInfo {
size_t size; // whole size of the surface
off_t offset; // offset of pixel data
uint32_t flags; // the flags of the surface
uint32_t width, height;
uint32_t pitch;
uint32_t name; // when use flink name
uint32_t drm_format; // DRM pixel format
size_t size; // whole size of the surface
off_t offset; // offset of pixel data
} SHAREDSURFINFO;
typedef struct JoinLayerInfo {
@@ -383,7 +359,6 @@ void __mg_start_client_desktop (void);
void __mg_update_window (HWND hwnd, int left, int top, int right, int bottom);
BOOL __mg_client_check_znode_hwnd (int slot, HWND hwnd, int cli);
BOOL __mg_client_check_hwnd (HWND hwnd, int cli);
BOOL __mg_client_on_layer_changed (GHANDLE layer_handle, int zi_shmid);
+4 -6
View File
@@ -521,16 +521,14 @@ static inline void _dc_step_y (PDC pdc, int step)
# define BLOCK_DRAW_SEM(pdc) \
do { \
if (pdc->surface->shared_header) { \
__mg_lock_file_for_write(pdc->surface->fd); \
} \
if (pdc->surface->shared_header) \
LOCK_SURFACE_SEM (pdc->surface->shared_header->sem_num); \
} while (0)
# define UNBLOCK_DRAW_SEM(pdc) \
do { \
if (pdc->surface->shared_header) { \
__mg_unlock_file_for_write(pdc->surface->fd); \
} \
if (pdc->surface->shared_header) \
UNLOCK_SURFACE_SEM (pdc->surface->shared_header->sem_num); \
} while (0)
# define IS_SCREEN_SURFACE(pdc) \
+8 -10
View File
@@ -51,9 +51,11 @@
#ifndef GUI_DRAWSEMOP_H
#define GUI_DRAWSEMOP_H
#include <errno.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include "misc.h"
#include <errno.h>
static inline void my_sem_op (int semid, int num, int op)
{
@@ -68,9 +70,6 @@ again:
if (errno == EINTR) {
goto again;
}
else {
_ERR_PRINTF("Failed semop: %m\n");
}
}
}
@@ -80,7 +79,10 @@ again:
#define LOCK_SCREEN_SEM() my_sem_op(SHAREDRES_SEMID, _IDX_SEM_SCR, -1)
#define UNLOCK_SCREEN_SEM() my_sem_op(SHAREDRES_SEMID, _IDX_SEM_SCR, 1)
extern int __mg_client_id;
#ifdef _MGSCHEMA_COMPOSITING
# define LOCK_SURFACE_SEM(num) my_sem_op(SHAREDRES_SEMID_SHARED_SURF, num, -1)
# define UNLOCK_SURFACE_SEM(num) my_sem_op(SHAREDRES_SEMID_SHARED_SURF, num, 1)
#endif
#ifdef _MGHAVE_CURSOR
@@ -155,10 +157,6 @@ again:
# define UNLOCK_MOUSEMOVE_SEM() my_sem_op(SHAREDRES_SEMID, _IDX_SEM_MOUSEMOVE, 1)
#endif /* _MGRM_PROCESSES */
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#ifdef __cplusplus
}
#endif /* __cplusplus */
+7 -36
View File
@@ -258,7 +258,7 @@ struct _MSGQUEUE
int loop_depth; // message loop depth, for dialog boxes
int idle_counter; // the idle connter for MSG_IDLE
DWORD last_ticks_desktop; // the last tick count for desktop timer
DWORD last_ticks; // the last tick count saved; since 5.0.14
/* Since 5.0.0, MiniGUI provides support for timers per message thread */
int nr_timers; // the number of active timers
@@ -911,40 +911,9 @@ static inline MSGQUEUE* getMsgQueueIfMainWindowInThisThread (PMAINWIN pMainWin)
#endif /* defined _MGHAVE_VIRTUAL_WINDOW */
#if 0 /* deprecated code */
/* since 5.0.0, we always use QS_DESKTIMER for desktop timer */
/* since 5.0.0, we no longer use the timer thread */
static inline void AlertDesktopTimerEvent (void)
{
if (__mg_dsk_msg_queue) {
__mg_dsk_msg_queue->expired_timer_mask = 1;
POST_MSGQ (__mg_dsk_msg_queue);
}
}
static inline void AlertDesktopTimerEvent (void)
{
__mg_dsk_msg_queue->dwState |= QS_DESKTIMER;
#ifdef _MGHAVE_VIRTUAL_WINDOW
if (getMsgQueueForThisThread() != __mg_dsk_msg_queue)
POST_MSGQ (__mg_dsk_msg_queue);
#endif /* defined _MGHAVE_VIRTUAL_WINDOW */
}
static inline void setMsgQueueTimerFlag (PMSGQUEUE pMsgQueue, int slot)
{
pMsgQueue->expired_timer_mask |= (0x01UL << slot);
POST_MSGQ (pMsgQueue);
}
static inline void removeMsgQueueTimerFlag (PMSGQUEUE pMsgQueue, int slot)
{
pMsgQueue->expired_timer_mask &= ~(0x01UL << slot);
}
#endif /* deprecated code */
BOOL mg_InitTimer (BOOL use_sys_timer);
void mg_TerminateTimer (BOOL use_sys_timer);
/* Since 5.0.14, remove arg use_sys_timer */
BOOL mg_InitTimer (void);
void mg_TerminateTimer (void);
/*window element renderer manager interface*/
extern WINDOW_ELEMENT_RENDERER * __mg_def_renderer;
@@ -958,7 +927,9 @@ BOOL gui_LoadIconRes(HDC hdc, const char* rdr_name, char* file);
void gui_WndRect(HWND hWnd, PRECT prc);
void gui_WndClientRect(HWND hWnd, PRECT prc);
HDC __mg_create_memdc_for_surface (struct GAL_Surface* surface);
/* Undisclosed APIs */
HDC CreateMemDCFromSurface (struct GAL_Surface* surface);
struct GAL_Surface* GetSurfaceFromDC (HDC hdc);
/* Since 5.0.0 */
#ifdef _MGRM_PROCESSES
+2 -14
View File
@@ -83,11 +83,6 @@ static inline int comp_key_string (const void *key1, const void *key2)
return strcmp (key1, key2);
}
static inline void free_val_alloc (void *val)
{
free (val);
}
typedef struct _map_t map_t;
typedef struct _map_entry_t {
struct rb_node node;
@@ -105,15 +100,8 @@ int __mg_map_get_size (map_t* map);
map_entry_t* __mg_map_find (map_t* map, const void* key);
map_entry_t* __mg_map_insert_ex2 (map_t* map, const void* key,
int __mg_map_insert_ex (map_t* map, const void* key,
const void* val, free_val_fn free_val_alt);
static int __mg_map_insert_ex (map_t* map, const void* key,
const void* val, free_val_fn free_val_alt)
{
return __mg_map_insert_ex2(map, key, val, NULL) ? 0 : -1;
}
static inline int __mg_map_insert (map_t* map, const void* key,
const void* val)
{
@@ -126,7 +114,7 @@ int __mg_map_find_replace_or_insert (map_t* map, const void* key,
int __mg_map_replace (map_t* map, const void* key,
const void* val, free_val_fn free_val_alt);
int __mg_map_erase (map_t* map, const void* key);
int __mg_map_erase (map_t* map, void* key);
int __mg_map_get_size (map_t* map);
#if 0 /* deprecated code */
+1 -7
View File
@@ -79,11 +79,6 @@ struct timezone {
extern "C" {
#endif /* __cplusplus */
void __mg_lock_file_for_read(int fd);
void __mg_unlock_file_for_read(int fd);
void __mg_lock_file_for_write(int fd);
void __mg_unlock_file_for_write(int fd);
unsigned int __mg_os_get_random_seed (void);
void __mg_os_time_delay (int ms);
void __mg_os_start_time (void);
@@ -120,11 +115,10 @@ void mg_TerminateMisc (void);
BOOL mg_InitSystemRes (void);
void mg_TerminateSystemRes (void);
/* Deprecated since 5.2.0
#ifdef _MGSCHEMA_COMPOSITING
int __mg_alloc_sem_for_shared_surf (void);
int __mg_free_sem_for_shared_surf (int sem_num);
#endif _MGSCHEMA_COMPOSITING */
#endif /* _MGSCHEMA_COMPOSITING */
size_t __mg_lookfor_unused_slot (unsigned char* bitmap, size_t len_bmp, int set);
+4 -4
View File
@@ -396,10 +396,10 @@ char * __mg_msgstr3 [] =
"MSG_SRVNOTIFY", // 0x0147
"MSG_UPDATECLIWIN", // 0x0148
"MSG_LAYERCHANGED", // 0x0149
"MSG_WINCOMPOSITED", // 0x014A
"MSG_MANAGE_MSGTHREAD", // 0x014B
"MSG_CALC_POSITION", // 0x014C
"MSG_WAKEUP_CLIENT", // 0x014D
"MSG_MANAGE_MSGTHREAD", // 0x014A
"MSG_CALC_POSITION", // 0x014B
"", // 0x014C
"", // 0x014D
"", // 0x014E
"", // 0x014F
+20 -35
View File
@@ -117,9 +117,7 @@ void GAL_FreeFormat(GAL_PixelFormat *format);
/* typedef for private surface blitting functions */
struct GAL_Surface;
typedef int (*GAL_blit)(GAL_VideoDevice *video,
struct GAL_Surface *src, GAL_Rect *srcrect,
typedef int (*GAL_blit)(struct GAL_Surface *src, GAL_Rect *srcrect,
struct GAL_Surface *dst, GAL_Rect *dstrect);
#if IS_COMPOSITING_SCHEMA
@@ -139,25 +137,20 @@ typedef struct _DirtyInfo {
* than the creator.
*/
typedef struct _SharedSurfaceHeader {
/* the name of the shared surface; since 5.2.0. */
char name[NAME_MAX + 1];
/* The number of semphore for this surface.
The SysV semaphore set id for synchronizing this shared surface:
SHAREDRES_SEMID_SHARED_SURF. */
int sem_num;
/* The client identifier of the creator. */
int create_cli;
/* The pid of the creator */
pid_t creator;
/* The file descriptor in context of the creator. */
int fd;
/* Not zero for hardware surface. */
int byhw;
/* Deprecated since 5.2.0.
The number of semphore for this surface.
The SysV semaphore set id for synchronizing this shared surface:
SHAREDRES_SEMID_SHARED_SURF.
int sem_num; */
/* Deprecated since 5.2.0.
The file descriptor in context of the creator.
int fd; */
/* The dirty information */
GAL_DirtyInfo dirty_info;
/* the size of the surface */
int width, height;
/* the pitch of the surface */
@@ -171,9 +164,6 @@ typedef struct _SharedSurfaceHeader {
size_t map_size;
/* the offset of pixels data */
off_t pixels_off;
/* The dirty information */
GAL_DirtyInfo dirty_info;
} GAL_SharedSurfaceHeader;
#endif /* IS_COMPOSITING_SCHEMA */
@@ -238,8 +228,6 @@ typedef struct GAL_Surface {
GAL_SharedSurfaceHeader *shared_header; /* Private */
/* The dirty info for non-shared surface. */
GAL_DirtyInfo *dirty_info; /* Private */
/* The file descriptor if the surface is a shared surface. */
int fd; /* Private; since 5.2.0. */
#endif
} GAL_Surface;
@@ -262,8 +250,6 @@ typedef struct GAL_Surface {
#define GAL_PREALLOC 0x01000000 /* Surface uses preallocated memory */
#define GAL_FORMAT_CHECKED 0x02000000 /* Pixman format checked */
#define GAL_SSURF_ATTACHED 0x04000000 /* The shared surface is attached to. */
#define GAL_SSURF_LOCKED 0x08000000 /* The shared surface is locked. */
/* Available for GAL_SetVideoMode() */
#define GAL_ANYFORMAT 0x10000000 /* Allow any video depth/pixel-format */
@@ -583,11 +569,6 @@ GAL_Surface *GAL_CreateRGBSurface
GAL_Surface *GAL_CreateRGBSurfaceFrom (void *pixels,
int width, int height, int depth, int pitch,
Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
/* Since 5.2.0 */
static GAL_Surface *GAL_RefSurface (GAL_Surface *surface) {
surface->refcount++;
return surface;
}
void GAL_FreeSurface (GAL_Surface *surface);
typedef struct REQ_HWSURFACE {
@@ -668,11 +649,11 @@ GAL_Surface *GAL_CreateSurfaceForZNodeAs (const GAL_Surface* ref_surf,
void GAL_FreeSharedSurfaceData (GAL_Surface *surface);
/* Attach to a shared RGB surface. */
GAL_Surface *GAL_AttachSharedRGBSurface (GAL_VideoDevice* video,
int fd, size_t map_size, Uint32 flags, BOOL with_wr);
GAL_Surface *GAL_AttachSharedRGBSurface (int fd, size_t map_size,
Uint32 flags, BOOL with_wr);
/* Detach from a shared RGB surface from the specific video device. */
void GAL_DetachSharedSurfaceData (GAL_Surface *surface);
/* Dettach from a shared RGB surface from the specific video device. */
void GAL_DettachSharedSurfaceData (GAL_Surface *surface);
/* Create a cursor surface from the specific video device. */
GAL_Surface* GAL_CreateCursorSurface (GAL_VideoDevice* video,
@@ -689,6 +670,7 @@ void GAL_MoveCursor (GAL_Surface* surface, int x, int y);
#endif /* defined _MGSCHEMA_COMPOSITING */
#if 0
/*
* GAL_LockSurface() sets up a surface for directly accessing the pixels.
* Between calls to GAL_LockSurface()/GAL_UnlockSurface(), you can write
@@ -698,7 +680,9 @@ void GAL_MoveCursor (GAL_Surface* surface, int x, int y);
*
* Not all surfaces require locking. If GAL_MUSTLOCK(surface) evaluates
* to 0, then you can read and write to the surface at any time, and the
* pixel format of the surface will not change.
* pixel format of the surface will not change. In particular, if the
* GAL_HWSURFACE flag is not given when calling GAL_SetVideoMode(), you
* will not need to lock the display surface before accessing it.
*
* No operating system or library calls should be made between lock/unlock
* pairs, as critical system locks may be held during this time.
@@ -707,6 +691,7 @@ void GAL_MoveCursor (GAL_Surface* surface, int x, int y);
*/
int GAL_LockSurface (GAL_Surface *surface);
void GAL_UnlockSurface (GAL_Surface *surface);
#endif
/*
* Set the color key (transparent pixel) in a blittable surface.
-8
View File
@@ -132,13 +132,6 @@ void __mg_client_del (int cli);
void __mg_release_global_res (int cli);
/* Since 5.2.0 */
int __mg_nssurf_map_new(void);
void __mg_nssurf_map_delete(void);
int __mg_nssurf_map_operate_srv(const OPERATENSSURFINFO* req_info,
int cli, int fd);
int __mg_get_shared_surface_srv(const char *itn_name, SHAREDSURFINFO *info);
void __mg_remove_client (int cli, int clifd);
int __mg_handle_request (int clifd, int req_id, int cli);
@@ -157,7 +150,6 @@ int __mg_remove_all_znodes_of_client (int cli);
int __mg_handle_normal_mouse_move (const ZORDERINFO* zi, int x, int y);
int __mg_get_znode_at_point (const ZORDERINFO* zi, int x, int y, HWND* hwnd);
ZORDERNODE *__mg_find_znode_by_client_hwnd (int cli, HWND hwnd);
int __mg_do_reghook_operation (int cli, const REGHOOKINFO* info);
int __mg_handle_mouse_hook (int message, WPARAM wParam, LPARAM lParam);
+2 -2
View File
@@ -112,7 +112,7 @@ typedef struct tagG_RES {
int nr_layers;
int semid_layer;
#if 0 && defined(_MGSCHEMA_COMPOSITING) // deprecated since 5.2.0
#ifdef _MGSCHEMA_COMPOSITING
int semid_shared_surf; /* the id of semaphore set for shared surfaces */
#endif
@@ -208,7 +208,7 @@ typedef G_RES* PG_RES;
#define SHAREDRES_NR_LAYSERS (((PG_RES)mgSharedRes)->nr_layers)
#define SHAREDRES_SEMID_LAYER (((PG_RES)mgSharedRes)->semid_layer)
#if 0 && defined(_MGSCHEMA_COMPOSITING) // Deprecated since 5.2.0
#ifdef _MGSCHEMA_COMPOSITING
# define SHAREDRES_SEMID_SHARED_SURF (((PG_RES)mgSharedRes)->semid_shared_surf)
#endif
+1 -1
View File
@@ -74,7 +74,7 @@ typedef struct _MSGQUEUE MSGQUEUE;
extern "C" {
#endif /* __cplusplus */
void __mg_update_tick_count (void* data);
DWORD __mg_update_tick_count (MSGQUEUE* msg_queue);
int __mg_check_expired_timers (MSGQUEUE* msg_queue, DWORD inter);
void __mg_remove_timers_by_msg_queue (MSGQUEUE* msg_queue);
void __mg_remove_timer (MSGQUEUE* msg_queue, int slot);
+1 -19
View File
@@ -228,7 +228,6 @@ static void composite_wallpaper_rect (CompositorCtxt* ctxt,
}
}
else {
SelectClipRect (HDC_SCREEN_SYS, dirty_rc);
SetBrushColor (HDC_SCREEN_SYS,
GetWindowElementPixelEx (HWND_DESKTOP, HDC_SCREEN_SYS,
WE_BGC_DESKTOP));
@@ -679,19 +678,6 @@ static BOOL merge_dirty_ppp (CompositorCtxt* ctxt, MG_Layer* layer, int zidx)
return rc;
}
#if 0
static void dump_dirty_region(CompositorCtxt* ctxt, const char *prefix, int zidx)
{
CLIPRGN* rgn = &ctxt->dirty_rgn;
_WRN_PRINTF("%s (%d): dirty region on screen: (%d, %d) %d x %d; "
"highest dirty win: %d; lowest dirty win: %d\n",
prefix, zidx,
rgn->rcBound.left, rgn->rcBound.top,
RECTW (rgn->rcBound), RECTH (rgn->rcBound),
ctxt->highest_dirty_win, ctxt->lowest_dirty_win);
}
#endif
static BOOL merge_dirty_win (CompositorCtxt* ctxt, MG_Layer* layer, int zidx)
{
BOOL rc = FALSE;
@@ -735,13 +721,9 @@ static BOOL merge_dirty_wpp (CompositorCtxt* ctxt, MG_Layer* layer)
static BOOL refresh_dirty_region (CompositorCtxt* ctxt, MG_Layer* layer)
{
/* the fallback compositor only manages znodes on the topmost layer. */
if (layer != mgTopmostLayer)
if (layer != mgTopmostLayer || IsEmptyClipRgn (&ctxt->dirty_rgn))
return FALSE;
if (IsEmptyClipRgn (&ctxt->dirty_rgn)) {
return FALSE;
}
if (ctxt->highest_dirty_ppp >= 0) {
composite_ppp_znodes (ctxt);
}
+16 -32
View File
@@ -56,6 +56,7 @@
#include <string.h>
#include <errno.h>
#define _DEBUG
#include "common.h"
#if defined(_MGRM_PROCESSES) && defined(_MGSCHEMA_COMPOSITING)
@@ -68,7 +69,6 @@
#include "constants.h"
#include "zorder.h"
#include "dc.h"
#include "server.h"
#define MAX_NR_COMPOSITORS 8
#define LEN_COMPOSITOR_NAME 15
@@ -133,51 +133,31 @@ static void lock_znode_surface (PDC pdc, ZORDERNODE* node)
{
if (node->lock_count == 0) {
if (pdc->surface->shared_header) {
__mg_lock_file_for_read(pdc->surface->fd);
LOCK_SURFACE_SEM (pdc->surface->shared_header->sem_num);
}
node->dirty_age = pdc->surface->dirty_info->dirty_age;
node->nr_dirty_rcs = pdc->surface->dirty_info->nr_dirty_rcs;
node->dirty_rcs = pdc->surface->dirty_info->dirty_rcs;
}
node->lock_count++;
}
static BOOL unlock_znode_surface (PDC pdc, ZORDERNODE* node)
static void unlock_znode_surface (PDC pdc, ZORDERNODE* node)
{
BOOL need_reset = FALSE;
if (node->lock_count > 0) {
node->lock_count--;
if (node->lock_count == 0) {
if (node->changes != pdc->surface->dirty_info->dirty_age) {
node->changes = pdc->surface->dirty_info->dirty_age;
need_reset = TRUE;
}
if (pdc->surface->shared_header) {
__mg_unlock_file_for_read(pdc->surface->fd);
}
if (pdc->surface->shared_header)
UNLOCK_SURFACE_SEM (pdc->surface->shared_header->sem_num);
node->dirty_age = 0;
node->nr_dirty_rcs = 0;
node->dirty_rcs = NULL;
}
}
return need_reset;
}
static void reset_znode_surface_dirty (PDC pdc, ZORDERNODE* node, int slot)
{
if (node->cli == 0 || slot == 0) {
pdc->surface->dirty_info->nr_dirty_rcs = 0;
}
else if (node->hwnd) {
MSG msg = { HWND_NULL, MSG_WINCOMPOSITED,
slot, (LPARAM)node->hwnd, (DWORD)node->changes };
__mg_send2client(&msg, mgClients + node->cli);
}
}
#if 0 /* not optimized */
@@ -342,8 +322,10 @@ static void composite_layer (MG_Layer* layer, CompositorCtxt* ctxt,
nodes = GET_MENUNODE(zi);
for (i = 0; i < zi->nr_popupmenus; i++) {
pdc = dc_HDC2PDC (nodes[i].mem_dc);
if (unlock_znode_surface (pdc, nodes + i))
reset_znode_surface_dirty (pdc, nodes + i, i);
nodes[i].changes = pdc->surface->dirty_info->dirty_age;
pdc->surface->dirty_info->nr_dirty_rcs = 0;
unlock_znode_surface (pdc, nodes + i);
}
}
@@ -353,8 +335,9 @@ static void composite_layer (MG_Layer* layer, CompositorCtxt* ctxt,
while ((next = __kernel_get_next_znode (zi, next)) > 0) {
if (nodes [next].flags & ZOF_VISIBLE) {
pdc = dc_HDC2PDC (nodes[next].mem_dc);
if (unlock_znode_surface (pdc, nodes + next))
reset_znode_surface_dirty (pdc, nodes + next, next);
nodes[next].changes = pdc->surface->dirty_info->dirty_age;
pdc->surface->dirty_info->nr_dirty_rcs = 0;
unlock_znode_surface (pdc, nodes + next);
}
}
@@ -363,8 +346,9 @@ static void composite_layer (MG_Layer* layer, CompositorCtxt* ctxt,
if (layer == mgTopmostLayer) {
pdc = dc_HDC2PDC (HDC_SCREEN);
if (pdc->surface->w > 0 && pdc->surface->h > 0) {
if (unlock_znode_surface (pdc, nodes))
reset_znode_surface_dirty (pdc, nodes, 0);
nodes[0].changes = pdc->surface->dirty_info->dirty_age;
pdc->surface->dirty_info->nr_dirty_rcs = 0;
unlock_znode_surface (pdc, nodes);
}
}
}
+14 -36
View File
@@ -1081,12 +1081,6 @@ void kernel_ShowCursorForGDI (BOOL fShow, void* pdc)
const RECT* prc;
prc = &cur_pdc->rc_output;
/* Since 5.0.13 */
if (!fShow) {
GAL_LockSurface(cur_pdc->surface);
}
if (cur_pdc->surface != __gal_screen) {
if (fShow) {
GAL_UpdateRect (cur_pdc->surface,
@@ -1096,7 +1090,7 @@ void kernel_ShowCursorForGDI (BOOL fShow, void* pdc)
}
else {
if (!mgIsServer && (SHAREDRES_TOPMOST_LAYER != __mg_layer)) {
goto done;
return;
}
if (!fShow) {
@@ -1115,12 +1109,6 @@ void kernel_ShowCursorForGDI (BOOL fShow, void* pdc)
UNLOCK_CURSOR_SEM ();
}
}
done:
/* Since 5.0.13 */
if (fShow) {
GAL_UnlockSurface(cur_pdc->surface);
}
}
#else /* defined _MGSCHEMA_SHAREDFB */
@@ -1136,12 +1124,6 @@ void kernel_ShowCursorForGDI (BOOL fShow, void* pdc)
}
prc = &cur_pdc->rc_output;
/* Since 5.0.13 */
if (!fShow) {
GAL_LockSurface(cur_pdc->surface);
}
if (cur_pdc->surface == __gal_screen) {
// Under compositing schema, we never call SyncUpdate in
// kernel_ShowCursorForGDI for __gal_screen.
@@ -1168,11 +1150,6 @@ void kernel_ShowCursorForGDI (BOOL fShow, void* pdc)
// For surface other than screen, we call SyncUpdate.
GAL_SyncUpdate (cur_pdc->surface);
}
/* Since 5.0.13 */
if (fShow) {
GAL_UnlockSurface(cur_pdc->surface);
}
}
#endif /* not defined _MGSCHEMA_SHAREDFB */
@@ -1251,25 +1228,26 @@ void kernel_ShowCursorForGDI (BOOL fShow, void* pdc)
PDC cur_pdc = (PDC)pdc;
const RECT* prc = NULL;
if (!mgIsServer && (SHAREDRES_TOPMOST_LAYER != __mg_layer)) {
return;
}
prc = &cur_pdc->rc_output;
/* Since 5.0.13 */
if (!fShow) {
GAL_LockSurface(cur_pdc->surface);
/* houhh20080827, if --disable-cursor, mginit can not update auto(qvfb). */
#if 0
if (cur_pdc->surface == __gal_screen
&& mgIsServer && (SHAREDRES_TOPMOST_LAYER != __mg_layer))
return;
if (fShow)
GAL_UpdateRect (cur_pdc->surface,
prc->left, prc->top, RECTWP(prc), RECTHP(prc));
#else
if (!mgIsServer && (SHAREDRES_TOPMOST_LAYER != __mg_layer)) {
return;
}
if (fShow)
GAL_UpdateRect (cur_pdc->surface,
prc->left, prc->top, RECTWP(prc), RECTHP(prc));
/* Since 5.0.13 */
if (fShow) {
GAL_UnlockSurface(cur_pdc->surface);
}
#endif
}
#endif /* _MGHAVE_CURSOR */
+2 -20
View File
@@ -448,11 +448,6 @@ void kernel_ShowCursorForGDI (BOOL fShow, void* pdc)
prc = &cur_pdc->rc_output;
/* Since 5.0.13 */
if (!fShow) {
GAL_LockSurface(cur_pdc->surface);
}
if (cur_pdc->surface != __gal_screen) {
if (fShow) {
GAL_UpdateRect (cur_pdc->surface,
@@ -477,7 +472,7 @@ void kernel_ShowCursorForGDI (BOOL fShow, void* pdc)
prc->left, prc->top, RECTWP(prc), RECTHP(prc));
//GAL_SyncUpdate (cur_pdc->surface);
}
goto done;
return;
}
if (fShow && nShowCount >= 0 && pCurCsr) {
@@ -493,12 +488,6 @@ void kernel_ShowCursorForGDI (BOOL fShow, void* pdc)
//GAL_SyncUpdate (cur_pdc->surface);
}
}
done:
/* Since 5.0.13 */
if (fShow) {
GAL_UnlockSurface(cur_pdc->surface);
}
}
int GUIAPI ShowCursor (BOOL fShow)
@@ -527,16 +516,9 @@ void kernel_ShowCursorForGDI(BOOL fShow, void* pdc)
prc = &cur_pdc->rc_output;
/* Since 5.0.13 */
if (!fShow) {
GAL_LockSurface(cur_pdc->surface);
}
else {
if (fShow)
GAL_UpdateRect (cur_pdc->surface,
prc->left, prc->top, RECTWP(prc), RECTHP(prc));
/* Since 5.0.13 */
GAL_UnlockSurface(cur_pdc->surface);
}
}
#endif /* _MGHAVE_CURSOR */
+3 -21
View File
@@ -472,15 +472,11 @@ void kernel_ShowCursorForGDI (BOOL fShow, void *pdc)
prc = &cur_pdc->rc_output;
/* Since 5.0.13 */
if (!fShow) {
GAL_LockSurface(cur_pdc->surface);
}
if (cur_pdc->surface != __gal_screen) {
if (fShow) {
GAL_UpdateRect (cur_pdc->surface,
prc->left, prc->top, RECTWP(prc), RECTHP(prc));
// GAL_SyncUpdate (cur_pdc->surface);
}
}
else {
@@ -504,7 +500,7 @@ void kernel_ShowCursorForGDI (BOOL fShow, void *pdc)
pthread_mutex_unlock(&__mg_mouselock);
// GAL_SyncUpdate (cur_pdc->surface);
}
goto done;
return;
}
if (fShow && nShowCount >= 0 && pCurCsr) {
@@ -522,12 +518,6 @@ void kernel_ShowCursorForGDI (BOOL fShow, void *pdc)
// GAL_SyncUpdate (cur_pdc->surface);
}
}
done:
/* Since 5.0.13 */
if (fShow) {
GAL_UnlockSurface(cur_pdc->surface);
}
}
int GUIAPI ShowCursor(BOOL fShow)
@@ -568,17 +558,9 @@ void kernel_ShowCursorForGDI (BOOL fShow, void* pdc)
prc = &cur_pdc->rc_output;
/* Since 5.0.13 */
if (!fShow) {
GAL_LockSurface(cur_pdc->surface);
}
else {
if (fShow)
GAL_UpdateRect (cur_pdc->surface,
prc->left, prc->top, RECTWP(prc), RECTHP(prc));
/* Since 5.0.13 */
GAL_UnlockSurface(cur_pdc->surface);
}
}
#endif /* _MGHAVE_CURSOR */
+16 -64
View File
@@ -55,7 +55,6 @@
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <assert.h>
#include "common.h"
@@ -365,7 +364,7 @@ static intptr_t cliAllocZOrderNode (PMAINWIN pWin, const COMPOSITINGINFO* ct_inf
}
if (ClientRequestEx2 (&req, caption, strlen(caption) + 1,
pWin->surf->fd,
pWin->surf->shared_header->fd,
&ret, sizeof (intptr_t), NULL) < 0)
return -1;
#else /* ndef _MGSCHEMA_COMPOSITING */
@@ -524,7 +523,7 @@ static intptr_t cliStartTrackPopupMenu (PTRACKMENUINFO ptmi)
info.surf_flags = surf->flags;
info.surf_size = surf->shared_header->map_size;
if (ClientRequestEx2 (&req, NULL, 0, surf->fd,
if (ClientRequestEx2 (&req, NULL, 0, surf->shared_header->fd,
&ret, sizeof (intptr_t), NULL) < 0)
return -1;
}
@@ -837,10 +836,8 @@ static int srvAllocZOrderNode (int cli, HWND hwnd, HWND main_win,
surf->refcount++;
}
else if (fd >= 0) {
surf = GAL_AttachSharedRGBSurface (NULL, fd,
surf_size, surf_flags, TRUE);
/* Since 5.2.0: keep fd available.
close (fd); */
surf = GAL_AttachSharedRGBSurface (fd, surf_size, surf_flags, TRUE);
close (fd);
}
else {
_ERR_PRINTF("KERNEL: not server but fd for shared surface is invalid\n");
@@ -848,7 +845,7 @@ static int srvAllocZOrderNode (int cli, HWND hwnd, HWND main_win,
}
if (surf) {
memdc = __mg_create_memdc_for_surface (surf);
memdc = CreateMemDCFromSurface (surf);
if (memdc == HDC_INVALID) {
if (cli > 0) {
GAL_FreeSurface (surf);
@@ -996,14 +993,12 @@ static int srvMoveWindow (int cli, int idx_znode, const RECT* rcWin,
surf->refcount++;
}
else {
surf = GAL_AttachSharedRGBSurface (NULL, fd,
surf_size, surf_flags, TRUE);
/* Since 5.2.0: keep fd available.
close (fd); */
surf = GAL_AttachSharedRGBSurface (fd, surf_size, surf_flags, TRUE);
close (fd);
}
if (surf) {
memdc = __mg_create_memdc_for_surface (surf);
memdc = CreateMemDCFromSurface (surf);
if (memdc == HDC_INVALID) {
if (cli > 0) {
GAL_FreeSurface (surf);
@@ -1018,6 +1013,7 @@ static int srvMoveWindow (int cli, int idx_znode, const RECT* rcWin,
return -1;
}
}
#endif /* def _MGSCHEMA_COMPOSITING */
ret = dskMoveWindow (cli, idx_znode, memdc, rcWin);
@@ -1524,33 +1520,6 @@ static BOOL _cb_update_rc_nocli (void* context,
}
#endif /* not defined _MGSCHEMA_COMPOSITING */
/* Since 5.2.0 */
ZORDERNODE *__mg_find_znode_by_client_hwnd (int cli, HWND hwnd)
{
ZORDERINFO* zi = get_zorder_info(cli);
ZORDERNODE* nodes;
if (zi == NULL)
return NULL;
int level, slot = -1;
nodes = GET_ZORDERNODE(zi);
for (level = 0; level < NR_ZORDER_LEVELS; level++) {
slot = zi->first_in_levels[level];
for (; slot > 0; slot = nodes[slot].next) {
if (nodes[slot].cli == cli && nodes[slot].hwnd == hwnd) {
goto found;
}
}
}
return NULL;
found:
assert(slot >= 0);
return nodes + slot;
}
int __mg_remove_all_znodes_of_client (int cli)
{
BOOL has_special = FALSE;
@@ -2211,7 +2180,7 @@ static int resize_window_surface (PMAINWIN pWin, const RECT* prcResult)
pWin->surf = new_surf;
if (pWin->surf->shared_header)
return pWin->surf->fd;
return pWin->surf->shared_header->fd;
else
return 0;
}
@@ -2256,10 +2225,9 @@ static int dskMoveGlobalControl (PMAINWIN pCtrl, RECT* prcExpect)
}
#ifdef _MGSCHEMA_COMPOSITING
/* Since 5.2.0: keep fd available. */
if (0 && pCtrl->surf->shared_header && pCtrl->surf->fd >= 0) {
close (pCtrl->surf->fd);
pCtrl->surf->fd = -1;
if (pCtrl->surf->shared_header && pCtrl->surf->shared_header->fd >= 0) {
close (pCtrl->surf->shared_header->fd);
pCtrl->surf->shared_header->fd = -1;
}
#endif
@@ -2288,10 +2256,9 @@ static int dskMoveMainWindow (PMAINWIN pWin, RECT* prcExpect)
__mg_update_dc_on_surface_changed ((HWND)pWin, pWin->surf);
}
/* Since 5.2.0: keep fd available. */
if (0 && pWin->surf->shared_header && pWin->surf->fd >= 0) {
close (pWin->surf->fd);
pWin->surf->fd = -1;
if (pWin->surf->shared_header && pWin->surf->shared_header->fd >= 0) {
close (pWin->surf->shared_header->fd);
pWin->surf->shared_header->fd = -1;
}
#endif
@@ -2907,21 +2874,6 @@ int __mg_handle_mouse_hook (int message, WPARAM wParam, LPARAM lParam)
}
#endif /* deprecated code */
/* used by client to check the validation of a hwnd in the given znode slot. */
BOOL __mg_client_check_znode_hwnd (int slot, HWND hwnd, int cli)
{
BOOL ret = FALSE;
ZORDERINFO* zi = __mg_zorder_info;
ZORDERNODE* nodes;
nodes = GET_ZORDERNODE(zi);
lock_zi_for_read (zi);
if (nodes[slot].hwnd == hwnd && nodes[slot].cli == cli)
ret = TRUE;
unlock_zi_for_read (zi);
return ret;
}
/* used by client to check the validation of a hwnd */
BOOL __mg_client_check_hwnd (HWND hwnd, int cli)
{
+1 -1
View File
@@ -145,7 +145,7 @@ static IDLEHANDLER std_idle_handler;
static BOOL idle_handler_for_desktop_thread (MSGQUEUE *msg_queue, BOOL wait)
{
__mg_update_tick_count (NULL);
__mg_update_tick_count (msg_queue);
return std_idle_handler (msg_queue, wait);
}
+3 -10
View File
@@ -1603,10 +1603,8 @@ static int srvStartTrackPopupMenu (int cli, const RECT* rc, HWND ptmi,
surf->refcount++;
}
else if (fd >= 0) {
surf = GAL_AttachSharedRGBSurface (NULL, fd,
surf_size, surf_flags, TRUE);
/* Since 5.2.0: keep fd available.
close (fd); */
surf = GAL_AttachSharedRGBSurface (fd, surf_size, surf_flags, TRUE);
close (fd);
}
else {
_WRN_PRINTF("not server but fd for shared surface is invalid\n");
@@ -1614,7 +1612,7 @@ static int srvStartTrackPopupMenu (int cli, const RECT* rc, HWND ptmi,
}
if (surf) {
memdc = __mg_create_memdc_for_surface (surf);
memdc = CreateMemDCFromSurface (surf);
if (memdc == HDC_INVALID) {
GAL_FreeSurface (surf);
_WRN_PRINTF("failed to create memory dc for znode\n");
@@ -1648,14 +1646,11 @@ static int srvStartTrackPopupMenu (int cli, const RECT* rc, HWND ptmi,
menu_nodes [zi->nr_popupmenus].flags = ZOF_TYPE_POPUPMENU;
menu_nodes [zi->nr_popupmenus].rc = *rc;
menu_nodes [zi->nr_popupmenus].hwnd = ptmi;
menu_nodes [zi->nr_popupmenus].cli = 0;
#ifdef _MGSCHEMA_COMPOSITING
menu_nodes [zi->nr_popupmenus].changes = 0;
menu_nodes [zi->nr_popupmenus].ct = CT_OPAQUE;
menu_nodes [zi->nr_popupmenus].ct_arg = 0;
menu_nodes [zi->nr_popupmenus].mem_dc = memdc;
menu_nodes [zi->nr_popupmenus].dirty_age = 0;
menu_nodes [zi->nr_popupmenus].nr_dirty_rcs = 0;
menu_nodes [zi->nr_popupmenus].dirty_rcs = NULL;
#endif
menu_nodes [zi->nr_popupmenus].priv_data = NULL;
@@ -2361,8 +2356,6 @@ static int AllocZOrderNodeEx (ZORDERINFO* zi, int cli, HWND hwnd, HWND main_win,
nodes [free_slot].ct = validate_compositing_type (flags, ct);
nodes [free_slot].ct_arg = ct_arg;
nodes [free_slot].mem_dc = mem_dc;
nodes [free_slot].dirty_age = 0;
nodes [free_slot].nr_dirty_rcs = 0;
nodes [free_slot].dirty_rcs = NULL;
#else
nodes [free_slot].age = 1;
+2 -2
View File
@@ -577,7 +577,7 @@ int GUIAPI InitGUI (int args, const char *agr[])
/* init timer for tick counter */
step++;
if (!mg_InitTimer (FALSE)) {
if (!mg_InitTimer()) {
_ERR_PRINTF ("KERNEL>InitGUI: failed to start time counter\n");
goto failure;
}
@@ -602,7 +602,7 @@ failure1:
void GUIAPI TerminateGUI (int not_used)
{
mg_TerminateTimer (FALSE);
mg_TerminateTimer ();
mg_FreeMsgQueueForThisThread (TRUE);
-11
View File
@@ -955,12 +955,6 @@ checkagain:
goto checkagain;
}
else {
/* no message, wait again. */
if (pMsgQueue->OnIdle && !pMsgQueue->OnIdle (pMsgQueue, FALSE)) {
handle_idle_message (pMsgQueue);
}
}
#else /* defined _MGHAVE_VIRTUAL_WINDOW */
/* no message, idle */
if (bWait) {
@@ -970,11 +964,6 @@ checkagain:
}
goto checkagain;
}
else {
if (!pMsgQueue->OnIdle (pMsgQueue, FALE)) {
handle_idle_message (pMsgQueue);
}
}
#endif /* not defined _MGHAVE_VIRTUAL_WINDOW */
/* no message */
+55 -139
View File
@@ -44,7 +44,7 @@
* <http://www.minigui.com/blog/minigui-licensing-policy/>.
*/
/*
** timer.c: The Timer module for MiniGUI-Threads.
** timer.c: The Timer module for MiniGUI.
**
** Current maintainer: Wei Yongming.
**
@@ -79,82 +79,45 @@
DWORD __mg_tick_counter = 0;
/* update timer count for desktop thread */
void __mg_update_tick_count (void *data)
/* update timer count for message and desktop thread */
DWORD __mg_update_tick_count (MSGQUEUE* msg_queue)
{
DWORD ticks;
#if defined(_MGRM_PROCESSES)
if (mgIsServer) {
__mg_tick_counter = __mg_os_get_time_ticks ();
SHAREDRES_TIMER_COUNTER = __mg_tick_counter;
ticks = __mg_os_get_time_ticks ();
SHAREDRES_TIMER_COUNTER = ticks;
}
else {
__mg_tick_counter = SHAREDRES_TIMER_COUNTER;
ticks = SHAREDRES_TIMER_COUNTER;
}
#else /* defined _MGRM_PROCESSES */
__mg_tick_counter = __mg_os_get_time_ticks ();
ticks = __mg_os_get_time_ticks ();
#endif /* not defined _MGRM_PROCESSES */
if (msg_queue && ticks != msg_queue->last_ticks) {
/* Since 5.0.0, the desktop only handles caret blinking in MSG_TIMEOUT
message, and the interval for the timer of desktop changes to 0.05s. */
if (__mg_tick_counter >
__mg_dsk_msg_queue->last_ticks_desktop + DESKTOP_TIMER_INERTVAL) {
message, and the interval for the timer of desktop changes to 0.05s.
*/
if (msg_queue == __mg_dsk_msg_queue) {
if (ticks > __mg_dsk_msg_queue->last_ticks +
DESKTOP_TIMER_INERTVAL) {
__mg_dsk_msg_queue->dwState |= QS_DESKTIMER;
#ifdef _MGRM_THREADS /* only wake up desktop for threads mode */
POST_MSGQ (__mg_dsk_msg_queue);
#endif
__mg_dsk_msg_queue->last_ticks_desktop = __mg_tick_counter;
}
}
msg_queue->last_ticks = ticks;
}
__mg_tick_counter = ticks;
return ticks;
}
#if 0 /* deprecated code */
#if defined(_MGRM_PROCESSES)
if (mgIsServer) {
DWORD elapsed_ticks;
/* Since 5.0.0, we use elapsed time in ms to count the ticks */
elapsed_ticks = __mg_os_get_elapsed_ms ();
elapsed_ticks = (elapsed_ticks + 5) / 10;
__mg_tick_counter += elapsed_ticks;
SHAREDRES_TIMER_COUNTER = __mg_tick_counter;
}
else {
__mg_tick_counter = SHAREDRES_TIMER_COUNTER;
}
#else /* defined _MGRM_PROCESSES */
DWORD elapsed_ticks;
/* Since 5.0.0, we use elapsed time in ms to count the ticks */
elapsed_ticks = __mg_os_get_elapsed_ms ();
elapsed_ticks = (elapsed_ticks + 5) / 10;
__mg_tick_counter += elapsed_ticks;
#endif /* not defined _MGRM_PROCESSES */
/* Since 5.0.0, the desktop only handles caret blinking in MSG_TIMEOUT
message, and the interval for the timer of desktop changes to 0.05s. */
if (__mg_tick_counter >
__mg_dsk_msg_queue->last_ticks_desktop + DESKTOP_TIMER_INERTVAL) {
__mg_dsk_msg_queue->dwState |= QS_DESKTIMER;
#ifdef _MGRM_THREADS /* only wake up desktop for threads mode */
POST_MSGQ (__mg_dsk_msg_queue);
#endif
__mg_dsk_msg_queue->last_ticks_desktop = __mg_tick_counter;
}
#endif /* deprecated code */
}
#ifdef __NOUNIX__
static BOOL install_system_timer (void)
{
return TRUE;
}
static BOOL unintall_system_timer (void)
{
return TRUE;
}
#else /* defined __NOUNIX__ */
#include <signal.h>
#include <unistd.h>
@@ -163,6 +126,12 @@ static BOOL unintall_system_timer (void)
static struct sigaction old_alarm_handler;
static struct itimerval old_timer;
static void timer_handler(int sig)
{
(void)sig;
__mg_update_tick_count(NULL);
}
static BOOL install_system_timer (void)
{
struct itimerval timerv;
@@ -171,20 +140,12 @@ static BOOL install_system_timer (void)
sigaction (SIGALRM, NULL, &old_alarm_handler);
siga = old_alarm_handler;
siga.sa_handler = (void(*)(int))__mg_update_tick_count;
#ifndef _MGRM_STANDALONE
siga.sa_handler = timer_handler;
siga.sa_flags = 0;
#else
siga.sa_flags = SA_RESTART;
#endif
sigaction (SIGALRM, &siga, NULL);
timerv.it_interval.tv_sec = 0;
#if defined(__uClinux__) && defined(_MGRM_STANDALONE)
timerv.it_interval.tv_usec = 100000; /* 100 ms */
#else
timerv.it_interval.tv_usec = 10000; /* 10 ms */
#endif
timerv.it_value = timerv.it_interval;
if (setitimer (ITIMER_REAL, &timerv, &old_timer) == -1) {
@@ -209,27 +170,31 @@ static BOOL unintall_system_timer (void)
return TRUE;
}
#endif /* defined(_MGRM_PROCESSES) */
#endif /* not defined __NOUNIX__ */
BOOL mg_InitTimer (BOOL use_sys_timer)
BOOL mg_InitTimer ()
{
__mg_tick_counter = 0;
__mg_os_start_time();
if (use_sys_timer) {
#if defined(_MGRM_PROCESSES)
if (mgIsServer) {
install_system_timer ();
}
#endif
return TRUE;
}
void mg_TerminateTimer (BOOL use_sys_timer)
void mg_TerminateTimer (void)
{
if (use_sys_timer)
#if defined(_MGRM_PROCESSES)
if (mgIsServer) {
unintall_system_timer ();
}
#endif
}
/************************* Functions run in message thread *******************/
int __mg_check_expired_timers (MSGQUEUE* msg_queue, DWORD inter)
@@ -247,34 +212,19 @@ int __mg_check_expired_timers (MSGQUEUE* msg_queue, DWORD inter)
int i;
TIMER** timer_slots = msg_queue->timer_slots;
__mg_update_tick_count (msg_queue);
for (i = 0; i < DEF_NR_TIMERS; i++) {
if (timer_slots[i]) {
if (__mg_tick_counter >= timer_slots[i]->ticks_expected) {
if (msg_queue->last_ticks >= timer_slots[i]->ticks_expected) {
/* setting timer flag is simple, we do not need to lock
msgq, or else we may encounter dead lock here */
msg_queue->expired_timer_mask |= (0x01UL << i);
POST_MSGQ (msg_queue);
timer_slots[i]->ticks_expected += timer_slots[i]->interv;
timer_slots[i]->ticks_fired = __mg_tick_counter;
timer_slots[i]->ticks_fired = msg_queue->last_ticks;
nr++;
}
#if 0 /* deprecated code */
timer_slots[i]->count += inter;
if (timer_slots[i]->count >= timer_slots[i]->interv) {
#ifdef _MGRM_PROCESSES
timer_slots[i]->ticks_current = SHAREDRES_TIMER_COUNTER;
#else
timer_slots[i]->ticks_current = __mg_tick_counter;
#endif
/* setting timer flag is simple, we do not need to lock msgq,
or else we may encounter dead lock here */
msg_queue->expired_timer_mask |= (0x01UL << i);
POST_MSGQ (msg_queue);
timer_slots[i]->count -= timer_slots[i]->interv;
nr++;
}
#endif /* deprecated code */
}
}
}
@@ -291,12 +241,7 @@ BOOL GUIAPI SetTimerEx (HWND hWnd, LINT id, DWORD interv,
int i;
int slot = -1;
TIMER** timer_slots;
PMSGQUEUE pMsgQueue;
#ifndef _MGRM_THREADS
/* Force to update tick count */
GetTickCount();
#endif
PMSGQUEUE msg_queue;
if (id == 0) {
_WRN_PRINTF ("bad identifier (%ld).\n", id);
@@ -307,12 +252,14 @@ BOOL GUIAPI SetTimerEx (HWND hWnd, LINT id, DWORD interv,
interv = 1;
}
timer_slots = getTimerSlotsForThisThread (&pMsgQueue);
timer_slots = getTimerSlotsForThisThread (&msg_queue);
if (MG_UNLIKELY (timer_slots == NULL)) {
_WRN_PRINTF ("called for non message thread\n");
goto badret;
}
__mg_update_tick_count (msg_queue);
/* Since 5.0.0: only check hWnd if timer_proc is NULL */
if (MG_UNLIKELY (timer_proc == NULL &&
!getMainWinIfWindowInThisThread (hWnd))) {
@@ -331,7 +278,7 @@ BOOL GUIAPI SetTimerEx (HWND hWnd, LINT id, DWORD interv,
/* Since 5.0.0: we reset timer parameters for duplicated call of
this function */
timer_slots[i]->interv = interv;
timer_slots[i]->ticks_expected = __mg_tick_counter + interv;
timer_slots[i]->ticks_expected = msg_queue->last_ticks + interv;
timer_slots[i]->ticks_fired = 0;
timer_slots[i]->proc = timer_proc;
return TRUE;
@@ -348,14 +295,14 @@ BOOL GUIAPI SetTimerEx (HWND hWnd, LINT id, DWORD interv,
timer_slots[slot]->hWnd = hWnd;
timer_slots[slot]->id = id;
timer_slots[slot]->interv = interv;
timer_slots[slot]->ticks_expected = __mg_tick_counter + interv;
timer_slots[slot]->ticks_expected = msg_queue->last_ticks + interv;
timer_slots[slot]->ticks_fired = 0;
timer_slots[slot]->proc = timer_proc;
_DBG_PRINTF ("ticks_expected (%d): %lu, tick_counter: %lu\n",
slot, timer_slots[slot]->ticks_expected, __mg_tick_counter);
slot, timer_slots[slot]->ticks_expected, msg_queue->last_ticks);
pMsgQueue->nr_timers++;
msg_queue->nr_timers++;
return TRUE;
@@ -363,24 +310,6 @@ badret:
return FALSE;
}
#if 0 /* deprected code */
#ifdef _MGRM_PROCESSES
static void reset_select_timeout (TIMER** timer_slots)
{
int i;
unsigned int interv = 0;
for (i = 0; i < DEF_NR_TIMERS; i++) {
if (timer_slots[i]) {
if (interv == 0 || timer_slots[i]->interv < interv)
interv = timer_slots[i]->interv;
}
}
__mg_set_select_timeout (USEC_10MS * interv);
}
#endif
#endif /* deprecated code */
void __mg_remove_timer (MSGQUEUE* msg_queue, int slot)
{
TIMER** timer_slots;
@@ -470,13 +399,14 @@ BOOL GUIAPI ResetTimerEx (HWND hWnd, LINT id, DWORD interv,
if (MG_LIKELY (msg_queue)) {
TIMER** timer_slots = msg_queue->timer_slots;
__mg_update_tick_count (msg_queue);
for (i = 0; i < DEF_NR_TIMERS; i++) {
if (timer_slots[i] &&
timer_slots[i]->hWnd == hWnd && timer_slots[i]->id == id) {
/* Should clear old timer flags */
msg_queue->expired_timer_mask &= ~(0x01UL << i);
timer_slots[i]->interv = interv;
timer_slots[i]->ticks_expected = __mg_tick_counter + interv;
timer_slots[i]->ticks_expected = msg_queue->last_ticks + interv;
timer_slots[i]->ticks_fired = 0;
if (timer_proc != (TIMERPROC)INV_PTR)
timer_slots[i]->proc = timer_proc;
@@ -548,20 +478,6 @@ BOOL GUIAPI HaveFreeTimer (void)
DWORD GUIAPI GetTickCount (void)
{
#if defined(_MGRM_PROCESSES)
if (mgIsServer) {
__mg_tick_counter = __mg_os_get_time_ticks ();
SHAREDRES_TIMER_COUNTER = __mg_tick_counter;
}
else {
__mg_tick_counter = SHAREDRES_TIMER_COUNTER;
}
#elif defined(_MGRM_STANDALONE)
__mg_tick_counter = __mg_os_get_time_ticks ();
#else /* not defined _MGRM_PROCESSES and _MGRM_PROCESSES */
/* do nothing here because the desktop thread updates the tick count */
#endif /* not defined _MGRM_PROCESSES and _MGRM_PROCESSES */
return __mg_tick_counter;
return __mg_update_tick_count(getMsgQueueForThisThread ());
}
+1 -1
View File
@@ -7,7 +7,7 @@ EXTRA_DIST= misc.c systext.c rwops.c endianrw.c nposix.c clipboard.c \
libmisc_la_SOURCES = misc.c systext.c rwops.c endianrw.c nposix.c clipboard.c \
math.c about.c license.c anon_file.c rbtree.c map.c \
error.c sockio.c lock_file.c
error.c sockio.c
SRC_FILES = $(libmisc_la_SOURCES)
LIB_NAME=libmisc
+1 -1
View File
@@ -114,7 +114,7 @@ static LRESULT AboutWinProc (HWND hWnd, UINT message,
DrawText (hdc,
"MiniGUI -- a mature cross-platform windowing system "
"and GUI support system for embedded or IoT devices.\n\n"
"Copyright (C) 2002 ~ 2023 FMSoft Co., Ltd.",
"Copyright (C) 2002 ~ 2020 FMSoft Co., Ltd.",
-1, &rcClient, DT_WORDBREAK | DT_CENTER);
EndPaint (hWnd, hdc);
-112
View File
@@ -1,112 +0,0 @@
///////////////////////////////////////////////////////////////////////////////
//
// 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) 2023, 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 <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/>.
*/
/*
** lock_file.c: This file include functions for locking/unlocking a file.
**
** Create date: 2023/09/10
**
** Current maintainer: Wei Yongming.
*/
#include "common.h"
#ifndef __NOUNIX__
#include "misc.h"
#include <unistd.h>
#include <sys/file.h>
#include <fcntl.h>
#include <errno.h>
void __mg_lock_file_for_read(int fd)
{
struct flock lock;
lock.l_type = F_RDLCK;
lock.l_whence = SEEK_SET;
lock.l_start = 0;
lock.l_len = 0;
while (fcntl(fd, F_SETLKW, &lock) == -1 && errno == EINTR);
}
void __mg_unlock_file_for_read(int fd)
{
struct flock lock;
lock.l_type = F_UNLCK;
lock.l_whence = SEEK_SET;
lock.l_start = 0;
lock.l_len = 0;
fcntl(fd, F_SETLK, &lock);
}
void __mg_lock_file_for_write(int fd)
{
struct flock lock;
lock.l_type = F_WRLCK;
lock.l_whence = SEEK_SET;
lock.l_start = 0;
lock.l_len = 0;
while (fcntl(fd, F_SETLKW, &lock) == -1 && errno == EINTR);
}
void __mg_unlock_file_for_write(int fd)
{
struct flock lock;
lock.l_type = F_UNLCK;
lock.l_whence = SEEK_SET;
lock.l_start = 0;
lock.l_len = 0;
fcntl(fd, F_SETLK, &lock);
}
#endif /* __NOUNIX__ */
+4 -4
View File
@@ -243,7 +243,7 @@ map_entry_t* __mg_map_find (map_t* map, const void* key)
return entry;
}
int __mg_map_erase (map_t* map, const void* key)
int __mg_map_erase (map_t* map, void* key)
{
int retval = -1;
map_entry_t* entry = NULL;
@@ -299,7 +299,7 @@ ret:
return retval;
}
map_entry_t* __mg_map_insert_ex2 (map_t* map, const void* key,
int __mg_map_insert_ex (map_t* map, const void* key,
const void* val, free_val_fn free_val_alt)
{
map_entry_t **pentry;
@@ -307,7 +307,7 @@ map_entry_t* __mg_map_insert_ex2 (map_t* map, const void* key,
map_entry_t *parent;
if (map == NULL)
return NULL;
return -1;
WRLOCK_MAP (map);
@@ -354,7 +354,7 @@ map_entry_t* __mg_map_insert_ex2 (map_t* map, const void* key,
}
UNLOCK_MAP (map);
return entry;
return 0;
}
int __mg_map_find_replace_or_insert (map_t* map, const void* key,
-4
View File
@@ -96,12 +96,8 @@ static BITMAP_TYPE_INFO bitmap_types [MAX_BITMAP_TYPES] =
{ "jpeg", __mg_init_jpg, __mg_load_jpg, __mg_cleanup_jpg, __mg_save_jpg, __mg_check_jpg },
#endif
#ifdef _MGIMAGE_PNG
#if _MGLIBPNG_VER == 16
{ "png", __mg_init_png, __mg_load_png, __mg_cleanup_png, __mg_save_png, __mg_check_png },
#else
{ "png", __mg_init_png, __mg_load_png, __mg_cleanup_png, NULL, __mg_check_png },
#endif
#endif
#ifdef _MGIMAGE_WEBP
{ "webp", __mg_init_webp, __mg_load_webp, __mg_cleanup_webp, NULL, __mg_check_webp },
#endif
-281
View File
@@ -381,287 +381,6 @@ BOOL __mg_check_png (MG_RWops* fp)
return png_check_sig (sig, 8);
}
static void png_error_callback (png_structp png, png_const_charp error_msg)
{
int *error = png_get_error_ptr (png);
*error = ERR_BMP_CANT_SAVE;
#ifdef PNG_SETJMP_SUPPORTED
longjmp (png_jmpbuf (png), 1);
#endif
}
static void png_warning_callback (png_structp png, png_const_charp error_msg)
{
}
static void png_output_flush_fn (png_structp png_ptr)
{
}
static void my_write_data_fn (png_structp png_ptr, png_bytep data,
png_size_t length)
{
png_size_t check;
png_voidp io_ptr = png_get_io_ptr(png_ptr);
if (MGUI_RWwrite((MG_RWops*)io_ptr, data, 1, length) !=
(size_t) length) {
png_error(png_ptr, "Write Error");
}
}
typedef BYTE* (*MYBITMAP_get_pixel_row)(unsigned int cinfo,
MYBITMAP* mybmp,RGB* pal);
static BYTE* MYBITMAP_get_pixel_row_pal16(unsigned int next_scanline,
MYBITMAP* mybmp, RGB* pal)
{
RGB rgb0, rgb1;
BYTE *bits = mybmp->bits + next_scanline * mybmp->pitch;
int nr_data = mybmp->w * 4;
BYTE *data = (BYTE *)malloc(nr_data);
uint8_t alpha = 0xFF;
for (int i = 0, j = 0, end_i = (mybmp->w + 1) >> 1; i < end_i; ++i) {
rgb0 = pal[ (bits[ i ] & 0XF0) >> 4 ];
rgb1 = pal[ bits[ i ] & 0X0F ];
data[ j ++ ] = rgb0.r;
data[ j ++ ] = rgb0.g;
data[ j ++ ] = rgb0.b;
data[ j ++ ] = alpha;
data[ j ++ ] = rgb1.r;
data[ j ++ ] = rgb1.g;
data[ j ++ ] = rgb1.b;
data[ j ++ ] = alpha;
}
return data;
}
static BYTE* MYBITMAP_get_pixel_row_pal256(unsigned int next_scanline,
MYBITMAP* mybmp, RGB* pal)
{
RGB rgb;
BYTE *bits = mybmp->bits + next_scanline * mybmp->pitch;
int nr_data = mybmp->w * 4;
BYTE *data = (BYTE *)malloc(nr_data);
uint8_t alpha = 0xFF;
for (int i = 0, j = 0; i < mybmp->w; i++, j += 4) {
rgb = pal [bits[i] ];
data[0] = rgb.r;
data[1] = rgb.g;
data[2] = rgb.b;
data[3] = alpha;
}
return data;
}
#define RGB_FROM_RGB565(pixel, r, g, b) \
{ \
r = (((pixel&0xF800)>>11)<<3); \
g = (((pixel&0x07E0)>>5)<<2); \
b = ((pixel&0x001F)<<3); \
}
static BYTE* MYBITMAP_get_pixel_row_RGB565(unsigned int next_scanline,
MYBITMAP* mybmp, RGB* pal)
{
Uint16* bits = (Uint16*)(mybmp->bits + next_scanline * mybmp->pitch);
int nr_data = mybmp->w * 4;
BYTE* data = (BYTE *)malloc(nr_data);
uint8_t alpha = 0xFF;
for (int i = 0, j = 0; i < nr_data; i += 4, j++) {
uint8_t *b = data + i;
Uint16 *pixel = bits + j;
RGB_FROM_RGB565(pixel[j], b[0], b[1], b[2])
b[3] = alpha;
}
return data;
}
static BYTE* MYBITMAP_get_pixel_row_RGB(unsigned int next_scanline,
MYBITMAP* mybmp, RGB* pal)
{
BYTE *bits = mybmp->bits + next_scanline * mybmp->pitch;
int nr_data = mybmp->w * 4;
BYTE *data = (BYTE *)malloc(nr_data);
uint8_t alpha = 0xFF;
for (int i = 0, j = 0; i < nr_data; i += 4, j += 3) {
uint8_t *b = data + i;
BYTE *pixel = bits + j;
b[0] = pixel[2];
b[1] = pixel[1];
b[2] = pixel[0];
b[3] = alpha;
}
return data;
}
static BYTE* MYBITMAP_get_pixel_row_BGR(unsigned int next_scanline,
MYBITMAP* mybmp, RGB* pal)
{
BYTE *bits = mybmp->bits + next_scanline * mybmp->pitch;
int nr_data = mybmp->w * 4;
BYTE *data = (BYTE *)malloc(nr_data);
uint8_t alpha = 0xFF;
for (int i = 0, j = 0; i < nr_data; i += 4, j += 3) {
uint8_t *b = data + i;
BYTE *pixel = bits + j;
b[0] = pixel[0];
b[1] = pixel[1];
b[2] = pixel[2];
b[3] = alpha;
}
return data;
}
static BYTE* MYBITMAP_get_pixel_row_RGBA(unsigned int next_scanline,
MYBITMAP* mybmp, RGB* pal)
{
BYTE *bits = mybmp->bits + next_scanline * mybmp->pitch;
int nr_data = mybmp->w * 4;
BYTE *data = (BYTE *)malloc(nr_data);
for (int i = 0; i < nr_data; i += 4) {
uint8_t *b = data + i;
BYTE *pixel = bits + i;
uint8_t alpha = pixel[3];
if (alpha == 0) {
b[0] = b[1] = b[2] = b[3] = 0;
} else {
b[0] = (pixel[2] * 255 + alpha / 2) / alpha; /* red */
b[1] = (pixel[1] * 255 + alpha / 2) / alpha; /* green */
b[2] = (pixel[0] * 255 + alpha / 2) / alpha; /* blue */
b[3] = alpha;
}
}
return data;
}
int __mg_save_png (MG_RWops* fp, MYBITMAP* bmp, RGB* pal)
{
png_struct *png;
png_info *info;
png_byte **volatile rows = NULL;
MYBITMAP_get_pixel_row get_row;
png_color_16 white;
int png_color_type;
int retcode = ERR_BMP_CANT_SAVE;
int bpc;
int bmp_type;
rows = calloc(bmp->h, sizeof(png_byte*));
if (rows == NULL) {
retcode = ERR_BMP_CANT_SAVE;
goto failed;
}
png = png_create_write_struct (PNG_LIBPNG_VER_STRING, &retcode,
png_error_callback, png_warning_callback);
if (png == NULL) {
retcode = ERR_BMP_MEM;
goto failed_clear_rows;
}
info = png_create_info_struct (png);
if (info == NULL) {
retcode = ERR_BMP_MEM;
goto failed_clear_struct;
}
#ifdef PNG_SETJMP_SUPPORTED
if (setjmp (png_jmpbuf (png))) {
goto failed_clear_struct;
}
#endif
png_set_write_fn (png, fp, my_write_data_fn, png_output_flush_fn);
bmp_type = bmp->flags & MYBMP_TYPE_MASK;
switch(bmp->depth) {
case 4:
get_row = MYBITMAP_get_pixel_row_pal16;
break;
case 8:
get_row = MYBITMAP_get_pixel_row_pal256;
break;
case 16:
get_row = MYBITMAP_get_pixel_row_RGB565;
break;
case 24:
if(MYBMP_TYPE_RGB == bmp_type)
get_row = MYBITMAP_get_pixel_row_RGB;
else
get_row = MYBITMAP_get_pixel_row_BGR;
break;
case 32:
get_row = MYBITMAP_get_pixel_row_RGBA;
break;
default:
_ERR_PRINTF("MYBMP>PNG: invalid MYBITMAP.depth = %d\n", bmp->depth);
goto failed_clear_struct;
}
for (int i = 0; i < bmp->h; i++) {
rows[i] = get_row(i, bmp, pal);
}
bpc = 8;
png_color_type = PNG_COLOR_TYPE_RGB_ALPHA;
png_set_IHDR (png, info,
bmp->w,
bmp->h, bpc,
png_color_type,
PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_DEFAULT,
PNG_FILTER_TYPE_DEFAULT);
white.gray = (1 << bpc) - 1;
white.red = white.blue = white.green = white.gray;
png_set_bKGD (png, info, &white);
png_write_info (png, info);
png_write_image (png, rows);
png_write_end (png, info);
retcode = ERR_BMP_OK;
failed_clear_struct:
png_destroy_write_struct (&png, &info);
failed_clear_rows:
for (int i = 0; i < bmp->h; i++) {
if (rows[i]) {
free(rows[i]);
}
}
free (rows);
failed:
return retcode;
}
#endif /* _MGLIBPNG_VER == 16 */
#endif /* _MGIMAGE_PNG */
+4 -8
View File
@@ -462,12 +462,11 @@ static void RLEClipBlit(int w, Uint8 *srcbuf, GAL_Surface *dst,
}
/* blit a colorkeyed RLE surface */
int GAL_RLEBlit(GAL_VideoDevice *video, GAL_Surface *src, GAL_Rect *srcrect,
int GAL_RLEBlit(GAL_Surface *src, GAL_Rect *srcrect,
GAL_Surface *dst, GAL_Rect *dstrect)
{
(void)video;
Uint8 *dstbuf;
Uint8 *srcbuf;
int x, y;
@@ -721,12 +720,9 @@ static void RLEAlphaClipBlit(int w, Uint8 *srcbuf, GAL_Surface *dst,
}
/* blit a pixel-alpha RLE surface */
int GAL_RLEAlphaBlit(GAL_VideoDevice *video,
GAL_Surface *src, GAL_Rect *srcrect,
int GAL_RLEAlphaBlit(GAL_Surface *src, GAL_Rect *srcrect,
GAL_Surface *dst, GAL_Rect *dstrect)
{
(void)video;
int x, y;
int w = src->w;
Uint8 *srcbuf, *dstbuf;
@@ -1506,7 +1502,7 @@ void GAL_UnRLESurface(GAL_Surface *surface, int recode)
full.h = surface->h;
alpha_flag = surface->flags & GAL_SRCALPHA;
surface->flags &= ~GAL_SRCALPHA; /* opaque blit */
GAL_RLEBlit(NULL, surface, &full, surface, &full);
GAL_RLEBlit(surface, &full, surface, &full);
surface->flags |= alpha_flag;
} else
UnRLEAlpha(surface);
+2 -4
View File
@@ -47,11 +47,9 @@
/* Useful functions and variables from RLEaccel.c */
extern int GAL_RLESurface(GAL_Surface *surface);
extern int GAL_RLEBlit(GAL_VideoDevice *video,
GAL_Surface *src, GAL_Rect *srcrect,
extern int GAL_RLEBlit(GAL_Surface *src, GAL_Rect *srcrect,
GAL_Surface *dst, GAL_Rect *dstrect);
extern int GAL_RLEAlphaBlit(GAL_VideoDevice *video,
GAL_Surface *src, GAL_Rect *srcrect,
extern int GAL_RLEAlphaBlit(GAL_Surface *src, GAL_Rect *srcrect,
GAL_Surface *dst, GAL_Rect *dstrect);
extern void GAL_UnRLESurface(GAL_Surface *surface, int recode);
+2
View File
@@ -157,6 +157,8 @@ static GAL_VideoDevice *BF533_CreateDevice(int devindex)
device->AllocHWSurface = BF533_AllocHWSurface;
device->CheckHWBlit = NULL;
device->FillHWRect = NULL;
device->SetHWColorKey = NULL;
device->SetHWAlpha = NULL;
device->FreeHWSurface = BF533_FreeHWSurface;
device->UpdateRects = BF533_UpdateRects;
+6 -15
View File
@@ -57,12 +57,9 @@
#include "memops.h"
/* The general purpose software blit routine */
static int GAL_SoftBlit(GAL_VideoDevice *video,
GAL_Surface *src, GAL_Rect *srcrect,
static int GAL_SoftBlit(GAL_Surface *src, GAL_Rect *srcrect,
GAL_Surface *dst, GAL_Rect *dstrect)
{
(void)video;
int okay;
/* Everything is okay at the beginning... */
@@ -169,14 +166,12 @@ static void GAL_BlitCopyOverlap(GAL_BlitInfo *info)
#ifdef _MGUSE_PIXMAN
#include <pixman.h>
static int GAL_PixmanBlit(GAL_VideoDevice *video,
struct GAL_Surface *src, GAL_Rect *srcrect,
static int GAL_PixmanBlit (struct GAL_Surface *src, GAL_Rect *srcrect,
struct GAL_Surface *dst, GAL_Rect *dstrect);
#endif
/* Figure out which of many blit routines to set up on a surface */
int GAL_CalculateBlit(GAL_Surface *surface, const GAL_Rect *srcrc,
const GAL_Rect *dstrc, DWORD op)
int GAL_CalculateBlit(GAL_Surface *surface)
{
int blit_index;
GAL_VideoDevice *src_video, *dst_video, *cur_video = NULL;
@@ -247,8 +242,7 @@ int GAL_CalculateBlit(GAL_Surface *surface, const GAL_Rect *srcrc,
if (hw_blit_ok && cur_video) {
GAL_VideoDevice *video = cur_video;
GAL_VideoDevice *this = cur_video;
video->CheckHWBlit (this, surface, srcrc,
surface->map->dst, dstrc, op);
video->CheckHWBlit (this, surface, surface->map->dst);
}
}
@@ -349,7 +343,7 @@ int GAL_SetupBlitting (GAL_Surface *src, GAL_Surface *dst, DWORD ops)
else
src->msk_img = NULL;
ops &= COLOR_BLEND_PIXMAN_MASK;
ops &= COLOR_BLEND_FLAGS_MASK;
if (ops == COLOR_BLEND_LEGACY) {
if ((src->flags & GAL_SRCPIXELALPHA) && src->format->Amask && src != dst) {
src->pix_op = PIXMAN_OP_OVER;
@@ -387,12 +381,9 @@ int GAL_CleanupBlitting (GAL_Surface *src, GAL_Surface *dst)
return 0;
}
static int GAL_PixmanBlit (GAL_VideoDevice *video,
struct GAL_Surface *src, GAL_Rect *srcrect,
static int GAL_PixmanBlit (struct GAL_Surface *src, GAL_Rect *srcrect,
struct GAL_Surface *dst, GAL_Rect *dstrect)
{
(void)video;
pixman_image_t *src_img = src->pix_img, *dst_img = dst->pix_img;
pixman_image_t *msk_img;
pixman_op_t op;
+1 -6
View File
@@ -80,11 +80,7 @@ typedef struct GAL_BlitMap {
Uint8 *table;
GAL_blit hw_blit;
GAL_blit sw_blit;
GAL_VideoDevice *video;
/* data for hardware blittor */
struct private_hwaccel *hw_data;
/* data for software blittor */
struct private_swaccel *sw_data;
int identity;
@@ -98,8 +94,7 @@ typedef struct GAL_BlitMap {
#include "blit_A.h"
/* Functions found in GAL_blit.c */
extern int GAL_CalculateBlit(GAL_Surface *surface, const GAL_Rect *srcrc,
const GAL_Rect *dstrc, DWORD op);
extern int GAL_CalculateBlit(GAL_Surface *surface);
/* Functions found in GAL_blit_{0,1,N,A}.c */
extern GAL_loblit GAL_CalculateBlit0(GAL_Surface *surface, int complex);
+2
View File
@@ -236,6 +236,8 @@ static GAL_VideoDevice *COMMLCD_CreateDevice (int devindex)
device->FreeHWSurface = COMMLCD_FreeHWSurface;
device->CheckHWBlit = NULL;
device->FillHWRect = NULL;
device->SetHWColorKey = NULL;
device->SetHWAlpha = NULL;
device->UpdateRects = NULL;
device->SyncUpdate = NULL;
+4 -3
View File
@@ -107,7 +107,7 @@ static int DFB_AllocHWSurface (_THIS, GAL_Surface *surface);
static void DFB_FreeHWSurface (_THIS, GAL_Surface *surface);
static int DFB_HWAccelBlit (GAL_Surface *src, GAL_Rect *srcrect, GAL_Surface *dst, GAL_Rect *dstrect);
static int DFB_CheckHWBlit (_THIS, GAL_Surface * src, GAL_Surface * dst);
static int DFB_FillHWRect (_THIS, GAL_Surface *dst, const GAL_Rect *rect, Uint32 color);
static int DFB_FillHWRect (_THIS, GAL_Surface *dst, GAL_Rect *rect, Uint32 color);
/* common dfb function address */
GAL_FunctionTable mgGALFuncTable = {
@@ -173,6 +173,8 @@ static GAL_VideoDevice *DFB_CreateDevice (int devindex)
device->AllocHWSurface = DFB_AllocHWSurface;
device->CheckHWBlit = DFB_CheckHWBlit;
device->FillHWRect = DFB_FillHWRect;
device->SetHWColorKey = NULL;
device->SetHWAlpha = NULL;
device->FreeHWSurface = DFB_FreeHWSurface;
device->free = DFB_DeleteDevice;
@@ -516,8 +518,7 @@ static void DFB_RequestHWSurface (_THIS, const REQ_HWSURFACE* request, REP_HWSUR
}
}
static int
DFB_FillHWRect (_THIS, GAL_Surface *dst, const GAL_Rect *rect, Uint32 color)
static int DFB_FillHWRect (_THIS, GAL_Surface *dst, GAL_Rect *rect, Uint32 color)
{
if ((dst->hwdata == NULL && dst != GAL_VideoSurface)) {
fprintf(stderr, "NEWGAL>DFB: src_hwdata or dst_hwdata NULL\n");

Some files were not shown because too many files have changed in this diff Show More