Ejemplo n.º 1
0
void nxgl_rectunion(FAR struct nxgl_rect_s *dest,
                    FAR const struct nxgl_rect_s *src1,
                    FAR const struct nxgl_rect_s *src2)
{
  dest->pt1.x = ngl_min(src1->pt1.x, src2->pt1.x);
  dest->pt1.y = ngl_min(src1->pt1.y, src2->pt1.y);
  dest->pt2.x = ngl_max(src1->pt2.x, src2->pt2.x);
  dest->pt2.y = ngl_max(src1->pt2.y, src2->pt2.y);
}
Ejemplo n.º 2
0
void nxtk_setsubwindows(FAR struct nxtk_framedwindow_s *fwnd)
{
  nxgl_coord_t fullheight;
  nxgl_coord_t bdrheight = 0;
  nxgl_coord_t tbtop     = fwnd->wnd.bounds.pt1.y;
  nxgl_coord_t tbheight  = 0;
  nxgl_coord_t fwtop     = fwnd->wnd.bounds.pt1.y;
  nxgl_coord_t fwheight  = 0;
  nxgl_coord_t fullwidth;
  nxgl_coord_t bdrwidth;
  nxgl_coord_t fwwidth;
  nxgl_coord_t fwleft;

  /* Divide up the vertical dimension of the window */

  fullheight = fwnd->wnd.bounds.pt2.y - fwnd->wnd.bounds.pt1.y + 1;

  /* Is it tall enough for a border? */

  if (fullheight > 0)
    {
      /* Get the border height */

      bdrheight = ngl_min(2 * CONFIG_NXTK_BORDERWIDTH, fullheight);

      /* Position the toolbar and client window just under the top border */

#if CONFIG_NXTK_BORDERWIDTH > 1
      tbtop += CONFIG_NXTK_BORDERWIDTH - 1;
      fwtop = tbtop + 1;
#else
      tbtop += CONFIG_NXTK_BORDERWIDTH;
      fwtop = tbtop;
#endif

      /* Is it big enough for any part of the toolbar? */

      if (fullheight > 2 * CONFIG_NXTK_BORDERWIDTH)
        {
           /* Yes.. get the height of the toolbar */

          tbheight  = fwnd->tbheight;
          if (tbheight >= fullheight - bdrheight)
            {
              tbheight = fullheight - bdrheight;
            }
          else
            {
              /* And the client window gets whatever is left */

              fwheight = fullheight - bdrheight - tbheight;
            }

          /* Position the client window just under the toolbar */

          fwtop += tbheight;
        }
    }

  /* Divide up the horizontal dimensions of the window */

  fullwidth = fwnd->wnd.bounds.pt2.x - fwnd->wnd.bounds.pt1.x + 1;
  bdrwidth  = ngl_min(2 * CONFIG_NXTK_BORDERWIDTH, fullwidth);
  fwwidth   = fullwidth - bdrwidth;
  fwleft    = fwnd->wnd.bounds.pt1.x + bdrwidth / 2;

  /* Realize the positions/dimensions */

  fwnd->tbrect.pt1.x = fwleft;
  fwnd->tbrect.pt1.y = tbtop;
  fwnd->tbrect.pt2.x = fwleft + fwwidth - 1;
  fwnd->tbrect.pt2.y = tbtop + tbheight - 1;

  fwnd->fwrect.pt1.x = fwleft;
  fwnd->fwrect.pt1.y = fwtop;
  fwnd->fwrect.pt2.x = fwleft + fwwidth - 1;
  fwnd->fwrect.pt2.y = fwtop + fwheight - 1;
}
Ejemplo n.º 3
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]);
        }
    }
}
Ejemplo n.º 4
0
int NXF_FUNCNAME(nxf_convert,NXFONTS_SUFFIX)
(FAR NXF_PIXEL_T *dest, uint16_t height, uint16_t width, uint16_t stride,
 FAR const struct nx_fontbitmap_s *bm, nxgl_mxpixel_t color)
{
  FAR uint8_t *line;
  FAR NXF_PIXEL_T *dptr;
  FAR const uint8_t *sptr;
  uint8_t bmbyte;
  int bmbit;
  int row;
  int col;
  int bmndx;

#if NXFONTS_BITSPERPIXEL < 8
  NXF_PIXEL_T mpixel;
  NXF_PIXEL_T mask;
  NXF_PIXEL_T pixel;
  int nbits;
#endif

  /* Get the starting position */

  line = (uint8_t*)dest + bm->metric.yoffset * stride + NXF_SCALEX(bm->metric.xoffset);

  /* Then copy the font */

  height = ngl_min(bm->metric.height, height - bm->metric.yoffset);
  width  = ngl_min(bm->metric.width, width - bm->metric.xoffset);

  /* Render each row of the glyph */

  sptr = bm->bitmap;
#if NXFONTS_BITSPERPIXEL < 8
  mpixel = NXF_MULTIPIXEL(color);

  /* Handle each row in both the input and output */

  for (row = 0; row < height; row++)
    {
      /* Process each byte in the glyph row */

      col   = 0;
      dptr  = (FAR NXF_PIXEL_T*)line;
      pixel = *dptr;
      mask  = NXF_INITMASK;
      nbits = 0;

      for (bmndx = 0; bmndx < bm->metric.stride && col < width; bmndx++)
        {
          bmbyte = *sptr++;

          /* Process each bit in one byte */

          for (bmbit = 7; bmbit >= 0 && col < width; bmbit--, col++)
            {
              /* Is the bit set? */

              if (bmbyte & (1 << bmbit))
                {
                  /* Yes.. set the bit to 'color' in the output */

                  pixel = ((pixel & ~mask) | (mpixel & mask));
                }

#ifdef CONFIG_NX_PACKEDMSFIRST
              mask >>= NXFONTS_BITSPERPIXEL;
#else
              mask <<= NXFONTS_BITSPERPIXEL;
#endif
              nbits += NXFONTS_BITSPERPIXEL;
              if (nbits >= 8)
                {
                  *dptr++ = pixel;
                  pixel = *dptr;
                  mask  = NXF_INITMASK;
                  nbits = 0;
                }
            }
        }

      /* The entire glyph row has been rendered.  Handle any fractional bytes at
       * the end of the row 
       */

      if (nbits > 0)
        {
          *dptr = pixel;
        }

      /* Point to the beginning of the next row */

      line += stride;
    }
#else
  /* Handle each row in both the input and output */

  for (row = 0; row < height; row++)
    {
      /* Process each byte in the glyph */

      col  = 0;
      dptr = (FAR NXF_PIXEL_T*)line;

      for (bmndx = 0; bmndx < bm->metric.stride && col < width; bmndx++)
        {
          bmbyte = *sptr++;

          /* Process each bit in the byte */

          for (bmbit = 7; bmbit >= 0 && col < width; bmbit--, col++)
           {
              /* Is the bit set? */

              if (bmbyte & (1 << bmbit))
                {
                  /* Yes.. set the bit to 'color' in the output */

                  *dptr++ = color;
                }
              else
                {
                  /* No... keep the background color in the output */

                  dptr++;
                }
            }
        }

      /* Advance to the beginning of the next line in the destination */

      line += stride;
    }
#endif
  return OK;
}