prepares point renderer for ball renderer

This commit is contained in:
Francisco Dans 2015-02-23 15:16:57 +01:00
parent 82c5ef2b96
commit cd396b19c3

View File

@ -3,6 +3,7 @@ var cartocss = require('./cartocss_render');
var Profiler = require('../profiler');
var carto = global.carto || require('carto');
var filters = require('./torque_filters');
var ballRenderer = require('./ball.js');
var TAU = Math.PI * 2;
var DEFAULT_CARTOCSS = [
@ -56,6 +57,7 @@ var filters = require('./torque_filters');
this.TILE_SIZE = 256;
this._style = null;
this._gradients = {};
this._ballRenderer = ballRenderer(this._canvas);
this._forcePoints = false;
}
@ -163,22 +165,23 @@ var filters = require('./torque_filters');
// renders all the layers (and frames for each layer) from cartocss
//
renderTile: function(tile, key) {
var prof = Profiler.metric('torque.renderer.point.renderLayers').start();
var layers = this._shader.getLayers();
for(var i = 0, n = layers.length; i < n; ++i ) {
var layer = layers[i];
if (layer.name() !== "Map") {
var sprites = this._sprites[i] || (this._sprites[i] = {});
// frames for each layer
for(var fr = 0; fr < layer.frames().length; ++fr) {
var frame = layer.frames()[fr];
var fr_sprites = sprites[frame] || (sprites[frame] = []);
this._renderTile(tile, key - frame, frame, fr_sprites, layer);
}
}
}
this._renderTile(tile, key, 0, null, null, null, pos);
// var prof = Profiler.metric('torque.renderer.point.renderLayers').start();
// var layers = this._shader.getLayers();
// for(var i = 0, n = layers.length; i < n; ++i ) {
// var layer = layers[i];
// if (layer.name() !== "Map") {
// var sprites = this._sprites[i] || (this._sprites[i] = {});
// // frames for each layer
// for(var fr = 0; fr < layer.frames().length; ++fr) {
// var frame = layer.frames()[fr];
// var fr_sprites = sprites[frame] || (sprites[frame] = []);
// this._renderTile(tile, key - frame, frame, fr_sprites, layer);
// }
// }
// }
prof.end(true);
// prof.end(true);
},
_createCanvas: function() {
@ -207,7 +210,7 @@ var filters = require('./torque_filters');
// renders a tile in the canvas for key defined in
// the torque tile
//
_renderTile: function(tile, key, frame_offset, sprites, shader, shaderVars) {
_renderTile: function(tile, key, frame_offset, sprites, shader, shaderVars, pos) {
if (!this._canvas) return;
var prof = Profiler.metric('torque.renderer.point.renderTile').start();
@ -228,15 +231,15 @@ var filters = require('./torque_filters');
var posIdx = tile.renderDataPos[pixelIndex + p];
var c = tile.renderData[pixelIndex + p];
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));
}
if (sp) {
var x = tile.x[posIdx]- (sp.width >> 1);
var y = tileMax - tile.y[posIdx]; // flip mercator
ctx.drawImage(sp, x, y - (sp.height >> 1));
}
// var sp = sprites[c];
// if (sp === undefined) {
// sp = sprites[c] = this.generateSprite(shader, c, torque.extend({ zoom: tile.z, 'frame-offset': frame_offset }, shaderVars));
// }
// if (sp) {
// var x = tile.x[posIdx]- (sp.width >> 1);
// var y = tileMax - tile.y[posIdx]; // flip mercator
// ctx.drawImage(sp, x, y - (sp.height >> 1));
// }
}
}
}