1
0
Fork 0
forked from nuttx/nuttx-update

Squashed commit of the following:

graphics:  nx_openwindow() and nxtk_openwindow() now accept an addtional 'flag' parameter.  This argument is not used at present but will, eventually enable a RAM backed, per-window framebuffer.

    graphics/Kconfig:  Add configuration to support a rambacked framebuffer. Current marked as EXPERIMENTAL because this is a work in progress.
This commit is contained in:
Gregory Nutt 2019-03-13 12:34:13 -06:00
parent 0454ae2a10
commit 8a46b1f488
13 changed files with 128 additions and 112 deletions

View file

@ -12,7 +12,7 @@
<h1><big><font color="#3c34ec">
<i>NX Graphics Subsystem</i>
</font></big></h1>
<p>Last Updated: March 10, 2019</p>
<p>Last Updated: March 13, 2019</p>
</td>
</tr>
</table>
@ -1348,7 +1348,7 @@ int nx_eventnotify(NXHANDLE handle, int signo);
#include &lt;nuttx/nx/nxglib.h&gt;
#include &lt;nuttx/nx/nx.h&gt;
NXWINDOW nx_openwindow(NXHANDLE handle,
NXWINDOW nx_openwindow(NXHANDLE handle, uint8_t flags,
FAR const struct nx_callback_s *cb,
FAR void *arg);
</pre></ul>
@ -1360,6 +1360,10 @@ NXWINDOW nx_openwindow(NXHANDLE handle,
<ul><dl>
<dt><code>handle</code>
<dd>The handle returned by <a href="#nxconnectinstance"><code>nx_connect()</code></a>.
<dt><code>flags</code>
<dd>Optional flags.
Must be zero unless <code>CONFIG_NX_RAMBACKED</code> is enabled.
In that case, it may be zero or <code>NXBE_WINDOW_RAMBACKED</code>.
<dt><code>cb</code>
<dd>Callbacks used to process window events
<dt><code>arg</code>
@ -2073,7 +2077,7 @@ typedef FAR void *NXTKWINDOW;
#include &lt;nuttx/nx/nx.h&gt;
#include &lt;nuttx/nx/nxtk.h&gt;
NXTKWINDOW nxtk_openwindow(NXHANDLE handle,
NXTKWINDOW nxtk_openwindow(NXHANDLE handle, uint8_t flags,
FAR const struct nx_callback_s *cb,
FAR void *arg);
</pre></ul>
@ -2085,6 +2089,10 @@ NXTKWINDOW nxtk_openwindow(NXHANDLE handle,
<dl>
<dt><code>handle</code>
<dd>The handle returned by <a href="#nxconnectinstance"><code>nx_connect()</code></a>.
<dt><code>flags</code>
<dd>Optional flags.
Must be zero unless <code>CONFIG_NX_RAMBACKED</code> is enabled.
In that case, it may be zero or <code>NXBE_WINDOW_RAMBACKED</code>.
<dt><code>cb</code>
<dd>Callbacks used to process window events
<dt><code>arg</code>
@ -3243,7 +3251,20 @@ int nxf_convert_32bpp(FAR uint32_t *dest, uint16_t height,
<ul>
<dl>
<dt><code>CONFIG_NX</code>
Enables overall support for graphics library and NX
<dd>Enables overall support for graphics library and NX
<dt><code>CONFIG_NX_RAMBACKED</code>
<dd>Enables RAM backed window support.
If this option is selected, then windows may be optionally created with a RAM frambuffer backing up the window content.
Rending into the window will result in rending into the backup framebuffer, then updating the physical display from the framebuffer.
<p>
The advantage of this option is that the application that manages window will no longer receive redraw() callbacks.
Those calls normally occur, for example, when a window "above" moves exposing a portion of the window below.
If this option is selected, then the system will redraw the exposed portion of the window from the backup framebuffer without intervention of the window applications.
This greatly reduces the complexity of the application and performance of the window at the expense of increased memory usage.
</p>
<p>
Redraw requests in other cases are also suppressed: Changes to window position, size, etc.
</p>
</dl>
</ul>

View file

@ -42,6 +42,28 @@ config NX_NPLANES
are willing to debug a lot of untested logic), this value should be
set to 1.
config NX_RAMBACKED
bool "RAM backed windows"
default n
depends on EXPERIMENTAL
---help---
If this option is selected, then windows may be optionally created
with a RAM frambuffer backing up the window content. Rending into
the window will result in rending into the backup framebuffer, then
updating the physical display from the framebuffer.
The advantage of this option is that the application that manages
window will no longer receive redraw() callbacks. Those calls
normally occur when a window "above" moves exposing a portion of the
window below. If this option is selected, then the system will
redraw the exposed portion of the window from the backup framebuffer
without intervention of the window applications. This greatly
reduces the complexity of the application and performance of the
window at the expense of increased memory usage.
Redraw requests in other cases are also suppressed: Changes to window
position, size, etc.
config NX_BGCOLOR
hex "Initial background color"
default 0x0

View file

@ -1,7 +1,7 @@
/****************************************************************************
* graphics/nxmu/nxmu_openwindow.c
*
* Copyright (C) 2008-2011 Gregory Nutt. All rights reserved.
* Copyright (C) 2008-2011, 2019 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -42,26 +42,6 @@
#include <nuttx/nx/nx.h>
#include "nxmu.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
@ -84,12 +64,13 @@
void nxmu_openwindow(FAR struct nxbe_state_s *be, FAR struct nxbe_window_s *wnd)
{
/* The window structure was allocated in nx_openwindow and all fields have
* been set to zero cb and conn which were initialized on the client side.
* On the server side, we need only initialize a few more the non zero fields
* and insert the new window at the top of the display.
* been set to zero; conn, flags, cb, and arg which were initialized on
* the client side. On the server side, we need only initialize a few
* more the non zero fields and insert the new window at the top of the
* display.
*/
wnd->be = be;
wnd->be = be;
/* Now, insert the new window at the top on the display. topwind is
* never NULL (it may point only at the background window, however)
@ -105,9 +86,9 @@ void nxmu_openwindow(FAR struct nxbe_state_s *be, FAR struct nxbe_window_s *wnd)
nxmu_reportposition(wnd);
#ifdef CONFIG_NX_XYINPUT
/* Provide the initial mouse settings to the client */
#ifdef CONFIG_NX_XYINPUT
nxmu_mousereport(wnd);
#endif
}

View file

@ -1,7 +1,8 @@
/****************************************************************************
* include/nuttx/nx/nx.h
*
* Copyright (C) 2008-2011, 2015, 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2008-2011, 2015, 2017, 2019 Gregory Nutt. All rights
* reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -379,6 +380,9 @@ int nx_eventnotify(NXHANDLE handle, int signo);
*
* Input Parameters:
* handle - The handle returned by nx_connect()
* flags - Optional flags. Must be zero unless CONFIG_NX_RAMBACKED is
* enabled. In that case, it may be zero or
* NXBE_WINDOW_RAMBACKED
* cb - Callbacks used to process window events
* arg - User provided value that will be returned with NX callbacks.
*
@ -388,8 +392,8 @@ int nx_eventnotify(NXHANDLE handle, int signo);
*
****************************************************************************/
NXWINDOW nx_openwindow(NXHANDLE handle, FAR const struct nx_callback_s *cb,
FAR void *arg);
NXWINDOW nx_openwindow(NXHANDLE handle, uint8_t flags,
FAR const struct nx_callback_s *cb, FAR void *arg);
/****************************************************************************
* Name: nx_closewindow
@ -908,6 +912,9 @@ void nx_redrawreq(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect);
* Input Parameters:
* handle - The handle returned by nx_connect
* hwnd - The pre-allocated window structure.
* flags - Optional flags. Must be zero unless CONFIG_NX_RAMBACKED is
* enabled. In that case, it may be zero or
* NXBE_WINDOW_RAMBACKED
* cb - Callbacks used to process window events
* arg - User provided value that will be returned with NX callbacks.
*
@ -917,7 +924,7 @@ void nx_redrawreq(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect);
*
****************************************************************************/
int nx_constructwindow(NXHANDLE handle, NXWINDOW hwnd,
int nx_constructwindow(NXHANDLE handle, NXWINDOW hwnd, uint8_t flags,
FAR const struct nx_callback_s *cb, FAR void *arg);
#undef EXTERN

View file

@ -1,7 +1,8 @@
/****************************************************************************
* include/nuttx/nx/nxbe.h
*
* Copyright (C) 2008-2011, 2013, 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2008-2011, 2013, 2017, 2019 Gregory Nutt. All rights
* reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -62,13 +63,32 @@
#endif
/* NXBE Definitions *********************************************************/
/* Window flags and helper macros */
#define NXBE_WINDOW_BLOCKED (1 << 0) /* The window is blocked and will not
* receive further input. */
/* Window flags and helper macros:
*
* NXBE_WINDOW_BLOCKED - Window input is blocked (internal use only)
* NXBE_WINDOW_RAMBACKED - Window is backed by a framebuffer
*/
#define NXBE_ISBLOCKED(wnd) (((wnd)->flags & NXBE_WINDOW_BLOCKED) != 0)
#define NXBE_SETBLOCKED(wnd) do { (wnd)->flags |= NXBE_WINDOW_BLOCKED; } while (0)
#define NXBE_WINDOW_BLOCKED (1 << 0) /* The window is blocked and will not
* receive further input. */
#define NXBE_WINDOW_RAMBACKED (1 << 1) /* Window is backed by a framebuffer */
#ifdef CONFIG_NX_RAMBACKED
# define NXBE_WINDOW_USER NXBE_WINDOW_RAMBACKED
#else
# define NXBE_WINDOW_USER 0
#endif
#define NXBE_ISBLOCKED(wnd) \
(((wnd)->flags & NXBE_WINDOW_BLOCKED) != 0)
#define NXBE_SETBLOCKED(wnd) \
do { (wnd)->flags |= NXBE_WINDOW_BLOCKED; } while (0)
#define NXBE_ISRAMBACKED(wnd) \
(((wnd)->flags & NXBE_WINDOW_RAMBACKED) != 0)
#define NXBE_SETRAMBACKED(wnd) \
do { (wnd)->flags |= NXBE_WINDOW_RAMBACKED; } while (0)
/****************************************************************************
* Public Types

View file

@ -1,7 +1,7 @@
/****************************************************************************
* include/nuttx/nx/nxmu.h
*
* Copyright (C) 2008-2013 Gregory Nutt. All rights reserved.
* Copyright (C) 2008-2013, 2019 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without

View file

@ -1,7 +1,7 @@
/****************************************************************************
* include/nuttx/nx/nxtk.h
*
* Copyright (C) 2008-2012, 2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2008-2012, 2015, 2019 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -122,6 +122,9 @@ extern "C"
*
* Input Parameters:
* handle - The handle returned by nx_connect
* flags - Optional flags. Must be zero unless CONFIG_NX_RAMBACKED is
* enabled. In that case, it may be zero or
* NXBE_WINDOW_RAMBACKED
* cb - Callbacks used to process window events
* arg - User provided value that will be returned with NXTK callbacks.
*
@ -131,8 +134,9 @@ extern "C"
*
****************************************************************************/
NXTKWINDOW nxtk_openwindow(NXHANDLE handle,
FAR const struct nx_callback_s *cb, FAR void *arg);
NXTKWINDOW nxtk_openwindow(NXHANDLE handle, uint8_t flags,
FAR const struct nx_callback_s *cb,
FAR void *arg);
/****************************************************************************
* Name: nxtk_closewindow

View file

@ -49,6 +49,7 @@
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/* Named indices into the 16 circle points generated by nxgl_circlepts */
#define POINT_0p0 0
@ -69,22 +70,6 @@
#define POINT_337p5 15
#define NCIRCLE_POINTS 16
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/

View file

@ -46,26 +46,6 @@
#include <nuttx/nx/nxglib.h>
#include <nuttx/nx/nx.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/

View file

@ -52,22 +52,6 @@
#define NCIRCLE_TRAPS 8
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/

View file

@ -1,7 +1,7 @@
/****************************************************************************
* libs/libnx/nxmu/nx_constsructwindow.c
*
* Copyright (C) 2008, 2011-2013 Gregory Nutt. All rights reserved.
* Copyright (C) 2008, 2011-2013, 2019 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -72,6 +72,9 @@
* Input Parameters:
* handle - The handle returned by nx_connect
* hwnd - The pre-allocated window structure.
* flags - Optional flags. Must be zero unless CONFIG_NX_RAMBACKED is
* enabled. In that case, it may be zero or
* NXBE_WINDOW_RAMBACKED
* cb - Callbacks used to process window events
* arg - User provided value that will be returned with NX callbacks.
*
@ -81,7 +84,7 @@
*
****************************************************************************/
int nx_constructwindow(NXHANDLE handle, NXWINDOW hwnd,
int nx_constructwindow(NXHANDLE handle, NXWINDOW hwnd, uint8_t flags,
FAR const struct nx_callback_s *cb, FAR void *arg)
{
FAR struct nxmu_conn_s *conn = (FAR struct nxmu_conn_s *)handle;
@ -89,13 +92,13 @@ int nx_constructwindow(NXHANDLE handle, NXWINDOW hwnd,
struct nxsvrmsg_openwindow_s outmsg;
#ifdef CONFIG_DEBUG_FEATURES
if (!wnd)
if (wnd == NULL)
{
set_errno(EINVAL);
return ERROR;
}
if (!conn || !cb)
if (conn == NULL || cb == NULL || (flags & ~NXBE_WINDOW_USER) != 0)
{
lib_ufree(wnd);
set_errno(EINVAL);
@ -103,11 +106,12 @@ int nx_constructwindow(NXHANDLE handle, NXWINDOW hwnd,
}
#endif
/* Setup only the connection structure, callbacks and client private data
* reference. The server will set everything else up.
/* Setup only the connection structure, user flags, callbacks and client
* private data reference. The server will set everything else up.
*/
wnd->conn = conn;
wnd->flags = flags;
wnd->cb = cb;
wnd->arg = arg;

View file

@ -1,7 +1,8 @@
/****************************************************************************
* libs/libnx/nxmu/nx_openwindow.c
*
* Copyright (C) 2008-2009, 2011-2013 Gregory Nutt. All rights reserved.
* Copyright (C) 2008-2009, 2011-2013, 2019 Gregory Nutt. All rights
* reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -60,6 +61,9 @@
*
* Input Parameters:
* handle - The handle returned by nx_connect
* flags - Optional flags. Must be zero unless CONFIG_NX_RAMBACKED is
* enabled. In that case, it may be zero or
* NXBE_WINDOW_RAMBACKED
* cb - Callbacks used to process window events
* arg - User provided value that will be returned with NX callbacks.
*
@ -69,8 +73,8 @@
*
****************************************************************************/
NXWINDOW nx_openwindow(NXHANDLE handle, FAR const struct nx_callback_s *cb,
FAR void *arg)
NXWINDOW nx_openwindow(NXHANDLE handle, uint8_t flags,
FAR const struct nx_callback_s *cb, FAR void *arg)
{
FAR struct nxbe_window_s *wnd;
int ret;
@ -94,7 +98,7 @@ NXWINDOW nx_openwindow(NXHANDLE handle, FAR const struct nx_callback_s *cb,
/* Then let nx_constructwindow do the rest */
ret = nx_constructwindow(handle, (NXWINDOW)wnd, cb, arg);
ret = nx_constructwindow(handle, (NXWINDOW)wnd, flags, cb, arg);
if (ret < 0)
{
/* An error occurred, the window has been freed */
@ -109,4 +113,3 @@ NXWINDOW nx_openwindow(NXHANDLE handle, FAR const struct nx_callback_s *cb,
return (NXWINDOW)wnd;
}

View file

@ -1,7 +1,8 @@
/****************************************************************************
* libs/libnx/nxtk/nxtk_openwindow.c
*
* Copyright (C) 2008-2009, 2012-2013 Gregory Nutt. All rights reserved.
* Copyright (C) 2008-2009, 2012-2013, 2019 Gregory Nutt. All rights
* reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -88,6 +89,9 @@ nxgl_mxpixel_t g_bordercolor3[CONFIG_NX_NPLANES] =
*
* Input Parameters:
* handle - The handle returned by nx_connect
* flags - Optional flags. Must be zero unless CONFIG_NX_RAMBACKED is
* enabled. In that case, it may be zero or
* NXBE_WINDOW_RAMBACKED
* cb - Callbacks used to process window events
* arg - User provided value that will be returned with NXTK callbacks.
*
@ -97,7 +101,7 @@ nxgl_mxpixel_t g_bordercolor3[CONFIG_NX_NPLANES] =
*
****************************************************************************/
NXTKWINDOW nxtk_openwindow(NXHANDLE handle,
NXTKWINDOW nxtk_openwindow(NXHANDLE handle, uint8_t flags,
FAR const struct nx_callback_s *cb,
FAR void *arg)
{
@ -105,7 +109,7 @@ NXTKWINDOW nxtk_openwindow(NXHANDLE handle,
int ret;
#ifdef CONFIG_DEBUG_FEATURES
if (!handle || !cb)
if (handle == NULL || cb == NULL)
{
set_errno(EINVAL);
return NULL;
@ -117,7 +121,7 @@ NXTKWINDOW nxtk_openwindow(NXHANDLE handle,
fwnd = (FAR struct nxtk_framedwindow_s *)
lib_uzalloc(sizeof(struct nxtk_framedwindow_s));
if (!fwnd)
if (fwnd == NULL)
{
set_errno(ENOMEM);
return NULL;
@ -130,7 +134,8 @@ NXTKWINDOW nxtk_openwindow(NXHANDLE handle,
/* Then let nx_constructwindow do the rest */
ret = nx_constructwindow(handle, (NXWINDOW)&fwnd->wnd, &g_nxtkcb, NULL);
ret = nx_constructwindow(handle, (NXWINDOW)&fwnd->wnd, flags, &g_nxtkcb,
NULL);
if (ret < 0)
{
/* An error occurred, the window has been freed */