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.

TightEncoder.h 3.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* Copyright (C) 2000-2003 Constantin Kaplinsky. All Rights Reserved.
  2. * Copyright (C) 2011 D. R. Commander
  3. * Copyright 2014 Pierre Ossman for Cendio AB
  4. *
  5. * This is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This software is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this software; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  18. * USA.
  19. */
  20. #ifndef __RFB_TIGHTENCODER_H__
  21. #define __RFB_TIGHTENCODER_H__
  22. #include <rdr/MemOutStream.h>
  23. #include <rdr/ZlibOutStream.h>
  24. #include <rfb/Encoder.h>
  25. namespace rfb {
  26. class TightEncoder : public Encoder {
  27. public:
  28. TightEncoder(SConnection* conn);
  29. virtual ~TightEncoder();
  30. virtual bool isSupported();
  31. virtual void setCompressLevel(int level);
  32. virtual void writeRect(const PixelBuffer* pb, const Palette& palette);
  33. virtual void writeSolidRect(int width, int height,
  34. const PixelFormat& pf,
  35. const rdr::U8* colour);
  36. protected:
  37. void writeMonoRect(const PixelBuffer* pb, const Palette& palette);
  38. void writeIndexedRect(const PixelBuffer* pb, const Palette& palette);
  39. void writeFullColourRect(const PixelBuffer* pb, const Palette& palette);
  40. void writePixels(const rdr::U8* buffer, const PixelFormat& pf,
  41. unsigned int count, rdr::OutStream* os);
  42. void writeCompact(rdr::OutStream* os, rdr::U32 value);
  43. rdr::OutStream* getZlibOutStream(int streamId, int level, size_t length);
  44. void flushZlibOutStream(rdr::OutStream* os);
  45. protected:
  46. // Preprocessor generated, optimised methods
  47. void writeMonoRect(int width, int height,
  48. const rdr::U8* buffer, int stride,
  49. const PixelFormat& pf, const Palette& palette);
  50. void writeMonoRect(int width, int height,
  51. const rdr::U16* buffer, int stride,
  52. const PixelFormat& pf, const Palette& palette);
  53. void writeMonoRect(int width, int height,
  54. const rdr::U32* buffer, int stride,
  55. const PixelFormat& pf, const Palette& palette);
  56. void writeIndexedRect(int width, int height,
  57. const rdr::U16* buffer, int stride,
  58. const PixelFormat& pf, const Palette& palette);
  59. void writeIndexedRect(int width, int height,
  60. const rdr::U32* buffer, int stride,
  61. const PixelFormat& pf, const Palette& palette);
  62. rdr::ZlibOutStream zlibStreams[4];
  63. rdr::MemOutStream memStream;
  64. int idxZlibLevel, monoZlibLevel, rawZlibLevel;
  65. };
  66. }
  67. #endif