rre.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * noVNC: HTML5 VNC client
  3. * Copyright (C) 2019 The noVNC Authors
  4. * Licensed under MPL 2.0 (see LICENSE.txt)
  5. *
  6. * See README.md for usage and integration instructions.
  7. *
  8. */
  9. export default class RREDecoder {
  10. constructor() {
  11. this._subrects = 0;
  12. }
  13. decodeRect(x, y, width, height, sock, display, depth) {
  14. if (this._subrects === 0) {
  15. if (sock.rQwait("RRE", 4 + 4)) {
  16. return false;
  17. }
  18. this._subrects = sock.rQshift32();
  19. let color = sock.rQshiftBytes(4); // Background
  20. display.fillRect(x, y, width, height, color);
  21. }
  22. while (this._subrects > 0) {
  23. if (sock.rQwait("RRE", 4 + 8)) {
  24. return false;
  25. }
  26. let color = sock.rQshiftBytes(4);
  27. let sx = sock.rQshift16();
  28. let sy = sock.rQshift16();
  29. let swidth = sock.rQshift16();
  30. let sheight = sock.rQshift16();
  31. display.fillRect(x + sx, y + sy, swidth, sheight, color);
  32. this._subrects--;
  33. }
  34. return true;
  35. }
  36. }