summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nuttx/graphics/nxbe/nxbe.h2
-rw-r--r--nuttx/graphics/nxbe/nxbe_filltrapezoid.c38
-rw-r--r--nuttx/graphics/nxmu/nx_filltrapezoid.c13
-rw-r--r--nuttx/graphics/nxmu/nxfe.h1
-rw-r--r--nuttx/graphics/nxmu/nxmu_server.c2
-rw-r--r--nuttx/graphics/nxsu/nx_filltrapezoid.c6
-rw-r--r--nuttx/include/nuttx/nx.h4
7 files changed, 49 insertions, 17 deletions
diff --git a/nuttx/graphics/nxbe/nxbe.h b/nuttx/graphics/nxbe/nxbe.h
index 1ba2aca61..bcfcb3e25 100644
--- a/nuttx/graphics/nxbe/nxbe.h
+++ b/nuttx/graphics/nxbe/nxbe.h
@@ -311,6 +311,7 @@ EXTERN void nxbe_fill(FAR struct nxbe_window_s *wnd,
*
* Input Parameters:
* wnd - The window structure reference
+ * clip - Clipping region (may be null)
* rect - The location to be filled
* col - The color to use in the fill
*
@@ -320,6 +321,7 @@ EXTERN void nxbe_fill(FAR struct nxbe_window_s *wnd,
****************************************************************************/
EXTERN void nxbe_filltrapezoid(FAR struct nxbe_window_s *wnd,
+ FAR const struct nxgl_rect_s *clip,
FAR const struct nxgl_trapezoid_s *trap,
nxgl_mxpixel_t color[CONFIG_NX_NPLANES]);
diff --git a/nuttx/graphics/nxbe/nxbe_filltrapezoid.c b/nuttx/graphics/nxbe/nxbe_filltrapezoid.c
index 78445e7f9..d314fec30 100644
--- a/nuttx/graphics/nxbe/nxbe_filltrapezoid.c
+++ b/nuttx/graphics/nxbe/nxbe_filltrapezoid.c
@@ -101,7 +101,8 @@ static void nxbe_clipfilltrapezoid(FAR struct nxbe_clipops_s *cops,
*
* Input Parameters:
* wnd - The window structure reference
- * rect - The location to be filled
+ * clip - Clipping region (in relative window coordinates)
+ * rect - The location to be filled (in relative window coordinates)
* col - The color to use in the fill
*
* Return:
@@ -110,11 +111,11 @@ static void nxbe_clipfilltrapezoid(FAR struct nxbe_clipops_s *cops,
****************************************************************************/
void nxbe_filltrapezoid(FAR struct nxbe_window_s *wnd,
+ FAR const struct nxgl_rect_s *clip,
FAR const struct nxgl_trapezoid_s *trap,
nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
{
struct nxbe_filltrap_s info;
- struct nxgl_rect_s bounds;
struct nxgl_rect_s remaining;
int i;
@@ -131,30 +132,43 @@ void nxbe_filltrapezoid(FAR struct nxbe_window_s *wnd,
nxgl_trapoffset(&info.trap, trap, wnd->origin.x, wnd->origin.y);
- /* Now create a bounding box that contains the trapezoid */
+ /* Create a bounding box that contains the trapezoid */
- bounds.pt1.x = b16toi(ngl_min(info.trap.top.x1, info.trap.bot.x1));
- bounds.pt1.y = b16toi(info.trap.top.y);
- bounds.pt2.x = b16toi(ngl_max(info.trap.top.x2, info.trap.bot.x2));
- bounds.pt2.y = b16toi(info.trap.bot.y);
+ remaining.pt1.x = b16toi(ngl_min(info.trap.top.x1, info.trap.bot.x1));
+ remaining.pt1.y = b16toi(info.trap.top.y);
+ remaining.pt2.x = b16toi(ngl_max(info.trap.top.x2, info.trap.bot.x2));
+ remaining.pt2.y = b16toi(info.trap.bot.y);
+
+ /* Clip to any user specified clipping window */
+
+ if (clip && !nxgl_nullrect(clip))
+ {
+ struct nxgl_rect_s tmp;
+ nxgl_rectoffset(&tmp, clip, wnd->origin.x, wnd->origin.y);
+ nxgl_rectintersect(&remaining, &remaining, &tmp);
+ }
/* Clip to the limits of the window and of the background screen */
- nxgl_rectintersect(&remaining, &bounds, &wnd->bounds);
+ nxgl_rectintersect(&remaining, &remaining, &wnd->bounds);
nxgl_rectintersect(&remaining, &remaining, &wnd->be->bkgd.bounds);
if (!nxgl_nullrect(&remaining))
{
+ info.cops.visible = nxbe_clipfilltrapezoid;
+ info.cops.obscured = nxbe_clipnull;
+
+ nxgl_trapcopy(&info.trap, trap);
+
+ /* Then process each color plane */
+
#if CONFIG_NX_NPLANES > 1
for (i = 0; i < wnd->be->vinfo.nplanes; i++)
#else
i = 0;
#endif
{
- info.cops.visible = nxbe_clipfilltrapezoid;
- info.cops.obscured = nxbe_clipnull;
- info.color = color[i];
-
+ info.color = color[i];
nxbe_clipper(wnd->above, &remaining, NX_CLIPORDER_DEFAULT,
&info.cops, &wnd->be->plane[i]);
}
diff --git a/nuttx/graphics/nxmu/nx_filltrapezoid.c b/nuttx/graphics/nxmu/nx_filltrapezoid.c
index 415305e7e..c55497bc2 100644
--- a/nuttx/graphics/nxmu/nx_filltrapezoid.c
+++ b/nuttx/graphics/nxmu/nx_filltrapezoid.c
@@ -40,6 +40,7 @@
#include <nuttx/config.h>
#include <sys/types.h>
+#include <string.h>
#include <mqueue.h>
#include <errno.h>
#include <debug.h>
@@ -80,6 +81,7 @@
*
* Input Parameters:
* hwnd - The window handle
+ * clip - Clipping region (may be null)
* trap - The trapezoidal region to be filled
* color - The color to use in the fill
*
@@ -88,7 +90,8 @@
*
****************************************************************************/
-int nx_filltrapezoid(NXWINDOW hwnd, FAR struct nxgl_trapezoid_s *trap,
+int nx_filltrapezoid(NXWINDOW hwnd, FAR const struct nxgl_rect_s *clip,
+ FAR const struct nxgl_trapezoid_s *trap,
nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
{
FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd;
@@ -109,6 +112,14 @@ int nx_filltrapezoid(NXWINDOW hwnd, FAR struct nxgl_trapezoid_s *trap,
outmsg.msgid = NX_SVRMSG_FILLTRAP;
outmsg.wnd = wnd;
+ if (clip)
+ {
+ nxgl_rectcopy(&outmsg.clip, clip);
+ }
+ else
+ {
+ memset(&outmsg.clip, 0, sizeof(struct nxgl_rect_s));
+ }
nxgl_trapcopy(&outmsg.trap, trap);
for (i = 0; i < CONFIG_NX_NPLANES; i++)
diff --git a/nuttx/graphics/nxmu/nxfe.h b/nuttx/graphics/nxmu/nxfe.h
index 9b8ff22ee..d5cf3279c 100644
--- a/nuttx/graphics/nxmu/nxfe.h
+++ b/nuttx/graphics/nxmu/nxfe.h
@@ -350,6 +350,7 @@ struct nxsvrmsg_filltrapezoid_s
{
uint32 msgid; /* NX_SVRMSG_FILLTRAP */
FAR struct nxbe_window_s *wnd; /* The window to fill */
+ FAR struct nxgl_rect_s clip; /* The clipping window */
struct nxgl_trapezoid_s trap; /* The trapezoidal region in the window to fill */
nxgl_mxpixel_t color[CONFIG_NX_NPLANES]; /* Color to use in the fill */
};
diff --git a/nuttx/graphics/nxmu/nxmu_server.c b/nuttx/graphics/nxmu/nxmu_server.c
index 1c6b9c94e..113eafe2c 100644
--- a/nuttx/graphics/nxmu/nxmu_server.c
+++ b/nuttx/graphics/nxmu/nxmu_server.c
@@ -444,7 +444,7 @@ int nx_runinstance(FAR const char *mqname, FAR struct fb_vtable_s *fb)
case NX_SVRMSG_FILLTRAP: /* Fill a trapezoidal region in the window with a color */
{
FAR struct nxsvrmsg_filltrapezoid_s *trapmsg = (FAR struct nxsvrmsg_filltrapezoid_s *)buffer;
- nxbe_filltrapezoid(trapmsg->wnd, &trapmsg->trap, trapmsg->color);
+ nxbe_filltrapezoid(trapmsg->wnd, &trapmsg->clip, &trapmsg->trap, trapmsg->color);
}
break;
case NX_SVRMSG_MOVE: /* Move a rectangular region within the window */
diff --git a/nuttx/graphics/nxsu/nx_filltrapezoid.c b/nuttx/graphics/nxsu/nx_filltrapezoid.c
index 0ba0bd7a1..ac105bd39 100644
--- a/nuttx/graphics/nxsu/nx_filltrapezoid.c
+++ b/nuttx/graphics/nxsu/nx_filltrapezoid.c
@@ -80,6 +80,7 @@
*
* Input Parameters:
* hwnd - The window handle
+ * clip - Clipping region (may be null)
* trap - The trapezoidal region to be filled
* color - The color to use in the fill
*
@@ -88,7 +89,8 @@
*
****************************************************************************/
-int nx_filltrapezoid(NXWINDOW hwnd, FAR struct nxgl_trapezoid_s *trap,
+int nx_filltrapezoid(NXWINDOW hwnd, FAR const struct nxgl_rect_s *clip,
+ FAR const struct nxgl_trapezoid_s *trap,
nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
{
#ifdef CONFIG_DEBUG
@@ -99,6 +101,6 @@ int nx_filltrapezoid(NXWINDOW hwnd, FAR struct nxgl_trapezoid_s *trap,
}
#endif
- nxbe_filltrapezoid((FAR struct nxbe_window_s *)hwnd, trap, color);
+ nxbe_filltrapezoid((FAR struct nxbe_window_s *)hwnd, clip, trap, color);
return OK;
}
diff --git a/nuttx/include/nuttx/nx.h b/nuttx/include/nuttx/nx.h
index fb4a07308..a5614caff 100644
--- a/nuttx/include/nuttx/nx.h
+++ b/nuttx/include/nuttx/nx.h
@@ -598,6 +598,7 @@ EXTERN int nx_fill(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
*
* Input Parameters:
* hwnd - The window handle
+ * clip - Clipping region (may be null)
* trap - The trapezoidal region to be filled
* color - The color to use in the fill
*
@@ -606,7 +607,8 @@ EXTERN int nx_fill(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
*
****************************************************************************/
-EXTERN int nx_filltrapezoid(NXWINDOW hwnd, FAR struct nxgl_trapezoid_s *trap,
+EXTERN int nx_filltrapezoid(NXWINDOW hwnd, FAR const struct nxgl_rect_s *clip,
+ FAR const struct nxgl_trapezoid_s *trap,
nxgl_mxpixel_t color[CONFIG_NX_NPLANES]);
/****************************************************************************