filltrapezoid needs a clipping rectangle

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1389 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2008-12-02 16:38:35 +00:00
parent 981d2a73be
commit fcb0515526
7 changed files with 49 additions and 17 deletions

View File

@ -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]);

View File

@ -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]);
}

View File

@ -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++)

View File

@ -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 */
};

View File

@ -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 */

View File

@ -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;
}

View File

@ -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]);
/****************************************************************************