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.

HextileEncoder.cxx 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
  2. * Copyright (C) 2005 Constantin Kaplinsky. All Rights Reserved.
  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. #include <rfb/encodings.h>
  20. #include <rfb/SMsgWriter.h>
  21. #include <rfb/SConnection.h>
  22. #include <rfb/HextileEncoder.h>
  23. #include <rfb/PixelFormat.h>
  24. #include <rfb/PixelBuffer.h>
  25. #include <rfb/Configuration.h>
  26. using namespace rfb;
  27. BoolParameter improvedHextile("ImprovedHextile",
  28. "Use improved compression algorithm for Hextile "
  29. "encoding which achieves better compression "
  30. "ratios by the cost of using more CPU time",
  31. true);
  32. #define BPP 8
  33. #include <rfb/hextileEncode.h>
  34. #include <rfb/hextileEncodeBetter.h>
  35. #undef BPP
  36. #define BPP 16
  37. #include <rfb/hextileEncode.h>
  38. #include <rfb/hextileEncodeBetter.h>
  39. #undef BPP
  40. #define BPP 32
  41. #include <rfb/hextileEncode.h>
  42. #include <rfb/hextileEncodeBetter.h>
  43. #undef BPP
  44. HextileEncoder::HextileEncoder(SConnection* conn) : Encoder(conn)
  45. {
  46. }
  47. HextileEncoder::~HextileEncoder()
  48. {
  49. }
  50. void HextileEncoder::writeRect(const Rect& r, PixelBuffer* pb)
  51. {
  52. conn->writer()->startRect(r, encodingHextile);
  53. rdr::OutStream* os = conn->getOutStream();
  54. const PixelFormat& pf = conn->cp.pf();
  55. switch (pf.bpp) {
  56. case 8:
  57. if (improvedHextile) {
  58. hextileEncodeBetter8(r, os, pf, pb);
  59. } else {
  60. hextileEncode8(r, os, pf, pb);
  61. }
  62. break;
  63. case 16:
  64. if (improvedHextile) {
  65. hextileEncodeBetter16(r, os, pf, pb);
  66. } else {
  67. hextileEncode16(r, os, pf, pb);
  68. }
  69. break;
  70. case 32:
  71. if (improvedHextile) {
  72. hextileEncodeBetter32(r, os, pf, pb);
  73. } else {
  74. hextileEncode32(r, os, pf, pb);
  75. }
  76. break;
  77. }
  78. conn->writer()->endRect();
  79. }