main
Raw Download raw file
 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
10export default class RREDecoder {
11    constructor() {
12        this._subrects = 0;
13    }
14
15    decodeRect(x, y, width, height, sock, display, depth) {
16        if (this._subrects === 0) {
17            if (sock.rQwait("RRE", 4 + 4)) {
18                return false;
19            }
20
21            this._subrects = sock.rQshift32();
22
23            let color = sock.rQshiftBytes(4);  // Background
24            display.fillRect(x, y, width, height, color);
25        }
26
27        while (this._subrects > 0) {
28            if (sock.rQwait("RRE", 4 + 8)) {
29                return false;
30            }
31
32            let color = sock.rQshiftBytes(4);
33            let sx = sock.rQshift16();
34            let sy = sock.rQshift16();
35            let swidth = sock.rQshift16();
36            let sheight = sock.rQshift16();
37            display.fillRect(x + sx, y + sy, swidth, sheight, color);
38
39            this._subrects--;
40        }
41
42        return true;
43    }
44}