aboutsummaryrefslogtreecommitdiff
path: root/nuttx/graphics/nxmu/nx_bitmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'nuttx/graphics/nxmu/nx_bitmap.c')
-rw-r--r--nuttx/graphics/nxmu/nx_bitmap.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/nuttx/graphics/nxmu/nx_bitmap.c b/nuttx/graphics/nxmu/nx_bitmap.c
index a86eda96a..a0bd748b0 100644
--- a/nuttx/graphics/nxmu/nx_bitmap.c
+++ b/nuttx/graphics/nxmu/nx_bitmap.c
@@ -100,6 +100,8 @@ int nx_bitmap(NXWINDOW hwnd, FAR const struct nxgl_rect_s *dest,
FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd;
struct nxsvrmsg_bitmap_s outmsg;
int i;
+ int ret;
+ sem_t sem_done;
#ifdef CONFIG_DEBUG
if (!wnd || !dest || !src || !origin)
@@ -124,7 +126,32 @@ int nx_bitmap(NXWINDOW hwnd, FAR const struct nxgl_rect_s *dest,
outmsg.origin.y = origin->y;
nxgl_rectcopy(&outmsg.dest, dest);
+
+ /* Create a semaphore for tracking command completion */
+
+ outmsg.sem_done = &sem_done;
+ ret = sem_init(&sem_done, 0, 0);
+
+ if (ret != OK)
+ {
+ gdbg("sem_init failed: %d\n", errno);
+ return ret;
+ }
+
/* Forward the fill command to the server */
- return nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_bitmap_s));
+ ret = nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_bitmap_s));
+
+ /* Wait that the command is completed, so that caller can release the buffer. */
+
+ if (ret == OK)
+ {
+ ret = sem_wait(&sem_done);
+ }
+
+ /* Destroy the semaphore and return. */
+
+ sem_destroy(&sem_done);
+
+ return ret;
}