Esempio n. 1
0
bool nxbe_visible(FAR struct nxbe_window_s *wnd,
                  FAR const struct nxgl_point_s *pos)
{
  struct nxbe_visible_s info;

  /* Check if the absolute position lies within the window */

  if (!nxgl_rectinside(&wnd->bounds, pos))
    {
      return false;
    }

  /* If this is the top window, then the psition is visible */

  if (!wnd->above)
    {
      return true;
    }

  /* The position within the window range, but the window is not at
   * the top.  We will have to work harder to determine if the point
   * visible
   */

  info.cops.visible  = nxbe_clipvisible;
  info.cops.obscured = nxbe_clipnull;
  info.visible       = false;

  nxbe_clipper(wnd->above, &wnd->bounds, NX_CLIPORDER_DEFAULT,
               &info.cops, &wnd->be->plane[0]);

  return info.visible;
}
Esempio n. 2
0
void nxbe_setpixel(FAR struct nxbe_window_s *wnd,
                   FAR const struct nxgl_point_s *pos,
                   nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
{
  struct nxbe_setpixel_s info;
  struct nxgl_rect_s rect;
  int i;

#ifdef CONFIG_DEBUG
  if (!wnd || !pos)
    {
      return;
    }
#endif

  /* Offset the position by the window origin */

  nxgl_vectoradd(&rect.pt1, pos, &wnd->bounds.pt1);

  /* Make sure that the point is within the limits of the window
   * and of the background screen
   */

  if (!nxgl_rectinside(&wnd->bounds, &rect.pt1) ||
      !nxgl_rectinside(&wnd->be->bkgd.bounds, &rect.pt1))
    {
      return;
    }

  /* Then create a bounding box and render the point if there it
   * is exposed.
   */

  rect.pt2.x = rect.pt1.x;
  rect.pt2.y = rect.pt1.y;

#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, &rect, NX_CLIPORDER_DEFAULT,
                   &info.cops, &wnd->be->plane[i]);
    }
}
Esempio n. 3
0
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

  /* Offset the rectangle by the window origin to convert it into a
   * bounding box
   */

  nxgl_rectoffset(&remaining, rect, wnd->bounds.pt1.x, wnd->bounds.pt1.y);

  /* Clip to the bounding box to the limits of the window and of the
   * background screen
   */

  nxgl_rectintersect(&remaining, &remaining, &wnd->bounds);
  nxgl_rectintersect(&remaining, &remaining, &wnd->be->bkgd.bounds);

  /* Then clip the bounding box due to other windows above this one.
   * Render the portions of the trapezoid exposed in visible regions.
   */

  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[i]);
        }
    }
}
Esempio n. 4
0
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
    }
}
Esempio n. 5
0
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->srcrect, 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]);
        }
    }

  /* Clip to determine what is inside the bounds */

  nxgl_rectintersect(&src, rect, &dstdata->srcrect);

  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);
   }
}
Esempio n. 6
0
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 remaining;
  int i;

#ifdef CONFIG_DEBUG
  if (!wnd || !trap)
    {
      return;
    }
#endif

  /* Offset the trapezoid by the window origin to position it within
   * the framebuffer region
   */

  nxgl_trapoffset(&info.trap, trap, wnd->bounds.pt1.x, wnd->bounds.pt1.y);

  /* Create a bounding box that contains the trapezoid */

  remaining.pt1.x = b16toi(ngl_min(info.trap.top.x1, info.trap.bot.x1));
  remaining.pt1.y = info.trap.top.y;
  remaining.pt2.x = b16toi(ngl_max(info.trap.top.x2, info.trap.bot.x2));
  remaining.pt2.y = info.trap.bot.y;

  /* Clip to any user specified clipping window */

  if (clip)
    {
      struct nxgl_rect_s tmp;
      nxgl_rectoffset(&tmp, clip, wnd->bounds.pt1.x, wnd->bounds.pt1.y);
      nxgl_rectintersect(&remaining, &remaining, &tmp);
    }

  /* Clip to the limits of the window and of the background screen */

  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;

      /* Then process each color plane */

#if CONFIG_NX_NPLANES > 1
      for (i = 0; i < wnd->be->vinfo.nplanes; i++)
#else
      i = 0;
#endif
        {
          info.color = color[i];
          nxbe_clipper(wnd->above, &remaining, NX_CLIPORDER_DEFAULT,
                       &info.cops, &wnd->be->plane[i]);
        }
    }
}
Esempio n. 7
0
void nxbe_move(FAR struct nxbe_window_s *wnd, FAR const struct nxgl_rect_s *rect,
               FAR const struct nxgl_point_s *offset)
{
  struct nxbe_move_s info;
  int i;

#ifdef CONFIG_DEBUG_FEATURES
  if (!wnd || !rect)
    {
      return;
    }
#endif

  /* Offset the rectangle by the window origin to create a bounding box */

  nxgl_rectoffset(&info.srcrect, rect, wnd->bounds.pt1.x, wnd->bounds.pt1.y);

  /* Clip to the limits of the window and of the background screen */

  nxgl_rectintersect(&info.srcrect, &info.srcrect, &wnd->bounds);
  nxgl_rectintersect(&info.srcrect, &info.srcrect, &wnd->be->bkgd.bounds);

  if (nxgl_nullrect(&info.srcrect))
    {
      return;
    }

  info.cops.visible  = nxbe_clipmovedest;
  info.cops.obscured = nxbe_clipnull;
  info.offset.x      = offset->x;
  info.offset.y      = offset->y;
  info.wnd           = wnd;

  /* The clip order depends up the direction that the rectangle is being
   * moved.
   */

  if (offset->y < 0)
    {
      /* Moving rectangle up */

      if (offset->x < 0)
        {
          /* Moving to upper-left */

          info.order = NX_CLIPORDER_TLRB; /* Top-left-right-bottom */
        }
      else
        {
          /* Moving to upper-right (or just up) */

          info.order = NX_CLIPORDER_TRLB;  /* Top-right-left-bottom */
        }
    }
  else
    {
      /* Moving rectangle down (or just left/right) */

      if (offset->x < 0)
        {
          /* Moving to lower-left */

          info.order = NX_CLIPORDER_BLRT; /* Bottom-left-right-top */
        }
      else
        {
          /* Moving to lower-right */

          info.order = NX_CLIPORDER_BRLT; /* Bottom-right-left-top */
        }
    }

  /* Then perform the move */

#if CONFIG_NX_NPLANES > 1
  for (i = 0; i < wnd->be->vinfo.nplanes; i++)
#else
  i = 0;
#endif
    {
      nxbe_clipper(wnd->above, &info.srcrect, info.order,
                   &info.cops, &wnd->be->plane[i]);
    }
}