Skip to content

Commit

Permalink
remove *_buffer files and consolidate buffer layouts
Browse files Browse the repository at this point in the history
  • Loading branch information
mourner committed Oct 1, 2015
1 parent 48210eb commit 7adae7a
Show file tree
Hide file tree
Showing 16 changed files with 66 additions and 206 deletions.
33 changes: 0 additions & 33 deletions js/data/buffer/buffer_set.js

This file was deleted.

19 changes: 0 additions & 19 deletions js/data/buffer/circle_vertex_buffer.js

This file was deleted.

27 changes: 0 additions & 27 deletions js/data/buffer/collision_box_vertex_buffer.js

This file was deleted.

19 changes: 0 additions & 19 deletions js/data/buffer/fill_vertex_buffer.js

This file was deleted.

23 changes: 0 additions & 23 deletions js/data/buffer/line_vertex_buffer.js

This file was deleted.

19 changes: 0 additions & 19 deletions js/data/buffer/outline_element_buffer.js

This file was deleted.

31 changes: 0 additions & 31 deletions js/data/buffer/symbol_vertex_buffer.js

This file was deleted.

19 changes: 0 additions & 19 deletions js/data/buffer/triangle_element_buffer.js

This file was deleted.

60 changes: 60 additions & 0 deletions js/data/buffer_set.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
'use strict';

var Buffer = require('./buffer');

module.exports = BufferSet;

var fillVertexOptions = {type: Buffer.BufferType.VERTEX, attributes: [
{name: 'pos', components: 2, type: Buffer.AttributeType.SHORT}
]};

var lineVertexOptions = {type: Buffer.BufferType.VERTEX, attributes: [
{name: 'pos', components: 2, type: Buffer.AttributeType.SHORT},
{name: 'data', components: 4, type: Buffer.AttributeType.BYTE}
]};

var symbolVertexOptions = {type: Buffer.BufferType.VERTEX, attributes: [
{name: 'pos', components: 2, type: Buffer.AttributeType.SHORT},
{name: 'offset', components: 2, type: Buffer.AttributeType.SHORT},
{name: 'data1', components: 4, type: Buffer.AttributeType.UNSIGNED_BYTE},
{name: 'data2', components: 4, type: Buffer.AttributeType.UNSIGNED_BYTE}
]};

var collisionBoxVertexOptions = {type: Buffer.BufferType.VERTEX, attributes: [
{name: 'pos', components: 2, type: Buffer.AttributeType.SHORT},
{name: 'extrude', components: 2, type: Buffer.AttributeType.SHORT},
{name: 'data', components: 2, type: Buffer.AttributeType.UNSIGNED_BYTE}
]};

var triangleElementOptions = {type: Buffer.BufferType.ELEMENT, attributes: [
{name: 'vertices', components: 3, type: Buffer.AttributeType.ELEMENT_ATTRIBUTE_TYPE}
]};

var outlineElementOptions = {type: Buffer.BufferType.ELEMENT, attributes: [
{name: 'vertices', components: 2, type: Buffer.AttributeType.ELEMENT_ATTRIBUTE_TYPE}
]};

var bufferOptions = {
glyphVertex: symbolVertexOptions,
glyphElement: triangleElementOptions,
iconVertex: symbolVertexOptions,
iconElement: triangleElementOptions,
circleVertex: fillVertexOptions,
circleElement: triangleElementOptions,
fillVertex: fillVertexOptions,
fillElement: triangleElementOptions,
outlineElement: outlineElementOptions,
lineVertex: lineVertexOptions,
lineElement: triangleElementOptions,
collisionBoxVertex: collisionBoxVertexOptions
};

function BufferSet(bufferset) {
bufferset = bufferset || {};

for (var id in bufferOptions) {
bufferset[id] = bufferset[id] || new Buffer(bufferOptions[id]);
}

return bufferset;
}
2 changes: 1 addition & 1 deletion js/source/tile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var glmatrix = require('gl-matrix');
var mat2 = glmatrix.mat2;
var mat4 = glmatrix.mat4;
var util = require('../util/util');
var BufferSet = require('../data/buffer/buffer_set');
var BufferSet = require('../data/buffer_set');

module.exports = Tile;

Expand Down
2 changes: 1 addition & 1 deletion js/source/worker_tile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

var FeatureTree = require('../data/feature_tree');
var CollisionTile = require('../symbol/collision_tile');
var BufferSet = require('../data/buffer/buffer_set');
var BufferSet = require('../data/buffer_set');
var createBucket = require('../data/create_bucket');

module.exports = WorkerTile;
Expand Down
2 changes: 1 addition & 1 deletion test/js/data/create_bucket.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

var test = require('prova');
var createBucket = require('../../../js/data/create_bucket');
var BufferSet = require('../../../js/data/buffer/buffer_set');
var BufferSet = require('../../../js/data/buffer_set');
var LineBucket = require('../../../js/data/line_bucket');
var FillBucket = require('../../../js/data/fill_bucket');
var SymbolBucket = require('../../../js/data/symbol_bucket');
Expand Down
2 changes: 1 addition & 1 deletion test/js/data/fill_bucket.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var Protobuf = require('pbf');
var VectorTile = require('vector-tile').VectorTile;
var Point = require('point-geometry');
var FillBucket = require('../../../js/data/fill_bucket');
var BufferSet = require('../../../js/data/buffer/buffer_set');
var BufferSet = require('../../../js/data/buffer_set');
var path = require('path');

// Load a fill feature from fixture tile.
Expand Down
2 changes: 1 addition & 1 deletion test/js/data/line_bucket.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var Protobuf = require('pbf');
var VectorTile = require('vector-tile').VectorTile;
var Point = require('point-geometry');
var LineBucket = require('../../../js/data/line_bucket');
var BufferSet = require('../../../js/data/buffer/buffer_set');
var BufferSet = require('../../../js/data/buffer_set');

// Load a line feature from fixture tile.
var vt = new VectorTile(new Protobuf(new Uint8Array(fs.readFileSync(path.join(__dirname, '/../../fixtures/mbsv5-6-18-23.vector.pbf')))));
Expand Down
2 changes: 1 addition & 1 deletion test/js/data/symbol_bucket.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var path = require('path');
var Protobuf = require('pbf');
var VectorTile = require('vector-tile').VectorTile;
var SymbolBucket = require('../../../js/data/symbol_bucket');
var BufferSet = require('../../../js/data/buffer/buffer_set');
var BufferSet = require('../../../js/data/buffer_set');
var Collision = require('../../../js/symbol/collision_tile');
var GlyphAtlas = require('../../../js/symbol/glyph_atlas');
var LayoutProperties = require('../../../js/style/layout_properties');
Expand Down
10 changes: 0 additions & 10 deletions test/js/geo/transform.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ var test = require('prova');
var Point = require('point-geometry');
var Transform = require('../../../js/geo/transform');
var LngLat = require('../../../js/geo/lng_lat');
var VertexBuffer = require('../../../js/data/buffer/line_vertex_buffer');

var fixed = require('../../testutil/fixed');
var fixedLngLat = fixed.LngLat;
Expand Down Expand Up @@ -136,12 +135,3 @@ test('transform', function(t) {
t.end();
});
});

test('vertex buffer', function(t) {
t.test('is initialized', function(t) {
var buf = new VertexBuffer();
t.deepEqual(buf.length, 0);
t.deepEqual(buf.capacity, 8192);
t.end();
});
});

0 comments on commit 7adae7a

Please sign in to comment.