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.

Decoder.java 3.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
  2. * Copyright (C) 2019 Brian P. Hinz
  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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
  17. * USA.
  18. */
  19. package com.tigervnc.rfb;
  20. import com.tigervnc.rdr.*;
  21. abstract public class Decoder {
  22. public static class DecoderFlags {
  23. // A constant for decoders that don't need anything special
  24. public static int DecoderPlain = 0;
  25. // All rects for this decoder must be handled in order
  26. public static int DecoderOrdered = 1 << 0;
  27. // Only some of the rects must be handled in order,
  28. // see doesRectsConflict()
  29. public static int DecoderPartiallyOrdered = 1 << 1;
  30. };
  31. public Decoder(int flags)
  32. {
  33. this.flags = flags;
  34. }
  35. abstract public void readRect(Rect r, InStream is,
  36. ServerParams server, OutStream os);
  37. abstract public void decodeRect(Rect r, Object buffer,
  38. int buflen, ServerParams server,
  39. ModifiablePixelBuffer pb);
  40. public void getAffectedRegion(Rect rect, Object buffer,
  41. int buflen, ServerParams server,
  42. Region region)
  43. {
  44. region.reset(rect);
  45. }
  46. public boolean doRectsConflict(Rect rectA, Object bufferA,
  47. int buflenA, Rect rectB,
  48. Object bufferB, int buflenB,
  49. ServerParams server)
  50. {
  51. return false;
  52. }
  53. static public boolean supported(int encoding)
  54. {
  55. switch(encoding) {
  56. case Encodings.encodingRaw:
  57. case Encodings.encodingCopyRect:
  58. case Encodings.encodingRRE:
  59. case Encodings.encodingHextile:
  60. case Encodings.encodingZRLE:
  61. case Encodings.encodingTight:
  62. return true;
  63. default:
  64. return false;
  65. }
  66. }
  67. static public Decoder createDecoder(int encoding) {
  68. switch(encoding) {
  69. case Encodings.encodingRaw:
  70. return new RawDecoder();
  71. case Encodings.encodingCopyRect:
  72. return new CopyRectDecoder();
  73. case Encodings.encodingRRE:
  74. return new RREDecoder();
  75. case Encodings.encodingHextile:
  76. return new HextileDecoder();
  77. case Encodings.encodingZRLE:
  78. return new ZRLEDecoder();
  79. case Encodings.encodingTight:
  80. return new TightDecoder();
  81. default:
  82. return null;
  83. }
  84. }
  85. public final int flags;
  86. }