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.

RREDecoder.cxx 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. #ifdef HAVE_CONFIG_H
  19. #include <config.h>
  20. #endif
  21. #include <rdr/InStream.h>
  22. #include <rdr/MemInStream.h>
  23. #include <rdr/OutStream.h>
  24. #include <rfb/ServerParams.h>
  25. #include <rfb/PixelBuffer.h>
  26. #include <rfb/RREDecoder.h>
  27. using namespace rfb;
  28. #define BPP 8
  29. #include <rfb/rreDecode.h>
  30. #undef BPP
  31. #define BPP 16
  32. #include <rfb/rreDecode.h>
  33. #undef BPP
  34. #define BPP 32
  35. #include <rfb/rreDecode.h>
  36. #undef BPP
  37. RREDecoder::RREDecoder() : Decoder(DecoderPlain)
  38. {
  39. }
  40. RREDecoder::~RREDecoder()
  41. {
  42. }
  43. bool RREDecoder::readRect(const Rect& /*r*/, rdr::InStream* is,
  44. const ServerParams& server, rdr::OutStream* os)
  45. {
  46. rdr::U32 numRects;
  47. size_t len;
  48. if (!is->hasData(4))
  49. return false;
  50. is->setRestorePoint();
  51. numRects = is->readU32();
  52. os->writeU32(numRects);
  53. len = server.pf().bpp/8 + numRects * (server.pf().bpp/8 + 8);
  54. if (!is->hasDataOrRestore(len))
  55. return false;
  56. is->clearRestorePoint();
  57. os->copyBytes(is, len);
  58. return true;
  59. }
  60. void RREDecoder::decodeRect(const Rect& r, const void* buffer,
  61. size_t buflen, const ServerParams& server,
  62. ModifiablePixelBuffer* pb)
  63. {
  64. rdr::MemInStream is(buffer, buflen);
  65. const PixelFormat& pf = server.pf();
  66. switch (pf.bpp) {
  67. case 8: rreDecode8 (r, &is, pf, pb); break;
  68. case 16: rreDecode16(r, &is, pf, pb); break;
  69. case 32: rreDecode32(r, &is, pf, pb); break;
  70. }
  71. }