mirror of
https://github.com/apache/nuttx.git
synced 2026-06-05 15:58:59 +08:00
VNC: Flush the update queue whenever the client asks for a whole screen update
This commit is contained in:
@@ -233,6 +233,7 @@ enum vnc_server_e
|
|||||||
struct vnc_fbupdate_s
|
struct vnc_fbupdate_s
|
||||||
{
|
{
|
||||||
FAR struct vnc_fbupdate_s *flink;
|
FAR struct vnc_fbupdate_s *flink;
|
||||||
|
bool whupd; /* True: whole screen update */
|
||||||
struct nxgl_rect_s rect; /* The enqueued update rectangle */
|
struct nxgl_rect_s rect; /* The enqueued update rectangle */
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -247,6 +248,7 @@ struct vnc_session_s
|
|||||||
struct socket listen; /* Listen socket */
|
struct socket listen; /* Listen socket */
|
||||||
struct socket connect; /* Connected socket */
|
struct socket connect; /* Connected socket */
|
||||||
volatile uint8_t state; /* See enum vnc_server_e */
|
volatile uint8_t state; /* See enum vnc_server_e */
|
||||||
|
volatile uint8_t nwhupd; /* Number of whole screen updates queued */
|
||||||
|
|
||||||
/* Display geometry and color characteristics */
|
/* Display geometry and color characteristics */
|
||||||
|
|
||||||
|
|||||||
@@ -253,11 +253,18 @@ vnc_remove_queue(FAR struct vnc_session_s *session)
|
|||||||
/* It is reserved.. go get it */
|
/* It is reserved.. go get it */
|
||||||
|
|
||||||
rect = (FAR struct vnc_fbupdate_s *)sq_remfirst(&session->updqueue);
|
rect = (FAR struct vnc_fbupdate_s *)sq_remfirst(&session->updqueue);
|
||||||
|
DEBUGASSERT(rect != NULL);
|
||||||
|
|
||||||
|
/* Check if we just removed the whole screen update from the queue */
|
||||||
|
|
||||||
|
if (session->nwhupd > 0 && rect->whupd)
|
||||||
|
{
|
||||||
|
session->nwhupd--;
|
||||||
|
updvdbg("Whole screen update: nwhupd=%d\n", session->nwhupd);
|
||||||
|
}
|
||||||
|
|
||||||
vnc_sem_debug(session, "After remove", 0);
|
vnc_sem_debug(session, "After remove", 0);
|
||||||
sched_unlock();
|
sched_unlock();
|
||||||
|
|
||||||
DEBUGASSERT(rect != NULL);
|
|
||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -486,6 +493,7 @@ int vnc_update_rectangle(FAR struct vnc_session_s *session,
|
|||||||
{
|
{
|
||||||
FAR struct vnc_fbupdate_s *update;
|
FAR struct vnc_fbupdate_s *update;
|
||||||
struct nxgl_rect_s intersection;
|
struct nxgl_rect_s intersection;
|
||||||
|
bool whupd;
|
||||||
|
|
||||||
/* Clip rectangle to the screen dimensions */
|
/* Clip rectangle to the screen dimensions */
|
||||||
|
|
||||||
@@ -499,44 +507,58 @@ int vnc_update_rectangle(FAR struct vnc_session_s *session,
|
|||||||
* of these (especially when it is confused)
|
* of these (especially when it is confused)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
whupd = (memcmp(&intersection, &g_wholescreen,
|
||||||
|
sizeof(struct nxgl_rect_s)) == 0);
|
||||||
|
|
||||||
|
/* Ignore all updates if there is a queue whole screen update */
|
||||||
|
|
||||||
sched_lock();
|
sched_lock();
|
||||||
if (memcmp(&intersection, &g_wholescreen, sizeof(struct nxgl_rect_s)) == 0)
|
if (session->nwhupd == 0)
|
||||||
{
|
{
|
||||||
FAR struct vnc_fbupdate_s *curr;
|
/* Is this a new whole screen update */
|
||||||
FAR struct vnc_fbupdate_s *next;
|
|
||||||
|
|
||||||
/* Yes.. discard all of the previously queued updates */
|
if (whupd)
|
||||||
|
|
||||||
updvdbg("Whole screen update...\n");
|
|
||||||
|
|
||||||
curr = (FAR struct vnc_fbupdate_s *)session->updqueue.head;
|
|
||||||
sq_init(&session->updqueue);
|
|
||||||
sem_reset(&session->queuesem, 0);
|
|
||||||
|
|
||||||
for (; curr != NULL; curr = next)
|
|
||||||
{
|
{
|
||||||
next = curr->flink;
|
FAR struct vnc_fbupdate_s *curr;
|
||||||
vnc_free_update(session, curr);
|
FAR struct vnc_fbupdate_s *next;
|
||||||
|
|
||||||
|
/* Yes.. discard all of the previously queued updates */
|
||||||
|
|
||||||
|
updvdbg("New whole screen update...\n");
|
||||||
|
|
||||||
|
curr = (FAR struct vnc_fbupdate_s *)session->updqueue.head;
|
||||||
|
sq_init(&session->updqueue);
|
||||||
|
sem_reset(&session->queuesem, 0);
|
||||||
|
|
||||||
|
for (; curr != NULL; curr = next)
|
||||||
|
{
|
||||||
|
next = curr->flink;
|
||||||
|
vnc_free_update(session, curr);
|
||||||
|
}
|
||||||
|
|
||||||
|
session->nwhupd = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Allocate an update structure... waiting if necessary */
|
||||||
|
|
||||||
|
update = vnc_alloc_update(session);
|
||||||
|
DEBUGASSERT(update != NULL);
|
||||||
|
|
||||||
|
/* Copy the clipped rectangle into the update structure */
|
||||||
|
|
||||||
|
update->whupd = whupd;
|
||||||
|
nxgl_rectcopy(&update->rect, &intersection);
|
||||||
|
|
||||||
|
/* Add the upate to the end of the update queue. */
|
||||||
|
|
||||||
|
vnc_add_queue(session, update);
|
||||||
|
|
||||||
|
updvdbg("Queued {(%d, %d),(%d, %d)}\n",
|
||||||
|
intersection.pt1.x, intersection.pt1.y,
|
||||||
|
intersection.pt2.x, intersection.pt2.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate an update structure... waiting if necessary */
|
|
||||||
|
|
||||||
update = vnc_alloc_update(session);
|
|
||||||
DEBUGASSERT(update != NULL);
|
|
||||||
|
|
||||||
/* Copy the clipped rectangle into the update structure */
|
|
||||||
|
|
||||||
nxgl_rectcopy(&update->rect, &intersection);
|
|
||||||
|
|
||||||
/* Add the upate to the end of the update queue. */
|
|
||||||
|
|
||||||
vnc_add_queue(session, update);
|
|
||||||
sched_unlock();
|
sched_unlock();
|
||||||
|
|
||||||
updvdbg("Queued {(%d, %d),(%d, %d)}\n",
|
|
||||||
intersection.pt1.x, intersection.pt1.y,
|
|
||||||
intersection.pt2.x, intersection.pt2.y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Since we ignore bad rectangles and wait for updata structures, there is
|
/* Since we ignore bad rectangles and wait for updata structures, there is
|
||||||
|
|||||||
Reference in New Issue
Block a user