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.

DeviceFrameBuffer.h 3.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. // -=- DeviceFrameBuffer.h
  19. //
  20. // The DeviceFrameBuffer class encapsulates the pixel data of a supplied
  21. // Device Context Handle (HDC)
  22. // *** THIS INTERFACE NEEDS TIDYING TO SEPARATE COORDINATE SYSTEMS BETTER ***
  23. #ifndef __RFB_WIN32_DEVICE_FRAME_BUFFER_H__
  24. #define __RFB_WIN32_DEVICE_FRAME_BUFFER_H__
  25. #include <windows.h>
  26. #include <rfb_win32/DIBSectionBuffer.h>
  27. #include <rfb/Cursor.h>
  28. #include <rfb/Region.h>
  29. #include <rfb/Exception.h>
  30. #include <rfb/Configuration.h>
  31. namespace rfb {
  32. class VNCServer;
  33. namespace win32 {
  34. // -=- DeviceFrameBuffer interface
  35. // DeviceFrameBuffer is passed an HDC referring to a window or to
  36. // the entire display. It may also be passed a rectangle specifying
  37. // the Device-relative coordinates of the actual rectangle to treat
  38. // as the desktop.
  39. // Coordinate systems start getting really annoying here. There are
  40. // three different "origins" to which coordinates might be relative:
  41. //
  42. // Desktop - VNC coordinates, top-left always (0,0)
  43. // Device - DC coordinates. Top-left *usually (0,0) but could be other.
  44. // Window - coordinates relative to the specified sub-rectangle within
  45. // the supplied DC.
  46. // Screen - Coordinates relative to the entire Windows virtual screen.
  47. // The virtual screen includes all monitors that are part of
  48. // the Windows desktop.
  49. // The data member is made to point to an internal mirror of the
  50. // current display data. Individual rectangles or regions of the
  51. // buffer can be brought up to date by calling the grab functions.
  52. class DeviceFrameBuffer : public DIBSectionBuffer {
  53. public:
  54. DeviceFrameBuffer(HDC deviceContext, const Rect& area_=Rect());
  55. virtual ~DeviceFrameBuffer();
  56. // - FrameBuffer overrides
  57. virtual void grabRect(const Rect &rect);
  58. virtual void grabRegion(const Region &region);
  59. // - DeviceFrameBuffer specific methods
  60. void setCursor(HCURSOR c, VNCServer* server);
  61. // Set whether grabRect should ignore errors or throw exceptions
  62. // Only set this if you are sure you'll capture the errors some other way!
  63. void setIgnoreGrabErrors(bool ie) {ignoreGrabErrors=ie;}
  64. static BoolParameter useCaptureBlt;
  65. protected:
  66. // Translate supplied Desktop coordinates into Device-relative coordinates
  67. // This translation may have been affected at start-time by the supplied sub-rect.
  68. Point desktopToDevice(const Point p) const {return p.translate(deviceCoords.tl);}
  69. HDC device;
  70. Rect deviceCoords;
  71. bool ignoreGrabErrors;
  72. };
  73. };
  74. };
  75. #endif // __RFB_WIN32_DEVICE_FRAME_BUFFER_H__