nxterm_redraw.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /****************************************************************************
  2. * graphics/nxterm/nxterm_redraw.c
  3. *
  4. * Licensed to the Apache Software Foundation (ASF) under one or more
  5. * contributor license agreements. See the NOTICE file distributed with
  6. * this work for additional information regarding copyright ownership. The
  7. * ASF licenses this file to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance with the
  9. * License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  15. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  16. * License for the specific language governing permissions and limitations
  17. * under the License.
  18. *
  19. ****************************************************************************/
  20. /****************************************************************************
  21. * Included Files
  22. ****************************************************************************/
  23. #include <nuttx/config.h>
  24. #include <stdint.h>
  25. #include <stdbool.h>
  26. #include <assert.h>
  27. #include <errno.h>
  28. #include <debug.h>
  29. #include <nuttx/nx/nx.h>
  30. #include <nuttx/nx/nxglib.h>
  31. #include "nxterm.h"
  32. /****************************************************************************
  33. * Public Functions
  34. ****************************************************************************/
  35. /****************************************************************************
  36. * Name: nxterm_redraw
  37. *
  38. * Description:
  39. * Re-draw a portion of the NX console. This function should be called
  40. * from the appropriate window callback logic.
  41. *
  42. * Input Parameters:
  43. * handle - A handle previously returned by nx_register, nxtk_register, or
  44. * nxtool_register.
  45. * rect - The rectangle that needs to be re-drawn (in window relative
  46. * coordinates)
  47. * more - true: More re-draw requests will follow
  48. *
  49. * Returned Value:
  50. * None
  51. *
  52. ****************************************************************************/
  53. void nxterm_redraw(NXTERM handle,
  54. FAR const struct nxgl_rect_s *rect,
  55. bool more)
  56. {
  57. FAR struct nxterm_state_s *priv;
  58. int ret;
  59. int i;
  60. DEBUGASSERT(handle && rect);
  61. ginfo("rect={(%d,%d),(%d,%d)} more=%s\n",
  62. rect->pt1.x, rect->pt1.y, rect->pt2.x, rect->pt2.y,
  63. more ? "true" : "false");
  64. /* Recover our private state structure */
  65. priv = (FAR struct nxterm_state_s *)handle;
  66. /* Get exclusive access to the state structure */
  67. do
  68. {
  69. ret = nxterm_semwait(priv);
  70. }
  71. while (ret < 0);
  72. /* Fill the rectangular region with the window background color */
  73. ret = priv->ops->fill(priv, rect, priv->wndo.wcolor);
  74. if (ret < 0)
  75. {
  76. gerr("ERROR: fill failed: %d\n", get_errno());
  77. }
  78. /* Then redraw each character on the display (Only the characters within
  79. * the rectangle will actually be redrawn).
  80. */
  81. for (i = 0; i < priv->nchars; i++)
  82. {
  83. nxterm_fillchar(priv, rect, &priv->bm[i]);
  84. }
  85. nxterm_sempost(priv);
  86. }