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.

XPixelBuffer.h 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* Copyright (C) 2007-2008 Constantin Kaplinsky. 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. //
  19. // XPixelBuffer.h
  20. //
  21. #ifndef __XPIXELBUFFER_H__
  22. #define __XPIXELBUFFER_H__
  23. #include <rfb/PixelBuffer.h>
  24. #include <rfb/VNCServer.h>
  25. #include <x0vncserver/Image.h>
  26. #include <x0vncserver/PollingManager.h>
  27. //
  28. // XPixelBuffer is an Image-based implementation of FullFramePixelBuffer.
  29. //
  30. class XPixelBuffer : public rfb::FullFramePixelBuffer
  31. {
  32. public:
  33. XPixelBuffer(Display *dpy, ImageFactory &factory, const rfb::Rect &rect);
  34. virtual ~XPixelBuffer();
  35. // Provide access to the underlying Image object.
  36. const Image *getImage() const { return m_image; }
  37. // Detect changed pixels, notify the server.
  38. inline void poll(rfb::VNCServer *server) { m_poller->poll(server); }
  39. // Override PixelBuffer::grabRegion().
  40. virtual void grabRegion(const rfb::Region& region);
  41. protected:
  42. PollingManager *m_poller;
  43. Display *m_dpy;
  44. Image* m_image;
  45. int m_offsetLeft;
  46. int m_offsetTop;
  47. // Copy pixels from the screen to the pixel buffer,
  48. // for the specified rectangular area of the buffer.
  49. inline void grabRect(const rfb::Rect &r) {
  50. m_image->get(DefaultRootWindow(m_dpy),
  51. m_offsetLeft + r.tl.x, m_offsetTop + r.tl.y,
  52. r.width(), r.height(), r.tl.x, r.tl.y);
  53. }
  54. };
  55. #endif // __XPIXELBUFFER_H__