mirror of
https://github.com/apache/nuttx.git
synced 2026-06-07 01:05:54 +08:00
sim framebuffer: Optimize the timing of window to open and to close
The window opens when the fb opens and closes when the fb closes. test step: run fb demo, 1. ./nuttx 2. fb Signed-off-by: jianglianfang <jianglianfang@xiaomi.com>
This commit is contained in:
committed by
Xiang Xiao
parent
eb0a43f4cf
commit
d5a8746be8
@@ -26,6 +26,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <errno.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <sys/ipc.h>
|
||||
@@ -106,8 +107,6 @@ static inline Display *sim_x11createframe(void)
|
||||
XSetWMProperties(display, g_window, &winprop, &iconprop, argv, 1,
|
||||
&hints, NULL, NULL);
|
||||
|
||||
XMapWindow(display, g_window);
|
||||
|
||||
/* Select window input events */
|
||||
|
||||
#if defined(CONFIG_SIM_AJOYSTICK)
|
||||
@@ -372,7 +371,7 @@ int sim_x11initialize(unsigned short width, unsigned short height,
|
||||
display = sim_x11createframe();
|
||||
if (display == NULL)
|
||||
{
|
||||
return -1;
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* Determine the supported pixel bpp of the current window */
|
||||
@@ -403,6 +402,40 @@ int sim_x11initialize(unsigned short width, unsigned short height,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sim_x11openwindow
|
||||
****************************************************************************/
|
||||
|
||||
int sim_x11openwindow(void)
|
||||
{
|
||||
if (g_display == NULL)
|
||||
{
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
XMapWindow(g_display, g_window);
|
||||
XSync(g_display, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sim_x11closewindow
|
||||
****************************************************************************/
|
||||
|
||||
int sim_x11closewindow(void)
|
||||
{
|
||||
if (g_display == NULL)
|
||||
{
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
XUnmapWindow(g_display, g_window);
|
||||
XSync(g_display, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sim_x11cmap
|
||||
****************************************************************************/
|
||||
@@ -416,7 +449,7 @@ int sim_x11cmap(unsigned short first, unsigned short len,
|
||||
|
||||
if (g_display == NULL)
|
||||
{
|
||||
return -1;
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* Convert each color to X11 scaling */
|
||||
@@ -455,7 +488,7 @@ int sim_x11update(void)
|
||||
{
|
||||
if (g_display == NULL)
|
||||
{
|
||||
return -1;
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
#ifndef CONFIG_SIM_X11NOSHM
|
||||
|
||||
@@ -95,6 +95,11 @@ static int sim_setcursor(struct fb_vtable_s *vtable,
|
||||
struct fb_setcursor_s *settings);
|
||||
#endif
|
||||
|
||||
/* Open/close window. */
|
||||
|
||||
static int sim_openwindow(struct fb_vtable_s *vtable);
|
||||
static int sim_closewindow(struct fb_vtable_s *vtable);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
@@ -160,12 +165,47 @@ static struct fb_vtable_s g_fbobject =
|
||||
.getcursor = sim_getcursor,
|
||||
.setcursor = sim_setcursor,
|
||||
#endif
|
||||
|
||||
.open = sim_openwindow,
|
||||
.close = sim_closewindow,
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sim_openwindow
|
||||
****************************************************************************/
|
||||
|
||||
static int sim_openwindow(struct fb_vtable_s *vtable)
|
||||
{
|
||||
int ret = OK;
|
||||
ginfo("vtable=%p\n", vtable);
|
||||
|
||||
#ifdef CONFIG_SIM_X11FB
|
||||
ret = sim_x11openwindow();
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sim_closewindow
|
||||
****************************************************************************/
|
||||
|
||||
static int sim_closewindow(struct fb_vtable_s *vtable)
|
||||
{
|
||||
int ret = OK;
|
||||
ginfo("vtable=%p\n", vtable);
|
||||
|
||||
#ifdef CONFIG_SIM_X11FB
|
||||
ret = sim_x11closewindow();
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sim_getvideoinfo
|
||||
****************************************************************************/
|
||||
|
||||
@@ -242,6 +242,8 @@ int sim_x11initialize(unsigned short width, unsigned short height,
|
||||
void **fbmem, size_t *fblen, unsigned char *bpp,
|
||||
unsigned short *stride);
|
||||
int sim_x11update(void);
|
||||
int sim_x11openwindow(void);
|
||||
int sim_x11closewindow(void);
|
||||
#ifdef CONFIG_FB_CMAP
|
||||
int sim_x11cmap(unsigned short first, unsigned short len,
|
||||
unsigned char *red, unsigned char *green,
|
||||
|
||||
Reference in New Issue
Block a user