let deltaX = sock.rQshift16();
let deltaY = sock.rQshift16();
+
+ if ((width === 0) || (height === 0)) {
+ return true;
+ }
+
display.copyImage(deltaX, deltaY, x, y, width, height);
return true;
const uncompressedSize = width * height * 3;
let data;
+ if (uncompressedSize === 0) {
+ return true;
+ }
+
if (uncompressedSize < 12) {
if (sock.rQwait("TIGHT", uncompressedSize)) {
return false;
let data;
+ if (uncompressedSize === 0) {
+ return true;
+ }
+
if (uncompressedSize < 12) {
if (sock.rQwait("TIGHT", uncompressedSize)) {
return false;
expect(display).to.have.displayed(targetData);
});
+
+ it('should handle empty rects', function () {
+ display.fillRect(0, 0, 4, 4, [ 0x00, 0x00, 0xff ]);
+ display.fillRect(2, 0, 2, 2, [ 0x00, 0xff, 0x00 ]);
+ display.fillRect(0, 2, 2, 2, [ 0x00, 0xff, 0x00 ]);
+
+ testDecodeRect(decoder, 1, 2, 0, 0, [0x00, 0x00, 0x00, 0x00], display, 24);
+
+ let targetData = new Uint8Array([
+ 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
+ 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
+ 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255,
+ 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255
+ ]);
+
+ expect(display).to.have.displayed(targetData);
+ });
});
let data = [45]; // an invalid subencoding
expect(() => testDecodeRect(decoder, 0, 0, 4, 4, data, display, 24)).to.throw();
});
+
+ it('should handle empty rects', function () {
+ display.fillRect(0, 0, 4, 4, [ 0x00, 0x00, 0xff ]);
+ display.fillRect(2, 0, 2, 2, [ 0x00, 0xff, 0x00 ]);
+ display.fillRect(0, 2, 2, 2, [ 0x00, 0xff, 0x00 ]);
+
+ testDecodeRect(decoder, 1, 2, 0, 0, [], display, 24);
+
+ let targetData = new Uint8Array([
+ 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
+ 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
+ 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255,
+ 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255
+ ]);
+
+ expect(display).to.have.displayed(targetData);
+ });
});
expect(display).to.have.displayed(targetData);
});
+
+ it('should handle empty rects', function () {
+ display.fillRect(0, 0, 4, 4, [ 0x00, 0x00, 0xff ]);
+ display.fillRect(2, 0, 2, 2, [ 0x00, 0xff, 0x00 ]);
+ display.fillRect(0, 2, 2, 2, [ 0x00, 0xff, 0x00 ]);
+
+ testDecodeRect(decoder, 1, 2, 0, 0, [], display, 24);
+
+ let targetData = new Uint8Array([
+ 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
+ 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
+ 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255,
+ 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255
+ ]);
+
+ expect(display).to.have.displayed(targetData);
+ });
+
+ it('should handle empty rects in low colour mode', function () {
+ display.fillRect(0, 0, 4, 4, [ 0x00, 0x00, 0xff ]);
+ display.fillRect(2, 0, 2, 2, [ 0x00, 0xff, 0x00 ]);
+ display.fillRect(0, 2, 2, 2, [ 0x00, 0xff, 0x00 ]);
+
+ testDecodeRect(decoder, 1, 2, 0, 0, [], display, 8);
+
+ let targetData = new Uint8Array([
+ 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
+ 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
+ 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255,
+ 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255
+ ]);
+
+ expect(display).to.have.displayed(targetData);
+ });
});
expect(display).to.have.displayed(targetData);
});
+
+ it('should handle empty rects', function () {
+ display.fillRect(0, 0, 4, 4, [ 0x00, 0x00, 0xff ]);
+ display.fillRect(2, 0, 2, 2, [ 0x00, 0xff, 0x00 ]);
+ display.fillRect(0, 2, 2, 2, [ 0x00, 0xff, 0x00 ]);
+
+ testDecodeRect(decoder, 1, 2, 0, 0, [ 0x00, 0xff, 0xff, 0xff, 0xff ], display, 24);
+
+ let targetData = new Uint8Array([
+ 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
+ 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
+ 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255,
+ 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255
+ ]);
+
+ expect(display).to.have.displayed(targetData);
+ });
});
// Not implemented yet
});
+ it('should handle empty copy rects', function () {
+ display.fillRect(0, 0, 4, 4, [ 0x00, 0x00, 0xff ]);
+ display.fillRect(2, 0, 2, 2, [ 0x00, 0xff, 0x00 ]);
+ display.fillRect(0, 2, 2, 2, [ 0x00, 0xff, 0x00 ]);
+
+ testDecodeRect(decoder, 1, 2, 0, 0, [ 0x00 ], display, 24);
+
+ let targetData = new Uint8Array([
+ 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
+ 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
+ 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255,
+ 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255
+ ]);
+
+ expect(display).to.have.displayed(targetData);
+ });
+
+ it('should handle empty palette rects', function () {
+ display.fillRect(0, 0, 4, 4, [ 0x00, 0x00, 0xff ]);
+ display.fillRect(2, 0, 2, 2, [ 0x00, 0xff, 0x00 ]);
+ display.fillRect(0, 2, 2, 2, [ 0x00, 0xff, 0x00 ]);
+
+ testDecodeRect(decoder, 1, 2, 0, 0,
+ [ 0x40, 0x01, 0x01,
+ 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff ], display, 24);
+
+ let targetData = new Uint8Array([
+ 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
+ 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
+ 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255,
+ 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255
+ ]);
+
+ expect(display).to.have.displayed(targetData);
+ });
+
+ it('should handle empty fill rects', function () {
+ display.fillRect(0, 0, 4, 4, [ 0x00, 0x00, 0xff ]);
+ display.fillRect(2, 0, 2, 2, [ 0x00, 0xff, 0x00 ]);
+ display.fillRect(0, 2, 2, 2, [ 0x00, 0xff, 0x00 ]);
+
+ testDecodeRect(decoder, 1, 2, 0, 0,
+ [ 0x80, 0xff, 0xff, 0xff ], display, 24);
+
+ let targetData = new Uint8Array([
+ 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
+ 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
+ 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255,
+ 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255
+ ]);
+
+ expect(display).to.have.displayed(targetData);
+ });
+
it('should handle JPEG rects', function (done) {
let data = [
// Control bytes