Compare commits

...
111 Commits
Author SHA1 Message Date
gengyue d68561769d modified for cross compile 2020-04-12 21:26:40 +08:00
Vincent Wei a693fa7dc2 optimize __mg_composite_dirty_znodes 2020-03-24 13:00:10 +08:00
Vincent Wei f7cb85401c add version to __ex_compositor_get; tune operations of CompositorOps to optimize it 2020-03-24 12:59:37 +08:00
Vincent Wei 433d5d6cc5 try to optimze cursor refresh (not finished) 2020-03-23 22:08:47 +08:00
Vincent Wei 98b66f158f comment out asynchronous update code 2020-03-23 19:00:14 +08:00
Vincent Wei 4fc71946ca support for asynchronous update 2020-03-23 18:45:13 +08:00
Vincent Wei 59c609dc2d fix a conditional compilation error 2020-03-23 18:22:45 +08:00
Vincent Wei ce6525d8f2 calling MainWindowCleanup for AboutDialogBox 2020-03-22 22:53:25 +08:00
Vincent Wei bbd1776911 only increase refcount for surface create for window and menu created by the server 2020-03-22 22:52:57 +08:00
Vincent Wei f196a67afe call EmptyClipRgn for temp region ergn 2020-03-22 22:52:01 +08:00
Vincent Wei 5f895b2ad9 increase refcount of surface for all memory DC 2020-03-22 20:01:36 +08:00
Vincent Wei e5c31ee766 free real screen surface when double buffering enabled 2020-03-22 20:00:44 +08:00
Vincent Wei 9f244a1093 call drmModeDirtyFB in SyncUpdate 2020-03-22 20:00:24 +08:00
Vincent Wei 43c387d0a0 debug for use refcount for all memory dc 2020-03-22 19:59:23 +08:00
Vincent Wei f662f45e86 no need to free surface explicitly 2020-03-22 19:48:51 +08:00
Vincent Wei 602f3c5748 remove debug printf 2020-03-22 18:24:47 +08:00
Vincent Wei 74f727cb2e fix a bug: must reset olddownkey to zero when got a KEYUP event 2020-03-22 18:05:32 +08:00
Vincent Wei dccc997e75 tune 2020-03-22 17:43:50 +08:00
Vincent Wei 41858de966 fix a bug: pass correct select timeout value 2020-03-22 17:37:43 +08:00
Vincent Wei 86b4d9c9ab fix a bug: always pass cli=0 for dskCalculateDefaultPosition 2020-03-22 17:36:18 +08:00
Vincent Wei 4144065fb8 tune comments 2020-03-22 17:35:54 +08:00
Vincent Wei 7932f5f687 tune 2020-03-21 21:49:05 +08:00
Vincent Wei 0a54e292e9 tune 2020-03-21 21:47:03 +08:00
Vincent Wei d3770381b8 add support for alpha_pixel_blt 2020-03-21 19:16:07 +08:00
Vincent Wei a5f13a023c tune ColorLogicalOp with the values from old DrmColorLogicOp 2020-03-21 19:15:37 +08:00
Vincent Wei 039121892b remove DrmColorLogicOp, use ColorLogicalOp instead; add alpha_pixel_blt operation 2020-03-21 19:15:01 +08:00
Vincent Wei 150f670d2e debug for hardware cursor by using plane 2020-03-21 18:49:20 +08:00
Vincent Wei 7fbd3ef4f3 tune code for authenticate client; remove use of drm_magic 2020-03-21 17:52:21 +08:00
Vincent Wei c03386f438 remove auth_magic 2020-03-21 17:48:57 +08:00
Vincent Wei 058db9ccdf handler authenticate_client for REQID_AUTHCLIENT 2020-03-21 17:48:40 +08:00
Vincent Wei a8c623b0dd remove drm_magic 2020-03-21 17:47:59 +08:00
Vincent Wei 50b7ee5fc2 add REQID_AUTHCLIENT 2020-03-21 17:47:43 +08:00
Vincent Wei 9a95f9b706 increase MAX_SYS_REQID for REQID_AUTHCLIENT 2020-03-21 17:47:08 +08:00
Vincent Wei 4da4e0b1ac tune 2020-03-21 15:41:21 +08:00
Vincent Wei 151400eac0 disable alpha for CT_COLORKEY 2020-03-21 15:39:49 +08:00
Vincent Wei f8bd1a67bc fix a conditional compilation error 2020-03-20 19:54:53 +08:00
Vincent Wei 3f65456f3f do not use dumb surface for shadow screen, use GAL_CreateRGBSurfaceInShm instead 2020-03-20 19:12:55 +08:00
Vincent Wei 8c102fcafd remove use of offset fields in GAL_Surface; initialize pixels_off to 0 2020-03-20 19:12:15 +08:00
Vincent Wei e8150805ff add surface-shm.c 2020-03-20 19:11:18 +08:00
Vincent Wei 88391c47d2 implement GAL_CreateRGBSurfaceInShm 2020-03-20 19:11:00 +08:00
Vincent Wei 8d8f51f660 remove offset field add pixels_off field in GAL_Surface; declare GAL_CreateRGBSurfaceInShm 2020-03-20 19:10:23 +08:00
Vincent Wei d2d10421b6 tune map_buffer 2020-03-19 22:29:10 +08:00
Vincent Wei 0e0c95e0a9 tune map_buffer: add scanout argument 2020-03-19 22:28:55 +08:00
Vincent Wei 61e22faeb9 pixels_size -> map_size 2020-03-19 21:45:08 +08:00
Vincent Wei d81d40f9b7 pixels_size -> map_size 2020-03-19 21:42:33 +08:00
Vincent Wei 66de31895a restore old DrmColorLogicOp 2020-03-19 21:41:38 +08:00
Vincent Wei bfec1da2a6 remove some unused code 2020-03-19 15:28:07 +08:00
Vincent Wei c76adc0602 test code: use memcpy directly for blitting from shadow screen to real screen 2020-03-19 12:09:45 +08:00
Vincent Wei 306dd9602a test code of sendfile 2020-03-18 22:40:01 +08:00
Vincent Wei 85c63e90fa use plane for hardware cursor 2020-03-18 18:06:01 +08:00
Vincent Wei cf537dd421 tune implementation accoring to the changes of DrmDriverOps and DrmSurfaceBuffer 2020-03-18 18:00:51 +08:00
Vincent Wei 334a77adaf tune DrmSurfaceInfo struct 2020-03-18 17:59:30 +08:00
Vincent Wei 6ce6de157b tune DrmSurfaceBuffer struct and DrmDriverOps 2020-03-18 17:58:58 +08:00
Vincent Wei 9eb0a8b40c cleanup debug info 2020-03-17 19:41:46 +08:00
Vincent Wei f1d670502c use plane for hardware cursor (not finished) 2020-03-17 17:32:39 +08:00
Vincent Wei 3269650084 use plane for hardware cursor (not finished) 2020-03-17 17:32:34 +08:00
Vincent Wei 53edb5dcba tune warning info 2020-03-17 17:31:46 +08:00
Vincent Wei 1f46ba258e change version to 4.9.2 2020-03-16 23:16:22 +08:00
Vincent Wei 959407d7ea do not use fd for get_shared_surface for sharedfb schema under PROC runmode 2020-03-16 23:01:28 +08:00
Vincent Wei 3eacf471ac tune 2020-03-16 23:00:35 +08:00
Vincent Wei a2b65ba39f add auth_magic 2020-03-16 23:00:09 +08:00
Vincent Wei 444d9bb1f7 call drmSetMaster and drmAuthMagic for sharedfb schema under PROCS runmode 2020-03-16 22:59:39 +08:00
Vincent Wei b54c186688 add auth magic for DRM engine in shared resource segment 2020-03-16 22:58:58 +08:00
Vincent Wei 19372b2fbb no need to use semaphore to lock the dirty rectangle 2020-03-16 22:58:24 +08:00
Vincent Wei 77c76c53ae tune 2020-03-16 22:57:51 +08:00
Vincent Wei 50ddc8e31c tune 2020-03-16 20:48:30 +08:00
Vincent Wei e67849db69 only mmap software shared surface 2020-03-16 20:45:41 +08:00
Vincent Wei 96a085170b tune error info 2020-03-16 20:44:57 +08:00
Vincent Wei ff6f42e291 debug 2020-03-16 20:44:34 +08:00
Vincent Wei f8ced41de6 add CopyVideoInfoToSharedRes method in GAL engine for PROCS and calling this method to copy the video info to shared resource segment when the process is the server 2020-03-16 17:38:50 +08:00
Vincent Wei 072ac4e166 send XVFB_CMD_QUIT command to pcxvfb process when terminating the IAL engine 2020-03-16 17:34:13 +08:00
Vincent Wei 43b8b8de59 add XVFBCmdEventData to send a command to pcxvfb process 2020-03-16 17:33:44 +08:00
Vincent Wei 5fa10b3d7f check name for shared surface 2020-03-16 14:49:16 +08:00
Vincent Wei fdac75dce0 call munmap only for software shared surface 2020-03-16 14:48:40 +08:00
Vincent Wei 44b8552307 call mg_DestroyFreeQMSGList after terminating desktop 2020-03-16 14:47:42 +08:00
Vincent Wei 6ad5529ee7 tune nr_lines_for_header 2020-03-15 22:17:14 +08:00
Vincent Wei 6b47d74be7 fix compilation errors/warnings 2020-03-15 22:11:16 +08:00
Vincent Wei 32f29cc159 implement UpdateRects and SyncUpdate 2020-03-15 21:28:08 +08:00
Vincent Wei 0d4b076fd5 tune fields of DrmVideoData 2020-03-15 21:27:41 +08:00
Vincent Wei cddfc2ed84 pass offset to __drm_create_surface_from_handle and __drm_create_surface_from_prime_fd 2020-03-15 21:27:14 +08:00
Vincent Wei 41b37abc13 define GAL_SharedSurfaceHeader structure for shadow surface bufffer 2020-03-15 19:17:33 +08:00
Vincent Wei d3e1837244 create dumb buffer from handle, name, and prime fd 2020-03-15 13:03:44 +08:00
Vincent Wei 1bc10fb83e use name when request the shared surface 2020-03-15 11:56:12 +08:00
Vincent Wei 7188627084 use name when request the shared surface 2020-03-15 11:55:43 +08:00
Vincent Wei 615d1e72d3 add real_name and shadow_name for double buffering 2020-03-15 11:55:09 +08:00
Vincent Wei cb8fb1a0c1 get info screen surfaces and create real_screen and shadow_screen for clients 2020-03-15 11:54:33 +08:00
Vincent Wei ed728100c3 more fields in SHAREDSURFINFO for convenience 2020-03-15 11:52:37 +08:00
Vincent Wei 56e24ff4ef check double buffering 2020-03-15 10:51:56 +08:00
Vincent Wei ba3a0030fc Do not init the fields in the shared resource segment for DRM engine; left them for DRM engine 2020-03-15 10:50:59 +08:00
Vincent Wei 2094cda9e5 tune fields in the shared resource segment for DRM engine 2020-03-15 10:50:15 +08:00
Vincent Wei aad307d676 define LEN_EXDRIVER_NAME is same as LEN_SO_NAME 2020-03-15 10:49:32 +08:00
Vincent Wei 3fa8169353 define backward compatible APIs for drmCreateDCFromXXX 2020-03-15 10:49:04 +08:00
Vincent Wei 5cf3418c15 more comments 2020-03-15 10:48:03 +08:00
Vincent Wei 3611804ecc change name of field map_size to size 2020-03-14 22:35:07 +08:00
Vincent Wei c121c87b75 add argument offset to drmCreateDCFromXXX functions 2020-03-14 22:34:29 +08:00
Vincent Wei 47f577b672 change field name 2020-03-14 22:34:03 +08:00
Vincent Wei 7ca92b6350 add some fields in GAL_PrivateVideoData for compisiting schema and double buffering 2020-03-14 22:33:32 +08:00
Vincent Wei e4cc1d4c26 code for sharedfb schema 2020-03-14 22:32:39 +08:00
Vincent Wei 9a076cba39 tune the argument types 2020-03-14 22:31:50 +08:00
Vincent Wei 74178caf8c change field map_size to size in SHAREDSURFINFO 2020-03-14 22:31:27 +08:00
Vincent Wei 4fee49aa43 add argument offset to drmCreateDCFromXXX functions 2020-03-14 22:31:01 +08:00
Vincent Wei fa13587088 restore drm_format field just for convenience 2020-03-14 22:29:50 +08:00
Vincent Wei 2b715208c0 add double_buffering key to drm section 2020-03-14 22:28:47 +08:00
Vincent Wei 1bbd5ea4f1 IS_SHAREDFB_SCHEMA -> IS_SHAREDFB_SCHEMA_PROCS; reflects for the changes of fields name and internal functions 2020-03-14 19:03:57 +08:00
Vincent Wei 4ea138ef19 implement methods for compositing schema and PROCS runmode 2020-03-14 19:01:49 +08:00
Vincent Wei a39c1caa4a tune fields name; add GAL_SharedSurfaceHeader for sharedfb schema 2020-03-14 19:00:17 +08:00
Vincent Wei b1b4ce2a66 remove redundant fields in DrmSurfaceInfo 2020-03-14 18:58:36 +08:00
Vincent Wei 7c92a9334d remove redundant fields in DrmSurfaceBuffer; simplify interfaces of DrmDriverOps 2020-03-14 18:57:42 +08:00
Vincent Wei aaa4ad1cbc tune description words 2020-03-13 15:02:03 +08:00
Vincent Wei 7b93d0878d tune COMMLCD engine for nwe GAL engine: use SyncUpdte method and sem_update semaphore insteadll dumb delaying 50ms 2020-03-13 14:34:42 +08:00
Vincent Wei 1c29f6373e fix a conditional compilation error 2020-03-13 14:33:03 +08:00
54 changed files with 3959 additions and 1735 deletions
+69 -69
View File
@@ -6,11 +6,6 @@ A mature and proven cross-platform GUI system for embedded and smart IoT devices
## TABLE OF CONTENTS
- [INTRODUCTION](#introduction)
- [A BRIEF BUILDING INSTRUCTION](#a-brief-building-instruction)
+ [Prerequisites](#prerequisites)
+ [Building MiniGUI Core](#building-minigui-core)
+ [Building whole MiniGUI](#building-whole-minigui)
+ [Unit Tests](#unit-tests)
- [NEW FEATURES IN VERSION 5.0.x](#new-features-in-version-50x)
+ [Compositing schema](#compositing-schema)
+ [New main window types](#new-main-window-types)
@@ -19,6 +14,11 @@ A mature and proven cross-platform GUI system for embedded and smart IoT devices
- [NEW FEATURES IN VERSION 4.0.x](#new-features-in-version-40x)
- [NEW FEATURES IN VERSION 3.2.x](#new-features-in-version-32x)
- [THE RUNTIME MODES OF MINIGUI](#the-runtime-modes-of-minigui)
- [A BRIEF BUILDING INSTRUCTION](#a-brief-building-instruction)
+ [Prerequisites](#prerequisites)
+ [Building MiniGUI Core](#building-minigui-core)
+ [Building whole MiniGUI](#building-whole-minigui)
+ [Unit Tests](#unit-tests)
- [HISTORY](#history)
- [AUTHORS AND COPYING](#authors-and-copying)
+ [Special Statement](#special-statement)
@@ -41,7 +41,7 @@ embedded systems or smart IoT devices based-on Linux/uClinux, eCos, and other
traditional RTOSes, such as RT-Thread, FreeRTOS, RTEMS, VxWorks, ThreadX,
Nucleus, pSOS, uC/OS-II, and OSE.
This is the source tree of MiniGUI Core, which provides windowing
This is the source tree of MiniGUI Core, which provides the windowing
and graphics interfaces as well as a lot of standard controls (toolkit).
Besides MiniGUI Core, FMSoft also provides some components
@@ -109,69 +109,6 @@ We now maintain all documents about MiniGUI on the following public repo:
<https://github.com/VincentWei/minigui-docs>
## A BRIEF BUILDING INSTRUCTION
This instruction assumes that you are using Ubuntu Linux.
### Prerequisites
You should run `apt install <package_name>` to install the following packages
on your Ubuntu Linux.
* Building tools:
* autoconf
* Dependent libraries (all are optional):
* libjpeg64-dev
* libpng12-dev (use libpng-dev on Ubuntu Linux 18.04 LTS)
* libfreetype6-dev
### Building MiniGUI Core
MiniGUI Core uses GNU autoconf/automake scripts to configure and build the project.
Run
$ ./configure; make; sudo make install
to configure, make, and install the headers and the libraries. If there is not
`configure` file, please run
$ ./autogen.sh
to generate the script.
MiniGUI Core also provides some configuration options to customize the features.
For more information, please run
$ ./configure --help
### Building whole MiniGUI
If you are anxious to see the comprehensive demo of MiniGUI Core
and MiniGUI components, please fetch one of the following repositories
from GitHub and follow the instructions to build MiniGUI Core,
MiniGUI components, the samples, and the demonstration programs:
<https://github.com/VincentWei/build-minigui-5.0>
or
<https://github.com/VincentWei/build-minigui-4.0>
or
<https://github.com/VincentWei/build-minigui-3.2>
### Unit Tests
Since MiniGUI 4.0.0, we organize the unit test code of MiniGUI APIs in the
following repository:
<https://github.com/VincentWei/mg-tests>
If you are interested in hacking the MiniGUI code, please visit this repository.
## NEW FEATURES IN VERSION 5.0.x
In version 5.0.0, we introduced some new and exciting features, and refactored
@@ -380,6 +317,69 @@ If a client exits or dies for some reasons, it will not damage other
clients and the server.
## A BRIEF BUILDING INSTRUCTION
This instruction assumes that you are using Ubuntu Linux.
### Prerequisites
You should run `apt install <package_name>` to install the following packages
on your Ubuntu Linux.
* Building tools:
* autoconf
* Dependent libraries (all are optional):
* libjpeg64-dev
* libpng12-dev (use libpng-dev on Ubuntu Linux 18.04 LTS)
* libfreetype6-dev
### Building MiniGUI Core
MiniGUI Core uses GNU autoconf/automake scripts to configure and build the project.
Run
$ ./configure; make; sudo make install
to configure, make, and install the headers and the libraries. If there is not
`configure` file, please run
$ ./autogen.sh
to generate the script.
MiniGUI Core also provides some configuration options to customize the features.
For more information, please run
$ ./configure --help
### Building whole MiniGUI
If you are anxious to see the comprehensive demo of MiniGUI Core
and MiniGUI components, please fetch one of the following repositories
from GitHub and follow the instructions to build MiniGUI Core,
MiniGUI components, the samples, and the demonstration programs:
<https://github.com/VincentWei/build-minigui-5.0>
or
<https://github.com/VincentWei/build-minigui-4.0>
or
<https://github.com/VincentWei/build-minigui-3.2>
### Unit Tests
Since MiniGUI 4.0.0, we organize the unit test code of MiniGUI APIs in the
following repository:
<https://github.com/VincentWei/mg-tests>
If you are interested in hacking the MiniGUI code, please visit this repository.
## HISTORY
21 years have pasted since MiniGUI was initially created at
+13 -31
View File
@@ -1,8 +1,6 @@
# Release Notes
- [Version 4.9.1](#version-491)
+ [What's new in this version](#whats-new-in-this-version)
- [Version 4.9.0](#version-490)
- [Version 4.9.2](#version-492)
+ [What's new in this version](#whats-new-in-this-version)
+ [Compositing schema](#compositing-schema)
+ [New main window styles](#new-main-window-styles)
@@ -12,31 +10,10 @@
+ [Changes leading to incompatibility](#changes-leading-to-incompatibility)
+ [Deprecated APIs](#deprecated-apis)
## Version 4.9.1
## Version 4.9.2
The MiniGUI development team announces the availability of MiniGUI 4.9.1,
which is the second preview release of MiniGUI 5.0.0.
This is an unstable release to show you some new and exciting features.
Here `unstable` means that the new APIs we introduced in this version
may change in the official release.
Nevertheless, we did our best to ensure backward compatibility of the
existed APIs so that the old applications can smoothly migrate to the new
version. We recommend that you test this version and report any bugs and
incompatibilities in
<https://github.com/VincentWei/minigui/tree/dev-4-1>
### What's new in this version
- Tune the `fbcon` (Linux Frame Buffer) engine to support compositing schema.
- Fix some bugs.
## Version 4.9.0
The MiniGUI development team announces the availability of MiniGUI 4.9.0,
which is the first preview release of MiniGUI 5.0.0.
The MiniGUI development team announces the availability of MiniGUI 4.9.2,
which is the third preview release of MiniGUI 5.0.0.
This is an unstable release to show you some new and exciting features.
Here `unstable` means that the new APIs we introduced in this version
@@ -89,6 +66,15 @@ exciting features for MiniGUI:
* ADJUSTMENTS:
- `g_rcScr` now is defined a macro calling function `GetScreenRect()`.
- `mgIsServer` now is define a macro calling function `IsServer()`.
* TUNNING
- Tune the `drm` (DRM) engine to support MiniGUI-Processes runtime mode
and compositing schema.
- Tune the `fbcon` (Linux Frame Buffer) engine to support compositing schema.
- Tune the `commlcd` (common LCD) engine to support cumulative updating and
compositing schema.
- Tune the `dummy` GAL engine to support MiniGUI-Processes runtime mode.
compositing schema.
- Fix some bugs.
* CLEANUP:
- Cleaned up a lot of internal symbols (the external functions and
global variables) in order to avoid name polution.
@@ -99,11 +85,7 @@ exciting features for MiniGUI:
The following new features will be developed in the successive versions of
4.9.x:
- Enhance DRM engine to support MiniGUI-Processes runtime mode and the
compositing schema.
- Enhance other frequently used GAL engines to support compositing schema.
- Provide a customized compositor which provides window animation effects as
an example in `mg-demos`.
### Compositing schema
+1 -1
View File
@@ -1,4 +1,4 @@
Version 4.9.1 (2019/03/11)
Version 5.0.0 (2019/03/31)
This is the second preview version of MiniGUI 5.0.0, an unstable version.
+6 -1
View File
@@ -172,5 +172,10 @@ tab2space() {
# sed -i 's/\<checkAndGetMainWindowPtrOfMainWin\>/checkAndGetMainWinIfMainWin/g' `grep '\<checkAndGetMainWindowPtrOfMainWin\>' -rl include/ src/`
# sed -i 's/\<checkAndGetMainWindowPtrOfControl\>/checkAndGetMainWinIfWindow/g' `grep '\<checkAndGetMainWindowPtrOfControl\>' -rl include/ src/`
sed -i 's/\<mg_GetMsgQueueForThisThread\>/getMsgQueueForThisThread/g' `grep '\<mg_GetMsgQueueForThisThread\>' -rl include/ src/`
# sed -i 's/\<mg_GetMsgQueueForThisThread\>/getMsgQueueForThisThread/g' `grep '\<mg_GetMsgQueueForThisThread\>' -rl include/ src/`
# sed -i 's/\<IS_SHAREDFB_SCHEMA\>/IS_SHAREDFB_SCHEMA_PROCS/g' `grep '\<IS_SHAREDFB_SCHEMA\>' -rl include/ src/`
sed -i 's/\<REQID_GETWPSURFACE\>/REQID_GETSHAREDSURFACE/g' `grep '\<REQID_GETWPSURFACE\>' -rl include/ src/`
exit 0
+4 -4
View File
@@ -1,6 +1,6 @@
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.60)
AC_INIT(libminigui, 4.9.1)
AC_INIT(libminigui, 4.9.2)
AC_CONFIG_SRCDIR(src/main/main.c)
dnl Set various version strings - taken gratefully from the SDL sources
@@ -16,9 +16,9 @@ dnl Set various version strings - taken gratefully from the SDL sources
#
MINIGUI_MAJOR_VERSION=4
MINIGUI_MINOR_VERSION=9
MINIGUI_MICRO_VERSION=1
MINIGUI_INTERFACE_AGE=1
MINIGUI_BINARY_AGE=1
MINIGUI_MICRO_VERSION=2
MINIGUI_INTERFACE_AGE=0
MINIGUI_BINARY_AGE=0
MINIGUI_VERSION=$MINIGUI_MAJOR_VERSION.$MINIGUI_MINOR_VERSION.$MINIGUI_MICRO_VERSION
AC_SUBST(MINIGUI_MAJOR_VERSION)
+6
View File
@@ -72,6 +72,12 @@ device=/dev/dri/card0
# The default value is 96.
dpi=96
# Whether double buffering is enabled.
# Use `true` or `yes` for enabled, anything else for disabled.
# Note that under compositing schema, double buffering is always enabled.
# Since 5.0.0.
double_buffering=true
# The filename of the shared library for the external driver.
# The equivalent environment variable: MG_GAL_DRM_DRIVER
exdriver=libhidrmdrivers.so.0
+161 -85
View File
@@ -92,64 +92,73 @@ struct _DrmDriver;
typedef struct _DrmDriver DrmDriver;
/**
* The struct type represents the bufffer can be used by
* MiniGUI NEWGAL engine for hardware surface.
* The structure type represents the buffer can be used by
* MiniGUI NEWGAL DRM engine for a hardware surface.
*/
typedef struct _DrmSurfaceBuffer {
/** The prime fd of the buffer */
int prime_fd;
/** The global name of the buffer */
uint32_t name;
/** The local handle of the buffer */
uint32_t handle;
/** The buffer identifier */
uint32_t id;
/** The widht of the buffer */
uint32_t width;
/** The height of the buffer */
uint32_t height;
/** The pitch (row stride in bytes) of the buffer */
uint32_t pitch;
/** The DRM format of the buffer */
uint32_t drm_format;
/**
* The prime file descriptor of the buffer.
* It has a value >= 0 when this buffer has a prime file descriptor;
* otherwise it has the value -1;
*/
int prime_fd;
/**
* The global name of the buffer.
* It has value > 0 when this buffer has a global name;
* otherwise it has the value 0;
*/
uint32_t name;
/**
* The frame buffer identifier if the buffer has been added as a
* frame buffer to the system, otherwise it has the value 0.
*/
uint32_t fb_id;
/** The DRM format of the buffer. */
uint32_t drm_format;
/** The bits per pixel */
uint32_t bpp:8;
/** The bytes per pixel */
uint32_t cpp:8;
/** Is foreign surface */
uint32_t foreign:1;
/** Is it a dumb buffer. Since 5.0.0. */
uint32_t dumb:1;
/** Is it a scanout buffer. Since 5.0.0. */
uint32_t scanout:1;
/** The width of the buffer. */
uint32_t width;
/** The height of the buffer. */
uint32_t height;
/** The pitch (row stride in bytes) of the buffer. */
uint32_t pitch;
/** The whole size in bytes of the buffer */
unsigned long size;
/** The mapped address of the buffer; NULL when the buffer is not mapped yet. */
uint8_t* pixels;
size_t size;
/**
* The offset from the buffer start to the real pixel data in bytes.
* It must be equal to or larger than the size of the buffer header.
* Since 5.0.0.
*/
off_t offset;
/**
* The mapped address of the buffer;
* NULL when the buffer is not mapped yet.
*
* The address of the pixel data:
* uint8_t* pixels = this->buff + this->offset;
*/
uint8_t* buff;
} DrmSurfaceBuffer;
/**
* The color logic operations.
*/
enum DrmColorLogicOp {
COLOR_LOGICOP_COPY = 0,
COLOR_LOGICOP_COPY_INVERTED,
COLOR_LOGICOP_CLEAR,
COLOR_LOGICOP_SET,
COLOR_LOGICOP_NOR,
COLOR_LOGICOP_NAND,
COLOR_LOGICOP_EQUIV,
COLOR_LOGICOP_INVERT,
COLOR_LOGICOP_XOR,
COLOR_LOGICOP_AND,
COLOR_LOGICOP_AND_INVERTED,
COLOR_LOGICOP_AND_REVERSE,
COLOR_LOGICOP_OR,
COLOR_LOGICOP_OR_INVERTED,
COLOR_LOGICOP_OR_REVERSE,
COLOR_LOGICOP_NOOP,
};
/**
* The struct type defines the operations for a DRI driver.
* The structure type defines the operations for a DRM driver.
*/
typedef struct _DrmDriverOps {
/**
@@ -160,81 +169,95 @@ typedef struct _DrmDriverOps {
DrmDriver* (*create_driver) (int device_fd);
/**
* This operation destroies the DrmDriver object.
* This operation destroys the DrmDriver object.
*
* \note The driver must implement this operation.
*/
void (*destroy_driver) (DrmDriver *driver);
/**
* This operation flushs the batch buffer of the driver or the hardware cache.
* This operation flushes the batch buffer of the driver or
* the hardware cache.
*
* \note This operation can be NULL.
*/
void (* flush_driver) (DrmDriver *driver);
/**
* This operation creates a buffer with the specified pixel format,
* width, and height. If succeed, a valid DrmSurfaceBuffer object will
* be returned; NULL on error. Note that the field of `pixels` of the
* DrmSurfaceBuffer object is NULL until the \a map_buffer was called.
* This operation creates a surface buffer with the specified pixel format,
* header size, width, and height. If succeed, a valid DrmSurfaceBuffer
* object will be returned; NULL on error. Note that the field of `buff`
* of the DrmSurfaceBuffer object is NULL until the \a map_buffer was called.
*
* \note The driver must implement this operation.
* \note The driver must implement this operation and fill all fields of
* the new DrmSurfaceBuffer object.
*/
DrmSurfaceBuffer* (* create_buffer) (DrmDriver *driver,
uint32_t drm_format,
unsigned int width, unsigned int height);
uint32_t drm_format, uint32_t hdr_size,
uint32_t width, uint32_t height);
/**
* This operation creates a buffer for the given handle
* with the specified pixel format, width, and height. If succeed,
* a valid DrmSurfaceBuffer object will be returned; NULL on error.
* This operation creates a buffer from a given and possibly foreign handle
* with the size of the buffer. If succeed, a valid DrmSurfaceBuffer object
* will be returned; NULL on error.
*
* \note This operation can be NULL.
* \note This operation can be NULL. Note that the handle might was created
* by a foreign module. If implemented, the driver must
* fill the correct prime_fd, handle, name, and size fields of the new
* DrmSurfaceBuffer object.
*/
DrmSurfaceBuffer* (* create_buffer_from_handle) (DrmDriver *driver,
uint32_t handle, unsigned long size, uint32_t drm_format,
unsigned int width, unsigned int height, unsigned int pitch);
uint32_t handle, size_t size);
/**
* This operation creates a buffer for the given system global name
* with the specified pixel format, width, and height. If succeed,
* a valid DrmSurfaceBuffer object will be returned; NULL on error.
* If succeed, a valid DrmSurfaceBuffer object will be returned;
* NULL on error.
*
* \note This operation can be NULL.
* \note This operation can be NULL. If implemented, the driver must
* fill the correct prime_fd, handle, name, and size fields of the new
* DrmSurfaceBuffer object.
*/
DrmSurfaceBuffer* (* create_buffer_from_name) (DrmDriver *driver,
uint32_t name, uint32_t drm_format,
unsigned int width, unsigned int height, unsigned int pitch);
uint32_t name);
/**
* This operation creates a buffer for the given PRIME file descriptor
* with the specified pixel format, width, height, and pitch. If succeed,
* a valid DrmSurfaceBuffer object will be returned; NULL on error.
*
* \note This operation can be NULL.
* \note This operation can be NULL. If implemented, the driver must
* fill the correct prime_fd, handle, name, and size fields of the new
* DrmSurfaceBuffer object.
*/
DrmSurfaceBuffer* (* create_buffer_from_prime_fd) (DrmDriver *driver,
int prime_fd, unsigned long size, uint32_t drm_format,
unsigned int width, unsigned int height, unsigned int 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.
*
* \note The driver must implement this operation.
* 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.
*
* \note The driver must implement this operation.
* \note The driver must implement this operation. The driver must
* set NULL for buff field of the DrmSurfaceBuffer object
* on success.
*/
void (* unmap_buffer) (DrmDriver *driver, DrmSurfaceBuffer* buffer);
/**
* This operation destroies a buffer.
* This operation destroys a buffer.
*
* \note The driver must implement this operation.
*/
@@ -256,7 +279,7 @@ typedef struct _DrmDriverOps {
* 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 blit operation.
* the driver does not support any hardware accelerated blitting operation.
*/
int (* check_blit) (DrmDriver *driver,
DrmSurfaceBuffer* src_buf, DrmSurfaceBuffer* dst_buf);
@@ -265,51 +288,104 @@ typedef struct _DrmDriverOps {
* 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 blit.
* hardware accelerated copy blitting.
*
* \note Currently, the logical operation is ignored.
*/
int (* copy_blit) (DrmDriver *driver,
DrmSurfaceBuffer* src_buf, const GAL_Rect* src_rc,
DrmSurfaceBuffer* dst_buf, const GAL_Rect* dst_rc,
enum DrmColorLogicOp logic_op);
ColorLogicalOp logic_op);
/**
* This operation blits pixles from a source buffer with the source alpha value
* specified to a destination buffer.
* This operation blits pixles 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 blit with alpha.
* 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);
DrmSurfaceBuffer* dst_buf, const GAL_Rect* dst_rc,
uint8_t alpha);
/**
* This operation blits pixles 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 blit with color key.
* 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);
DrmSurfaceBuffer* dst_buf, const GAL_Rect* dst_rc,
uint32_t color_key);
/**
* This operation blits pixles from a source buffer with the source alpha value
* specified to a destination buffer, but skipping the pixel value specified.
* This operation blits pixles 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 blit with alpha and color key.
* 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 pixles 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;
/** Implement this stub to return the DRI driver operations */
DrmDriverOps* __drm_ex_driver_get (const char* driver_name, int device_fd);
/** The current version of DRM driver. */
#define DRM_DRIVER_VERSION 1
/**
* Implement this stub to return the DRI driver operations
*
* This function takes three arguments and returns NULL or
* a valid pointer of DrmDriverOps to MiniGUI.
*
* This function can return different DrmDriverOps to MiniGUI according to
* the driver name and device file descriptor. In this way, your DRM engine
* driver implementation can support multiple GPUs.
*
* If the external stub returns NULL, MiniGUI will try to use the dumb
* frame buffer instead.
*
* \param driver_name This argument gives the driver name determined
* by MiniGUI. Generally, it is the kernel driver name for your GPU.
* For example, for Intel i915/i965 GPUs, the driver name will be `i915`.
* \param device_fd This argument gives the file descriptor of the
* opened DRI device.
* \param version A pointer to an integer which will contain the
* versionc of the DRM engine driver.
*
* \return NULL or a valid pointer to DrmDriverOps.
*
* \note We use the version control since 4.0.7. It will be intialized
* to zero by MiniGUI before calling this function. Because an old
* driver for MiniGUI 4.0.6 or earlier will not change the value,
* MiniGUI will deny to load the old driver.
*
* The constant \a DRM_DRIVER_VERSION defines the current version code.
*/
DrmDriverOps* __drm_ex_driver_get (const char* driver_name, int device_fd,
int* version);
/** @} end of external_stubs_dri */
+65 -32
View File
@@ -5304,22 +5304,22 @@ typedef enum {
* The color logical operations.
*/
typedef enum {
COLOR_LOGIC_OP_COPY = 0,
COLOR_LOGIC_OP_COPY_INVERTED,
COLOR_LOGIC_OP_CLEAR,
COLOR_LOGIC_OP_SET,
COLOR_LOGIC_OP_NOR,
COLOR_LOGIC_OP_NAND,
COLOR_LOGIC_OP_EQUIV,
COLOR_LOGIC_OP_INVERT,
COLOR_LOGIC_OP_XOR,
COLOR_LOGIC_OP_AND,
COLOR_LOGIC_OP_AND_INVERTED,
COLOR_LOGIC_OP_AND_REVERSE,
COLOR_LOGIC_OP_OR,
COLOR_LOGIC_OP_OR_INVERTED,
COLOR_LOGIC_OP_OR_REVERSE,
COLOR_LOGIC_OP_NOOP,
COLOR_LOGICOP_CLEAR = 0,
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;
/**
@@ -14345,14 +14345,18 @@ MG_EXPORT int drmGetDeviceFD (GHANDLE video);
* THe struct type defines the DRM surface information.
*/
typedef struct _DrmSurfaceInfo {
/** The prime fd of the buffer object. */
int prime_fd;
/** The global name of the buffer object. */
uint32_t name;
/** The local handle of the buffer object. */
uint32_t handle;
/** The buffer identifier. */
uint32_t id;
/** The prime fd of the buffer object. If it was no exported as a global
buffer object, it has the value -1. */
int prime_fd;
/** The global name of the buffer object. It has the value 0 when it was
not expored as global buffer object. */
uint32_t name;
/** The frame buffer identifier. If the buffer was not added as
a frame buffer to the system, it has the value 0. */
uint32_t fb_id;
/** The width of the surface. */
uint32_t width;
/** The height of the surface. */
@@ -14362,7 +14366,9 @@ typedef struct _DrmSurfaceInfo {
/** The DRM pixel format. */
uint32_t drm_format;
/** Size in bytes of the buffer object. */
unsigned long size;
size_t size;
/** The offset from the buffer start to the real pixel data. */
off_t offset;
} DrmSurfaceInfo;
/**
@@ -14384,15 +14390,24 @@ MG_EXPORT BOOL drmGetSurfaceInfo (GHANDLE video, HDC hdc, DrmSurfaceInfo* info);
* \param video The video handle.
* \param name The name handle of the DRM surface.
* \param drm_format The DRM pixel format.
* \param offset The offset from the buffer start to the real pixel data.
* \param width The width of the DRM surface.
* \param height The height of the DRM surface.
* \param pitch The pitch (row stride) of the DRM surface.
*
* \return The handle to the memory DC for success, HDC_INVALID for failure.
*/
MG_EXPORT HDC drmCreateDCFromName (GHANDLE video,
uint32_t name, uint32_t drm_format,
unsigned int width, unsigned int height, uint32_t pitch);
MG_EXPORT HDC drmCreateDCFromNameEx (GHANDLE video,
uint32_t name, uint32_t drm_format, off_t offset,
uint32_t width, uint32_t height, uint32_t pitch);
static inline HDC drmCreateDCFromName (GHANDLE video,
uint32_t name, uint32_t drm_format,
uint32_t width, uint32_t height, uint32_t pitch)
{
return drmCreateDCFromNameEx (video,
name, drm_format, 0, width, height, pitch);
}
/**
* This function creates a memory DC with a DRM surface which is created by
@@ -14402,15 +14417,24 @@ MG_EXPORT HDC drmCreateDCFromName (GHANDLE video,
* \param prime_fd The PRIME file descriptor.
* \param size The size of the DRM surface in bytes.
* \param drm_format The DRM pixel format.
* \param offset The offset from the buffer start to the real pixel data.
* \param width The width of the DRM surface.
* \param height The height of the DRM surface.
* \param pitch The pitch (row stride) of the DRM surface.
*
* \return The handle to the memory DC for success, HDC_INVALID for failure.
*/
MG_EXPORT HDC drmCreateDCFromPrimeFd (GHANDLE video,
int prime_fd, unsigned long size, uint32_t drm_format,
unsigned int width, unsigned int height, uint32_t pitch);
MG_EXPORT HDC drmCreateDCFromPrimeFdEx (GHANDLE video,
int prime_fd, size_t size, uint32_t drm_format, off_t offset,
uint32_t width, uint32_t height, uint32_t pitch);
static inline HDC drmCreateDCFromPrimeFd (GHANDLE video,
int prime_fd, size_t size, uint32_t drm_format,
uint32_t width, uint32_t height, uint32_t pitch)
{
return drmCreateDCFromPrimeFdEx (video,
prime_fd, size, drm_format, 0, width, height, pitch);
}
/**
* This function creates a memory DC with a DRM surface which is created by
@@ -14420,15 +14444,24 @@ MG_EXPORT HDC drmCreateDCFromPrimeFd (GHANDLE video,
* \param handle The handle of the DRM surface.
* \param size The size of the DRM surface in bytes.
* \param drm_format The DRM pixel format.
* \param offset The offset from the buffer start to the real pixel data.
* \param width The width of the DRM surface.
* \param height The height of the DRM surface.
* \param pitch The pitch (row stride) of the DRM surface.
*
* \return The handle to the memory DC for success, HDC_INVALID for failure.
*/
MG_EXPORT HDC drmCreateDCFromHandle (GHANDLE video,
uint32_t handle, unsigned long size, uint32_t drm_format,
unsigned int width, unsigned int height, uint32_t pitch);
MG_EXPORT HDC drmCreateDCFromHandleEx (GHANDLE video,
uint32_t handle, size_t size, uint32_t drm_format, off_t offset,
uint32_t width, uint32_t height, uint32_t pitch);
static inline HDC drmCreateDCFromHandle (GHANDLE video,
uint32_t handle, size_t size, uint32_t drm_format,
uint32_t width, uint32_t height, uint32_t pitch)
{
return drmCreateDCFromHandleEx (video,
handle, size, drm_format, 0, width, height, pitch);
}
/** @} end of gdi_drm_fns */
+35 -6
View File
@@ -1574,23 +1574,44 @@ typedef struct _CompositorOps {
*/
void (*on_layer_op) (CompositorCtxt* ctxt, int layer_op,
MG_Layer* layer, MG_Client* client);
/**
* This operation will be called when the server intends to composite
* the whole screen for the particular layer.
* The compositor can reset the dirty region for the layer.
* If it returns FALSE, the compositor will not handle the layer.
*/
BOOL (*reset_dirty_region) (CompositorCtxt* ctxt, MG_Layer* layer);
/**
* This operation will be called when there are some dirty
* rectangles in the specific popup menu z-node.
* The compositor should merge the dirty rectangles to the
* dirty region maintained for the current layer.
*/
void (*on_dirty_ppp) (CompositorCtxt* ctxt, int zidx);
BOOL (*merge_dirty_ppp) (CompositorCtxt* ctxt, MG_Layer* layer, int zidx);
/**
* This operation will be called when there are some dirty rectangles
* in the specific window z-node on the specific layer.
* The compositor should merge the dirty rectangles to the
* dirty region maintained for the current layer.
*/
void (*on_dirty_win) (CompositorCtxt* ctxt, MG_Layer* layer, int zidx);
BOOL (*merge_dirty_win) (CompositorCtxt* ctxt, MG_Layer* layer, int zidx);
/**
* This operation will be called when there are some dirty rectangles
* in the wallpaper pattern.
* The compositor should merge the dirty rectangles of the wallpaper
* pattern to the dirty region maintained for the current layer.
*/
void (*on_dirty_wpp) (CompositorCtxt* ctxt);
BOOL (*merge_dirty_wpp) (CompositorCtxt* ctxt, MG_Layer* layer);
/**
* This operation will be called to composite the dirty region
* for the particular layer.
*/
BOOL (*refresh_dirty_region) (CompositorCtxt* ctxt, MG_Layer* layer);
/**
* This operation will be called when a z-node was out of action, e.g.,
@@ -1771,18 +1792,26 @@ MG_EXPORT BOOL GUIAPI ServerUnregisterCompositor (const char* name);
MG_EXPORT const CompositorOps* GUIAPI ServerSelectCompositor (
const char* name, CompositorCtxt** ctxt);
#define COMPSOR_OPS_VERSION 1
/**
* Implement this stub to return the compositor operations
* for a specific compositor name if you implement the compositor
* in a shared library.
*
* \param name The name of the compositor desired.
* \param fallback The fallback operations for this compositor.
* \param fallback_ops The fallback operations.
* \param version The version code for the operations of the compositor.
*
* \note The compositor should return the version code it follows through
* \a version argument. If the version code is not matched, MiniGUI
* will refuse to load the compositor. The current version code
* is defined by \a COMPSOR_OPS_VERSION.
*
* \return The compositor operations for specific name, NULL for error.
*/
const CompositorOps* __ex_compositor_get (const char* name,
const CompositorOps* fallback);
const CompositorOps* fallback_ops, int* version);
#endif /* defined _MGSCHEMA_COMPOSITING */
@@ -1822,7 +1851,7 @@ const CompositorOps* __ex_compositor_get (const char* name,
*
* \sa RegisterRequestHandler
*/
#define MAX_SYS_REQID 0x0022
#define MAX_SYS_REQID 0x0023
/**
* \def MAX_REQID
+1 -1
View File
@@ -192,7 +192,7 @@ int GUIAPI ClientRequestEx2 (const REQUEST* request,
&& (__mg_client_id == 0 && request->id != REQID_JOINLAYER)) {
#elif defined(_MGSCHEMA_COMPOSITING)
if (__mg_client_id == 0 && request->id != REQID_JOINLAYER &&
request->id != REQID_GETWPSURFACE) {
request->id != REQID_GETSHAREDSURFACE) {
#else
if (__mg_client_id == 0 && request->id != REQID_JOINLAYER) {
#endif
+5 -4
View File
@@ -2203,14 +2203,15 @@ static int create_memdc_for_menu (TRACKMENUINFO* ptmi)
static void delete_memdc_for_menu (TRACKMENUINFO* ptmi)
{
if (ptmi->dc != HDC_INVALID) {
GAL_Surface *surf = GetSurfaceFromDC (ptmi->dc);
DeleteMemDC (ptmi->dc);
ptmi->dc = HDC_INVALID;
#if 0 /* deprecated code: we always do refcount++ for any memdc */
/* we must free the surface here, or it can not be freed actually
due to the referenced count. */
GAL_Surface *surf = GetSurfaceFromDC (ptmi->dc);
GAL_FreeSurface (surf);
#endif /* deprecated code */
DeleteMemDC (ptmi->dc);
ptmi->dc = HDC_INVALID;
}
}
+1 -1
View File
@@ -4261,7 +4261,7 @@ HWND GUIAPI CreateMainWindowEx2 (PMAINWINCREATE pCreateInfo, LINT id,
{pCreateInfo->lx, pCreateInfo->ty,
pCreateInfo->rx, pCreateInfo->by} };
// we ignore the retval. may fail for client of procs runmode
// we ignore the retval. may fail for client under procs runmode
SendMessage (HWND_DESKTOP, MSG_CALC_POSITION, 0, (LPARAM)&info);
pCreateInfo->lx = info.rc.left;
+27 -18
View File
@@ -64,6 +64,9 @@ extern "C" {
#define SHOW_HIDE_TYPE 5
#define XVFB_CLOSE_TYPE 6
/* Since 5.0.0: command */
#define CMD_TYPE 7
struct PCXVFbKeyData
{
unsigned int unicode;
@@ -74,36 +77,35 @@ struct PCXVFbKeyData
typedef struct _XVFBKEYDATA
{
unsigned short key_code;
unsigned short key_state;
unsigned short key_code;
unsigned short key_state;
} XVFBKEYDATA;
typedef struct _XVFBMOUSEDATA
{
unsigned short x;
unsigned short y;
unsigned int button;
unsigned short x;
unsigned short y;
unsigned int button;
} XVFBMOUSEDATA;
typedef struct _XVFBEVENTDATA
{
int event_type;
union
{
XVFBKEYDATA key;
XVFBMOUSEDATA mouse;
} data;
int event_type;
union {
XVFBKEYDATA key;
XVFBMOUSEDATA mouse;
} data;
} XVFBEVENT;
typedef struct _XVFBCaptionEventData{
int event_type;
int size;
char buff[0];
int event_type;
int size;
char buff[0];
}XVFBCaptionEventData;
typedef struct _XVFBIMEEventData{
int event_type;
int ime_open;
int event_type;
int ime_open;
}XVFBIMEEventData;
typedef struct _XVFBIMEMSGEventData{
@@ -117,6 +119,13 @@ typedef struct _XVFBShowHideEventData{
int show; /* 0 to hide, 1 to show */
}XVFBShowHideEventData;
/* Since 5.0.0: command */
#define XVFB_CMD_QUIT 0
typedef struct _XVFBCmdEventData {
int event_type;
int cmd;
} XVFBCmdEventData;
extern int __mg_pcxvfb_server_sockfd;
extern int __mg_pcxvfb_client_sockfd;
@@ -124,8 +133,8 @@ BOOL ial_InitPCXVFBInput (INPUT* input, const char* mdev, const char* mtype);
void TermPCXVFBInput (void);
MG_EXPORT void GUIAPI VFBOpenIME(int bOpen);
MG_EXPORT void GUIAPI VFBSetIMETextCallback(void (*setIMEText)(void *, const char* text),
void *user_data);
MG_EXPORT void GUIAPI VFBSetIMETextCallback(void (*setIMEText)(void *,
const char* text), void *user_data);
MG_EXPORT void GUIAPI VFBSetCaption(const char* caption);
MG_EXPORT void GUIAPI VFBShowWindow(int show);
+17 -11
View File
@@ -689,21 +689,19 @@ BOOL ial_InitPCXVFBInput (INPUT* input, const char* mdev, const char* mtype)
{
char path[PATH_MAX], *template;
template = getenv("MG_ENV_RECORD_IAL");
if (template)
{
if (template) {
#if 0
snprintf(path, sizeof(path), "%s%ld", template, time(NULL));
snprintf(path, sizeof(path), "%s%ld", template, time(NULL));
#else
snprintf(path, sizeof(path), "%s", template);
snprintf(path, sizeof(path), "%s", template);
#endif
path[sizeof(path)/sizeof(path[0])-1] = 0;
path[sizeof(path)/sizeof(path[0])-1] = 0;
open_rec (path);
record_time_start = getcurtime();
}
open_rec (path);
record_time_start = getcurtime();
}
}
return TRUE;
}
@@ -725,6 +723,14 @@ void TermPCXVFBInput (void)
socket_file[49] = '\0';
if (__mg_pcxvfb_client_sockfd >= 0) {
/* Since 5.0.0: send a quit command to XVFB */
XVFBCmdEventData cmd = { CMD_TYPE, XVFB_CMD_QUIT };
if (mg_writesocket (__mg_pcxvfb_client_sockfd, &cmd, sizeof (cmd)) <
sizeof (cmd)) {
// do nothing
}
close(__mg_pcxvfb_client_sockfd);
__mg_pcxvfb_client_sockfd = -1;
}
@@ -733,7 +739,7 @@ void TermPCXVFBInput (void)
__mg_pcxvfb_server_sockfd = -1;
}
unlink(socket_file);
#if defined(_MGRM_PROCESSES) && !defined(_MGRM_STANDALONE)
#if defined(_MGRM_PROCESSES)
if (mgIsServer) {
remove("/tmp/.pcxvfb_tmp");
}
@@ -741,4 +747,4 @@ void TermPCXVFBInput (void)
#endif /* WIN32 */
}
#endif /* _MGGAL_PCXVFB*/
#endif /* _MGGAL_PCXVFB */
+19 -5
View File
@@ -101,8 +101,14 @@
#define REQID_COPYCURSOR 0x001B
/* Since 5.0.0 */
// Get global wallpaper pattern surface
#define REQID_GETWPSURFACE 0x001C
// Get shared surface
#define REQID_GETSHAREDSURFACE 0x001C
// for compositing schema
#define SYSSF_WALLPAPER_PATTER "syssf-wallpaper-pattern"
// for sharedfb schema
#define SYSSF_REAL_SCREEN "syssf-real-screen"
#define SYSSF_SHADOW_SCREEN "syssf-shadow-screen"
// Load cursor from PNG file
#define REQID_LOADCURSOR_PNG 0x001D
// Load cursor from in-memory PNG
@@ -117,7 +123,10 @@
// Calculate the position a main window with WS_EX_AUTOPOSITION
#define REQID_CALCPOSITION 0x0022
#define REQID_SYS_LAST REQID_CALCPOSITION
// Authenticate client
#define REQID_AUTHCLIENT 0x0023
#define REQID_SYS_LAST REQID_AUTHCLIENT
/*
* XXX: To fellows who need to add a new REQID,
@@ -135,8 +144,13 @@ MGUI_COMPILE_TIME_ASSERT(sys_request_id, MAX_SYS_REQID >= REQID_SYS_LAST);
/* Since 5.0.0 */
typedef struct _SharedSurfInfo {
Uint32 flags;
size_t map_size;
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 {
+4 -4
View File
@@ -62,9 +62,9 @@
#endif
#if defined(_MGRM_PROCESSES) && defined(_MGSCHEMA_SHAREDFB)
# define IS_SHAREDFB_SCHEMA 1
# define IS_SHAREDFB_SCHEMA_PROCS 1
#else
# define IS_SHAREDFB_SCHEMA 0
# define IS_SHAREDFB_SCHEMA_PROCS 0
#endif
/* the maximal number of the dirty rects */
@@ -167,13 +167,13 @@ enum {
#endif
/* constants for engine name and video mode */
#define LEN_SO_NAME 127 // name length of a shared object (library)
#define LEN_DEVICE_NAME 127
#define LEN_EXDRIVER_NAME 127
#define LEN_EXDRIVER_NAME LEN_SO_NAME
#define LEN_ENGINE_NAME 23
#define LEN_VIDEO_MODE 31
#define LEN_MTYPE_NAME 23
#define LEN_FOURCC_FORMAT 7
#define LEN_SO_NAME 255 // name length of a shared object (library)
/* misc constants and utilities */
+1 -1
View File
@@ -162,7 +162,7 @@ dump_message (const MSG* msg, const char* name)
name, msg->message, Message2Str (msg->message),
msg->hwnd, (PVOID)msg->wParam, (PVOID)msg->lParam);
#else
_MG_PRINTF ("Message(%s): %u, Wnd: %p, wP: %p, lP: %p.\n",
_MG_PRINTF ("Message(%s) for %s: %u, Wnd: %p, wP: %p, lP: %p.\n",
#ifdef _MGHAVE_VIRTUAL_WINDOW
msg->pSyncMsg?"SYNC":"NORM",
#else
+53 -19
View File
@@ -64,6 +64,10 @@
#include <semaphore.h>
#endif
#if IS_SHAREDFB_SCHEMA_PROCS
#include <semaphore.h>
#endif
#define DISABLE_THREADS
#define GAL_mutex int
@@ -131,15 +135,10 @@ typedef struct _DirtyInfo {
* than the creator.
*/
typedef struct _SharedSurfaceHeader {
#if 0
/* The semaphore for this shared surface */
sem_t sem_lock;
#else
/* The number of semphore for this surface.
The SysV semaphore set id for synchronizing this shared surface:
SHAREDRES_SEMID_SHARED_SURF. */
int sem_num;
#endif
/* The pid of the creator */
pid_t creator;
@@ -159,27 +158,35 @@ typedef struct _SharedSurfaceHeader {
/* the RGBA masks */
Uint32 Rmask, Gmask, Bmask, Amask;
/* the size of the buffer */
size_t buf_size;
/* the pixels */
char buf[0];
/* the size of the whole buffer */
size_t map_size;
/* the offset of pixels data */
off_t pixels_off;
} GAL_SharedSurfaceHeader;
#endif /* IS_COMPOSITING_SCHEMA */
/* The header for shadow screen; used to store the dirty rectangle. */
typedef struct _ShadowSurfaceHeader {
/* The dirty rectangle */
RECT dirty_rc;
} GAL_ShadowSurfaceHeader;
/*
* This structure should be treated as read-only, except for 'pixels',
* which, if not NULL, contains the raw pixel data for the surface.
*/
typedef struct GAL_Surface {
Uint32 flags; /* Read-only */
GAL_PixelFormat *format; /* Read-only */
void *video; /* Read-only */
int w, h; /* Read-only */
void *video; /* Read-only */
GAL_PixelFormat *format; /* Read-only */
Uint32 flags; /* Read-only */
Uint32 pixels_off; /* Read-only; since 5.0.0, replace old offset */
int w, h; /* Read-only */
/* VW[2018-01-18]: For 64b, use signed int instead of Uint32 for pitch. */
int pitch; /* Read-only */
int dpi; /* Read-only */
void *pixels; /* Read-write */
int offset; /* Private */
int pitch; /* Read-only */
int dpi; /* Read-only */
void *pixels; /* Read-write */
/* Hardware-specific surface info */
struct private_hwdata *hwdata;
@@ -231,8 +238,7 @@ typedef struct GAL_Surface {
/* Evaluates to true if the surface needs to be locked before access */
#define GAL_MUSTLOCK(surface) \
(surface->offset || \
((surface->flags & (GAL_HWSURFACE|GAL_ASYNCBLIT|GAL_RLEACCEL)) != 0))
((surface->flags & (GAL_HWSURFACE|GAL_ASYNCBLIT|GAL_RLEACCEL)) != 0)
/* Useful for determining the video hardware capabilities */
typedef struct {
@@ -958,6 +964,34 @@ BYTE* gal_PutPixelKeyAlpha (GAL_Surface* dst,
#define mg_TerminateGAL GAL_VideoQuit
#ifdef _MGRM_PROCESSES
/* Since 5.0.0: copy video information to the shared resource */
BOOL GAL_CopyVideoInfoToSharedRes (void);
/* Since 5.0.0: create/attach a surface in/to named shared memory */
GAL_Surface * GAL_CreateRGBSurfaceInShm (const char* shm_name, BOOL create,
Uint32 rw_modes, Uint32 hdr_size, int width, int height, int depth,
Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
#endif /* _MGRM_PROCESSES */
#ifdef _MGGAL_DRM
/* functions implemented in DRM engine. */
BOOL __drm_get_surface_info (GAL_Surface *surface, DrmSurfaceInfo* info);
GAL_Surface* __drm_create_surface_from_name (GHANDLE video,
uint32_t name, uint32_t drm_format, uint32_t pixels_off,
uint32_t width, uint32_t height, uint32_t pitch);
GAL_Surface* __drm_create_surface_from_handle (GHANDLE video,
uint32_t handle, size_t size, uint32_t drm_format, uint32_t pixels_off,
uint32_t width, uint32_t height, uint32_t pitch);
GAL_Surface* __drm_create_surface_from_prime_fd (GHANDLE video,
int prime_fd, size_t size, uint32_t drm_format, uint32_t pixels_off,
uint32_t width, uint32_t height, uint32_t pitch);
#endif /* defined _MGGAL_DRM */
#ifdef __cplusplus
}
#endif /* __cplusplus */
+12 -5
View File
@@ -102,10 +102,13 @@ typedef struct tagG_RES {
char video_engine [LEN_ENGINE_NAME + 1];
char video_mode [LEN_VIDEO_MODE + 1];
char video_device [LEN_DEVICE_NAME + 1];
char video_exdriver [LEN_EXDRIVER_NAME + 1];
char video_fourcc [LEN_FOURCC_FORMAT + 1];
int video_dpi, video_hres, video_vres, video_depth;
Uint32 video_rmask, video_gmask, video_bmask, video_amask;
#ifdef _MGGAL_DRM
char video_exdriver [LEN_EXDRIVER_NAME + 1];
Uint32 video_drm_format;
Uint32 video_dbl_buff:1;
#endif
int nr_layers;
int semid_layer;
@@ -168,8 +171,6 @@ typedef G_RES* PG_RES;
#define SHAREDRES_VIDEO_ENGINE (((PG_RES)mgSharedRes)->video_engine)
#define SHAREDRES_VIDEO_MODE (((PG_RES)mgSharedRes)->video_mode)
#define SHAREDRES_VIDEO_DEVICE (((PG_RES)mgSharedRes)->video_device)
#define SHAREDRES_VIDEO_FOURCC (((PG_RES)mgSharedRes)->video_fourcc)
#define SHAREDRES_VIDEO_EXDRIVER (((PG_RES)mgSharedRes)->video_exdriver)
#define SHAREDRES_VIDEO_DPI (((PG_RES)mgSharedRes)->video_dpi)
#define SHAREDRES_VIDEO_HRES (((PG_RES)mgSharedRes)->video_hres)
#define SHAREDRES_VIDEO_VRES (((PG_RES)mgSharedRes)->video_vres)
@@ -179,6 +180,12 @@ typedef G_RES* PG_RES;
#define SHAREDRES_VIDEO_BMASK (((PG_RES)mgSharedRes)->video_bmask)
#define SHAREDRES_VIDEO_AMASK (((PG_RES)mgSharedRes)->video_amask)
#ifdef _MGGAL_DRM
#define SHAREDRES_VIDEO_EXDRIVER (((PG_RES)mgSharedRes)->video_exdriver)
#define SHAREDRES_VIDEO_DRM_FORMAT (((PG_RES)mgSharedRes)->video_drm_format)
#define SHAREDRES_VIDEO_DBL_BUFF (((PG_RES)mgSharedRes)->video_dbl_buff)
#endif
#define SHAREDRES_TIMER_COUNTER (((PG_RES)mgSharedRes)->timer_counter)
#define SHAREDRES_TICK_ON_LOCKSEM (((PG_RES)mgSharedRes)->tick_on_locksem)
#define SHAREDRES_TIMEOUT (((PG_RES)mgSharedRes)->timeout)
@@ -205,7 +212,7 @@ typedef G_RES* PG_RES;
# define SHAREDRES_SEMID_SHARED_SURF (((PG_RES)mgSharedRes)->semid_shared_surf)
#endif
#define SHAREDRES_NR_GLOBALS (((PG_RES)mgSharedRes)->nr_globals)
#define SHAREDRES_NR_GLOBALS (((PG_RES)mgSharedRes)->nr_globals)
#define SHAREDRES_DEF_NR_TOPMOSTS (((PG_RES)mgSharedRes)->def_nr_topmosts)
#define SHAREDRES_DEF_NR_NORMALS (((PG_RES)mgSharedRes)->dev_nr_normals)
+108 -97
View File
@@ -67,12 +67,17 @@
#define SIZE_CLIPRC_HEAP 64
#define DIRTY_ZT_PPP 0x01
#define DIRTY_ZT_WIN 0x02
#define DIRTY_ZT_WPP 0x04
struct _CompositorCtxt {
RECT rc_screen; // screen rect - avoid duplicated GetScreenRect calls
BLOCKHEAP cliprc_heap;// heap for clipping rects
CLIPRGN wins_rgn; // visible region for all windows (subtract popup menus)
CLIPRGN dirty_rgn; // the dirty region
CLIPRGN inv_rgn; // the invalid region for a specific znode
//Uint32 dirty_types;// the dirty znode types.
};
static CompositorCtxt* initialize (const char* name)
@@ -256,30 +261,6 @@ static inline void tile_dirty_region_for_wallpaper (CompositorCtxt* ctxt)
}
}
static BOOL generate_dirty_region (CompositorCtxt* ctxt,
const ZNODEHEADER* znode_hdr, const CLIPRGN* znode_rgn)
{
EmptyClipRgn (&ctxt->dirty_rgn);
if (znode_hdr && znode_hdr->dirty_rcs) {
int i;
for (i = 0; i < znode_hdr->nr_dirty_rcs; i++) {
RECT rc;
// device coordinates to screen coordinates
rc = znode_hdr->dirty_rcs [i];
OffsetRect (&rc, znode_hdr->rc.left, znode_hdr->rc.top);
AddClipRect (&ctxt->dirty_rgn, &rc);
}
if (znode_rgn)
IntersectRegion (&ctxt->dirty_rgn, &ctxt->dirty_rgn, znode_rgn);
else
IntersectClipRect (&ctxt->dirty_rgn, &ctxt->rc_screen);
}
return !IsEmptyClipRgn (&ctxt->dirty_rgn);
}
static void composite_wallpaper_rect (CompositorCtxt* ctxt,
const RECT* dirty_rc)
{
@@ -300,6 +281,8 @@ static void composite_wallpaper_rect (CompositorCtxt* ctxt,
RECT eff_rc;
if (IntersectRect (&eff_rc, dirty_rc, &rc)) {
SelectClipRect (HDC_SCREEN_SYS, &eff_rc);
SetMemDCColorKey (HDC_SCREEN, 0, 0);
SetMemDCAlpha (HDC_SCREEN, 0, 0);
BitBlt (HDC_SCREEN, 0, 0, RECTW (rc), RECTH (rc),
HDC_SCREEN_SYS, rc.left, rc.top, 0);
}
@@ -423,6 +406,7 @@ static void composite_all_lucent_win_znodes_above (CompositorCtxt* ctxt,
switch (znode_hdr->ct & CT_SYSTEM_MASK) {
case CT_COLORKEY:
SetMemDCAlpha (znode_hdr->mem_dc, 0, 0);
SetMemDCColorKey (znode_hdr->mem_dc,
MEMDC_FLAG_SRCCOLORKEY,
DWORD2Pixel (znode_hdr->mem_dc, znode_hdr->ct_arg));
@@ -439,6 +423,7 @@ static void composite_all_lucent_win_znodes_above (CompositorCtxt* ctxt,
break;
case CT_ALPHAPIXEL:
SetMemDCColorKey (znode_hdr->mem_dc, 0, 0);
SetMemDCAlpha (znode_hdr->mem_dc,
MEMDC_FLAG_SRCPIXELALPHA, 0);
break;
@@ -526,63 +511,6 @@ static void composite_on_dirty_region (CompositorCtxt* ctxt, int from)
SyncUpdateDC (HDC_SCREEN_SYS);
}
static void on_dirty_win (CompositorCtxt* ctxt, MG_Layer* layer, int zidx)
{
const ZNODEHEADER* znode_hdr = NULL;
CLIPRGN *rgn;
/* the fallback compositor only manages znodes on the topmost layer. */
if (layer != mgTopmostLayer || zidx <= 0)
return;
_DBG_PRINTF("called: %d\n", zidx);
/* generate the dirty region */
znode_hdr = ServerGetWinZNodeHeader (NULL, zidx, (void**)&rgn, TRUE);
assert (znode_hdr);
if (generate_dirty_region (ctxt, znode_hdr, rgn)) {
if (znode_hdr->changes == 0) {
/* It's the first exposure of the window. */
_MG_PRINTF ("It is the first exposure of the window (%d): %u\n",
zidx, znode_hdr->dirty_age);
}
if (IsEmptyClipRgn (&ctxt->dirty_rgn)) {
goto ret;
}
composite_on_dirty_region (ctxt, zidx);
}
ret:
ServerReleaseWinZNodeHeader (NULL, zidx);
}
static void on_dirty_wpp (CompositorCtxt* ctxt)
{
const ZNODEHEADER* znode_hdr;
//_DBG_PRINTF ("called\n");
znode_hdr = ServerGetWinZNodeHeader (NULL, 0, NULL, TRUE);
assert (znode_hdr);
if (generate_dirty_region (ctxt, znode_hdr, NULL)) {
tile_dirty_region_for_wallpaper (ctxt);
subtract_opaque_win_znodes_above (ctxt, 0);
//subtract_opaque_ppp_znodes (ctxt);
if (IsEmptyClipRgn (&ctxt->dirty_rgn)) {
goto ret;
}
composite_on_dirty_region (ctxt, 0);
}
ret:
ServerReleaseWinZNodeHeader (NULL, 0);
}
static void rebuild_wins_region (CompositorCtxt* ctxt)
{
int i, nr_ppps;
@@ -679,29 +607,110 @@ static void on_showing_ppp (CompositorCtxt* ctxt, int zidx)
SubtractRegion (&ctxt->wins_rgn, &ctxt->wins_rgn, rgn);
}
static void on_dirty_ppp (CompositorCtxt* ctxt, int zidx)
static BOOL reset_dirty_region (CompositorCtxt* ctxt, MG_Layer* layer)
{
if (layer != mgTopmostLayer)
return FALSE;
//ctxt->dirty_types = 0;
EmptyClipRgn (&ctxt->dirty_rgn);
return TRUE;
}
static BOOL generate_dirty_region (CompositorCtxt* ctxt,
const ZNODEHEADER* znode_hdr, const CLIPRGN* znode_rgn)
{
if (znode_hdr && znode_hdr->dirty_rcs) {
int i;
for (i = 0; i < znode_hdr->nr_dirty_rcs; i++) {
RECT rc;
// device coordinates to screen coordinates
rc = znode_hdr->dirty_rcs [i];
OffsetRect (&rc, znode_hdr->rc.left, znode_hdr->rc.top);
AddClipRect (&ctxt->dirty_rgn, &rc);
}
if (znode_rgn)
IntersectRegion (&ctxt->dirty_rgn, &ctxt->dirty_rgn, znode_rgn);
else
IntersectClipRect (&ctxt->dirty_rgn, &ctxt->rc_screen);
}
return !IsEmptyClipRgn (&ctxt->dirty_rgn);
}
static BOOL merge_dirty_ppp (CompositorCtxt* ctxt, MG_Layer* layer, int zidx)
{
BOOL rc = FALSE;
const ZNODEHEADER* znode_hdr;
CLIPRGN* rgn;
_DBG_PRINTF ("called\n");
_DBG_PRINTF("called: %d\n", zidx);
/* the fallback compositor only manages znodes on the topmost layer. */
if (layer != mgTopmostLayer || zidx <= 0)
return rc;
znode_hdr = ServerGetPopupMenuZNodeHeader (zidx, (void**)&rgn, TRUE);
assert (znode_hdr);
assert (rgn);
if (generate_dirty_region (ctxt, znode_hdr, rgn)) {
SelectClipRegion (HDC_SCREEN_SYS, &ctxt->dirty_rgn);
BitBlt (znode_hdr->mem_dc, 0, 0,
RECTW (znode_hdr->rc), RECTH (znode_hdr->rc),
HDC_SCREEN_SYS, znode_hdr->rc.left, znode_hdr->rc.top, 0);
//ctxt->dirty_types |= DIRTY_ZT_PPP;
rc = TRUE;
}
ServerReleasePopupMenuZNodeHeader (zidx);
return rc;
}
SelectClipRect (HDC_SCREEN_SYS, &ctxt->rc_screen);
EmptyClipRgn (&ctxt->dirty_rgn);
static BOOL merge_dirty_win (CompositorCtxt* ctxt, MG_Layer* layer, int zidx)
{
BOOL rc = FALSE;
const ZNODEHEADER* znode_hdr = NULL;
CLIPRGN *rgn;
/* the fallback compositor only manages znodes on the topmost layer. */
if (layer != mgTopmostLayer || zidx <= 0)
return rc;
_DBG_PRINTF("called: %d\n", zidx);
/* merge the dirty region */
znode_hdr = ServerGetWinZNodeHeader (NULL, zidx, (void**)&rgn, TRUE);
if (generate_dirty_region (ctxt, znode_hdr, rgn)) {
//ctxt->dirty_types |= DIRTY_ZT_WIN;
rc = TRUE;
}
ServerReleaseWinZNodeHeader (NULL, zidx);
return rc;
}
static BOOL merge_dirty_wpp (CompositorCtxt* ctxt, MG_Layer* layer)
{
BOOL rc = FALSE;
const ZNODEHEADER* znode_hdr;
znode_hdr = ServerGetWinZNodeHeader (NULL, 0, NULL, TRUE);
if (generate_dirty_region (ctxt, znode_hdr, NULL)) {
tile_dirty_region_for_wallpaper (ctxt);
//subtract_opaque_win_znodes_above (ctxt, 0);
//ctxt->dirty_types |= DIRTY_ZT_WPP;
rc = TRUE;
}
ServerReleasePopupMenuZNodeHeader (zidx);
ServerReleaseWinZNodeHeader (NULL, 0);
return rc;
}
SyncUpdateDC (HDC_SCREEN_SYS);
BOOL refresh_dirty_region (CompositorCtxt* ctxt, MG_Layer* layer)
{
/* the fallback compositor only manages znodes on the topmost layer. */
if (layer != mgTopmostLayer || IsEmptyClipRgn (&ctxt->dirty_rgn))
return FALSE;
composite_ppp_znodes (ctxt);
composite_on_dirty_region (ctxt, 0);
EmptyClipRgn (&ctxt->dirty_rgn);
return TRUE;
}
static void on_hiding_ppp (CompositorCtxt* ctxt, int zidx)
@@ -903,9 +912,11 @@ CompositorOps __mg_fallback_compositor = {
calc_mainwin_pos: calc_mainwin_pos,
purge_ppp_data: purge_ppp_data,
purge_win_data: purge_win_data,
on_dirty_ppp: on_dirty_ppp,
on_dirty_win: on_dirty_win,
on_dirty_wpp: on_dirty_wpp,
reset_dirty_region: reset_dirty_region,
merge_dirty_ppp: merge_dirty_ppp,
merge_dirty_win: merge_dirty_win,
merge_dirty_wpp: merge_dirty_wpp,
refresh_dirty_region: refresh_dirty_region,
on_dirty_screen: on_dirty_screen,
on_showing_ppp: on_showing_ppp,
on_hiding_ppp: on_hiding_ppp,
+128 -2
View File
@@ -88,8 +88,11 @@ static const CompositorOps* load_default_compositor (void)
{
const char* filename = NULL;
char buff [LEN_SO_NAME + 1];
const CompositorOps* (*ex_compsor_get) (const char*, const CompositorOps*);
const CompositorOps* (*ex_compsor_get) (const char*,
const CompositorOps*, int*);
char* error;
const CompositorOps* ops;
int version = 0;
filename = getenv ("MG_DEF_COMPOSITOR_SO");
if (filename == NULL) {
@@ -117,7 +120,13 @@ static const CompositorOps* load_default_compositor (void)
return NULL;
}
return ex_compsor_get (COMPSOR_NAME_DEFAULT, &__mg_fallback_compositor);
ops = ex_compsor_get (COMPSOR_NAME_DEFAULT,
&__mg_fallback_compositor, &version);
if (ops == NULL || version != COMPSOR_OPS_VERSION)
return NULL;
return ops;
}
static void lock_znode_surface (PDC pdc, ZORDERNODE* node)
@@ -151,6 +160,7 @@ static void unlock_znode_surface (PDC pdc, ZORDERNODE* node)
}
}
#if 0 /* not optimized */
void __mg_composite_dirty_znodes (void)
{
MG_Layer* layer;
@@ -245,6 +255,122 @@ void __mg_composite_dirty_znodes (void)
}
}
#else /* not optimized */
static void composite_layer (MG_Layer* layer, CompositorCtxt* ctxt,
const CompositorOps* ops)
{
ZORDERINFO* zi;
ZORDERNODE* nodes;
int i, next;
unsigned int changes_in_dc;
PDC pdc;
zi = (ZORDERINFO*)layer->zorder_info;
if (!ops->reset_dirty_region (ctxt, layer))
return;
/* travel menu znodes on the layer */
if (zi->nr_popupmenus > 0) {
nodes = GET_MENUNODE(zi);
for (i = 0; i < zi->nr_popupmenus; i++) {
pdc = dc_HDC2PDC (nodes[i].mem_dc);
assert (pdc->surface->dirty_info);
lock_znode_surface (pdc, nodes + i);
changes_in_dc = pdc->surface->dirty_info->dirty_age;
if (changes_in_dc != nodes[i].changes) {
ops->merge_dirty_ppp (ctxt, layer, i);
}
}
}
/* travel win znodes on the layer */
nodes = GET_ZORDERNODE(zi);
next = 0;
while ((next = __kernel_get_next_znode (zi, next)) > 0) {
if (nodes [next].flags & ZOF_VISIBLE) {
pdc = dc_HDC2PDC (nodes[next].mem_dc);
assert (pdc->surface->dirty_info);
lock_znode_surface (pdc, nodes + next);
changes_in_dc = pdc->surface->dirty_info->dirty_age;
if (changes_in_dc != nodes[next].changes) {
ops->merge_dirty_win (ctxt, layer, next);
}
}
}
/* check wallpaper pattern */
pdc = dc_HDC2PDC (HDC_SCREEN);
if (pdc->surface->w > 0 && pdc->surface->h > 0) {
assert (pdc->surface->dirty_info);
lock_znode_surface (pdc, nodes);
changes_in_dc = pdc->surface->dirty_info->dirty_age;
if (changes_in_dc != nodes[0].changes) {
ops->merge_dirty_wpp (ctxt, layer);
}
}
ops->refresh_dirty_region (ctxt, layer);
/* unlock the znode surfaces for popup menus */
if (zi->nr_popupmenus > 0) {
nodes = GET_MENUNODE(zi);
for (i = 0; i < zi->nr_popupmenus; i++) {
pdc = dc_HDC2PDC (nodes[i].mem_dc);
nodes[i].changes = pdc->surface->dirty_info->dirty_age;
pdc->surface->dirty_info->nr_dirty_rcs = 0;
unlock_znode_surface (pdc, nodes + i);
}
}
/* unlock the znode surfaces for windows */
nodes = GET_ZORDERNODE(zi);
next = 0;
while ((next = __kernel_get_next_znode (zi, next)) > 0) {
if (nodes [next].flags & ZOF_VISIBLE) {
pdc = dc_HDC2PDC (nodes[next].mem_dc);
nodes[next].changes = pdc->surface->dirty_info->dirty_age;
pdc->surface->dirty_info->nr_dirty_rcs = 0;
unlock_znode_surface (pdc, nodes + next);
}
}
/* unlock the znode surfaces for wallpaper patter */
pdc = dc_HDC2PDC (HDC_SCREEN);
if (pdc->surface->w > 0 && pdc->surface->h > 0) {
nodes[0].changes = pdc->surface->dirty_info->dirty_age;
pdc->surface->dirty_info->nr_dirty_rcs = 0;
unlock_znode_surface (pdc, nodes);
}
}
void __mg_composite_dirty_znodes (void)
{
MG_Layer* layer;
CompositorCtxt* ctxt;
const CompositorOps* ops = ServerSelectCompositor (NULL, &ctxt);
assert (ops);
/* first handle the topmost layer */
composite_layer (mgTopmostLayer, ctxt, ops);
/* then handle other layers */
layer = mgLayers;
while (layer) {
if (layer != mgTopmostLayer) {
composite_layer (layer, ctxt, ops);
}
layer = layer->next;
}
}
#endif /* optimized */
static void purge_znodes_private_data_in_layer (const CompositorOps* ops,
CompositorCtxt* ctxt, MG_Layer* layer)
{
+1 -1
View File
@@ -152,7 +152,7 @@ static HCURSOR load_cursor_from_mem (const void* area)
const Uint8* p = (Uint8*)area;
WORD16 wTemp;
int w, h, xhot, yhot, colornum;
int w = 0, h = 0, xhot = 0, yhot = 0, colornum = 0;
#if 0
DWORD32 size;
#endif
+37 -46
View File
@@ -80,7 +80,6 @@
#include "drawsemop.h"
#include "readbmp.h"
static int oldx = -1, oldy;
static RECT cliprc = {0, 0, 0, 0};
#ifdef _MGHAVE_CURSOR
@@ -903,6 +902,7 @@ HCURSOR GUIAPI GetDefaultCursor (void)
/* The return value indicates whether mouse has moved. */
/* TRUE for moved. */
/* NOTE that only server can call this function. */
/* Since 5.0.0, this function only changes the cursor position */
BOOL kernel_RefreshCursor (int* x, int* y, int* button)
{
int curx, cury;
@@ -912,51 +912,14 @@ BOOL kernel_RefreshCursor (int* x, int* y, int* button)
return FALSE;
IAL_GetMouseXY (x, y);
SHAREDRES_MOUSEX = curx = *x;
SHAREDRES_MOUSEY = cury = *y;
curx = *x;
cury = *y;
if (button)
SHAREDRES_BUTTON = *button = IAL_GetMouseButton ();
if (oldx != curx || oldy != cury) {
#ifdef _MGHAVE_CURSOR
#ifdef _MGSCHEMA_SHAREDFB
LOCK_CURSOR_SEM ();
CSR_CURSORX = curx;
CSR_CURSORY = cury;
if (CSR_SHOW_COUNT >= 0 && CSR_CURRENT) {
if (get_hidecursor_sem_val ()) {
reset_hidecursor_sem ();
}
else {
hidecursor ();
}
showcursor ();
GAL_SyncUpdate (__gal_screen);
}
// GAL_SyncUpdate (__gal_screen);
UNLOCK_CURSOR_SEM ();
#else /* _MGSCHEMA_SHAREDFB */
CSR_CURSORX = curx;
CSR_CURSORY = cury;
if (CSR_SHOW_COUNT >= 0 && CSR_CURRENT) {
if (csr_bmp.bmBits) {
hidecursor ();
showcursor ();
GAL_SyncUpdate (__gal_screen);
}
else {
PCURSOR pcsr = (PCURSOR)CSR_CURRENT;
GAL_MoveCursor (pcsr->surface, curx, cury);
}
}
#endif /* _MGSCHEMA_COMPOSITING */
#endif /* _MGHAVE_CURSOR */
oldx = curx;
oldy = cury;
if (SHAREDRES_MOUSEX != curx || SHAREDRES_MOUSEY != cury) {
SHAREDRES_MOUSEX = curx;
SHAREDRES_MOUSEY = cury;
moved = TRUE;
}
@@ -965,21 +928,49 @@ BOOL kernel_RefreshCursor (int* x, int* y, int* button)
#ifdef _MGHAVE_CURSOR
#ifdef _MGSCHEMA_SHAREDFB
/* show cursor hidden by client GDI function */
/* Change cursor position and show cursor hidden by client GDI function */
void kernel_ReShowCursor (void)
{
#ifdef _MGSCHEMA_SHAREDFB
LOCK_CURSOR_SEM ();
if (CSR_SHOW_COUNT >= 0 && CSR_CURRENT) {
if (get_hidecursor_sem_val ()) {
reset_hidecursor_sem ();
showcursor ();
GAL_SyncUpdate (__gal_screen);
}
else if (CSR_CURSORX != SHAREDRES_MOUSEX ||
CSR_CURSORY != SHAREDRES_MOUSEY) {
CSR_CURSORX = SHAREDRES_MOUSEX;
CSR_CURSORY = SHAREDRES_MOUSEY;
hidecursor ();
showcursor ();
GAL_SyncUpdate (__gal_screen);
}
}
UNLOCK_CURSOR_SEM ();
#else /* _MGSCHEMA_SHAREDFB */
if (CSR_SHOW_COUNT >= 0 && CSR_CURRENT &&
(CSR_CURSORX != SHAREDRES_MOUSEX ||
CSR_CURSORY != SHAREDRES_MOUSEY)) {
CSR_CURSORX = SHAREDRES_MOUSEX;
CSR_CURSORY = SHAREDRES_MOUSEY;
if (csr_bmp.bmBits) {
hidecursor ();
showcursor ();
GAL_SyncUpdate (__gal_screen);
}
else {
PCURSOR pcsr = (PCURSOR)CSR_CURRENT;
GAL_MoveCursor (pcsr->surface, CSR_CURSORX, CSR_CURSORY);
}
}
#endif /* _MGSCHEMA_COMPOSITING */
}
#endif /* defined _MGSCHEMA_SHAREDFB */
/* Always call with "setdef = FALSE" for clients at server side. */
HCURSOR GUIAPI SetCursorEx (HCURSOR hcsr, BOOL setdef)
+25 -24
View File
@@ -357,8 +357,7 @@ static intptr_t cliAllocZOrderNode (PMAINWIN pWin, const COMPOSITINGINFO* ct_inf
assert (pWin->surf && pWin->surf->shared_header);
info.surf_flags = pWin->surf->flags;
info.surf_size = pWin->surf->shared_header->buf_size;
info.surf_size += sizeof (*pWin->surf->shared_header);
info.surf_size = pWin->surf->shared_header->map_size;
if (ct_info) {
info.ct = ct_info->type;
@@ -474,8 +473,7 @@ static intptr_t cliMoveWindow (PMAINWIN pWin, const RECT* rcWin, int fd)
#ifdef _MGSCHEMA_COMPOSITING
info.surf_flags = pWin->surf->flags;
info.surf_size = pWin->surf->shared_header->buf_size;
info.surf_size += sizeof (*pWin->surf->shared_header);
info.surf_size = pWin->surf->shared_header->map_size;
#endif
if (ClientRequestEx2 (&req, NULL, 0, fd,
@@ -529,8 +527,7 @@ static intptr_t cliStartTrackPopupMenu (PTRACKMENUINFO ptmi)
assert (surf->shared_header);
info.surf_flags = surf->flags;
info.surf_size = surf->shared_header->buf_size;
info.surf_size += sizeof (*surf->shared_header);
info.surf_size = surf->shared_header->map_size;
if (ClientRequestEx2 (&req, NULL, 0, surf->shared_header->fd,
&ret, sizeof (intptr_t), NULL) < 0)
return -1;
@@ -818,6 +815,9 @@ static int srvAllocZOrderNode (int cli, HWND hwnd, HWND main_win,
if (cli == 0) {
PMAINWIN pwin = (PMAINWIN)hwnd;
surf = pwin->surf;
// prevent to free this surface when deleting memdc for znode.
surf->refcount++;
}
else if (fd >= 0) {
surf = GAL_AttachSharedRGBSurface (fd, surf_size, surf_flags, TRUE);
@@ -830,6 +830,7 @@ static int srvAllocZOrderNode (int cli, HWND hwnd, HWND main_win,
if (surf) {
memdc = CreateMemDCFromSurface (surf);
_WRN_PRINTF ("surface (%p) refcount: %d\n", surf, surf->refcount);
if (memdc == HDC_INVALID) {
if (cli > 0) {
GAL_FreeSurface (surf);
@@ -964,28 +965,31 @@ static int srvMoveWindow (int cli, int idx_znode, const RECT* rcWin,
if (cli == 0) {
PMAINWIN pwin = (PMAINWIN)hwnd;
surf = pwin->surf;
// prevent to free this surface when deleting memdc for znode.
surf->refcount++;
}
else {
surf = GAL_AttachSharedRGBSurface (fd, surf_size, surf_flags, TRUE);
close (fd);
}
}
if (surf) {
memdc = CreateMemDCFromSurface (surf);
if (memdc == HDC_INVALID) {
if (cli > 0) {
GAL_FreeSurface (surf);
if (surf) {
memdc = CreateMemDCFromSurface (surf);
if (memdc == HDC_INVALID) {
if (cli > 0) {
GAL_FreeSurface (surf);
}
_ERR_PRINTF("KERNEL: failed to create new memory dc for znode\n");
return -1;
}
_ERR_PRINTF("KERNEL: failed to create new memory dc for znode\n");
}
else {
_ERR_PRINTF("KERNEL: failed to attach to shared surface\n");
return -1;
}
}
else if (fd >= 0) {
_ERR_PRINTF("KERNEL: failed to attach to shared surface\n");
return -1;
}
#endif /* def _MGSCHEMA_COMPOSITING */
ret = dskMoveWindow (cli, idx_znode, memdc, rcWin);
@@ -3677,9 +3681,7 @@ static int srvDesktopCommand (int id)
unlock_zi_for_read (__mg_zorder_info);
}
else if (id == IDM_ENDSESSION) {
if (SERVER_HAS_NO_MAINWINDOW()) {
ExitGUISafely (-1);
}
SendMessage (HWND_DESKTOP, MSG_ENDSESSION, 0, 0);
}
#ifdef _MGHAVE_MENU
else if (id >= IDM_FIRSTWINDOW && id < IDM_SWITCH_LAYER) {
@@ -4094,10 +4096,8 @@ static int srvSesseionMessageHandler (int message, WPARAM wParam, LPARAM lParam)
break;
case MSG_ERASEDESKTOP:
if (dsk_ops->paint_desktop)
dsk_ops->paint_desktop(dt_context, hDesktopDC, (PRECT)lParam);
break;
case MSG_DT_KEYLONGPRESS:
@@ -4114,6 +4114,7 @@ static int srvSesseionMessageHandler (int message, WPARAM wParam, LPARAM lParam)
#ifdef _MGHAVE_MENU
case MSG_DT_RBUTTONUP:
if (sg_DesktopMenu)
srvUpdateDesktopMenu ();
#endif
case MSG_DT_LBUTTONDOWN:
@@ -4375,7 +4376,7 @@ static LRESULT DesktopWinProc (HWND hWnd, UINT message,
/* Since 5.0.0 */
case MSG_CALC_POSITION:
if (mgIsServer) {
dskCalculateDefaultPosition (0, (CALCPOSINFO*)lParam);
dskCalculateDefaultPosition ((int)wParam, (CALCPOSINFO*)lParam);
return 0;
}
else
+2
View File
@@ -1570,6 +1570,8 @@ static int srvStartTrackPopupMenu (int cli, const RECT* rc, HWND ptmi,
GAL_Surface* surf;
if (cli == 0) {
surf = GetSurfaceFromDC (((PTRACKMENUINFO)ptmi)->dc);
// prevent to free this surface when deleting memdc for znode.
surf->refcount++;
}
else if (fd >= 0) {
surf = GAL_AttachSharedRGBSurface (fd, surf_size, surf_flags, TRUE);
+3 -1
View File
@@ -348,7 +348,7 @@ BOOL kernel_GetLWEvent (int event, PLWEVENT lwe)
}
timeout_count = __mg_tick_counter + timeout_threshold;
// There was a event occurred.
// There was an event occurred.
if (event & IAL_MOUSEEVENT) {
if (!IAL_UpdateMouse ())
return 0;
@@ -459,6 +459,7 @@ BOOL kernel_GetLWEvent (int event, PLWEVENT lwe)
#endif
ke->event = KE_KEYUP;
ke->scancode = i;
olddownkey = 0;
break;
}
}
@@ -765,6 +766,7 @@ BOOL kernel_GetLWEvent (int event, PLWEVENT lwe)
if(oldkeystate[i] && !keystate[i]) {
ke->event = KE_KEYUP;
ke->scancode = i;
olddownkey = 0;
break;
}
}
+7 -1
View File
@@ -480,6 +480,8 @@ int InitGUI (int argc, const char* agr[])
*/
strncpy (SHAREDRES_VIDEO_ENGINE, engine, LEN_ENGINE_NAME);
strncpy (SHAREDRES_VIDEO_MODE, mode, LEN_VIDEO_MODE);
#if 0 /* deprecated code */
// these fileds will be initialized by DRM engine.
if (GetMgEtcValue (engine, "device",
SHAREDRES_VIDEO_DEVICE, LEN_DEVICE_NAME) < 0)
*SHAREDRES_VIDEO_DEVICE = 0;
@@ -489,6 +491,7 @@ int InitGUI (int argc, const char* agr[])
if (GetMgEtcValue (engine, "exdriver",
SHAREDRES_VIDEO_EXDRIVER, LEN_EXDRIVER_NAME) < 0)
*SHAREDRES_VIDEO_EXDRIVER = 0;
#endif /* deprecated code */
SHAREDRES_VIDEO_DPI = __gal_screen->dpi;
SHAREDRES_VIDEO_HRES = __gal_screen->w;
@@ -498,6 +501,8 @@ int InitGUI (int argc, const char* agr[])
SHAREDRES_VIDEO_GMASK = __gal_screen->format->Gmask;
SHAREDRES_VIDEO_BMASK = __gal_screen->format->Bmask;
SHAREDRES_VIDEO_AMASK = __gal_screen->format->Amask;
GAL_CopyVideoInfoToSharedRes();
}
else {
_DBG_PRINTF("Engien info from shared resource: %s %s %d\n",
@@ -579,7 +584,6 @@ void TerminateGUI (int rcByGUI)
__mg_join_all_message_threads ();
#endif
mg_DestroyFreeQMSGList ();
mg_TerminateAccel ();
mg_TerminateControlClass ();
@@ -613,6 +617,8 @@ void TerminateGUI (int rcByGUI)
}
#endif
mg_DestroyFreeQMSGList ();
#ifdef _MGHAVE_ADV_2DAPI
extern void miFreeArcCache (void);
miFreeArcCache ();
+6 -6
View File
@@ -274,7 +274,7 @@ void __kernel_free_z_order_info (ZORDERINFO* zi)
}
#if 0 /* deprecated code */
#if IS_SHAREDFB_SCHEMA
#if IS_SHAREDFB_SCHEMA_PROCS
int __kernel_alloc_z_order_info (int nr_topmosts, int nr_normals)
{
@@ -299,7 +299,7 @@ int __kernel_alloc_z_order_info (int nr_topmosts, int nr_normals)
return zorder_shmid;
}
#else /* not IS_SHAREDFB_SCHEMA */
#else /* not IS_SHAREDFB_SCHEMA_PROCS */
ZORDERINFO* __kernel_alloc_z_order_info (int nr_topmosts, int nr_normals)
{
@@ -378,14 +378,14 @@ ZORDERINFO* __kernel_alloc_z_order_info (int nr_topmosts, int nr_normals)
return zi;
}
#endif /* not IS_SHAREDFB_SCHEMA */
#endif /* not IS_SHAREDFB_SCHEMA_PROCS */
void __kernel_free_z_order_info (ZORDERINFO* zi)
{
#if IS_SHAREDFB_SCHEMA
#if IS_SHAREDFB_SCHEMA_PROCS
if (shmdt (zi) < 0)
perror ("Detaches shared zorder nodes");
#else /* not IS_SHAREDFB_SCHEMA */
#else /* not IS_SHAREDFB_SCHEMA_PROCS */
#ifdef _MGRM_THREADS
#ifndef __NOUNIX__
@@ -396,7 +396,7 @@ void __kernel_free_z_order_info (ZORDERINFO* zi)
#endif /* _MGRM_THREADS */
free (zi);
#endif /* not IS_SHAREDFB_SCHEMA */
#endif /* not IS_SHAREDFB_SCHEMA_PROCS */
}
#endif /* deprecated code */
+2
View File
@@ -127,6 +127,8 @@ static LRESULT AboutWinProc (HWND hWnd, UINT message,
DestroyMainWindow (hWnd);
#ifdef _MGRM_THREADS
PostQuitMessage (hWnd);
#else
MainWindowCleanup (hWnd);
#endif
return 0;
}
+2
View File
@@ -61,6 +61,8 @@
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef _MGUSE_SHMOPEN
#include <sys/mman.h>
+1
View File
@@ -39,6 +39,7 @@ COMMON_SRCS = \
videomem-bucket.c \
surface-shared.c \
surface-cursor.c \
surface-shm.c \
shadow-screen.h \
shadow-screen.c \
$(NULL_FILE)
+4 -4
View File
@@ -476,7 +476,7 @@ int GAL_RLEBlit(GAL_Surface *src, GAL_Rect *srcrect,
/* Set up the source and destination pointers */
x = dstrect->x;
y = dstrect->y;
dstbuf = (Uint8 *)dst->pixels + dst->offset
dstbuf = (Uint8 *)dst->pixels
+ y * dst->pitch + x * src->format->BytesPerPixel;
srcbuf = (Uint8 *)src->map->sw_data->aux_data;
@@ -730,7 +730,7 @@ int GAL_RLEAlphaBlit(GAL_Surface *src, GAL_Rect *srcrect,
x = dstrect->x;
y = dstrect->y;
dstbuf = (Uint8 *)dst->pixels + dst->offset
dstbuf = (Uint8 *)dst->pixels
+ y * dst->pitch + x * df->BytesPerPixel;
srcbuf = (Uint8 *)src->map->sw_data->aux_data + sizeof(RLEDestFormat);
@@ -1098,7 +1098,7 @@ static int RLEAlphaSurface(GAL_Surface *surface)
int x, y;
int h = surface->h, w = surface->w;
GAL_PixelFormat *sf = surface->format;
Uint32 *src = (Uint32 *)((Uint8 *)surface->pixels + surface->offset);
Uint32 *src = (Uint32 *)((Uint8 *)surface->pixels);
Uint8 *lastline = dst; /* end of last non-blank line */
/* opaque counts are 8 or 16 bits, depending on target depth */
@@ -1283,7 +1283,7 @@ static int RLEColorkeySurface(GAL_Surface *surface)
}
/* Set up the conversion */
srcbuf = (Uint8 *)surface->pixels+surface->offset;
srcbuf = (Uint8 *)surface->pixels;
maxn = bpp == 4 ? 65535 : 255;
dst = rlebuf;
rgbmask = ~surface->format->Amask;
+3 -4
View File
@@ -77,13 +77,13 @@ static int GAL_SoftBlit(GAL_Surface *src, GAL_Rect *srcrect,
GAL_loblit RunBlit;
/* Set up the blit information */
info.s_pixels = (Uint8 *)src->pixels + src->offset +
info.s_pixels = (Uint8 *)src->pixels +
(Uint16)srcrect->y*src->pitch +
(Uint16)srcrect->x*src->format->BytesPerPixel;
info.s_width = srcrect->w;
info.s_height = srcrect->h;
info.s_skip=src->pitch-info.s_width*src->format->BytesPerPixel;
info.d_pixels = (Uint8 *)dst->pixels + dst->offset +
info.d_pixels = (Uint8 *)dst->pixels +
(Uint16)dstrect->y*dst->pitch +
(Uint16)dstrect->x*dst->format->BytesPerPixel;
info.d_width = dstrect->w;
@@ -290,8 +290,7 @@ int GAL_CalculateBlit(GAL_Surface *surface)
if(surface->flags & GAL_RLEACCELOK
&& (surface->flags & GAL_HWACCEL) != GAL_HWACCEL) {
if(surface->map->identity
&& (blit_index == 1
if(surface->map->identity && (blit_index == 1
|| (blit_index == 3 && !surface->format->Amask))) {
if ( GAL_RLESurface(surface) == 0 )
surface->map->sw_blit = GAL_RLEBlit;
+62 -10
View File
@@ -94,26 +94,70 @@ static void COMMLCD_DeleteDevice(GAL_VideoDevice *device)
static void COMMLCD_UpdateRects_Sync (_THIS, int numrects, GAL_Rect *rects)
{
int i;
RECT bound;
/* sync update */
bound = this->hidden->rc_dirty;
for (i = 0; i < numrects; i++) {
RECT rc;
SetRect (&rc, rects[i].x, rects[i].y,
rects[i].x + rects[i].w, rects[i].y + rects[i].h);
if (!IsRectEmpty (&rc)) {
__mg_commlcd_ops.update (&rc);
if (IsRectEmpty (&bound))
bound = rc;
else
GetBoundRect (&bound, &bound, &rc);
}
if (!IsRectEmpty (&bound)) {
RECT rcScr = GetScreenRect();
if (IntersectRect (&bound, &bound, &rcScr)) {
this->hidden->rc_dirty = bound;
this->hidden->dirty = TRUE;
}
}
}
static BOOL _valid_async_updater = TRUE;
static BOOL COMMLCD_SyncUpdate_Sync (_THIS)
{
if (!IsRectEmpty (&this->hidden->rc_dirty)) {
__mg_commlcd_ops.update (&this->hidden->rc_dirty);
SetRect (&this->hidden->rc_dirty, 0, 0, 0, 0);
this->hidden->dirty = FALSE;
return TRUE;
}
return FALSE;
}
static BOOL COMMLCD_SyncUpdate_Async (_THIS)
{
BOOL rc = FALSE;
pthread_mutex_lock (&this->hidden->update_lock);
if (this->hidden->dirty) {
// signal the update thread to do update
sem_post (&this->hidden->sem_update);
rc = TRUE;
}
pthread_mutex_unlock (&this->hidden->update_lock);
return rc;
}
static void* task_do_update (void* data)
{
_THIS;
this = data;
if (pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL))
return NULL;
do {
sem_wait (&this->hidden->sem_update);
pthread_testcancel ();
pthread_mutex_lock (&this->hidden->update_lock);
if (this->hidden->dirty) {
__mg_commlcd_ops.update (&this->hidden->rc_dirty);
@@ -122,8 +166,11 @@ static void* task_do_update (void* data)
this->hidden->dirty = FALSE;
}
pthread_mutex_unlock (&this->hidden->update_lock);
#if 0 /* since 5.0.0: use semaphore */
__mg_os_time_delay(50); /* 50 ms */
} while (_valid_async_updater);
#endif
} while (1);
return NULL;
}
@@ -186,12 +233,13 @@ static GAL_VideoDevice *COMMLCD_CreateDevice (int devindex)
device->SetColors = COMMLCD_SetColors;
device->VideoQuit = COMMLCD_VideoQuit;
device->AllocHWSurface = COMMLCD_AllocHWSurface;
device->FreeHWSurface = COMMLCD_FreeHWSurface;
device->CheckHWBlit = NULL;
device->FillHWRect = NULL;
device->SetHWColorKey = NULL;
device->SetHWAlpha = NULL;
device->FreeHWSurface = COMMLCD_FreeHWSurface;
device->UpdateRects = NULL;
device->SyncUpdate = NULL;
device->free = COMMLCD_DeleteDevice;
return device;
@@ -307,11 +355,15 @@ static GAL_Surface *COMMLCD_SetVideoMode(_THIS, GAL_Surface *current,
if (li.update_method == COMMLCD_UPDATE_NONE) {
this->UpdateRects = NULL;
this->SyncUpdate = NULL;
this->hidden->update_th = 0;
}
else if (li.update_method == COMMLCD_UPDATE_ASYNC) {
this->UpdateRects = COMMLCD_UpdateRects_Async;
this->SyncUpdate = COMMLCD_SyncUpdate_Async;
pthread_mutex_init (&this->hidden->update_lock, NULL);
sem_init (&this->hidden->sem_update, 0, 0);
#if 0
pthread_attr_t new_attr;
@@ -324,10 +376,10 @@ static GAL_Surface *COMMLCD_SetVideoMode(_THIS, GAL_Surface *current,
pthread_create (&this->hidden->update_th, NULL,
task_do_update, this);
#endif
pthread_mutex_init (&this->hidden->update_lock, NULL);
}
else {
this->UpdateRects = COMMLCD_UpdateRects_Sync;
this->SyncUpdate = COMMLCD_SyncUpdate_Sync;
this->hidden->update_th = 0;
}
@@ -342,9 +394,9 @@ static void COMMLCD_VideoQuit (_THIS)
}
if (this->hidden->update_th) {
/* quit the update task */
_valid_async_updater = FALSE;
pthread_join(this->hidden->update_th, NULL);
/* send cancel request */
pthread_cancel (this->hidden->update_th);
pthread_join (this->hidden->update_th, NULL);
}
if (__mg_commlcd_ops.release)
+3
View File
@@ -47,6 +47,8 @@
#ifndef _GAL_COMMLCD_H
#define _GAL_COMMLCD_H
#include <semaphore.h>
#include "sysvideo.h"
#include "exstubs.h"
@@ -68,6 +70,7 @@ struct GAL_PrivateVideoData {
RECT rc_dirty;
pthread_t update_th;
pthread_mutex_t update_lock;
sem_t sem_update;
};
struct commlcd_ops {
+2 -2
View File
@@ -117,7 +117,7 @@ GAL_FunctionTable mgGALFuncTable = {
DFB_SetColors,
DFB_UpdateRects,
DFB_VideoQuit,
#if IS_SHAREDFB_SCHEMA
#if IS_SHAREDFB_SCHEMA_PROCS
DFB_RequestHWSurface,
#endif
DFB_AllocHWSurface,
@@ -167,7 +167,7 @@ static GAL_VideoDevice *DFB_CreateDevice (int devindex)
device->SetColors = DFB_SetColors;
device->VideoQuit = DFB_VideoQuit;
device->UpdateRects = DFB_UpdateRects;
#if IS_SHAREDFB_SCHEMA
#if IS_SHAREDFB_SCHEMA_PROCS
device->RequestHWSurface = DFB_RequestHWSurface;
#endif
device->AllocHWSurface = DFB_AllocHWSurface;
+2620 -1065
View File
File diff suppressed because it is too large Load Diff
+45 -15
View File
@@ -15,7 +15,7 @@
* and Graphics User Interface (GUI) support system for embedded systems
* and smart IoT devices.
*
* Copyright (C) 2019, Beijing FMSoft Technologies Co., Ltd.
* Copyright (C) 2019 ~ 2020, 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
@@ -58,9 +58,49 @@
typedef struct drm_mode_info DrmModeInfo;
typedef struct GAL_PrivateVideoData {
char dev_name[LEN_DEVICE_NAME + 1];
/* For compositing schema, we force to use double buffering */
#ifdef _MGSCHEMA_COMPOSITING
GAL_Surface *real_screen, *shadow_screen;
DrmSurfaceBuffer *cursor_buff;
uint32_t cursor_plane_id;
/* Used to simulate the hardware cursor when hardware cursor not available. */
GAL_Surface *cursor;
int csr_x, csr_y;
int hot_x, hot_y;
#if 0 /* test code */
/* for asynchronous update */
pthread_t update_th;
pthread_mutex_t update_lock;
sem_t sem_update;
#endif /* test code */
#else /* defined _MGSCHEMA_COMPOSITING */
/* When double buffering supported, the real surface represents the ultimate
* scan-out frame buffer, and the shadow screen represents the rendering
* surface. When double buffering disabled, shadow_screen is NULL. */
GAL_Surface *real_screen, *shadow_screen;
/* the global names of real screen and shadow screen */
uint32_t real_name, shadow_name;
#endif /* not defined _MGSCHEMA_COMPOSITING */
#if !IS_SHAREDFB_SCHEMA_PROCS
RECT dirty_rc;
#endif
char* dev_name;
char* ex_driver;
int dev_fd;
/* capabilities */
uint32_t cap_cursor_width;
uint32_t cap_cursor_height;
uint32_t cap_dumb:1;
uint32_t dbl_buff:1;
uint32_t scanout_buff_id;
void* exdrv_handle;
DrmDriverOps* driver_ops;
DrmDriver* driver;
@@ -68,23 +108,13 @@ typedef struct GAL_PrivateVideoData {
DrmModeInfo* mode_list;
GAL_Rect** modes;
int bpp;
uint32_t width;
uint32_t height;
uint32_t pitch;
uint32_t size;
uint32_t scanout_buff_id;
uint8_t* scanout_fb;
DrmModeInfo* saved_info;
drmModeCrtc* saved_crtc;
/* only valid when using DUMB frame buffer */
uint32_t handle;
/* only valid when using DRM driver */
#if 0 /* deprecated code */
uint32_t console_buff_id;
uint8_t* scanout_fb;
#endif /* deprecated code */
} DrmVideoData;
#endif /* _NEWGAL_DRIVIDEO_H */
+6
View File
@@ -152,6 +152,12 @@ static int FB_Available(void)
static void FB_DeleteDevice(GAL_VideoDevice *device)
{
#ifdef _MGSCHEMA_COMPOSITING
if (device->hidden->shadow_screen) {
GAL_FreeSurface (device->hidden->real_screen);
}
#endif /* _MGSCHEMA_COMPOSITING */
free(device->hidden);
free(device);
}
+1 -1
View File
@@ -236,7 +236,7 @@ static GAL_VideoDevice *HI3560A_CreateDevice(int devindex)
device->SetVideoMode = HI3560A_SetVideoMode;
device->SetColors = HI3560A_SetColors;
device->VideoQuit = HI3560A_VideoQuit;
#if IS_SHAREDFB_SCHEMA
#if IS_SHAREDFB_SCHEMA_PROCS
device->RequestHWSurface = HI3560A_RequestHWSurface;
#endif
device->AllocHWSurface = HI3560A_AllocHWSurface;
+1 -1
View File
@@ -1851,7 +1851,7 @@ static GAL_VideoDevice *HI3510_CreateDevice (int devindex)
this->SetVideoMode = HI3510_SetVideoMode;
//this->SetColors = FB_SetColors;
this->VideoQuit = HI3510_VideoQuit;
#if IS_SHAREDFB_SCHEMA
#if IS_SHAREDFB_SCHEMA_PROCS
this->RequestHWSurface = HI3510_RequestHWSurface;
#endif
this->AllocHWSurface = HI3510_AllocHWSurface;
+1 -1
View File
@@ -1843,7 +1843,7 @@ static GAL_VideoDevice *HI3560_CreateDevice (int devindex)
this->ListModes = HI3560_ListModes;
this->SetVideoMode = HI3560_SetVideoMode;
this->VideoQuit = HI3560_VideoQuit;
#if IS_SHAREDFB_SCHEMA
#if IS_SHAREDFB_SCHEMA_PROCS
this->RequestHWSurface = HI3560_RequestHWSurface;
#endif
this->AllocHWSurface = HI3560_AllocHWSurface;
+11 -11
View File
@@ -219,8 +219,10 @@ static GAL_Surface* create_wp_surface(GAL_Surface* screen)
screen->format->BitsPerPixel,
screen->format->Rmask, screen->format->Gmask,
screen->format->Bmask, screen->format->Amask);
_DBG_PRINTF ("GAL_CreateSharedRGBSurface: buf_size: %lu, fd: %d\n",
wp_surf->shared_header->buf_size, wp_surf->shared_header->fd);
_WRN_PRINTF ("GAL_CreateSharedRGBSurface: map size: %lu, fd: %d, RGBAmasks: %x, %x, %x, %x\n",
wp_surf->shared_header->map_size, wp_surf->shared_header->fd,
wp_surf->format->Rmask, wp_surf->format->Gmask,
wp_surf->format->Bmask, wp_surf->format->Amask);
}
else {
goto empty;
@@ -233,17 +235,17 @@ static GAL_Surface* create_wp_surface(GAL_Surface* screen)
int fd = -1;
SHAREDSURFINFO info;
req.id = REQID_GETWPSURFACE;
req.data = &fd;
req.len_data = sizeof(int);
req.id = REQID_GETSHAREDSURFACE;
req.data = SYSSF_WALLPAPER_PATTER;
req.len_data = strlen (SYSSF_WALLPAPER_PATTER) + 1;
if ((ClientRequestEx2 (&req, NULL, 0, -1,
&info, sizeof (SHAREDSURFINFO), &fd) < 0) || (fd < 0))
goto empty;
_DBG_PRINTF ("REQID_GETWPSURFACE: map_size (%lu), flags (0x%x), fd: %d\n",
info.map_size, info.flags, fd);
wp_surf = GAL_AttachSharedRGBSurface (fd, info.map_size,
_WRN_PRINTF ("REQID_GETSHAREDSURFACE: size (%lu), flags (0x%x), fd: %d\n",
info.size, info.flags, fd);
wp_surf = GAL_AttachSharedRGBSurface (fd, info.size,
info.flags, TRUE);
close (fd);
@@ -302,9 +304,7 @@ int mg_InitGAL (char* engine, char* mode)
if (GAL_VideoInit (engine, 0)) {
GAL_VideoQuit ();
_ERR_PRINTF ("NEWGAL: Does not find matched engine: %s.\n", engine);
if (IS_COMPOSITING_SCHEMA) {
_ERR_PRINTF (" Or the specified engine does not support compositing schema.\n");
}
_ERR_PRINTF (" Or failed to initialize the engine.\n");
return ERR_NO_MATCH;
}
+1 -1
View File
@@ -190,7 +190,7 @@ static GAL_VideoDevice *S3C6410_CreateDevice(int devindex)
device->SetVideoMode = S3C6410_SetVideoMode;
device->SetColors = S3C6410_SetColors;
device->VideoQuit = S3C6410_VideoQuit;
#if IS_SHAREDFB_SCHEMA
#if IS_SHAREDFB_SCHEMA_PROCS
device->RequestHWSurface = S3C6410_RequestHWSurface;
#endif
device->AllocHWSurface = S3C6410_AllocHWSurface;
+1 -1
View File
@@ -847,7 +847,7 @@ static GAL_VideoDevice *STGFB_CreateDevice (int devindex)
this->SetColors = STGFB_SetColors;
this->VideoQuit = STGFB_VideoQuit;
this->UpdateRects = STGFB_UpdateRects;
#if IS_SHAREDFB_SCHEMA
#if IS_SHAREDFB_SCHEMA_PROCS
this->RequestHWSurface = STGFB_RequestHWSurface;
#endif
this->AllocHWSurface = STGFB_AllocHWSurface;
+1 -1
View File
@@ -97,7 +97,7 @@ GAL_Surface * GAL_CreateCursorSurface (GAL_VideoDevice *video,
surface->h = height;
surface->pitch = GAL_CalculatePitch (surface);
surface->pixels = NULL;
surface->offset = 0;
surface->pixels_off = 0;
// for off-screen surface, DPI always be the default value
surface->dpi = GDCAP_DPI_DEFAULT;
surface->hwdata = NULL;
+57 -56
View File
@@ -130,7 +130,7 @@ GAL_Surface * GAL_CreateSharedRGBSurface (GAL_VideoDevice *video,
surface->h = height;
surface->pitch = GAL_CalculatePitch (surface);
surface->pixels = NULL;
surface->offset = 0;
surface->pixels_off = 0;
// for off-screen surface, DPI always be the default value
surface->dpi = GDCAP_DPI_DEFAULT;
surface->hwdata = NULL;
@@ -148,32 +148,35 @@ GAL_Surface * GAL_CreateSharedRGBSurface (GAL_VideoDevice *video,
/* Get the pixels */
{
int fd = -1;
size_t buf_size;
off_t buf_off;
off_t map_size;
void* data_map;
size_t map_size;
off_t pixels_off;
GAL_SharedSurfaceHeader* hdr;
int byhw = 1;
if ((flags & GAL_HWSURFACE) == GAL_HWSURFACE &&
video->AllocSharedHWSurface) {
fd = video->AllocSharedHWSurface (video, surface,
&buf_size, &buf_off, rw_modes);
&map_size, &pixels_off, rw_modes);
hdr = surface->shared_header;
}
if (fd < 0) { // fallback to use software surface
size_t pixels_size;
void* data_map;
off_t file_size;
byhw = 0;
buf_size = (surface->h * surface->pitch);
buf_off = sizeof (GAL_SharedSurfaceHeader);
pixels_size = (surface->h * surface->pitch);
pixels_off = sizeof (GAL_SharedSurfaceHeader);
file_size = pixels_off + pixels_size;
#if 0
/* rounde file size to multiple of page size */
file_size = buf_off + buf_size;
file_size = ROUND_TO_MULTIPLE(file_size, getpagesize ());
buf_size = file_size - buf_off;
pixels_size = file_size - pixels_off;
#endif
_DBG_PRINTF("shared surface: size (%d x %d), pitch (%d), file_size (%lu)\n",
_DBG_PRINTF("shared surface (%d x %d): pitch(%d), filesize(%lu)\n",
surface->w, surface->h, surface->pitch, file_size);
fd = __mg_create_anonymous_file (file_size, NULL, rw_modes);
@@ -182,17 +185,17 @@ GAL_Surface * GAL_CreateSharedRGBSurface (GAL_VideoDevice *video,
}
surface->video = NULL;
}
map_size = buf_off + buf_size;
data_map = mmap (NULL, map_size, PROT_READ | PROT_WRITE,
MAP_SHARED, fd, 0);
if (data_map == MAP_FAILED) {
close (fd);
goto error;
}
map_size = file_size;
data_map = mmap (NULL, map_size, PROT_READ | PROT_WRITE,
MAP_SHARED, fd, 0);
if (data_map == MAP_FAILED) {
close (fd);
goto error;
}
surface->shared_header = hdr = (GAL_SharedSurfaceHeader*)data_map;
surface->shared_header = hdr = (GAL_SharedSurfaceHeader*)data_map;
}
/* fill fileds of shared header */
memset (hdr, 0, sizeof(GAL_SharedSurfaceHeader));
@@ -207,7 +210,8 @@ GAL_Surface * GAL_CreateSharedRGBSurface (GAL_VideoDevice *video,
hdr->Gmask = Gmask;
hdr->Bmask = Bmask;
hdr->Amask = Amask;
hdr->buf_size = buf_size;
hdr->map_size = map_size;
hdr->pixels_off = pixels_off;
surface->dirty_info = &hdr->dirty_info;
surface->dirty_info->dirty_age = 0;
@@ -226,19 +230,7 @@ GAL_Surface * GAL_CreateSharedRGBSurface (GAL_VideoDevice *video,
}
}
#if 0
/* Use a unnamed POSIX semaphore shared between processes */
if (sem_init (&hdr->sem_lock, 1, 1) < 0) {
if (errno == ENOSYS) {
_ERR_PRINTF("The system does not support process-shared semaphore.\n");
}
goto error;
}
BOOL sem_inited = TRUE;
#endif
surface->pixels = surface->shared_header->buf;
// memset (surface->pixels, 0, buf_size);
surface->pixels = (uint8_t*)surface->shared_header + pixels_off;
if (byhw)
surface->flags |= GAL_HWSURFACE;
@@ -277,8 +269,7 @@ error:
else {
close (surface->shared_header->fd);
munmap (surface->shared_header,
surface->shared_header->buf_size
+ sizeof(GAL_SharedSurfaceHeader));
surface->shared_header->map_size);
}
surface->shared_header = NULL;
@@ -310,18 +301,20 @@ void GAL_FreeSharedSurfaceData (GAL_Surface *surface)
__mg_free_sem_for_shared_surf (surface->shared_header->sem_num);
}
// the file descriptor may have been closed.
if (surface->shared_header->fd >= 0) {
close (surface->shared_header->fd);
surface->shared_header->fd = -1;
}
if (surface->shared_header->byhw) {
assert (video->FreeSharedHWSurface);
video->FreeSharedHWSurface (video, surface);
surface->hwdata = NULL;
}
else {
// the file descriptor may have been closed.
if (surface->shared_header->fd >= 0)
close (surface->shared_header->fd);
munmap (surface->shared_header,
surface->shared_header->buf_size
+ sizeof (GAL_SharedSurfaceHeader));
surface->shared_header->map_size);
}
surface->pixels = NULL;
@@ -335,7 +328,7 @@ void GAL_FreeSharedSurfaceData (GAL_Surface *surface)
GAL_Surface * GAL_AttachSharedRGBSurface (int fd, size_t map_size,
Uint32 flags, BOOL with_wr)
{
GAL_VideoDevice *video;
GAL_VideoDevice *video = NULL;
GAL_Surface *surface;
void* data_map = MAP_FAILED;
GAL_SharedSurfaceHeader* hdr;
@@ -368,6 +361,7 @@ GAL_Surface * GAL_AttachSharedRGBSurface (int fd, size_t map_size,
surface->flags = flags;
surface->shared_header = NULL;
surface->hwdata = NULL;
if (video && video->AttachSharedHWSurface) {
// this method should fill hwdata and shared_header fields if success
video->AttachSharedHWSurface (video, surface, fd, map_size, with_wr);
@@ -384,7 +378,7 @@ GAL_Surface * GAL_AttachSharedRGBSurface (int fd, size_t map_size,
data_map = mmap (NULL, map_size, prot, MAP_SHARED, fd, 0);
if (data_map == MAP_FAILED) {
_ERR_PRINTF("NEWGAL: Failed to map shared RGB surface: %d\n", fd);
return NULL;
goto error;
}
surface->hwdata = NULL;
@@ -395,8 +389,13 @@ GAL_Surface * GAL_AttachSharedRGBSurface (int fd, size_t map_size,
/* map successfully */
hdr = surface->shared_header;
if (surface->hwdata)
surface->flags |= GAL_HWSURFACE;
else
surface->flags &= ~GAL_HWSURFACE;
surface->dirty_info = &hdr->dirty_info;
surface->pixels = hdr->buf;
surface->pixels = (uint8_t*)hdr + hdr->pixels_off;
surface->format = GAL_AllocFormat (hdr->depth,
hdr->Rmask, hdr->Gmask, hdr->Bmask, hdr->Amask);
if (surface->format == NULL) {
@@ -405,8 +404,8 @@ GAL_Surface * GAL_AttachSharedRGBSurface (int fd, size_t map_size,
surface->w = hdr->width;
surface->h = hdr->height;
surface->pitch = GAL_CalculatePitch (surface);
surface->offset = 0;
surface->pitch = hdr->pitch;
surface->pixels_off = 0;
// for off-screen surface, DPI always be the default value
surface->dpi = GDCAP_DPI_DEFAULT;
surface->map = NULL;
@@ -429,12 +428,12 @@ GAL_Surface * GAL_AttachSharedRGBSurface (int fd, size_t map_size,
return (surface);
error:
if (data_map != MAP_FAILED) {
if (video && video->DettachSharedHWSurface) {
video->DettachSharedHWSurface (video, surface);
}
else
munmap (data_map, map_size);
if (video && surface && surface->hwdata) {
assert (video->DettachSharedHWSurface);
video->DettachSharedHWSurface (video, surface);
}
else if (data_map != MAP_FAILED) {
munmap (data_map, map_size);
}
if (surface)
@@ -453,14 +452,16 @@ void GAL_DettachSharedSurfaceData (GAL_Surface *surface)
assert (surface->shared_header);
if (video && video->DettachSharedHWSurface) {
if (video && surface->hwdata) {
assert (video->DettachSharedHWSurface);
video->DettachSharedHWSurface (video, surface);
surface->hwdata = NULL;
}
else {
munmap (surface->shared_header,
surface->shared_header->map_size);
}
munmap (surface->shared_header,
surface->shared_header->buf_size
+ sizeof (GAL_SharedSurfaceHeader));
surface->pixels = NULL;
surface->shared_header = NULL;
surface->dirty_info = NULL;
+175
View File
@@ -0,0 +1,175 @@
///////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT NOTICE
//
// The following open source license statement does not apply to any
// entity in the Exception List published by FMSoft.
//
// For more information, please visit:
//
// https://www.fmsoft.cn/exception-list
//
//////////////////////////////////////////////////////////////////////////////
/*
* This file is part of MiniGUI, a mature cross-platform windowing
* and Graphics User Interface (GUI) support system for embedded systems
* and smart IoT devices.
*
* Copyright (C) 2002~2020, Beijing FMSoft Technologies Co., Ltd.
* Copyright (C) 1998~2002, WEI Yongming
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Or,
*
* As this program is a library, any link to this program must follow
* GNU General Public License version 3 (GPLv3). If you cannot accept
* GPLv3, you need to be licensed from FMSoft.
*
* If you have got a commercial license of this program, please use it
* under the terms and conditions of the commercial license.
*
* For more information about the commercial license, please refer to
* <http://www.minigui.com/blog/minigui-licensing-policy/>.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _DEBUG
#include "common.h"
#include "minigui.h"
#include "constants.h"
#ifdef _MGRM_PROCESSES
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h> /* For O_* constants */
#include <unistd.h>
#include "misc.h"
#include "newgal.h"
/*
* Create a RGB surface in shared memory in the appropriate depth and pixel format
*/
GAL_Surface * GAL_CreateRGBSurfaceInShm (const char* shm_name, BOOL create,
Uint32 rw_modes, Uint32 hdr_size, int width, int height, int depth,
Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
{
int fd = -1, pitch;
size_t map_size, offset;
uint8_t* buff = NULL;
GAL_Surface* surface = NULL;
if (width <= 0 || height <= 0)
return NULL;
if (create) {
fd = shm_open (shm_name, O_CREAT | O_RDWR | O_CLOEXEC, rw_modes);
}
else {
fd = shm_open (shm_name, O_RDWR | O_CLOEXEC, rw_modes);
}
if (fd <= 0) {
_DBG_PRINTF ("failed to call shm_open: %m\n");
return NULL;
}
pitch = width * ((depth + 7) / 8);
pitch = (pitch + 3) & ~3;
if (hdr_size) {
int nr_hdr_lines = hdr_size / pitch;
if (hdr_size % pitch)
nr_hdr_lines++;
map_size = pitch * (height + nr_hdr_lines);
offset = pitch * nr_hdr_lines;
}
else {
map_size = pitch * height;
offset = 0;
}
_DBG_PRINTF ("map_size for depth (%d), width (%d), height (%d): %lu\n",
depth, width, height, map_size);
if (create && ftruncate (fd, map_size)) {
close (fd);
_DBG_PRINTF ("failed to call ftruncate: %m\n");
goto error;
}
else {
off_t file_size = lseek (fd, 0, SEEK_END);
if (file_size != map_size) {
_DBG_PRINTF ("file size (%lu) does not match the map size (%lu), "
"width (%d), height (%d), depth (%d)\n",
file_size, map_size, width, height, depth);
goto error;
}
}
buff = mmap (NULL, map_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (buff == MAP_FAILED) {
_DBG_PRINTF ("failed to call mmap: %m\n");
buff = NULL;
goto error;
}
/* create a null size software surface first */
surface = GAL_CreateRGBSurface (GAL_SWSURFACE, 0, 0, depth,
Rmask, Gmask, Bmask, Amask);
if (surface == NULL) {
_DBG_PRINTF ("failed to create null surface\n");
goto error;
}
/* Get the pixels */
surface->flags |= GAL_PREALLOC;
surface->w = width;
surface->h = height;
surface->pitch = pitch;
surface->pixels_off = offset;
surface->pixels = buff + offset;
surface->hwdata = (void*)map_size; // use hwdata for map_size
close (fd);
return surface;
error:
if (surface) {
surface->pixels = NULL;
GAL_FreeSurface (surface);
}
if (buff) {
munmap (buff, map_size);
}
if (fd >= 0) {
close (fd);
shm_unlink (shm_name);
}
return NULL;
}
#endif /* defined _MGRM_PROCESSES */
+20 -2
View File
@@ -57,6 +57,10 @@
#include "memops.h"
#include "leaks.h"
#ifdef _MGRM_PROCESSES
#include <sys/mman.h> /* for munmap */
#endif /* _MGRM_PROCESSES */
/* Public routines */
/*
* Create an empty RGB surface of the appropriate depth
@@ -132,7 +136,7 @@ GAL_Surface * GAL_CreateRGBSurface (Uint32 flags,
surface->h = height;
surface->pitch = GAL_CalculatePitch(surface);
surface->pixels = NULL;
surface->offset = 0;
surface->pixels_off = 0;
// for off-screen surface, DPI always be the default value
surface->dpi = GDCAP_DPI_DEFAULT;
surface->hwdata = NULL;
@@ -1748,6 +1752,20 @@ void GAL_FreeSurface (GAL_Surface *surface)
assert (video->FreeHWSurface);
video->FreeHWSurface (video, surface);
}
#ifdef _MGRM_PROCESSES
else if ((surface->flags & GAL_HWSURFACE) == GAL_SWSURFACE &&
(surface->flags & GAL_PREALLOC) == GAL_PREALLOC &&
surface->hwdata) {
// This is a surface created in / attached to a named shared memory.
size_t map_size;
uint8_t* buff;
map_size = (size_t)surface->hwdata;
buff = surface->pixels - surface->pixels_off;
munmap (buff, map_size);
}
#endif /* _MGRM_PROCESSES */
else if (surface->pixels &&
((surface->flags & GAL_PREALLOC) != GAL_PREALLOC)) {
free (surface->pixels);
@@ -1760,7 +1778,7 @@ void GAL_FreeSurface (GAL_Surface *surface)
#endif
}
#if IS_SHAREDFB_SCHEMA
#if IS_SHAREDFB_SCHEMA_PROCS
void GAL_RequestHWSurface (const REQ_HWSURFACE* request, REP_HWSURFACE* reply)
{
if (__mg_current_video->RequestHWSurface) {
+5 -3
View File
@@ -143,6 +143,8 @@ struct GAL_VideoDevice {
GAL_VideoInfo info;
#ifdef _MGRM_PROCESSES
/* Copy video information to shared resource segment */
void (*CopyVideoInfoToSharedRes)(_THIS);
/* Request a surface in video memory */
void (*RequestHWSurface)(_THIS, const REQ_HWSURFACE* request,
REP_HWSURFACE* reply);
@@ -156,7 +158,7 @@ struct GAL_VideoDevice {
Set to NULL if no hardware shared surface supported.
Return the PRIME file descriptor if success, otherwize -1. */
int (*AllocSharedHWSurface)(_THIS, GAL_Surface *surface,
size_t* buf_size, off_t* buf_off, Uint32 rw_modes);
size_t* map_size, off_t* pixels_off, Uint32 rw_modes);
/* Free a shared surface in hardware video memory.
Set to NULL if no hardware shared surface supported.
@@ -167,7 +169,7 @@ struct GAL_VideoDevice {
Set to NULL if no hardware shared surface supported.
Return 0 if success, otherwize -1. */
int (*AttachSharedHWSurface)(_THIS, GAL_Surface *surface,
int fd, size_t mapsize, BOOL with_rw);
int prime_fd, size_t mapsize, BOOL with_rw);
/* Dettach from a shared surface in hardware video memory.
Set to NULL if no hardware shared surface supported.
@@ -182,7 +184,7 @@ struct GAL_VideoDevice {
/* Free a dumb surface allocated from hardware.
Set to NULL if dumb surface is not supported.
Return 0 if success, otherwise -1. */
int (*FreeDumbSurface)(_THIS, GAL_Surface *surface);
void (*FreeDumbSurface)(_THIS, GAL_Surface *surface);
/* Set hardware cursor.
Set to NULL or return -1 if no hardware cursor support. */

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