Standardise on a single blit function
Keep everything simpler by always blitting in the same pixel format. It's up to the decoders to convert if they need to.
This commit is contained in:
committed by
Lauri Kasanen
parent
c7a7ce70be
commit
ae1bc396bf
@@ -36,15 +36,10 @@ describe('CopyRect Decoder', function () {
|
||||
});
|
||||
|
||||
it('should handle the CopyRect encoding', function () {
|
||||
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
|
||||
]);
|
||||
|
||||
// seed some initial data to copy
|
||||
display.blitRgbxImage(0, 0, 4, 2, new Uint8Array(targetData.slice(0, 32)), 0);
|
||||
display.fillRect(0, 0, 4, 4, [ 0x11, 0x22, 0x33 ]);
|
||||
display.fillRect(0, 0, 2, 2, [ 0xff, 0x00, 0x00 ]);
|
||||
display.fillRect(2, 0, 2, 2, [ 0x00, 0xff, 0x00 ]);
|
||||
|
||||
testDecodeRect(decoder, 0, 2, 2, 2,
|
||||
[0x00, 0x02, 0x00, 0x00],
|
||||
@@ -53,6 +48,13 @@ describe('CopyRect Decoder', function () {
|
||||
[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);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -322,18 +322,6 @@ describe('Display/Canvas Helper', function () {
|
||||
expect(display).to.have.displayed(checkedData);
|
||||
});
|
||||
|
||||
it('should support drawing RGB blit images with true color via #blitRgbImage', function () {
|
||||
const data = [];
|
||||
for (let i = 0; i < 16; i++) {
|
||||
data[i * 3] = checkedData[i * 4];
|
||||
data[i * 3 + 1] = checkedData[i * 4 + 1];
|
||||
data[i * 3 + 2] = checkedData[i * 4 + 2];
|
||||
}
|
||||
display.blitRgbImage(0, 0, 4, 4, data, 0);
|
||||
display.flip();
|
||||
expect(display).to.have.displayed(checkedData);
|
||||
});
|
||||
|
||||
it('should support drawing an image object via #drawImage', function () {
|
||||
const img = makeImageCanvas(checkedData);
|
||||
display.drawImage(img, 0, 0);
|
||||
@@ -416,13 +404,6 @@ describe('Display/Canvas Helper', function () {
|
||||
expect(display.blitImage).to.have.been.calledWith(3, 4, 5, 6, [7, 8, 9], 0);
|
||||
});
|
||||
|
||||
it('should draw a blit RGB image on type "blitRgb"', function () {
|
||||
display.blitRgbImage = sinon.spy();
|
||||
display._renderQPush({ type: 'blitRgb', x: 3, y: 4, width: 5, height: 6, data: [7, 8, 9] });
|
||||
expect(display.blitRgbImage).to.have.been.calledOnce;
|
||||
expect(display.blitRgbImage).to.have.been.calledWith(3, 4, 5, 6, [7, 8, 9], 0);
|
||||
});
|
||||
|
||||
it('should copy a region on type "copy"', function () {
|
||||
display.copyImage = sinon.spy();
|
||||
display._renderQPush({ type: 'copy', x: 3, y: 4, width: 5, height: 6, oldX: 7, oldY: 8 });
|
||||
|
||||
Reference in New Issue
Block a user