VNC: Add hooks to receive updates when the display is modified

This commit is contained in:
Gregory Nutt 2016-04-17 12:26:03 -06:00
parent 0de102706e
commit 1214f99c25
4 changed files with 110 additions and 2 deletions

View File

@ -8,6 +8,7 @@ menuconfig VNCSERVER
default n
depends on NET_TCP && !NX_LCDDRIVER && EXPERIMENTAL
select NET_TCP_READAHEAD
select NX_UPDATE
---help---
Enable support for a VNC Remote Frame Buffer (RFB) server.

View File

@ -406,7 +406,7 @@ int up_fbinitialize(int display)
*/
gvdbg("Starting the VNC server for display %d\n", display);
DEBUGASSERT(display >= 8 && display < RFB_MAX_DISPLAYS);
DEBUGASSERT(display >= 0 && display < RFB_MAX_DISPLAYS);
(void)itoa(display, str, 10);
argv[0] = str;
@ -513,3 +513,54 @@ void up_fbuninitialize(int display)
UNUSED(fbinfo);
}
/****************************************************************************
* Name: nx_notify_rectangle
*
* Description:
* When CONFIG_NX_UPDATE=y, then the graphics system will callout to
* inform some external module that the display has been updated. This
* would be useful in a couple for cases.
*
* - When a serial LCD is used, but a framebuffer is used to access the
* LCD. In this case, the update callout can be used to refresh the
* affected region of the display.
*
* - When VNC is enabled. This is case, this callout is necessary to
* update the remote frame buffer to match the local framebuffer.
*
* When this feature is enabled, some external logic must provide this
* interface. This is the function that will handle the notification. It
* receives the rectangular region that was updated on the provided plane.
*
****************************************************************************/
#ifdef CONFIG_NX_UPDATE
void nx_notify_rectangle(FAR NX_PLANEINFOTYPE *pinfo,
FAR const struct nxgl_rect_s *rect)
{
FAR struct vnc_session_s *session;
int ret;
DEBUGASSERT(pinfo != NULL && rect != NULL);
/* Recover the session informatin from the display number in the planeinfo
* structure.
*/
DEBUGASSERT(pinfo->display >= 0 && pinfo->display < RFB_MAX_DISPLAYS);
session = vnc_find_session(pinfo->display);
/* Verify that the session is still valid */
if (session != NULL && session->state == VNCSERVER_RUNNING)
{
/* Queue the rectangular update */
ret = vnc_update_rectangle(session, rect);
if (ret < 0)
{
gdbg("ERROR: vnc_update_rectangle failed: %d\n", ret);
}
}
}
#endif

View File

@ -56,6 +56,14 @@
/* Configuration */
#ifndef CONFIG_NET_TCP_READAHEAD
# error CONFIG_NET_TCP_READAHEAD must be set to use VNC
#endif
#ifndef CONFIG_NX_UPDATE
# error CONFIG_NX_UPDATE must be set to use VNC
#endif
#if !defined(CONFIG_VNCSERVER_PROTO3p3) && !defined(CONFIG_VNCSERVER_PROTO3p8)
# error No VNC protocol selected
#endif
@ -268,6 +276,25 @@ int vnc_start_updater(FAR struct vnc_session_s *session);
int vnc_stop_updater(FAR struct vnc_session_s *session);
/****************************************************************************
* Name: vnc_update_rectangle
*
* Description:
* Queue an update of the specified rectangular region on the display.
*
* Input Parameters:
* session - An instance of the session structure.
* rect - The rectanglular region to be updated.
*
* Returned Value:
* Zero (OK) is returned on success; a negated errno value is returned on
* any failure.
*
****************************************************************************/
int vnc_update_rectangle(FAR struct vnc_session_s *session,
FAR const struct nxgl_rect_s *rect);
/****************************************************************************
* Name: vnc_receiver
*

View File

@ -42,6 +42,7 @@
#include <sched.h>
#include <pthread.h>
#include <assert.h>
#include <errno.h>
#include "vnc_server.h"
@ -75,7 +76,7 @@ static FAR void *vnc_updater(FAR void *arg)
#warning Missing logic
}
return NULL;
return NULL;
}
/****************************************************************************
@ -169,3 +170,31 @@ int vnc_stop_updater(FAR struct vnc_session_s *session)
return OK;
}
/****************************************************************************
* Name: vnc_update_rectangle
*
* Description:
* Queue an update of the specified rectangular region on the display.
*
* Input Parameters:
* session - An instance of the session structure.
* rect - The rectanglular region to be updated.
*
* Returned Value:
* Zero (OK) is returned on success; a negated errno value is returned on
* any failure.
*
****************************************************************************/
int vnc_update_rectangle(FAR struct vnc_session_s *session,
FAR const struct nxgl_rect_s *rect)
{
/* Make sure that the rectangle has a area */
if (!nxgl_nullrect(rect))
{
#warning Missing logic
}
return -ENOSYS;
}