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.

Region.h 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
  2. * Copyright 2016-2020 Pierre Ossman for Cendio AB
  3. *
  4. * This is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This software 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
  15. * along with this software; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  17. * USA.
  18. */
  19. // Region class wrapper around pixman's region operations
  20. #ifndef __RFB_REGION_INCLUDED__
  21. #define __RFB_REGION_INCLUDED__
  22. #include <rfb/Rect.h>
  23. #include <vector>
  24. struct pixman_region16;
  25. namespace rfb {
  26. class Region {
  27. public:
  28. // Create an empty region
  29. Region();
  30. // Create a rectangular region
  31. Region(const Rect& r);
  32. Region(const Region& r);
  33. Region &operator=(const Region& src);
  34. ~Region();
  35. // the following methods alter the region in place:
  36. void clear();
  37. void reset(const Rect& r);
  38. void translate(const rfb::Point& delta);
  39. void assign_intersect(const Region& r);
  40. void assign_union(const Region& r);
  41. void assign_subtract(const Region& r);
  42. // the following three operations return a new region:
  43. Region intersect(const Region& r) const;
  44. Region union_(const Region& r) const;
  45. Region subtract(const Region& r) const;
  46. bool equals(const Region& b) const;
  47. int numRects() const;
  48. bool is_empty() const { return numRects() == 0; }
  49. bool get_rects(std::vector<Rect>* rects, bool left2right=true,
  50. bool topdown=true) const;
  51. Rect get_bounding_rect() const;
  52. void debug_print(const char *prefix) const;
  53. protected:
  54. struct pixman_region16* rgn;
  55. };
  56. };
  57. #endif // __RFB_REGION_INCLUDED__