DirtRect.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2016 RWS Inc, All Rights Reserved
  4. //
  5. // This program is free software; you can redistribute it and/or modify
  6. // it under the terms of version 2 of the GNU General Public License as published by
  7. // the Free Software Foundation
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License along
  15. // with this program; if not, write to the Free Software Foundation, Inc.,
  16. // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. //
  18. #ifndef DIRTRECT_H
  19. #define DIRTRECT_H
  20. //////////////////////////////////////////////////////////////////////////////
  21. // Headers.
  22. //////////////////////////////////////////////////////////////////////////////
  23. #include "System.h"
  24. // If PATHS_IN_INCLUDES macro is defined, we can utilized relative
  25. // paths to a header file. In this case we generally go off of our
  26. // RSPiX root directory. System.h MUST be included before this macro
  27. // is evaluated. System.h is the header that, based on the current
  28. // platform (or more so in this case on the compiler), defines
  29. // PATHS_IN_INCLUDES. Blue.h includes system.h so you can include that
  30. // instead.
  31. #ifdef PATHS_IN_INCLUDES
  32. #include "ORANGE/CDT/List.h"
  33. #else
  34. #include "list.h"
  35. #endif // PATHS_IN_INCLUDES
  36. //////////////////////////////////////////////////////////////////////////////
  37. // Macros.
  38. //////////////////////////////////////////////////////////////////////////////
  39. //////////////////////////////////////////////////////////////////////////////
  40. // Typedefs.
  41. //////////////////////////////////////////////////////////////////////////////
  42. // This structure is used to encapsulate a rectangle used by RDirtyRects.
  43. typedef struct
  44. {
  45. short sX;
  46. short sY;
  47. short sW;
  48. short sH;
  49. } RDRect;
  50. //*******************************************************************
  51. // NOTE: Do NOT call Insert, InsertHead, or AddTail unless you want
  52. // a rectangle to be added w/o combination. A rectangle added later
  53. // may be combined with that one, however.
  54. //*******************************************************************
  55. class RDirtyRects : public RList<RDRect>
  56. {
  57. public: // Typedefs.
  58. public: // Con/Destruction.
  59. RDirtyRects();
  60. RDirtyRects( short sMinDistX, // Copied into m_sMinDistanceX.
  61. short sMinDistY, // Copied into m_sMinDistanceY.
  62. short sClipX = -1, // Copied into m_sClipX.
  63. short sClipY = -1);// Copied into m_sClipY.
  64. ~RDirtyRects();
  65. public: // Implementation.
  66. // Use GetHead, GetTail, GetNext, and GetPrev to get the RRects
  67. // in no particular order.
  68. // Add a rectangle to the list of dirty rectangles.
  69. // The rectangle may get combined with another.
  70. // Returns 0 on success.
  71. short Add(RDRect* pdr);
  72. short Add(short sX, short sY, short sW, short sH);
  73. // Empty the list of dirty rectangles.
  74. void Empty(void);
  75. protected: // Internal use only.
  76. // Combine a rectangle with rectangles already in
  77. // the list if possible.
  78. // Returns 0 if combined.
  79. short Combine(RDRect* pdr);
  80. // Expand pdrExpand by pdrNew.
  81. void Expand(RDRect* pdrExpand, RDRect* pdrNew);
  82. // Clip sPos + sDistance to 0 to sClipDistance.
  83. // Returns non-zero if clipped out.
  84. short Clip(short* psPos, short* psDistance, short sClipDistance);
  85. public: // User may/should modify these.
  86. short m_sMinDistanceX; // Minimum x-distance between rectangles.
  87. // All rectangles closer will be combined.
  88. short m_sMinDistanceY; // Minimum y-distance between rectangles.
  89. // All rectangles closer will be combined.
  90. short m_sClipX; // Clip input rectangles in the x direction.
  91. short m_sClipY; // Clip input rectangles in the y direction.
  92. };
  93. #endif // DIRTRECT
  94. //////////////////////////////////////////////////////////////////////////////
  95. // EOF
  96. //////////////////////////////////////////////////////////////////////////////