Graphics backend

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1320 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2008-11-27 22:56:45 +00:00
parent f14b4b3942
commit 3ba6819bb9
15 changed files with 2529 additions and 0 deletions

41
graphics/nxbe/Make.defs Normal file
View file

@ -0,0 +1,41 @@
############################################################################
# graphics/nxbe/Make.defs
#
# Copyright (C) 2008 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name NuttX nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################
NXBE_ASRCS =
NXBE_CSRCS = nxbe_fbconfigure.c nxbe_colormap.c nxbe_clipper.c \
nxbe_closewindow.c \
nxbe_setposition.c nxbe_setsize.c nxbe_raise.c nxbe_lower.c \
nxbe_fill.c nxbe_move.c nxbe_bitmap.c \
nxbe_redraw.c nxbe_redrawbelow.c

413
graphics/nxbe/nxbe.h Normal file
View file

@ -0,0 +1,413 @@
/****************************************************************************
* graphics/nxbe/nxbe.h
*
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#ifndef __GRAPHICS_NXBE_NXBE_H
#define __GRAPHICS_NXBE_NXBE_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <nuttx/fb.h>
#include <nuttx/nxglib.h>
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
#ifndef CONFIG_NX_NPLANES
# define CONFIG_NX_NPLANES 1 /* Max number of color planes supported */
#endif
/* Mnemonics for indices */
#define NX_TOP_NDX (0)
#define NX_LEFT_NDX (1)
#define NX_RIGHT_NDX (2)
#define NX_BOTTOM_NDX (3)
/* These are the values for the clipping order provided to nx_clipper */
#define NX_CLIPORDER_TLRB (0) /* Top-left-right-bottom */
#define NX_CLIPORDER_TRLB (1) /* Top-right-left-bottom */
#define NX_CLIPORDER_BLRT (2) /* Bottom-left-right-top */
#define NX_CLIPORDER_BRLT (3) /* Bottom-right-left-top */
#define NX_CLIPORDER_DEFAULT NX_CLIPORDER_TLRB
/****************************************************************************
* Public Types
****************************************************************************/
/* Rasterization ************************************************************/
/* A tiny vtable of raster operation function pointers. The types of the
* function points must match the rasterizer types exported by nxglib
*/
struct nxbe_plane_s
{
/* Raster operation callbacks for this bits-per-pixel value */
void (*fillrectangle)(FAR struct fb_planeinfo_s *pinfo,
FAR const struct nxgl_rect_s *rect,
nxgl_mxpixel_t color);
void (*moverectangle)(FAR struct fb_planeinfo_s *pinfo,
FAR const struct nxgl_rect_s *rect,
FAR struct nxgl_point_s *offset);
void (*copyrectangle)(FAR struct fb_planeinfo_s *pinfo,
FAR const struct nxgl_rect_s *dest,
FAR const void *src,
FAR const struct nxgl_point_s *origin,
unsigned int srcstride);
/* Framebuffer plane info describing destination video plane */
struct fb_planeinfo_s pinfo;
};
/* Clipping *****************************************************************/
/* Clipping callback functions called nxbe_clipper for each visible and
* obscured region of a rectangle within a window.
*/
struct nxbe_clipops_s
{
void (*visible)(FAR struct nxbe_clipops_s *cops,
FAR struct nxbe_plane_s *plane,
FAR const struct nxgl_rect_s *rect);
void (*obscured)(FAR struct nxbe_clipops_s *cops,
FAR struct nxbe_plane_s *plane,
FAR const struct nxgl_rect_s *rect);
};
/* Windows ******************************************************************/
/* This structure represents one window. */
struct nxbe_state_s;
struct nxfe_conn_s;
struct nxbe_window_s
{
/* State information */
FAR struct nxbe_state_s *be; /* The back-end state structure */
#ifdef CONFIG_NX_MULTIUSER
FAR struct nxfe_conn_s *conn; /* Connection to the window client */
#endif
/* The following links provide the window's vertical position using a
* singly linked list.
*/
FAR struct nxbe_window_s *above; /* The window "above" this window */
FAR struct nxbe_window_s *below; /* The window "below this one */
struct nxgl_rect_s bounds; /* The bounding rectangle of window */
struct nxgl_point_s origin; /* The position of the top-left corner of the window */
};
/* Back-end state ***********************************************************/
/* This structure describes the overall back-end window state */
struct nxbe_state_s
{
/* The window list (with the background window always at the bottom) */
FAR struct nxbe_window_s *topwnd; /* The window at the top of the display */
struct nxbe_window_s bkgd; /* The background window is always at the bottom */
/* vinfo describes the video controller and plane[n].pinfo describes color
* plane 'n' supported by the video controller. Most common color models
* fit in one plane, but this array provides future support for hardware
* with planar YUV types with 3 or 4 color planes.
*/
struct fb_videoinfo_s vinfo;
/* Rasterizing functions selected to match the BPP reported in pinfo[] */
struct nxbe_plane_s plane[CONFIG_NX_NPLANES];
};
/****************************************************************************
* Public Data
****************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C" {
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nxbe_colormap
*
* Description:
* Set the harware color map to the palette expected by NX
*
****************************************************************************/
#if CONFIG_FB_CMAP
EXTERN int nxbe_colormap(FAR const fb_vtable_s *fb);
#endif
/****************************************************************************
* Name: nx_fbconfigure
*
* Description:
* Configure the back end state structure based on information from the
* framebuffer driver
*
****************************************************************************/
EXTERN int nxbe_fbconfigure(FAR struct fb_vtable_s *fb,
FAR struct nxbe_state_s *be);
/****************************************************************************
* Name: nxbe_closewindow
*
* Description:
* Close an existing window
*
* Input Parameters:
* wnd - The window to be closed (and deallocated)
*
* Return:
* None
*
****************************************************************************/
EXTERN void nxbe_closewindow(struct nxbe_window_s *wnd);
/****************************************************************************
* Name: nxbe_setposition
*
* Descripton:
* This function checks for intersections and redraws the display after
* a change in the position of a window.
*
****************************************************************************/
EXTERN void nxbe_setposition(FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_point_s *pos);
/****************************************************************************
* Name: nxbe_setsize
*
* Descripton:
* This function checks for intersections and redraws the display after
* a change in the size of a window.
*
****************************************************************************/
EXTERN void nxbe_setsize(FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_rect_s *size);
/****************************************************************************
* Name: nxbe_raise
*
* Description:
* Bring the specified window to the top of the display.
*
****************************************************************************/
EXTERN void nxbe_raise(FAR struct nxbe_window_s *wnd);
/****************************************************************************
* Name: nxbe_lower
*
* Description:
* Lower the specified window to the bottom of the display.
*
****************************************************************************/
EXTERN void nxbe_lower(FAR struct nxbe_window_s *wnd);
/****************************************************************************
* Name: nxbe_fill
*
* Description:
* Fill the specified rectangle in the window with the specified color
*
* Input Parameters:
* wnd - The window structure reference
* rect - The location to be filled
* col - The color to use in the fill
*
* Return:
* None
*
****************************************************************************/
EXTERN void nxbe_fill(FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_rect_s *rect,
nxgl_mxpixel_t color[CONFIG_NX_NPLANES]);
/****************************************************************************
* Name: nxbe_move
*
* Description:
* Move a rectangular region within the window
*
* Input Parameters:
* wnd - The window within which the move is to be done
* rect - Describes the rectangular region to move
* offset - The offset to move the region
*
* Return:
* None
*
****************************************************************************/
EXTERN void nxbe_move(FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_rect_s *rect,
FAR const struct nxgl_point_s *offset);
/****************************************************************************
* Name: nxbe_bitmap
*
* Description:
* Copy a rectangular region of a larger image into the rectangle in the
* specified window.
*
* Input Parameters:
* wnd - The window that will receive the bitmap image
* dest - Describes the rectangular on the display that will receive the
* the bit map.
* src - The start of the source image.
* origin - The origin of the upper, left-most corner of the full bitmap.
* Both dest and origin are in window coordinates, however, origin
* may lie outside of the display.
* stride - The width of the full source image in pixels.
*
* Return:
* OK on success; ERROR on failure with errno set appropriately
*
****************************************************************************/
EXTERN void nxbe_bitmap(FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_rect_s *dest,
FAR const void *src[CONFIG_NX_NPLANES],
FAR const struct nxgl_point_s *origin,
unsigned int stride);
/****************************************************************************
* Name: nxbe_redraw
*
* Descripton:
* Re-draw the visible portions of the rectangular region for the
* specified window
*
****************************************************************************/
EXTERN void nxbe_redraw(FAR struct nxbe_state_s *be,
FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_rect_s *rect);
/****************************************************************************
* Name: nxbe_redrawbelow
*
* Descripton:
* Re-draw the visible portions of the rectangular region for all windows
* below (and including) the specified window. This function is called
* whenever a window is closed, moved, lowered or re-sized in order to
* expose newly visible portions of lower windows.
*
****************************************************************************/
EXTERN void nxbe_redrawbelow(FAR struct nxbe_state_s *be,
FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_rect_s *rect);
/****************************************************************************
* Name: nxbe_clipper
*
* Descripton:
* Perform flexible clipping operations. Callbacks are executed for
* each oscured and visible portions of the window.
*
* Input Parameters:
* wnd - The window to be clipped.
* rect - The region of concern within the window
* order - Specifies the order to process the parts of the non-intersecting
* sub-rectangles.
* cops - The callbacks to handle obscured and visible parts of the
* sub-rectangles.
* plane - The raster operations to be used by the callback functions.
* These may vary with different color formats.
*
* Returned Value:
* None
*
****************************************************************************/
EXTERN void nxbe_clipper(FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_rect_s *dest, ubyte order,
FAR struct nxbe_clipops_s *cops,
FAR struct nxbe_plane_s *plane);
/****************************************************************************
* Name: nxbe_clipnull
*
* Descripton:
* The do-nothing clipping callback function
*
****************************************************************************/
EXTERN void nxbe_clipnull(FAR struct nxbe_clipops_s *cops,
FAR struct nxbe_plane_s *plane,
FAR const struct nxgl_rect_s *rect);
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __GRAPHICS_NXBE_NXBE_H */

184
graphics/nxbe/nxbe_bitmap.c Normal file
View file

@ -0,0 +1,184 @@
/****************************************************************************
* graphics/nxbe/nxbe_bitmap.c
*
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/nxglib.h>
#include "nxbe.h"
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
struct nx_bitmap_s
{
struct nxbe_clipops_s cops;
FAR const void *src; /* The start of the source image. */
struct nxgl_point_s origin; /* Offset into the source image data */
unsigned int stride; /* The width of the full source image in pixels. */
};
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: nxs_clipcopy
*
* Description:
* Called from nxbe_clipper() to performed the fill operation on visible portions
* of the rectangle.
*
****************************************************************************/
static void nxs_clipcopy(FAR struct nxbe_clipops_s *cops,
FAR struct nxbe_plane_s *plane,
FAR const struct nxgl_rect_s *rect)
{
struct nx_bitmap_s *bminfo = (struct nx_bitmap_s *)cops;
plane->copyrectangle(&plane->pinfo, rect, bminfo->src,
&bminfo->origin, bminfo->stride);
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nxbe_bitmap
*
* Description:
* Copy a rectangular region of a larger image into the rectangle in the
* specified window.
*
* Input Parameters:
* wnd - The window that will receive the bitmap image
* dest - Describes the rectangular on the display that will receive the
* the bit map.
* src - The start of the source image.
* origin - The origin of the upper, left-most corner of the full bitmap.
* Both dest and origin are in window coordinates, however, origin
* may lie outside of the display.
* stride - The width of the full source image in pixels.
*
* Return:
* OK on success; ERROR on failure with errno set appropriately
*
****************************************************************************/
void nxbe_bitmap(FAR struct nxbe_window_s *wnd, FAR const struct nxgl_rect_s *dest,
FAR const void *src[CONFIG_NX_NPLANES],
FAR const struct nxgl_point_s *origin, unsigned int stride)
{
struct nx_bitmap_s info;
struct nxgl_rect_s remaining;
int i;
#ifdef CONFIG_DEBUG
if (!wnd || !dest || !src || !origin)
{
return;
}
#endif
/* Verify that the destination rectangle begins "below" and to the "right"
* of the origin
*/
if (dest->pt1.x < origin->x || dest->pt1.y < origin->y)
{
gdbg("Bad dest start position\n");
return;
}
/* Verify that the width of the destination rectangle does not exceed the
* with of the source bitmap data
*/
if ((((dest->pt2.x - origin->x) * wnd->be->plane[0].pinfo.bpp) >> 3) > stride)
{
gdbg("Bad dest width\n");
return;
}
/* Clip to the limits of the window and of the background screen */
nxgl_rectintersect(&remaining, dest, &wnd->bounds);
nxgl_rectintersect(&remaining, &remaining, &wnd->be->bkgd.bounds);
if (nxgl_nullrect(&remaining))
{
return;
}
/* Then perform the clipped fill */
#if CONFIG_NX_NPLANES > 1
for (i = 0; i < wnd->be->vinfo.nplanes; i++)
#else
i = 0;
#endif
{
info.cops.visible = nxs_clipcopy;
info.cops.obscured = nxbe_clipnull;
info.src = src[i];
info.origin.x = origin->x;
info.origin.y = origin->y;
info.stride = stride;
nxbe_clipper(wnd->above, &remaining, NX_CLIPORDER_DEFAULT,
&info.cops, &wnd->be->plane[i]);
}
}

View file

@ -0,0 +1,277 @@
/****************************************************************************
* graphics/nxbe/nxbe_clipper.c
*
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <stdlib.h>
#include <debug.h>
#include <nuttx/nxglib.h>
#include "nxbe.h"
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
#define NX_INITIAL_STACKSIZE (32)
/****************************************************************************
* Private Types
****************************************************************************/
/* This structure is a container that retains an associated between a
* window instance and a rectangle.
*/
struct nxbe_cliprect_s
{
FAR struct nxbe_window_s *wnd;
struct nxgl_rect_s rect;
};
/* This is the stack of pending clip operations */
struct nxbe_clipstack_s
{
uint16 npushed; /* Number of deferred rectangles in stack */
uint16 mxrects; /* The capacity of the stack */
struct nxbe_cliprect_s *stack; /* The stack of deferred rectangles */
};
/****************************************************************************
* Private Data
****************************************************************************/
static const ubyte g_nxcliporder[4][4] =
{
{ NX_TOP_NDX, NX_LEFT_NDX, NX_RIGHT_NDX, NX_BOTTOM_NDX }, /* index = NX_CLIPORDER_TLRB */
{ NX_TOP_NDX, NX_RIGHT_NDX, NX_LEFT_NDX, NX_BOTTOM_NDX }, /* NX_CLIPORDER_TRLB */
{ NX_BOTTOM_NDX, NX_LEFT_NDX, NX_RIGHT_NDX, NX_TOP_NDX }, /* NX_CLIPORDER_BLRT */
{ NX_BOTTOM_NDX, NX_RIGHT_NDX, NX_LEFT_NDX, NX_TOP_NDX } /* NX_CLIPORDER_BRLT */
};
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: nxbe_pushrectangle
****************************************************************************/
static inline void nxbe_pushrectangle(FAR struct nxbe_clipstack_s *stack,
FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_rect_s *rect)
{
/* Check if there is room on the stack to hold another rectangle */
if ((stack->npushed + 1) > stack->mxrects)
{
/* No then we will need to reallocate the stack to hole more */
int mxrects = stack->mxrects ? 2 * stack->mxrects : NX_INITIAL_STACKSIZE;
struct nxbe_cliprect_s *newstack;
newstack = realloc(stack->stack, sizeof(struct nxbe_cliprect_s) * mxrects);
if (!newstack)
{
gdbg("Failed to reallocate stack\n");
return;
}
stack->stack = newstack;
stack->mxrects = mxrects;
}
/* Then push the new rectangle onto the stack */
stack->stack[stack->npushed].wnd = wnd;
nxgl_rectcopy(&stack->stack[stack->npushed].rect, rect);
stack->npushed++;
}
/****************************************************************************
* Name: nxbe_poprectangle
****************************************************************************/
static inline boolean nxbe_poprectangle(struct nxbe_clipstack_s *stack,
FAR struct nxbe_window_s **wnd,
struct nxgl_rect_s *rect)
{
if(stack->npushed > 0)
{
stack->npushed--;
*wnd = stack->stack[stack->npushed].wnd;
nxgl_rectcopy(rect, &stack->stack[stack->npushed].rect);
return TRUE;
}
return FALSE;
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nxbe_clipper
*
* Descripton:
* Perform flexible clipping operations. Callbacks are executed for
* each oscured and visible portions of the window.
*
* Input Parameters:
* wnd - The window to be clipped.
* rect - The region of concern within the window
* order - Specifies the order to process the parts of the non-intersecting
* sub-rectangles.
* cops - The callbacks to handle obscured and visible parts of the
* sub-rectangles.
* plane - The raster operations to be used by the callback functions.
* These may vary with different color formats.
*
* Returned Value:
* None
*
****************************************************************************/
void nxbe_clipper(FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_rect_s *dest, ubyte order,
FAR struct nxbe_clipops_s *cops,
FAR struct nxbe_plane_s *plane)
{
struct nxbe_clipstack_s stack;
FAR struct nxbe_window_s *currw;
struct nxgl_rect_s rect;
struct nxgl_rect_s obscuredrect;
struct nxgl_rect_s currbounds;
struct nxgl_rect_s nonoverlapped[4];
int i;
/* Initialize the stack where we will keep deferred rectangle operations */
stack.npushed = 0;
stack.mxrects = 0;
stack.stack = NULL;
/* Loop until there are no further pending operations */
nxgl_rectcopy(&rect, dest); /* Start with the whole dest rectangle */
do
{
/* Loop for every window from the current window and above. Only windows
* above the current window can obscure the current window
*/
for (currw = wnd; currw; currw = currw->above)
{
/* Does the current window overlap the dest rectangle? */
currbounds = currw->bounds;
if (nxgl_rectoverlap(&rect, &currbounds))
{
/* Yes.. then it obscures all or part of the dest rectangle.
* Divide the potentially visible, non-overlapping regions into 4
* smaller rectangles and push them onto the stack for processing
* on the next time through the outer loop.
*/
nxgl_nonintersecting(nonoverlapped, &rect, &currbounds);
for (i = 3; i >= 0; i--)
{
/* Push the rectangles in the order specific by the input
* argument of that name.
*/
struct nxgl_rect_s *candidate = &nonoverlapped[g_nxcliporder[order][i]];
if (!nxgl_nullrect(candidate))
{
nxbe_pushrectangle(&stack, currw->above, candidate);
}
}
/* Now performed any required processing on the obscurred,
* overlapped region.
*/
nxgl_rectintersect(&obscuredrect, &rect, &currbounds);
cops->obscured(cops, plane, &obscuredrect);
/* Break out of the loop to process the pushed rectangles */
break;
}
}
/* If there are no other windows overlapping this rectangle, then this
* rectangular region must be visible.
*/
if (!currw && !nxgl_nullrect(&rect))
{
cops->visible(cops, plane, &rect);
}
}
while (nxbe_poprectangle(&stack, &wnd, &rect));
/* Done! If any stack was allocated, then free it before exit-ting */
if (stack.stack)
{
free(stack.stack);
}
}
/****************************************************************************
* Name: nxbe_clipnull
*
* Descripton:
* The do-nothing clipping callback function
*
****************************************************************************/
void nxbe_clipnull(FAR struct nxbe_clipops_s *cops,
FAR struct nxbe_plane_s *plane,
FAR const struct nxgl_rect_s *rect)
{
}

View file

@ -0,0 +1,129 @@
/****************************************************************************
* graphics/nxbe/nxbe_closewindow.c
*
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <stdlib.h>
#include <assert.h>
#include <debug.h>
#include <nuttx/nx.h>
#include "nxfe.h"
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nxbe_closewindow
*
* Description:
* Close an existing window
*
* Input Parameters:
* wnd - The window to be closed (and deallocated)
*
* Return:
* None
*
****************************************************************************/
void nxbe_closewindow(struct nxbe_window_s *wnd)
{
FAR struct nxbe_state_s *be = wnd->be;
#ifdef CONFIG_DEBUG
if (!wnd)
{
return;
}
/* The background window should never be closed */
DEBUGASSERT(wnd != &be->bkgd);
#endif
/* Is there a window above the one being closed? */
if (wnd->above)
{
/* Yes, now the window below that on is the window below
* the one being closed.
*/
wnd->above->below = wnd->below;
}
else
{
/* No, then the top window is the one below this (which
* can never be NULL because the background window is
* always at the true bottom of the list
*/
be->topwnd = wnd->below;
}
/* There is always a window below the one being closed (because
* the background is never closed. Now, the window above that
* is the window above the one that is being closed.
*/
wnd->below->above = wnd->above;
free(wnd);
}

View file

@ -0,0 +1,147 @@
/****************************************************************************
* graphics/nxbe/nxbe_colormap.c
*
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <errno.h>
#include <debug.h>
#include "nxbe.h"
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nxbe_colormap
*
* Description:
* Set the harware color map to the palette expected by NX
*
****************************************************************************/
#if CONFIG_FB_CMAP
int nxbe_colormap(FAR const fb_vtable_s *fb)
{
struct fb_cmap cmap;
ubyte *alloc;
ubyte *red;
ubyte *green;
ubyte *blue;
ubyte rval;
ubyte gval;
int size;
int ndx;
int ret;
int i, j, k;
/* Allocate the color map tables */
size = 3 * NX_NCOLORS * sizeof(uint16);
alloc = (ubyte*)malloc(size);
if (alloc < 0)
{
return -ENOMEM;
}
memset(alloc, 0xff, size);
red = alloc;
green = &alloc[NX_NCOLORS];
blue = &alloc[2*NX_NCOLORS];
/* Initialize the color map tables. 6*6*6 = 216, the rest
* are (0xffff, 0xffff, 0xffff)
*/
ndx = 0;
for (i = 0; i < 6; i++)
{
rval = (i * (NX_NCOLORS-1) / 5) << 8;
for (j = 0; j < 6; j++)
{
gval = (j * (NX_NCOLORS-1) / 5) << 8;
for (k = 0; k < 6; k++)
{
red[ndx] = rval;
green[ndx] = gval;
blue[ndx] = k * (NX_NCOLORS-1) / 5;
ndx++;
}
}
}
/* Now configure the cmap structure */
cmap.len = NX_NCOLORS;
cmap.red = red;
cmap.green = green;
cmap.blue = blue;
#ifdef CONFIG_FB_TRANSPARENCY
cmap.transp = NULL;
#endif
/* Then set the color map */
ret =fb->putcmap(fb, &cmap);
free(cmap);
return ret;
}
#endif

View file

@ -0,0 +1,196 @@
/****************************************************************************
* graphics/nxbe/nxbe_fbconfigure.c
*
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <errno.h>
#include <debug.h>
#include "nxbe.h"
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nxbe_fbconfigure
*
* Description:
* Configure the back end state structure based on information from the
* framebuffer driver
*
****************************************************************************/
int nxbe_fbconfigure(FAR struct fb_vtable_s *fb, FAR struct nxbe_state_s *be)
{
int ret;
int i;
/* Get the video controller configuration */
ret = fb->getvideoinfo(fb, &be->vinfo);
if (ret < 0)
{
gdbg("Failed to get vinfo\n");
return ret;
}
/* Check the number of color planes */
if (be->vinfo.nplanes > CONFIG_NX_NPLANES)
{
gdbg("NX configured for only %d planes, controller wants %d\n",
CONFIG_NX_NPLANES, be->vinfo.nplanes);
return -E2BIG;
}
else if (be->vinfo.nplanes < CONFIG_NX_NPLANES)
{
gdbg("NX configured for %d planes, controller only needs %d\n",
CONFIG_NX_NPLANES, be->vinfo.nplanes);
}
/* Then get information about each color plane */
for (i = 0; i < be->vinfo.nplanes; i++)
{
ret = fb->getplaneinfo(fb, i, &be->plane[i].pinfo);
if (ret < 0)
{
gdbg("Failed to get pinfo[%d]\n", i);
return ret;
}
/* Select rasterizers to match the BPP reported for this plane.
* NOTE that there are configuration options to eliminate support
* for unused BPP values. If the unused BPP values are not suppressed
* in this way, then ALL rasterizers will be drawn into the link and
* will signicantly increase the size
*/
#ifndef CONFIG_NXGLIB_DISABLE_1BPP
if (be->plane[i].pinfo.bpp == 1)
{
be->plane[i].fillrectangle = nxgl_fillrectangle_1bpp;
be->plane[i].moverectangle = nxgl_moverectangle_1bpp;
be->plane[i].copyrectangle = nxgl_copyrectangle_1bpp;
}
else
#endif
#ifndef CONFIG_NXGLIB_DISABLE_2BPP
if (be->plane[i].pinfo.bpp == 2)
{
be->plane[i].fillrectangle = nxgl_fillrectangle_2bpp;
be->plane[i].moverectangle = nxgl_moverectangle_2bpp;
be->plane[i].copyrectangle = nxgl_copyrectangle_2bpp;
}
else
#endif
#ifndef CONFIG_NXGLIB_DISABLE_4BPP
if (be->plane[i].pinfo.bpp == 4)
{
be->plane[i].fillrectangle = nxgl_fillrectangle_4bpp;
be->plane[i].moverectangle = nxgl_moverectangle_4bpp;
be->plane[i].copyrectangle = nxgl_copyrectangle_4bpp;
}
else
#endif
#ifndef CONFIG_NXGLIB_DISABLE_8BPP
if (be->plane[i].pinfo.bpp == 8)
{
be->plane[i].fillrectangle = nxgl_fillrectangle_8bpp;
be->plane[i].moverectangle = nxgl_moverectangle_8bpp;
be->plane[i].copyrectangle = nxgl_copyrectangle_8bpp;
}
else
#endif
#ifndef CONFIG_NXGLIB_DISABLE_16BPP
if (be->plane[i].pinfo.bpp == 16)
{
be->plane[i].fillrectangle = nxgl_fillrectangle_16bpp;
be->plane[i].moverectangle = nxgl_moverectangle_16bpp;
be->plane[i].copyrectangle = nxgl_copyrectangle_16bpp;
}
else
#endif
#ifndef CONFIG_NXGLIB_DISABLE_24BPP
if (be->plane[i].pinfo.bpp == 24)
{
be->plane[i].fillrectangle = nxgl_fillrectangle_24bpp;
be->plane[i].moverectangle = nxgl_moverectangle_24bpp;
be->plane[i].copyrectangle = nxgl_copyrectangle_24bpp;
}
else
#endif
#ifndef CONFIG_NXGLIB_DISABLE_32BPP
if (be->plane[i].pinfo.bpp == 32)
{
be->plane[i].fillrectangle = nxgl_fillrectangle_32bpp;
be->plane[i].moverectangle = nxgl_moverectangle_32bpp;
be->plane[i].copyrectangle = nxgl_copyrectangle_32bpp;
}
else
#endif
{
gdbg("Unsupported pinfo[%d] BPP: %d\n", i, be->plane[i].pinfo.bpp);
return -ENOSYS;
}
}
return OK;
}

145
graphics/nxbe/nxbe_fill.c Normal file
View file

@ -0,0 +1,145 @@
/****************************************************************************
* graphics/nxbe/nxbe_fill.c
*
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <nuttx/nxglib.h>
#include "nxbe.h"
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
struct nxbe_fill_s
{
struct nxbe_clipops_s cops;
nxgl_mxpixel_t color;
};
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: nxbe_clipfill
*
* Description:
* Called from nxbe_clipper() to performed the fill operation on visible portions
* of the rectangle.
*
****************************************************************************/
static void nxbe_clipfill(FAR struct nxbe_clipops_s *cops,
FAR struct nxbe_plane_s *plane,
FAR const struct nxgl_rect_s *rect)
{
struct nxbe_fill_s *fillinfo = (struct nxbe_fill_s *)cops;
plane->fillrectangle(&plane->pinfo, rect, fillinfo->color);
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nxbe_fill
*
* Description:
* Fill the specified rectangle in the window with the specified color
*
* Input Parameters:
* wnd - The window structure reference
* rect - The location to be filled
* col - The color to use in the fill
*
* Return:
* None
*
****************************************************************************/
void nxbe_fill(FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_rect_s *rect,
nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
{
struct nxbe_fill_s info;
struct nxgl_rect_s remaining;
int i;
#ifdef CONFIG_DEBUG
if (!wnd || !rect)
{
return;
}
#endif
/* Clip to the limits of the window and of the background screen */
nxgl_rectintersect(&remaining, rect, &wnd->bounds);
nxgl_rectintersect(&remaining, &remaining, &wnd->be->bkgd.bounds);
if (!nxgl_nullrect(&remaining))
{
#if CONFIG_NX_NPLANES > 1
for (i = 0; i < wnd->be->vinfo.nplanes; i++)
#else
i = 0;
#endif
{
info.cops.visible = nxbe_clipfill;
info.cops.obscured = nxbe_clipnull;
info.color = color[i];
nxbe_clipper(wnd->above, &remaining, NX_CLIPORDER_DEFAULT,
&info.cops, &wnd->be->plane[0]);
}
}
}

122
graphics/nxbe/nxbe_lower.c Normal file
View file

@ -0,0 +1,122 @@
/****************************************************************************
* graphics/nxbe/nxbe_lower.c
*
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <debug.h>
#include <nuttx/nxglib.h>
#include "nxbe.h"
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nxbe_lower
*
* Description:
* Lower the specified window to the bottom of the display.
*
****************************************************************************/
void nxbe_lower(FAR struct nxbe_window_s *wnd)
{
FAR struct nxbe_state_s *be = wnd->be;
/* If the window is already at the bottom, then there is nothing to do */
if (!wnd->below || wnd->below == &be->bkgd)
{
return;
}
/* Remove the window from its current position in the list */
wnd->below->above = wnd->above;
/* Was it at the top of the display? */
if (wnd->above)
{
/* No... it was in the middle somewhere */
wnd->above->below = wnd->below;
}
else
{
/* Yes.. set the new top window */
be->topwnd = wnd->below;
be->topwnd->above = NULL;
}
/* Redraw the windows that were below us (excluding this window that
* will be at the bottom; it is currently not in the list)
*/
nxbe_redrawbelow(be, wnd->below, &wnd->bounds);
/* Then put the lowered window at the bottom (just above the background window) */
wnd->below = &be->bkgd;
wnd->above = be->bkgd.above;
be->bkgd.above = wnd;
}

263
graphics/nxbe/nxbe_move.c Normal file
View file

@ -0,0 +1,263 @@
/****************************************************************************
* graphics/nxbe/nxbe_move.c
*
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <nuttx/nxglib.h>
#include <nuttx/nx.h>
#include "nxbe.h"
#include "nxfe.h"
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
struct nxbe_move_s
{
struct nxbe_clipops_s cops;
struct nxgl_point_s offset;
FAR struct nxbe_window_s *wnd;
struct nxgl_rect_s srcsize;
ubyte order;
};
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: nxbe_clipmovesrc
*
* Description:
* Called from nxbe_clipper() to performed the move operation on visible regions
* of the rectangle.
*
****************************************************************************/
static void nxbe_clipmovesrc(FAR struct nxbe_clipops_s *cops,
FAR struct nxbe_plane_s *plane,
FAR const struct nxgl_rect_s *rect)
{
struct nxbe_move_s *info = (struct nxbe_move_s *)cops;
if (info->offset.x != 0 || info->offset.y != 0)
{
struct nxgl_rect_s dest;
nxgl_rectoffset(&dest, rect, info->offset.x, info->offset.y);
plane->moverectangle(&plane->pinfo, &dest, &info->offset);
}
}
/****************************************************************************
* Name: nxbe_clipmoveobscured
*
* Description:
* Called from nxbe_clipper() to performed the move operation on obsrured regions
* of the rectangle.
*
****************************************************************************/
static void nxbe_clipmoveobscured(FAR struct nxbe_clipops_s *cops,
FAR struct nxbe_plane_s *plane,
FAR const struct nxgl_rect_s *rect)
{
struct nxbe_move_s *info = (struct nxbe_move_s *)cops;
struct nxgl_rect_s dst;
nxgl_rectoffset(&dst, rect, info->offset.x, info->offset.y);
nxfe_redrawreq(info->wnd, &dst);
}
/****************************************************************************
* Name: nxbe_clipmovedest
*
* Description:
* Called from nxbe_clipper() to performed the move operation on visible regions
* of the rectangle.
*
****************************************************************************/
static void nxbe_clipmovedest(FAR struct nxbe_clipops_s *cops,
FAR struct nxbe_plane_s *plane,
FAR const struct nxgl_rect_s *rect)
{
struct nxbe_move_s *dstdata = (struct nxbe_move_s *)cops;
struct nxbe_window_s *wnd = dstdata->wnd;
struct nxgl_point_s offset = dstdata->offset;
struct nxgl_rect_s src;
struct nxgl_rect_s tmprect1;
struct nxgl_rect_s tmprect2;
struct nxgl_rect_s nonintersecting[4];
int i;
/* Redraw dest regions where the source is outside of the bounds of the
* background window
*/
nxgl_rectoffset(&tmprect1, &dstdata->srcsize, offset.x, offset.y);
nxgl_rectintersect(&tmprect2, &tmprect1, &wnd->be->bkgd.bounds);
nxgl_nonintersecting(nonintersecting, rect, &tmprect2);
for (i = 0; i < 4; i++)
{
if (!nxgl_nullrect(&nonintersecting[i]))
{
nxfe_redrawreq(dstdata->wnd, &nonintersecting[i]);
}
}
/* Cip to determine what is inside the bounds */
nxgl_rectoffset(&tmprect1, rect, -offset.x, -offset.y);
nxgl_rectintersect(&src, &tmprect1, &dstdata->srcsize);
if (!nxgl_nullrect(&src))
{
struct nxbe_move_s srcinfo;
srcinfo.cops.visible = nxbe_clipmovesrc;
srcinfo.cops.obscured = nxbe_clipmoveobscured;
srcinfo.offset = offset;
srcinfo.wnd = wnd;
nxbe_clipper(dstdata->wnd->above, &src, dstdata->order,
&srcinfo.cops, plane);
}
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nxbe_move
*
* Description:
* Move a rectangular region within the window
*
* Input Parameters:
* wnd - The window within which the move is to be done
* rect - Describes the rectangular region to move
* offset - The offset to move the region
*
* Return:
* None
*
****************************************************************************/
void nxbe_move(FAR struct nxbe_window_s *wnd, FAR const struct nxgl_rect_s *rect,
FAR const struct nxgl_point_s *offset)
{
FAR const struct nxgl_rect_s *bounds = &wnd->bounds;
struct nxbe_move_s info;
struct nxgl_rect_s remaining;
int i;
#ifdef CONFIG_DEBUG
if (!wnd || !rect)
{
return;
}
#endif
/* Clip to the limits of the window and of the background screen */
nxgl_rectintersect(&remaining, rect, &wnd->bounds);
nxgl_rectintersect(&remaining, &remaining, &wnd->be->bkgd.bounds);
if (nxgl_nullrect(&remaining))
{
return;
}
info.cops.visible = nxbe_clipmovedest;
info.cops.obscured = nxbe_clipnull;
info.offset.x = offset->x;
info.offset.y = offset->y;
info.wnd = wnd;
if (offset->y < 0)
{
if (offset->x < 0)
{
info.order = NX_CLIPORDER_TLRB; /* Top-left-right-bottom */
}
else
{
info.order = NX_CLIPORDER_TRLB; /* Top-right-left-bottom */
}
}
else
{
if (offset->x < 0)
{
info.order = NX_CLIPORDER_BLRT; /* Bottom-left-right-top */
}
else
{
info.order = NX_CLIPORDER_BRLT; /* Bottom-right-left-top */
}
}
nxgl_rectintersect(&info.srcsize, bounds, &wnd->be->bkgd.bounds);
#if CONFIG_NX_NPLANES > 1
for (i = 0; i < wnd->be->vinfo.nplanes; i++)
#else
i = 0;
#endif
{
nxbe_clipper(wnd->above, &remaining, info.order,
&info.cops, &wnd->be->plane[i]);
}
}

145
graphics/nxbe/nxbe_raise.c Normal file
View file

@ -0,0 +1,145 @@
/****************************************************************************
* graphics/nxbe/nxbe_raise.c
*
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <nuttx/nxglib.h>
#include "nxbe.h"
#include "nxfe.h"
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
struct nxbe_raise_s
{
struct nxbe_clipops_s cops;
FAR struct nxbe_window_s *wnd;
};
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: nxbe_clipraise
****************************************************************************/
static void nxbe_clipraise(FAR struct nxbe_clipops_s *cops,
FAR struct nxbe_plane_s *plane,
FAR const struct nxgl_rect_s *rect)
{
FAR struct nxbe_window_s *wnd = ((struct nxbe_raise_s *)cops)->wnd;
nxfe_redrawreq(wnd, rect);
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nxbe_raise
*
* Description:
* Bring the specified window to the top of the display.
*
****************************************************************************/
void nxbe_raise(FAR struct nxbe_window_s *wnd)
{
FAR struct nxbe_state_s *be = wnd->be;
struct nxgl_rect_s rect;
struct nxbe_raise_s info;
if (!wnd->above)
{
return;
}
/* Redraw the bits that are currently obscured */
nxgl_rectintersect(&rect, &wnd->bounds, &be->bkgd.bounds);
if (!nxgl_nullrect(&rect))
{
int i;
info.cops.visible = nxbe_clipnull;
info.cops.obscured = nxbe_clipraise;
info.wnd = wnd;
#if CONFIG_NX_NPLANES > 1
for (i = 0; i < be->vinfo.nplanes; i++)
#else
i = 0;
#endif
{
nxbe_clipper(wnd->above, &rect, NX_CLIPORDER_DEFAULT,
&info.cops, &be->plane[i]);
}
}
/* Remove window from the list. Note that there is always
* some below this window (it may only be the background window)
*/
wnd->above->below = wnd->below;
wnd->below->above = wnd->above;
/* Then put it back in the list at the top */
wnd->above = NULL;
wnd->below = be->topwnd;
be->topwnd->above = wnd;
be->topwnd = wnd;
}

138
graphics/nxbe/nxbe_redraw.c Normal file
View file

@ -0,0 +1,138 @@
/****************************************************************************
* graphics/nxbe/nxbe_redraw.c
*
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <errno.h>
#include <debug.h>
#include "nxbe.h"
#include "nxfe.h"
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
struct nxbe_redraw_s
{
struct nxbe_clipops_s cops;
FAR struct nxbe_window_s *wnd;
};
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: nxbe_clipredraw
****************************************************************************/
static void nxbe_clipredraw(FAR struct nxbe_clipops_s *cops,
FAR struct nxbe_plane_s *plane,
FAR const struct nxgl_rect_s *rect)
{
FAR struct nxbe_window_s *wnd = ((struct nxbe_redraw_s *)cops)->wnd;
if (wnd)
{
nxfe_redrawreq(wnd, rect);
}
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nxbe_redraw
*
* Descripton:
* Re-draw the visible portions of the rectangular region for the
* specified window
*
****************************************************************************/
void nxbe_redraw(FAR struct nxbe_state_s *be,
FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_rect_s *rect)
{
struct nxbe_redraw_s info;
struct nxgl_rect_s remaining;
#if CONFIG_NX_NPLANES > 1
int i;
#endif
/* Clip to the limits of the window and of the background screen */
nxgl_rectintersect(&remaining, rect, &be->bkgd.bounds);
nxgl_rectintersect(&remaining, &remaining, &wnd->bounds);
if (!nxgl_nullrect(&remaining))
{
/* Now, request to re-draw any visible rectangular regions not obscured
* by windows above this one.
*/
info.cops.visible = nxbe_clipredraw;
info.cops.obscured = nxbe_clipnull;
info.wnd = wnd;
#if CONFIG_NX_NPLANES > 1
for (i = 0; i < be->vinfo.nplanes; i++)
{
nxbe_clipper(wnd->above, &remaining, NX_CLIPORDER_DEFAULT,
&info.cops, &be->plane[i]);
}
#else
nxbe_clipper(wnd->above, &remaining, NX_CLIPORDER_DEFAULT,
&info.cops, &be->plane[0]);
#endif
}
}

View file

@ -0,0 +1,92 @@
/****************************************************************************
* graphics/nxbe/nxbe_redraw.c
*
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <errno.h>
#include <debug.h>
#include "nxbe.h"
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nxbe_redrawbelow
*
* Descripton:
* Re-draw the visible portions of the rectangular region for all windows
* below (and including) the specified window. This function is called
* whenever a window is closed, moved, lowered or re-sized in order to
* expose newly visible portions of lower windows.
*
****************************************************************************/
void nxbe_redrawbelow(FAR struct nxbe_state_s *be, FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_rect_s *rect)
{
FAR struct nxbe_window_s *currwnd;
for (currwnd = wnd; currwnd; currwnd = currwnd->below)
{
nxbe_redraw(be, currwnd, rect);
}
}

View file

@ -0,0 +1,124 @@
/****************************************************************************
* graphics/nxbe/nxbe_setposition.c
*
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <nuttx/nx.h>
#include "nxbe.h"
#include "nxfe.h"
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nxbe_setposition
*
* Descripton:
* This function checks for intersections and redraws the display after
* a change in the position of a window.
*
****************************************************************************/
void nxbe_setposition(FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_point_s *pos)
{
struct nxgl_rect_s rect;
#ifdef CONFIG_DEBUG
if (!wnd)
{
return;
}
#endif
/* Back out the old window origin position from the bounding box */
nxgl_rectoffset(&rect, &wnd->bounds, -wnd->origin.x, -wnd->origin.y);
/* Set the new origin */
wnd->origin.x = pos->x;
wnd->origin.y = pos->y;
/* Add the new window origin back into the bounding box */
nxgl_rectoffset(&wnd->bounds, &rect, wnd->origin.x, wnd->origin.y);
/* Clip the rectangle so that is lies with the screen defined by the
* background window.
*/
nxgl_rectintersect(&rect, &rect, &wnd->be->bkgd.bounds);
/* Then redraw this window AND all windows below it. Having moved the
* window, we may have exposed previoulsy obscured portions of windows
* below this one.
*/
nxbe_redrawbelow(wnd->be, wnd, &rect);
/* Report the new size/position */
#ifdef CONFIG_NX_MULTIUSER
nxmu_getposition(wnd);
#endif
}

View file

@ -0,0 +1,113 @@
/****************************************************************************
* graphics/nxbe/nxbe_setsize.c
*
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <nuttx/nx.h>
#include "nxfe.h"
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nxbe_setsize
*
* Descripton:
* This function checks for intersections and redraws the display after
* a change in the size of a window.
*
****************************************************************************/
void nxbe_setsize(FAR struct nxbe_window_s *wnd,
FAR const struct nxgl_rect_s *size)
{
struct nxgl_rect_s rect;
#ifdef CONFIG_DEBUG
if (!wnd)
{
return;
}
#endif
/* Add the window origin to get the bounding box */
nxgl_rectoffset(&wnd->bounds, size, wnd->origin.x, wnd->origin.y);
/* Clip the bounding box so that is lies with the screen defined by the
* background window.
*/
nxgl_rectintersect(&rect, &wnd->bounds, &wnd->be->bkgd.bounds);
/* Then redraw this window AND all windows below it. Having resized the
* window, we may have exposed previoulsy obscured portions of windows
* below this one.
*/
nxbe_redrawbelow(wnd->be, wnd, &rect);
/* Report the new size/position */
#ifdef CONFIG_NX_MULTIUSER
nxmu_getposition(wnd);
#endif
}