Skip to content

Commit

Permalink
Merge pull request #1053 from Viglino/revert-1052-master
Browse files Browse the repository at this point in the history
Revert "Swipe : Each WebGL tile only clears its part of the canvas"
  • Loading branch information
Viglino authored Apr 18, 2024
2 parents e98142a + 0ec690d commit 3c2d09b
Showing 1 changed file with 20 additions and 21 deletions.
41 changes: 20 additions & 21 deletions src/control/Swipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,33 +304,32 @@ var ol_control_Swipe = class olcontrolSwipe extends ol_control_Control {
var ctx = e.context;
if (ctx instanceof WebGLRenderingContext) {
if (e.type === 'prerender') {
// Clear
ctx.clearColor(0, 0, 0, 0);
ctx.clear(ctx.COLOR_BUFFER_BIT);

// Clip
ctx.enable(ctx.SCISSOR_TEST);

const mapSize = this.getMap().getSize(); // [width, height] in CSS pixels
var mapSize = this.getMap().getSize(); // [width, height] in CSS pixels


// get render coordinates and dimensions given CSS coordinates
const bottomLeft = this._transformPt(e, [0, mapSize[1]]);
const topRight = this._transformPt(e, [mapSize[0], 0]);
var bottomLeft = this._transformPt(e, [0, mapSize[1]]);
var topRight = this._transformPt(e, [mapSize[0], 0]);

const fullWidth = topRight[0] - bottomLeft[0];
const fullHeight = topRight[1] - bottomLeft[1];
var fullWidth = topRight[0] - bottomLeft[0];
var fullHeight = topRight[1] - bottomLeft[1];
var width, height;
if (this.get('orientation') === "vertical") {
height = fullHeight;
width = Math.round(fullWidth * this.get('position'));
height = fullHeight;
} else {
width = fullWidth;
height = Math.round((fullHeight * this.get('position')));
bottomLeft[1] += fullHeight - height;
}
ctx.scissor(bottomLeft[0], bottomLeft[1], width, height);

// Clear
ctx.clearColor(0, 0, 0, 0);
ctx.clear(ctx.COLOR_BUFFER_BIT);
}
} else {
var size = e.frameState.size;
Expand All @@ -355,21 +354,25 @@ var ol_control_Swipe = class olcontrolSwipe extends ol_control_Control {
/** @private
*/
precomposeRight(e) {
const ctx = e.context;
var ctx = e.context;
if (ctx instanceof WebGLRenderingContext) {
if (e.type === 'prerender') {
// Clear
ctx.clearColor(0, 0, 0, 0);
ctx.clear(ctx.COLOR_BUFFER_BIT);

// Clip
ctx.enable(ctx.SCISSOR_TEST);

const mapSize = this.getMap().getSize(); // [width, height] in CSS pixels
var mapSize = this.getMap().getSize(); // [width, height] in CSS pixels


// get render coordinates and dimensions given CSS coordinates
const bottomLeft = this._transformPt(e, [0, mapSize[1]]);
const topRight = this._transformPt(e, [mapSize[0], 0]);
var bottomLeft = this._transformPt(e, [0, mapSize[1]]);
var topRight = this._transformPt(e, [mapSize[0], 0]);

const fullWidth = topRight[0] - bottomLeft[0];
const fullHeight = topRight[1] - bottomLeft[1];
var fullWidth = topRight[0] - bottomLeft[0];
var fullHeight = topRight[1] - bottomLeft[1];
var width, height;
if (this.get('orientation') === "vertical") {
height = fullHeight;
Expand All @@ -380,10 +383,6 @@ var ol_control_Swipe = class olcontrolSwipe extends ol_control_Control {
height = Math.round(fullHeight * (1 - this.get('position')));
}
ctx.scissor(bottomLeft[0], bottomLeft[1], width, height);

// Clear
ctx.clearColor(0, 0, 0, 0);
ctx.clear(ctx.COLOR_BUFFER_BIT);
}
} else {
var size = e.frameState.size;
Expand Down

0 comments on commit 3c2d09b

Please sign in to comment.