Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swipe : Each WebGL tile only clears its part of the canvas #1052

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 21 additions & 20 deletions src/control/Swipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,32 +304,33 @@ 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);

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


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

var fullWidth = topRight[0] - bottomLeft[0];
var fullHeight = topRight[1] - bottomLeft[1];
const fullWidth = topRight[0] - bottomLeft[0];
const fullHeight = topRight[1] - bottomLeft[1];
var width, height;
if (this.get('orientation') === "vertical") {
width = Math.round(fullWidth * this.get('position'));
height = fullHeight;
width = Math.round(fullWidth * this.get('position'));
} 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 @@ -354,25 +355,21 @@ var ol_control_Swipe = class olcontrolSwipe extends ol_control_Control {
/** @private
*/
precomposeRight(e) {
var ctx = e.context;
const 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);

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

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

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

var fullWidth = topRight[0] - bottomLeft[0];
var fullHeight = topRight[1] - bottomLeft[1];
const fullWidth = topRight[0] - bottomLeft[0];
const fullHeight = topRight[1] - bottomLeft[1];
var width, height;
if (this.get('orientation') === "vertical") {
height = fullHeight;
Expand All @@ -383,6 +380,10 @@ 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