mirror of
https://github.com/VincentWei/MiniGUI.git
synced 2026-02-07 19:37:00 +08:00
add the method update for commlcd newgal engine
This commit is contained in:
@@ -229,7 +229,8 @@ struct commlcd_ops __mg_commlcd_ops = {
|
||||
L2F50113T00_open,
|
||||
L2F50113T00_getscreeninfo,
|
||||
L2F50113T00_close,
|
||||
L2F50113T00_setpalette
|
||||
L2F50113T00_setpalette,
|
||||
NULL
|
||||
};
|
||||
|
||||
#endif /* __TARGET_C33L05__ */
|
||||
|
||||
@@ -76,7 +76,60 @@ static void COMMLCD_DeleteDevice(GAL_VideoDevice *device)
|
||||
free (device);
|
||||
}
|
||||
|
||||
static GAL_VideoDevice *COMMLCD_CreateDevice(int devindex)
|
||||
static void* task_do_update (void* data)
|
||||
{
|
||||
_THIS;
|
||||
this = data;
|
||||
|
||||
while (1) {
|
||||
pthread_mutex_lock (&this->hidden->update_lock);
|
||||
if (this->hidden->dirty) {
|
||||
__mg_commlcd_ops.update (&this->hidden->ditry_rect);
|
||||
|
||||
SetRect (&this->hidden->ditry_rect, 0, 0, 0, 0);
|
||||
this->hidden->dirty = FALSE;
|
||||
}
|
||||
pthread_mutex_unlock (&this->hidden->update_lock);
|
||||
usleep (50*1000) /* 50 ms */
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void COMMLCD_UpdateRects (_THIS, int numrects, GAL_Rect *rects)
|
||||
{
|
||||
int i;
|
||||
RECT bound;
|
||||
|
||||
if (__mg_commlcd_ops.update == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
pthread_mutex_lock (&this->hidden->update_lock);
|
||||
|
||||
bound = this->hidden->rc_dirty;
|
||||
for (i = 0; i < numrects; i++) {
|
||||
RECT rc;
|
||||
SetRect (&rc, rects[i].x, rects[i].y,
|
||||
rects[i].x + rects[i].w, rects[i].y + rects[i].h);
|
||||
if (IsRectEmpty (&bound))
|
||||
bound = rc;
|
||||
else
|
||||
GetBoundRect (&bound, &bound, &rc);
|
||||
}
|
||||
|
||||
if (!IsRectEmpty (&bound)) {
|
||||
if (IntersectRect (&bound, &bound, &g_rcScr)) {
|
||||
this->hidden->rc_dirty = bound;
|
||||
this->hidden->dirty = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
pthread_mutex_unlock (&this->hidden->update_lock);
|
||||
return;
|
||||
}
|
||||
|
||||
static GAL_VideoDevice *COMMLCD_CreateDevice (int devindex)
|
||||
{
|
||||
GAL_VideoDevice *device;
|
||||
|
||||
@@ -111,6 +164,7 @@ static GAL_VideoDevice *COMMLCD_CreateDevice(int devindex)
|
||||
device->SetHWColorKey = NULL;
|
||||
device->SetHWAlpha = NULL;
|
||||
device->FreeHWSurface = COMMLCD_FreeHWSurface;
|
||||
device->UpdateRects = COMMLCD_UpdateRects;
|
||||
|
||||
device->free = COMMLCD_DeleteDevice;
|
||||
return device;
|
||||
@@ -175,16 +229,30 @@ static GAL_Surface *COMMLCD_SetVideoMode(_THIS, GAL_Surface *current,
|
||||
current->pitch = this->hidden->pitch;
|
||||
current->pixels = this->hidden->fb;
|
||||
|
||||
if (__mg_commlcd_ops.update) {
|
||||
pthread_attr_t new_attr;
|
||||
|
||||
pthread_attr_init (&new_attr);
|
||||
pthread_attr_setdetachstate (&new_attr, PTHREAD_CREATE_DETACHED);
|
||||
ret = pthread_create (&this->hidden->update_th, &new_attr,
|
||||
task_do_update, this);
|
||||
pthread_attr_destroy (&new_attr);
|
||||
}
|
||||
|
||||
/* We're done */
|
||||
return current;
|
||||
}
|
||||
|
||||
static void COMMLCD_VideoQuit(_THIS)
|
||||
static void COMMLCD_VideoQuit (_THIS)
|
||||
{
|
||||
if (this->screen && this->screen->pixels) {
|
||||
this->screen->pixels = NULL;
|
||||
}
|
||||
|
||||
if (__mg_commlcd_ops.update) {
|
||||
/* quit the update task */
|
||||
}
|
||||
|
||||
if (__mg_commlcd_ops.release)
|
||||
__mg_commlcd_ops.release ();
|
||||
|
||||
@@ -194,7 +262,7 @@ static void COMMLCD_VideoQuit(_THIS)
|
||||
static GAL_Rect **COMMLCD_ListModes (_THIS, GAL_PixelFormat *format,
|
||||
Uint32 flags)
|
||||
{
|
||||
return (GAL_Rect **) -1;
|
||||
return (GAL_Rect **) -1;
|
||||
}
|
||||
|
||||
/* We don't actually allow hardware surfaces other than the main one */
|
||||
|
||||
@@ -49,6 +49,11 @@ extern "C" {
|
||||
struct GAL_PrivateVideoData {
|
||||
int w, h, pitch;
|
||||
void *fb;
|
||||
|
||||
int dirty;
|
||||
RECT rc_dirty;
|
||||
pthread_t update_th;
|
||||
pthread_mutex_t update_lock;
|
||||
};
|
||||
|
||||
/* The pixel format defined by depth */
|
||||
@@ -76,6 +81,8 @@ struct commlcd_ops {
|
||||
int (*release) (void);
|
||||
/* return value: number set, zero on error */
|
||||
int (*setclut) (int firstcolor, int ncolors, GAL_Color *colors);
|
||||
/* return value: number set, zero on error */
|
||||
int (*update) (const RECT* rc_dirty);
|
||||
};
|
||||
|
||||
extern struct commlcd_ops __mg_commlcd_ops;
|
||||
|
||||
@@ -71,6 +71,7 @@ struct commlcd_ops __mg_commlcd_ops = {
|
||||
a_init,
|
||||
a_getinfo,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
@@ -89,6 +89,7 @@ struct commlcd_ops __mg_commlcd_ops = {
|
||||
a_init,
|
||||
a_getinfo,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
@@ -55,14 +55,15 @@
|
||||
extern int __commlcd_drv_init (void);
|
||||
extern int __commlcd_drv_getinfo (struct commlcd_info *li);
|
||||
extern int __commlcd_drv_release (void);
|
||||
extern int __commlcd_drv_setclut (int firstcolor,
|
||||
int ncolors, GAL_Color *colors);
|
||||
extern int __commlcd_drv_setclut (int firstcolor, int ncolors, GAL_Color *colors);
|
||||
extern int __commlcd_drv_update (const RECT* rc_dirty);
|
||||
|
||||
struct commlcd_ops __mg_commlcd_ops = {
|
||||
__commlcd_drv_init,
|
||||
__commlcd_drv_getinfo,
|
||||
__commlcd_drv_release,
|
||||
__commlcd_drv_setclut
|
||||
__commlcd_drv_setclut,
|
||||
__commlcd_drv_update
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -110,6 +110,7 @@ struct commlcd_ops __mg_commlcd_ops = {
|
||||
a_init,
|
||||
a_getinfo,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
@@ -112,14 +112,15 @@ static int a_setclut (int firstcolor, int ncolors, GAL_Color *colors)
|
||||
#endif
|
||||
|
||||
struct lcd_ops __mg_commlcd_ops = {
|
||||
a_init,
|
||||
a_getinfo,
|
||||
NULL,
|
||||
a_init,
|
||||
a_getinfo,
|
||||
NULL,
|
||||
#ifndef _VESA_SUPPORT
|
||||
a_setclut
|
||||
a_setclut,
|
||||
#else
|
||||
NULL
|
||||
NULL,
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
|
||||
#endif /* __VXWORKS__ && __TARGET_VXI386__ */
|
||||
|
||||
@@ -99,10 +99,11 @@ static int a_release(void)
|
||||
}
|
||||
|
||||
struct lcd_ops __mg_commlcd_ops = {
|
||||
a_init,
|
||||
a_getinfo,
|
||||
a_release,
|
||||
NULL
|
||||
a_init,
|
||||
a_getinfo,
|
||||
a_release,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
#endif /* __VXWORKS__ && __TARGET_PPC__ */
|
||||
|
||||
@@ -63,7 +63,8 @@ struct commlcd_ops __mg_commlcd_ops = {
|
||||
wvfb_drv_lcd_init,
|
||||
wvfb_drv_lcd_getinfo,
|
||||
NULL,
|
||||
wvfb_drv_setclut
|
||||
wvfb_drv_setclut,
|
||||
NULL
|
||||
};
|
||||
|
||||
#endif /* WIN32 && __TARGET_WVFB__ */
|
||||
|
||||
Reference in New Issue
Block a user