示例#1
0
int nx_fill(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
            nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
{
  FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd;
  struct nxsvrmsg_fill_s  outmsg;

#ifdef CONFIG_DEBUG
  if (!wnd || !rect || !color)
    {
      set_errno(EINVAL);
      return ERROR;
    }
#endif

  /* Format the fill command */

  outmsg.msgid = NX_SVRMSG_FILL;
  outmsg.wnd   = wnd;

  nxgl_rectcopy(&outmsg.rect, rect);
  nxgl_colorcopy(outmsg.color, color);

  /* Forward the fill command to the server */

  return nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_fill_s));
}
示例#2
0
int nx_setpixel(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos,
                nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
{
  FAR struct nxbe_window_s  *wnd = (FAR struct nxbe_window_s *)hwnd;
  struct nxsvrmsg_setpixel_s outmsg;

#ifdef CONFIG_DEBUG
  if (!wnd || !pos || !color)
    {
      set_errno(EINVAL);
      return ERROR;
    }
#endif

  /* Format the fill command */

  outmsg.msgid = NX_SVRMSG_SETPIXEL;
  outmsg.wnd   = wnd;
  outmsg.pos.x = pos->x;
  outmsg.pos.y = pos->y;

  nxgl_colorcopy(outmsg.color, color);

  /* Forward the fill command to the server */

  return nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_setpixel_s));
}
示例#3
0
int nx_fill(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
            nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
{
  FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd;
  struct nxsvrmsg_fill_s  outmsg;
  int                     ret;

#ifdef CONFIG_DEBUG
  if (!wnd || !wnd->conn || !rect || !color)
    {
      errno = EINVAL;
      return ERROR;
    }
#endif

  /* Format the fill command */

  outmsg.msgid = NX_SVRMSG_FILL;
  outmsg.wnd   = wnd;

  nxgl_rectcopy(&outmsg.rect, rect);
  nxgl_colorcopy(outmsg.color, color);

  /* Forward the fill command to the server */

  ret = mq_send(wnd->conn->cwrmq, &outmsg, sizeof(struct nxsvrmsg_fill_s), NX_SVRMSG_PRIO);
  if (ret < 0)
    {
      gdbg("mq_send failed: %d\n", errno);
    }
  return ret;
}
示例#4
0
int nx_setbgcolor(NXHANDLE handle,
                  nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
{
  FAR struct nxfe_conn_s *conn = (FAR struct nxfe_conn_s *)handle;
  struct nxsvrmsg_setbgcolor_s outmsg;
  int ret;

#ifdef CONFIG_DEBUG
  if (!conn)
    {
      errno = EINVAL;
      return ERROR;
    }
#endif

  /* Format the fill command */

  outmsg.msgid = NX_SVRMSG_SETBGCOLOR;
  nxgl_colorcopy(outmsg.color, color);

  /* Forward the fill command to the server */

  ret = mq_send(conn->cwrmq, &outmsg, sizeof(struct nxsvrmsg_setbgcolor_s), NX_SVRMSG_PRIO);
  if (ret < 0)
    {
      gdbg("mq_send failed: %d\n", errno);
    }
  return ret;
}
示例#5
0
int nx_setbgcolor(NXHANDLE handle,
                  nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
{
  FAR struct nxfe_state_s *fe = (FAR struct nxfe_state_s *)handle;

#ifdef CONFIG_DEBUG
  if (!fe)
    {
      errno = EINVAL;
      return ERROR;
    }
#endif

  /* Has the background color changed? */

  if (!nxgl_colorcmp(fe->be.bgcolor, color))
    {
      /* Yes.. fill the background */

      nxgl_colorcopy(fe->be.bgcolor, color);
      nxbe_fill(&fe->be.bkgd, &fe->be.bkgd.bounds, color);
    }

  return OK;
}
示例#6
0
int nx_setbgcolor(NXHANDLE handle,
                  nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
{
  FAR struct nxfe_state_s *fe = (FAR struct nxfe_state_s *)handle;

#ifdef CONFIG_DEBUG
  if (!fe)
    {
      errno = EINVAL;
      return ERROR;
    }
#endif

  nxgl_colorcopy(fe->be.bgcolor, color);
  nxbe_fill(&fe->be.bkgd, &fe->be.bkgd.bounds, color);
  return OK;
}
示例#7
0
int nx_setbgcolor(NXHANDLE handle,
                  nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
{
  FAR struct nxfe_conn_s *conn = (FAR struct nxfe_conn_s *)handle;
  struct nxsvrmsg_setbgcolor_s outmsg;

#ifdef CONFIG_DEBUG
  if (!conn)
    {
      errno = EINVAL;
      return ERROR;
    }
#endif

  /* Format the fill command */

  outmsg.msgid = NX_SVRMSG_SETBGCOLOR;
  nxgl_colorcopy(outmsg.color, color);

  /* Forward the fill command to the server */

  return nxmu_sendserver(conn, &outmsg, sizeof(struct nxsvrmsg_setbgcolor_s));
}
示例#8
0
int nxbe_configure(FAR NX_DRIVERTYPE *dev, FAR struct nxbe_state_s *be)
{
  int ret;
  int i;

  /* Get the video controller configuration */

  ret = dev->getvideoinfo(dev, &be->vinfo);
  if (ret < 0)
    {
      gdbg("Failed to get vinfo\n");
      return ret;
    }

  /* Set the initial background color */

  nxgl_colorcopy(be->bgcolor, g_bgcolor);

  /* Check the number of color planes */

#ifdef CONFIG_DEBUG
  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);
    }
#endif

  /* Then get information about each color plane */

  for (i = 0; i < be->vinfo.nplanes; i++)
    {
      ret = dev->getplaneinfo(dev, 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_NX_DISABLE_1BPP
      if (be->plane[i].pinfo.bpp == 1)
        {
          be->plane[i].setpixel      = nxgl_setpixel_1bpp;
          be->plane[i].fillrectangle = nxgl_fillrectangle_1bpp;
          be->plane[i].getrectangle  = nxgl_getrectangle_1bpp;
          be->plane[i].filltrapezoid = nxgl_filltrapezoid_1bpp;
          be->plane[i].moverectangle = nxgl_moverectangle_1bpp;
          be->plane[i].copyrectangle = nxgl_copyrectangle_1bpp;
        }
      else
#endif
#ifndef CONFIG_NX_DISABLE_2BPP
      if (be->plane[i].pinfo.bpp == 2)
        {
          be->plane[i].setpixel      = nxgl_setpixel_2bpp;
          be->plane[i].fillrectangle = nxgl_fillrectangle_2bpp;
          be->plane[i].getrectangle  = nxgl_getrectangle_2bpp;
          be->plane[i].filltrapezoid = nxgl_filltrapezoid_2bpp;
          be->plane[i].moverectangle = nxgl_moverectangle_2bpp;
          be->plane[i].copyrectangle = nxgl_copyrectangle_2bpp;
        }
      else
#endif
#ifndef CONFIG_NX_DISABLE_4BPP
      if (be->plane[i].pinfo.bpp == 4)
        {
          be->plane[i].setpixel      = nxgl_setpixel_4bpp;
          be->plane[i].fillrectangle = nxgl_fillrectangle_4bpp;
          be->plane[i].getrectangle  = nxgl_getrectangle_4bpp;
          be->plane[i].filltrapezoid = nxgl_filltrapezoid_4bpp;
          be->plane[i].moverectangle = nxgl_moverectangle_4bpp;
          be->plane[i].copyrectangle = nxgl_copyrectangle_4bpp;
        }
      else
#endif
#ifndef CONFIG_NX_DISABLE_8BPP
      if (be->plane[i].pinfo.bpp == 8)
        {
          be->plane[i].setpixel      = nxgl_setpixel_8bpp;
          be->plane[i].fillrectangle = nxgl_fillrectangle_8bpp;
          be->plane[i].getrectangle  = nxgl_getrectangle_8bpp;
          be->plane[i].filltrapezoid = nxgl_filltrapezoid_8bpp;
          be->plane[i].moverectangle = nxgl_moverectangle_8bpp;
          be->plane[i].copyrectangle = nxgl_copyrectangle_8bpp;
        }
      else
#endif
#ifndef CONFIG_NX_DISABLE_16BPP
      if (be->plane[i].pinfo.bpp == 16)
        {
          be->plane[i].setpixel      = nxgl_setpixel_16bpp;
          be->plane[i].fillrectangle = nxgl_fillrectangle_16bpp;
          be->plane[i].getrectangle  = nxgl_getrectangle_16bpp;
          be->plane[i].filltrapezoid = nxgl_filltrapezoid_16bpp;
          be->plane[i].moverectangle = nxgl_moverectangle_16bpp;
          be->plane[i].copyrectangle = nxgl_copyrectangle_16bpp;
        }
      else
#endif
#ifndef CONFIG_NX_DISABLE_24BPP
      if (be->plane[i].pinfo.bpp == 24)
        {
          be->plane[i].setpixel      = nxgl_setpixel_24bpp;
          be->plane[i].fillrectangle = nxgl_fillrectangle_24bpp;
          be->plane[i].getrectangle  = nxgl_getrectangle_24bpp;
          be->plane[i].filltrapezoid = nxgl_filltrapezoid_24bpp;
          be->plane[i].moverectangle = nxgl_moverectangle_24bpp;
          be->plane[i].copyrectangle = nxgl_copyrectangle_24bpp;
        }
      else
#endif
#ifndef CONFIG_NX_DISABLE_32BPP
      if (be->plane[i].pinfo.bpp == 32)
        {
          be->plane[i].setpixel      = nxgl_setpixel_32bpp;
          be->plane[i].fillrectangle = nxgl_fillrectangle_32bpp;
          be->plane[i].getrectangle  = nxgl_getrectangle_32bpp;
          be->plane[i].filltrapezoid = nxgl_filltrapezoid_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;
}
示例#9
0
int nx_runinstance(FAR const char *mqname, FAR NX_DRIVERTYPE *dev)
{
  struct nxfe_state_s     fe;
  FAR struct nxsvrmsg_s *msg;
  uint8_t                buffer[NX_MXSVRMSGLEN];
  int                    nbytes;
  int                    ret;

  /* Initialization *********************************************************/

  /* Sanity checking */

#ifdef CONFIG_DEBUG
  if (!mqname || !dev)
    {
      errno = EINVAL;
      return ERROR;
    }
#endif

  /* Initialize and configure the server */

  ret = nxmu_setup(mqname, dev, &fe);
  if (ret < 0)
    {
      return ret; /* nxmu_setup sets errno */
    }

  /* Produce the initial, background display */

  nxbe_redraw(&fe.be, &fe.be.bkgd, &fe.be.bkgd.bounds);

  /* Message Loop ***********************************************************/

  /* Then loop forever processing incoming messages */

  for (;;)
    {
       /* Receive the next server message */

       nbytes = mq_receive(fe.conn.crdmq, buffer, NX_MXSVRMSGLEN, 0);
       if (nbytes < 0)
         {
           if (errno != EINTR)
             {
               gdbg("mq_receive failed: %d\n", errno);
               goto errout; /* mq_receive sets errno */
             }
           continue;
         }

       /* Dispatch the message appropriately */

       DEBUGASSERT(nbytes >= sizeof(struct nxsvrmsg_s));
       msg = (FAR struct nxsvrmsg_s *)buffer;

       gvdbg("Received opcode=%d nbytes=%d\n", msg->msgid, nbytes);
       switch (msg->msgid)
         {
         /* Messages sent from clients to the NX server *********************/

         case NX_SVRMSG_CONNECT: /* Establish connection with new NX server client */
           {
             FAR struct nxsvrmsg_s *connmsg = (FAR struct nxsvrmsg_s *)buffer;
             nxmu_connect(connmsg->conn);
           }
           break;

         case NX_SVRMSG_DISCONNECT: /* Tear down connection with terminating client */
           {
             FAR struct nxsvrmsg_s *disconnmsg = (FAR struct nxsvrmsg_s *)buffer;
             nxmu_disconnect(disconnmsg->conn);
           }
           break;

         case NX_SVRMSG_OPENWINDOW: /* Create a new window */
           {
             FAR struct nxsvrmsg_openwindow_s *openmsg = (FAR struct nxsvrmsg_openwindow_s *)buffer;
             nxmu_openwindow(&fe.be, openmsg->wnd);
           }
           break;

         case NX_SVRMSG_CLOSEWINDOW: /* Close an existing window */
           {
             FAR struct nxsvrmsg_closewindow_s *closemsg = (FAR struct nxsvrmsg_closewindow_s *)buffer;
             nxbe_closewindow(closemsg->wnd);
           }
           break;

         case NX_SVRMSG_BLOCKED: /* Block messsages to a window */
           {
             FAR struct nxsvrmsg_blocked_s *blocked = (FAR struct nxsvrmsg_blocked_s *)buffer;
             nxmu_blocked(blocked->wnd, blocked->arg);
           }
           break;

         case NX_SVRMSG_REQUESTBKGD: /* Give access to the background window */
           {
             FAR struct nxsvrmsg_requestbkgd_s *rqbgmsg = (FAR struct nxsvrmsg_requestbkgd_s *)buffer;
             nxmu_requestbkgd(rqbgmsg->conn, &fe.be, rqbgmsg->cb, rqbgmsg->arg);
           }
           break;

         case NX_SVRMSG_RELEASEBKGD: /* End access to the background window */
           {
             nxmu_releasebkgd(&fe);
           }
           break;

         case NX_SVRMSG_SETPOSITION: /* Change window position */
           {
             FAR struct nxsvrmsg_setposition_s *setposmsg = (FAR struct nxsvrmsg_setposition_s *)buffer;
             nxbe_setposition(setposmsg->wnd, &setposmsg->pos);
           }
           break;

         case NX_SVRMSG_SETSIZE: /* Change window size */
           {
             FAR struct nxsvrmsg_setsize_s *setsizemsg = (FAR struct nxsvrmsg_setsize_s *)buffer;
             nxbe_setsize(setsizemsg->wnd, &setsizemsg->size);
           }
           break;

         case NX_SVRMSG_GETPOSITION: /* Get the window size/position */
           {
             FAR struct nxsvrmsg_getposition_s *getposmsg = (FAR struct nxsvrmsg_getposition_s *)buffer;
             nxfe_reportposition(getposmsg->wnd);
           }
           break;

         case NX_SVRMSG_RAISE: /* Move the window to the top of the display */
           {
             FAR struct nxsvrmsg_raise_s *raisemsg = (FAR struct nxsvrmsg_raise_s *)buffer;
             nxbe_raise(raisemsg->wnd);
           }
           break;

         case NX_SVRMSG_LOWER: /* Lower the window to the bottom of the display */
           {
             FAR struct nxsvrmsg_lower_s *lowermsg = (FAR struct nxsvrmsg_lower_s *)buffer;
             nxbe_lower(lowermsg->wnd);
           }
           break;

         case NX_SVRMSG_SETPIXEL: /* Set a single pixel in the window with a color */
           {
             FAR struct nxsvrmsg_setpixel_s *setmsg = (FAR struct nxsvrmsg_setpixel_s *)buffer;
             nxbe_setpixel(setmsg->wnd, &setmsg->pos, setmsg->color);
           }
           break;

         case NX_SVRMSG_FILL: /* Fill a rectangular region in the window with a color */
           {
             FAR struct nxsvrmsg_fill_s *fillmsg = (FAR struct nxsvrmsg_fill_s *)buffer;
             nxbe_fill(fillmsg->wnd, &fillmsg->rect, fillmsg->color);
           }
           break;

         case NX_SVRMSG_GETRECTANGLE: /* Get a rectangular region from the window */
           {
             FAR struct nxsvrmsg_getrectangle_s *getmsg = (FAR struct nxsvrmsg_getrectangle_s *)buffer;
             nxbe_getrectangle(getmsg->wnd, &getmsg->rect, getmsg->plane, getmsg->dest, getmsg->deststride);

             if (getmsg->sem_done)
              {
                sem_post(getmsg->sem_done);
              }
           }
           break;

         case NX_SVRMSG_FILLTRAP: /* Fill a trapezoidal region in the window with a color */
           {
             FAR struct nxsvrmsg_filltrapezoid_s *trapmsg = (FAR struct nxsvrmsg_filltrapezoid_s *)buffer;
             nxbe_filltrapezoid(trapmsg->wnd, &trapmsg->clip, &trapmsg->trap, trapmsg->color);
           }
           break;
         case NX_SVRMSG_MOVE: /* Move a rectangular region within the window */
           {
             FAR struct nxsvrmsg_move_s *movemsg = (FAR struct nxsvrmsg_move_s *)buffer;
             nxbe_move(movemsg->wnd, &movemsg->rect, &movemsg->offset);
           }
           break;

         case NX_SVRMSG_BITMAP: /* Copy a rectangular bitmap into the window */
           {
             FAR struct nxsvrmsg_bitmap_s *bmpmsg = (FAR struct nxsvrmsg_bitmap_s *)buffer;
             nxbe_bitmap(bmpmsg->wnd, &bmpmsg->dest, bmpmsg->src, &bmpmsg->origin, bmpmsg->stride);

             if (bmpmsg->sem_done)
              {
                sem_post(bmpmsg->sem_done);
              }
           }
           break;

         case NX_SVRMSG_SETBGCOLOR: /* Set the color of the background */
           {
             FAR struct nxsvrmsg_setbgcolor_s *bgcolormsg =
               (FAR struct nxsvrmsg_setbgcolor_s *)buffer;

             /* Has the background color changed? */

             if (!nxgl_colorcmp(fe.be.bgcolor, bgcolormsg->color))
               {
                 /* Yes.. fill the background */

                 nxgl_colorcopy(fe.be.bgcolor, bgcolormsg->color);
                 nxbe_fill(&fe.be.bkgd, &fe.be.bkgd.bounds, bgcolormsg->color);
               }
           }
           break;

#ifdef CONFIG_NX_XYINPUT
         case NX_SVRMSG_MOUSEIN: /* New mouse report from mouse client */
           {
             FAR struct nxsvrmsg_mousein_s *mousemsg = (FAR struct nxsvrmsg_mousein_s *)buffer;
             nxmu_mousein(&fe, &mousemsg->pt, mousemsg->buttons);
           }
           break;
#endif
#ifdef CONFIG_NX_KBD
         case NX_SVRMSG_KBDIN: /* New keyboard report from keyboard client */
           {
             FAR struct nxsvrmsg_kbdin_s *kbdmsg = (FAR struct nxsvrmsg_kbdin_s *)buffer;
             nxmu_kbdin(&fe, kbdmsg->nch, kbdmsg->ch);
           }
           break;
#endif

         case NX_SVRMSG_REDRAWREQ: /* Request re-drawing of rectangular region */
           {
             FAR struct nxsvrmsg_redrawreq_s *redrawmsg = (FAR struct nxsvrmsg_redrawreq_s *)buffer;
             nxfe_redrawreq(redrawmsg->wnd, &redrawmsg->rect);
           }
           break;

         /* Messages sent to the background window **************************/

         case NX_CLIMSG_REDRAW: /* Re-draw the background window */
            {
              FAR struct nxclimsg_redraw_s *redraw = (FAR struct nxclimsg_redraw_s *)buffer;
              DEBUGASSERT(redraw->wnd == &fe.be.bkgd);
              gvdbg("Re-draw background rect={(%d,%d),(%d,%d)}\n",
                    redraw->rect.pt1.x, redraw->rect.pt1.y,
                    redraw->rect.pt2.x, redraw->rect.pt2.y);
              nxbe_fill(&fe.be.bkgd, &redraw->rect, fe.be.bgcolor);
            }
          break;

         case NX_CLIMSG_MOUSEIN:      /* Ignored */
         case NX_CLIMSG_KBDIN:
           break;

         case NX_CLIMSG_CONNECTED:    /* Shouldn't happen */
         case NX_CLIMSG_DISCONNECTED:
         default:
           gdbg("Unrecognized command: %d\n", msg->msgid);
           break;
         }
    }

errout:
  nxmu_shutdown(&fe);
  return OK;
}