Compare commits

...

2 Commits

Author SHA1 Message Date
Francisco Dans
6f351dd5fb removes redundant divisions from loop 2015-05-06 12:39:59 +02:00
Francisco Dans
de5ad67a38 avoids repeated creation of shaderVars object 2015-05-06 12:39:26 +02:00
2 changed files with 9 additions and 14 deletions

View File

@ -9,20 +9,10 @@ JS_CLIENT_FILES= lib/torque/*.js \
lib/torque/leaflet/canvas_layer.js \
lib/torque/leaflet/torque.js
all: dist/torque.js dist/torque.full.js
dist/torque.full.uncompressed.js: dist_folder dist/torque.uncompressed.js
$(BROWSERIFY) lib/torque/index.js --standalone torque > dist/torque.full.uncompressed.js
dist/torque.full.js: dist_folder dist/torque.full.uncompressed.js
$(UGLIFYJS) dist/torque.full.uncompressed.js > dist/torque.full.js
dist/torque.uncompressed.js: dist_folder $(JS_CLIENT_FILES)
$(BROWSERIFY) lib/torque/index.js --no-bundle-external --standalone torque > dist/torque.uncompressed.js
dist/torque.js: dist_folder dist/torque.uncompressed.js
$(UGLIFYJS) dist/torque.uncompressed.js > dist/torque.js
dist_folder:
mkdir -p dist

View File

@ -243,6 +243,7 @@ var Filters = require('./torque_filters');
_renderTile: function(tile, key, frame_offset, sprites, shader, shaderVars) {
if (!this._canvas) return;
shaderVars = shaderVars || { zoom: tile.z, 'frame-offset': frame_offset };
var prof = Profiler.metric('torque.renderer.point.renderTile').start();
var ctx = this._ctx;
var blendMode = compop2canvas(shader.eval('comp-op')) || this.options.blendmode;
@ -255,7 +256,11 @@ var Filters = require('./torque_filters');
}
var tileMax = this.options.resolution * (this.TILE_SIZE/this.options.resolution - 1)
var activePixels = tile.timeCount[key];
var anchor = this.options.resolution/2;
var anchor = this.options.resolution >> 1;
if(this._style){
var adjustmentFactor = this._style["marker-width"];
var adjustmentFactorAnchored = adjustmentFactor + anchor;
}
if (activePixels) {
var pixelIndex = tile.timeIndex[key];
for(var p = 0; p < activePixels; ++p) {
@ -264,12 +269,12 @@ var Filters = require('./torque_filters');
if (c) {
var sp = sprites[c];
if (sp === undefined) {
sp = sprites[c] = this.generateSprite(shader, c, torque.extend({ zoom: tile.z, 'frame-offset': frame_offset }, shaderVars));
sp = sprites[c] = this.generateSprite(shader, c, shaderVars);
}
if (sp) {
var x = tile.x[posIdx]- (sp.width >> 1) + anchor;
var x = tile.x[posIdx]- adjustmentFactorAnchored;
var y = tileMax - tile.y[posIdx] + anchor; // flip mercator
ctx.drawImage(sp, x, y - (sp.height >> 1));
ctx.drawImage(sp, x, y - adjustmentFactor);
}
}
}