Skip to content

Commit ad9245c

Browse files
committed
TilemapLayer - {missing changes}
1 parent 818d5bc commit ad9245c

1 file changed

Lines changed: 9 additions & 54 deletions

File tree

src/tilemap/TilemapLayer.js

Lines changed: 9 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -133,17 +133,12 @@ Phaser.TilemapLayer = function (game, tilemap, index, width, height) {
133133
* Using a canvas bitblt/copy when the source and destinations region overlap produces unexpected behavior
134134
* in some browsers, notably Safari.
135135
*
136-
* @property {integer} copySliceCount - [Internal] The number of vertical slices to copy when using a `copyCanvas`.
137-
* This is ratio of the pixel count of the primary canvas to the copy canvas.
138-
* *Note*: Safari 7 based canvas implemenations do not work correctly if slices are used.
139-
*
140136
* @default
141137
*/
142138
this.renderSettings = {
143139
enableScrollDelta: true,
144140
overdrawRatio: 0.20,
145-
copyCanvas: null,
146-
copySliceCount: 1
141+
copyCanvas: null
147142
};
148143

149144
/**
@@ -716,16 +711,7 @@ Phaser.TilemapLayer.prototype.shiftCanvas = function (context, x, y)
716711
}
717712

718713
var copyCanvas = this.renderSettings.copyCanvas;
719-
if (!copyCanvas)
720-
{
721-
// Avoids a second copy but flickers in Safari / Safari Mobile
722-
// Ref. https://github.com/photonstorm/phaser/issues/1439
723-
context.save();
724-
context.globalCompositeOperation = 'copy';
725-
context.drawImage(canvas, dx, dy, copyW, copyH, sx, sy, copyW, copyH);
726-
context.restore();
727-
}
728-
else if (this.renderSettings.copySliceCount === 1)
714+
if (copyCanvas)
729715
{
730716
// Use a second copy buffer, without slice support, for Safari .. again.
731717
// Ensure copy canvas is large enough
@@ -744,45 +730,14 @@ Phaser.TilemapLayer.prototype.shiftCanvas = function (context, x, y)
744730
}
745731
else
746732
{
747-
// Copying happens in slices to minimize copy canvas size overhead
748-
// (This does not work correctly in Safari 7 under move-region-up.)
749-
var sliceCount = this.renderSettings.copySliceCount;
750-
var sH = Math.ceil(copyH / sliceCount);
751-
// Ensure copy canvas is large enough
752-
if (copyCanvas.width < copyW || copyCanvas.height < sH)
753-
{
754-
copyCanvas.width = copyW;
755-
copyCanvas.height = sH;
756-
}
757-
758-
var vShift;
759-
if (dy >= sy)
760-
{
761-
// move old region up, or don't change vertically - copy top to bottom
762-
vShift = sH;
763-
}
764-
else
765-
{
766-
// move old region down - copy segments from bottom to top
767-
vShift = -sH;
768-
dy += (sH * (sliceCount - 1));
769-
sy += (sH * (sliceCount - 1));
770-
}
771-
772-
var copyContext = copyCanvas.getContext('2d');
773-
while (sliceCount--)
774-
{
775-
copyContext.clearRect(0, 0, copyW, sH);
776-
copyContext.drawImage(canvas, dx, dy, copyW, sH, 0, 0, copyW, sH);
777-
// clear allows default 'source-over' semantics
778-
context.clearRect(sx, sy, copyW, sH);
779-
context.drawImage(copyCanvas, 0, 0, copyW, sH, sx, sy, copyW, sH);
780-
781-
dy += vShift;
782-
sy += vShift;
783-
}
784-
733+
// Avoids a second copy but flickers in Safari / Safari Mobile
734+
// Ref. https://github.com/photonstorm/phaser/issues/1439
735+
context.save();
736+
context.globalCompositeOperation = 'copy';
737+
context.drawImage(canvas, dx, dy, copyW, copyH, sx, sy, copyW, copyH);
738+
context.restore();
785739
}
740+
786741
};
787742

788743
/**

0 commit comments

Comments
 (0)