Skip to content

Commit

Permalink
flipping problem fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pgurenko authored and alinefm committed Jul 3, 2019
1 parent 1ab22ad commit 0c0d76a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
14 changes: 8 additions & 6 deletions ui/spice-web-client/lib/images/bitmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ wdi.BMP2 = $.spcExtend(wdi.SpiceObject, {
var paletteSize = 0, unique, paletteData, numEnts = 0;
if (bpp <= 8 && bpp > 0) {
var palette = [];
if (flags & 1) {
if (flags & wdi.SpiceBitmapFlags.SPICE_BITMAP_FLAGS_PAL_CACHE_ME) {
var paletteOffset = this.bytesToInt32(imageData); // From the begininig of the spice packet?
len = imageData.length;
paletteSize = 4*Math.pow(2,bpp);
Expand Down Expand Up @@ -64,10 +64,11 @@ wdi.BMP2 = $.spcExtend(wdi.SpiceObject, {
paletteSize: numEnts * 4,
palette: palette,
stride: stride,
type: type
type: type,
flags: flags
});
},

setContent: function(c) {
this.imageSize = c.imageSize;
this.width = c.width;
Expand All @@ -79,8 +80,9 @@ wdi.BMP2 = $.spcExtend(wdi.SpiceObject, {
this.size = this.offset + this.imageSize;
this.stride = c.stride;
this.type = c.type;
this.flags = c.flags;
},

marshall: function(context) {
var type = this.type;
var palette = this.palette;
Expand All @@ -89,13 +91,14 @@ wdi.BMP2 = $.spcExtend(wdi.SpiceObject, {
var stride = this.stride;
var data = this.imageData;
var size = data.length;
var flags = this.flags;

var pixelsStride = stride * 8/this.bpp;
var bytesStride = pixelsStride * 4;
var buf = new ArrayBuffer(bytesStride * height);
var buf8 = new Uint8ClampedArray(buf);
var buf32 = new Uint32Array(buf);
var topdown = false;
var topdown = flags & wdi.SpiceBitmapFlags.SPICE_BITMAP_FLAGS_TOP_DOWN;

var oct, i, pos, buffPos, spiceColor;
var b;
Expand Down Expand Up @@ -141,7 +144,6 @@ wdi.BMP2 = $.spcExtend(wdi.SpiceObject, {
}

} else if (type === wdi.SpiceBitmapFmt.SPICE_BITMAP_FMT_RGBA) {
topdown = true;
for (pos = 0; pos < size; pos+=4) {
b = data[pos];
data[pos] = data[pos+2];
Expand Down
2 changes: 1 addition & 1 deletion ui/spice-web-client/lib/rasterEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ wdi.RasterEngine = $.spcExtend(wdi.EventObject.prototype, {
URL.revokeObjectURL(url);
var box = stream.computedBox;
// we only rotate the stream if spice tells us so through the TOP_DOWN flag mask
if (!stream.flags & wdi.SpiceStreamFlags.SPICE_STREAM_FLAGS_TOP_DOWN) {
if (!(stream.flags & wdi.SpiceStreamFlags.SPICE_STREAM_FLAGS_TOP_DOWN)) {
var offsetX = box.x + (this.width/2);
var offsetY = box.y + (this.height/2);
context.save();
Expand Down
5 changes: 2 additions & 3 deletions ui/spice-web-client/process/playbackprocess.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ wdi.PlaybackProcess = $.spcExtend(wdi.EventObject.prototype, {
wdi.Debug.warn('The client browser does not support Web Audio API');
}
this.startTime = 0;
this.typedBuffer = new ArrayBuffer(1024*32);
this.typedBuffer = new ArrayBuffer(this.minBuffSize*2);
this.position = 0;
},

Expand Down Expand Up @@ -96,10 +96,9 @@ wdi.PlaybackProcess = $.spcExtend(wdi.EventObject.prototype, {
flush: function(dataTimestamp) {
if(this.position > 0) {
if (this.started) {
this.playSound(this.typedBuffer, dataTimestamp);
this.playSound(this.typedBuffer.slice(0, this.position), dataTimestamp);
}
this.position = 0;
this.typedBuffer = new ArrayBuffer(1024*32);
}
},

Expand Down

0 comments on commit 0c0d76a

Please sign in to comment.