You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
  2. *
  3. * This is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation; either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This software is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this software; if not, write to the Free Software
  15. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  16. * USA.
  17. */
  18. #ifndef __RFB_UPDATETRACKER_INCLUDED__
  19. #define __RFB_UPDATETRACKER_INCLUDED__
  20. #include <rfb/Rect.h>
  21. #include <rfb/Region.h>
  22. #include <rfb/PixelBuffer.h>
  23. namespace rfb {
  24. class UpdateInfo {
  25. public:
  26. Region changed;
  27. Region copied;
  28. Point copy_delta;
  29. bool is_empty() const {
  30. return copied.is_empty() && changed.is_empty();
  31. }
  32. // NOTE: We do not ever use UpdateInfo::numRects(), because Tight encoding
  33. // complicates computing the number of rectangles.
  34. /*
  35. int numRects() const {
  36. return copied.numRects() + changed.numRects();
  37. }
  38. */
  39. };
  40. class UpdateTracker {
  41. public:
  42. UpdateTracker() {};
  43. virtual ~UpdateTracker() {};
  44. virtual void add_changed(const Region &region) = 0;
  45. virtual void add_copied(const Region &dest, const Point &delta) = 0;
  46. };
  47. class ClippingUpdateTracker : public UpdateTracker {
  48. public:
  49. ClippingUpdateTracker() : ut(0) {}
  50. ClippingUpdateTracker(UpdateTracker* ut_, const Rect& r=Rect()) : ut(ut_), clipRect(r) {}
  51. void setUpdateTracker(UpdateTracker* ut_) {ut = ut_;}
  52. void setClipRect(const Rect& cr) {clipRect = cr;}
  53. virtual void add_changed(const Region &region);
  54. virtual void add_copied(const Region &dest, const Point &delta);
  55. protected:
  56. UpdateTracker* ut;
  57. Rect clipRect;
  58. };
  59. class SimpleUpdateTracker : public UpdateTracker {
  60. public:
  61. SimpleUpdateTracker();
  62. virtual ~SimpleUpdateTracker();
  63. virtual void add_changed(const Region &region);
  64. virtual void add_copied(const Region &dest, const Point &delta);
  65. virtual void subtract(const Region& region);
  66. // Fill the supplied UpdateInfo structure with update information
  67. // FIXME: Provide getUpdateInfo() with no clipping, for better efficiency.
  68. virtual void getUpdateInfo(UpdateInfo* info, const Region& cliprgn);
  69. // Copy the contained updates to another tracker
  70. virtual void copyTo(UpdateTracker* to) const;
  71. // Move the entire update region by an offset
  72. void translate(const Point& p) {changed.translate(p); copied.translate(p);}
  73. virtual bool is_empty() const {return changed.is_empty() && copied.is_empty();}
  74. virtual void clear() {changed.clear(); copied.clear();};
  75. protected:
  76. Region changed;
  77. Region copied;
  78. Point copy_delta;
  79. };
  80. }
  81. #endif // __RFB_UPDATETRACKER_INCLUDED__