use a function to transform comp-op to composite operation

This commit is contained in:
javi 2014-12-17 08:48:23 +01:00
parent e9f738914c
commit c3b159b64d

View File

@ -26,13 +26,17 @@ var carto = global.carto || require('carto');
"dst-in": 'destination-in', "dst-in": 'destination-in',
"src-out": 'source-out', "src-out": 'source-out',
"dst-out": 'destination-out', "dst-out": 'destination-out',
"src-atop": '', "src-atop": null,
"dst-atop": '', "dst-atop": null,
"xor": '', "xor": null,
"darken": 'darken', "darken": 'darken',
"lighten": 'lighten' "lighten": 'lighten'
} }
function compop2canvas(compop) {
return COMP_OP_TO_CANVAS[compop] || compop;
}
// //
// this renderer just render points depending of the value // this renderer just render points depending of the value
// //
@ -61,9 +65,9 @@ var carto = global.carto || require('carto');
var ctx = this._ctx; var ctx = this._ctx;
ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.setTransform(1, 0, 0, 1, 0, 0);
var compop = this._Map['comp-op'] var compop = this._Map['comp-op']
ctx.globalCompositeOperation = COMP_OP_TO_CANVAS[compop]; ctx.globalCompositeOperation = compop2canvas(compop);
ctx.fillStyle = color; ctx.fillStyle = color;
ctx.fillRect(0, 0, this._canvas.width, canvas.height); ctx.fillRect(0, 0, canvas.width, canvas.height);
} }
}, },
@ -178,7 +182,7 @@ var carto = global.carto || require('carto');
var prof = Profiler.metric('torque.renderer.point.renderTile').start(); var prof = Profiler.metric('torque.renderer.point.renderTile').start();
var ctx = this._ctx; var ctx = this._ctx;
var blendMode = COMP_OP_TO_CANVAS[shader.eval('comp-op')] || this.options.blendmode; var blendMode = compop2canvas(shader.eval('comp-op')) || this.options.blendmode;
if(blendMode) { if(blendMode) {
ctx.globalCompositeOperation = blendMode; ctx.globalCompositeOperation = blendMode;
} }