mirror of
https://github.com/VincentWei/MiniGUI.git
synced 2026-02-07 19:37:00 +08:00
use update lock (semaphore) for sharedfb schema under MiniGUI-Processes
This commit is contained in:
@@ -59,6 +59,10 @@
|
||||
#include <sys/time.h>
|
||||
#include <sys/termios.h>
|
||||
|
||||
#ifdef _MGSCHEMA_SHAREDFB
|
||||
#include <semaphore.h>
|
||||
#endif
|
||||
|
||||
#include "constants.h"
|
||||
|
||||
enum {
|
||||
@@ -108,6 +112,9 @@ typedef struct tagG_RES {
|
||||
char video_exdriver [LEN_EXDRIVER_NAME + 1];
|
||||
Uint32 video_drm_format;
|
||||
Uint32 video_dbl_buff:1;
|
||||
#ifdef _MGSCHEMA_SHAREDFB
|
||||
sem_t video_update_lock; /* the semaphore used for sync update */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int nr_layers;
|
||||
@@ -184,6 +191,9 @@ typedef G_RES* PG_RES;
|
||||
#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)
|
||||
#ifdef _MGSCHEMA_SHAREDFB
|
||||
#define SHAREDRES_VIDEO_UPDATE_LOCK (&((PG_RES)mgSharedRes)->video_update_lock)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define SHAREDRES_TIMER_COUNTER (((PG_RES)mgSharedRes)->timer_counter)
|
||||
|
||||
@@ -1248,6 +1248,15 @@ static GAL_VideoDevice *DRM_CreateDevice(int devindex)
|
||||
strcasecmp (tmp, "yes") == 0) {
|
||||
device->hidden->dbl_buff = 1;
|
||||
}
|
||||
|
||||
#ifdef _MGSCHEMA_SHAREDFB
|
||||
if (device->hidden->dbl_buff) {
|
||||
if (sem_init (SHAREDRES_VIDEO_UPDATE_LOCK, 1, 0)) {
|
||||
_WRN_PRINTF ("Failed to create update lock\n");
|
||||
device->hidden->dbl_buff = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#ifdef _MGRM_PROCESSES
|
||||
else {
|
||||
@@ -1257,7 +1266,7 @@ static GAL_VideoDevice *DRM_CreateDevice(int devindex)
|
||||
|
||||
/* override double buffering */
|
||||
#if IS_COMPOSITING_SCHEMA
|
||||
/* force to use double buffering to compositing schema */
|
||||
/* force to use double buffering for compositing schema */
|
||||
if (mgIsServer) {
|
||||
device->hidden->dbl_buff = 1;
|
||||
#if 0 /* test code */
|
||||
@@ -1650,6 +1659,14 @@ static void DRM_VideoQuit(_THIS)
|
||||
this->screen->pixels = NULL;
|
||||
}
|
||||
|
||||
#if defined (_MGRM_PROCESSES) && defined (_MGSCHEMA_SHAREDFB)
|
||||
if (mgIsServer && this->hidden->dbl_buff) {
|
||||
if (sem_destroy (SHAREDRES_VIDEO_UPDATE_LOCK)) {
|
||||
_ERR_PRINTF ("Failed to destroy the update lock\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0 /* test code */
|
||||
#ifdef _MBSCHEMA_COMPOSITING
|
||||
if (this->hidden->update_th) {
|
||||
@@ -3202,6 +3219,10 @@ static void DRM_UpdateRects (_THIS, int numrects, GAL_Rect *rects)
|
||||
RECT bound;
|
||||
|
||||
#if IS_SHAREDFB_SCHEMA_PROCS
|
||||
if (this->hidden->dbl_buff) {
|
||||
sem_wait (SHAREDRES_VIDEO_UPDATE_LOCK);
|
||||
}
|
||||
|
||||
GAL_ShadowSurfaceHeader* hdr;
|
||||
if (this->hidden->shadow_screen->flags & GAL_HWSURFACE) {
|
||||
hdr = (GAL_ShadowSurfaceHeader*)
|
||||
@@ -3233,6 +3254,12 @@ static void DRM_UpdateRects (_THIS, int numrects, GAL_Rect *rects)
|
||||
bound = GetScreenRect();
|
||||
if (!IntersectRect (dirty_rc, dirty_rc, &bound))
|
||||
SetRectEmpty (dirty_rc);
|
||||
|
||||
#if IS_SHAREDFB_SCHEMA_PROCS
|
||||
if (this->hidden->dbl_buff) {
|
||||
sem_post (SHAREDRES_VIDEO_UPDATE_LOCK);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static BOOL DRM_SyncUpdate (_THIS)
|
||||
@@ -3242,6 +3269,10 @@ static BOOL DRM_SyncUpdate (_THIS)
|
||||
RECT bound;
|
||||
|
||||
#if IS_SHAREDFB_SCHEMA_PROCS
|
||||
if (this->hidden->dbl_buff) {
|
||||
sem_wait (SHAREDRES_VIDEO_UPDATE_LOCK);
|
||||
}
|
||||
|
||||
GAL_ShadowSurfaceHeader* hdr;
|
||||
if (this->hidden->shadow_screen->flags & GAL_HWSURFACE) {
|
||||
hdr = (GAL_ShadowSurfaceHeader*)
|
||||
@@ -3344,7 +3375,14 @@ static BOOL DRM_SyncUpdate (_THIS)
|
||||
}
|
||||
|
||||
SetRectEmpty (dirty_rc);
|
||||
|
||||
ret:
|
||||
#if IS_SHAREDFB_SCHEMA_PROCS
|
||||
if (this->hidden->dbl_buff) {
|
||||
sem_post (SHAREDRES_VIDEO_UPDATE_LOCK);
|
||||
}
|
||||
#endif
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user