Private if not used elsewhere; underscore suffix only if private

This commit is contained in:
Tim Schaub
2022-07-21 13:03:10 -07:00
parent 998dc82592
commit 5182b16452
8 changed files with 32 additions and 22 deletions

View File

@@ -36,19 +36,19 @@ class AbstractBatchRenderer {
constructor(helper, worker, vertexShader, fragmentShader, customAttributes) { constructor(helper, worker, vertexShader, fragmentShader, customAttributes) {
/** /**
* @type {import("../../webgl/Helper.js").default} * @type {import("../../webgl/Helper.js").default}
* @protected * @private
*/ */
this.helper_ = helper; this.helper_ = helper;
/** /**
* @type {Worker} * @type {Worker}
* @protected * @private
*/ */
this.worker_ = worker; this.worker_ = worker;
/** /**
* @type {WebGLProgram} * @type {WebGLProgram}
* @protected * @private
*/ */
this.program_ = this.helper_.getProgram(fragmentShader, vertexShader); this.program_ = this.helper_.getProgram(fragmentShader, vertexShader);
@@ -57,13 +57,13 @@ class AbstractBatchRenderer {
* @type {Array<import('../../webgl/Helper.js').AttributeDescription>} * @type {Array<import('../../webgl/Helper.js').AttributeDescription>}
* @protected * @protected
*/ */
this.attributes_ = []; this.attributes = [];
/** /**
* @type {Array<CustomAttribute>} * @type {Array<CustomAttribute>}
* @protected * @protected
*/ */
this.customAttributes_ = customAttributes; this.customAttributes = customAttributes;
} }
/** /**
@@ -102,7 +102,7 @@ class AbstractBatchRenderer {
this.helper_.useProgram(this.program_, frameState); this.helper_.useProgram(this.program_, frameState);
this.helper_.bindBuffer(batch.verticesBuffer); this.helper_.bindBuffer(batch.verticesBuffer);
this.helper_.bindBuffer(batch.indicesBuffer); this.helper_.bindBuffer(batch.indicesBuffer);
this.helper_.enableAttributes(this.attributes_); this.helper_.enableAttributes(this.attributes);
const renderCount = batch.indicesBuffer.getSize(); const renderCount = batch.indicesBuffer.getSize();
this.helper_.drawElements(0, renderCount); this.helper_.drawElements(0, renderCount);
@@ -150,7 +150,7 @@ class AbstractBatchRenderer {
type: messageType, type: messageType,
renderInstructions: batch.renderInstructions.buffer, renderInstructions: batch.renderInstructions.buffer,
renderInstructionsTransform: batch.renderInstructionsTransform, renderInstructionsTransform: batch.renderInstructionsTransform,
customAttributesCount: this.customAttributes_.length, customAttributesCount: this.customAttributes.length,
}; };
this.worker_.postMessage(message, [batch.renderInstructions.buffer]); this.worker_.postMessage(message, [batch.renderInstructions.buffer]);

View File

@@ -28,7 +28,7 @@ class LineStringBatchRenderer extends AbstractBatchRenderer {
super(helper, worker, vertexShader, fragmentShader, customAttributes); super(helper, worker, vertexShader, fragmentShader, customAttributes);
// vertices for lines must hold both a position (x,y) and an offset (dx,dy) // vertices for lines must hold both a position (x,y) and an offset (dx,dy)
this.attributes_ = [ this.attributes = [
{ {
name: Attributes.SEGMENT_START, name: Attributes.SEGMENT_START,
size: 2, size: 2,
@@ -68,7 +68,7 @@ class LineStringBatchRenderer extends AbstractBatchRenderer {
// + 1 instruction per line (for vertices count) // + 1 instruction per line (for vertices count)
const totalInstructionsCount = const totalInstructionsCount =
2 * batch.verticesCount + 2 * batch.verticesCount +
(1 + this.customAttributes_.length) * batch.geometriesCount; (1 + this.customAttributes.length) * batch.geometriesCount;
if ( if (
!batch.renderInstructions || !batch.renderInstructions ||
batch.renderInstructions.length !== totalInstructionsCount batch.renderInstructions.length !== totalInstructionsCount
@@ -95,8 +95,8 @@ class LineStringBatchRenderer extends AbstractBatchRenderer {
); );
// custom attributes // custom attributes
for (let k = 0, kk = this.customAttributes_.length; k < kk; k++) { for (let k = 0, kk = this.customAttributes.length; k < kk; k++) {
value = this.customAttributes_[k].callback( value = this.customAttributes[k].callback(
batchEntry.feature, batchEntry.feature,
batchEntry.properties batchEntry.properties
); );

View File

@@ -28,7 +28,7 @@ class PointBatchRenderer extends AbstractBatchRenderer {
super(helper, worker, vertexShader, fragmentShader, customAttributes); super(helper, worker, vertexShader, fragmentShader, customAttributes);
// vertices for point must hold both a position (x,y) and an index (their position in the quad) // vertices for point must hold both a position (x,y) and an index (their position in the quad)
this.attributes_ = [ this.attributes = [
{ {
name: Attributes.POSITION, name: Attributes.POSITION,
size: 2, size: 2,
@@ -61,7 +61,7 @@ class PointBatchRenderer extends AbstractBatchRenderer {
// 2 instructions per vertex for position (x and y) // 2 instructions per vertex for position (x and y)
// + 1 instruction per vertex per custom attributes // + 1 instruction per vertex per custom attributes
const totalInstructionsCount = const totalInstructionsCount =
(2 + this.customAttributes_.length) * batch.geometriesCount; (2 + this.customAttributes.length) * batch.geometriesCount;
if ( if (
!batch.renderInstructions || !batch.renderInstructions ||
batch.renderInstructions.length !== totalInstructionsCount batch.renderInstructions.length !== totalInstructionsCount
@@ -85,8 +85,8 @@ class PointBatchRenderer extends AbstractBatchRenderer {
batch.renderInstructions[renderIndex++] = tmpCoords[1]; batch.renderInstructions[renderIndex++] = tmpCoords[1];
// pushing custom attributes // pushing custom attributes
for (let j = 0, jj = this.customAttributes_.length; j < jj; j++) { for (let j = 0, jj = this.customAttributes.length; j < jj; j++) {
value = this.customAttributes_[j].callback( value = this.customAttributes[j].callback(
batchEntry.feature, batchEntry.feature,
batchEntry.properties batchEntry.properties
); );

View File

@@ -26,7 +26,7 @@ class PolygonBatchRenderer extends AbstractBatchRenderer {
super(helper, worker, vertexShader, fragmentShader, customAttributes); super(helper, worker, vertexShader, fragmentShader, customAttributes);
// By default only a position attribute is required to render polygons // By default only a position attribute is required to render polygons
this.attributes_ = [ this.attributes = [
{ {
name: Attributes.POSITION, name: Attributes.POSITION,
size: 2, size: 2,
@@ -57,7 +57,7 @@ class PolygonBatchRenderer extends AbstractBatchRenderer {
// + 1 instruction per ring (for vertices count in ring) // + 1 instruction per ring (for vertices count in ring)
const totalInstructionsCount = const totalInstructionsCount =
2 * batch.verticesCount + 2 * batch.verticesCount +
(1 + this.customAttributes_.length) * batch.geometriesCount + (1 + this.customAttributes.length) * batch.geometriesCount +
batch.ringsCount; batch.ringsCount;
if ( if (
!batch.renderInstructions || !batch.renderInstructions ||
@@ -85,8 +85,8 @@ class PolygonBatchRenderer extends AbstractBatchRenderer {
); );
// custom attributes // custom attributes
for (let k = 0, kk = this.customAttributes_.length; k < kk; k++) { for (let k = 0, kk = this.customAttributes.length; k < kk; k++) {
value = this.customAttributes_[k].callback( value = this.customAttributes[k].callback(
batchEntry.feature, batchEntry.feature,
batchEntry.properties batchEntry.properties
); );

View File

@@ -292,7 +292,11 @@ class WebGLPointsLayerRenderer extends WebGLLayerRenderer {
*/ */
this.generateBuffersRun_ = 0; this.generateBuffersRun_ = 0;
/**
* @private
*/
this.worker_ = createWebGLWorker(); this.worker_ = createWebGLWorker();
this.worker_.addEventListener( this.worker_.addEventListener(
'message', 'message',
/** /**

View File

@@ -156,8 +156,14 @@ class WebGLVectorLayerRenderer extends WebGLLayerRenderer {
DEFAULT_POINT_FRAGMENT; DEFAULT_POINT_FRAGMENT;
this.pointAttributes_ = toAttributesArray(pointAttributesWithDefault); this.pointAttributes_ = toAttributesArray(pointAttributesWithDefault);
/**
* @private
*/
this.worker_ = createWebGLWorker(); this.worker_ = createWebGLWorker();
/**
* @private
*/
this.batch_ = new MixedGeometryBatch(); this.batch_ = new MixedGeometryBatch();
const source = this.getLayer().getSource(); const source = this.getLayer().getSource();

View File

@@ -89,7 +89,7 @@ describe('Batch renderers', function () {
}); });
describe('constructor', function () { describe('constructor', function () {
it('generates the attributes list', function () { it('generates the attributes list', function () {
expect(batchRenderer.attributes_).to.eql([ expect(batchRenderer.attributes).to.eql([
{name: 'a_position', size: 2, type: FLOAT}, {name: 'a_position', size: 2, type: FLOAT},
{name: 'a_index', size: 1, type: FLOAT}, {name: 'a_index', size: 1, type: FLOAT},
{name: 'a_test', size: 1, type: FLOAT}, {name: 'a_test', size: 1, type: FLOAT},
@@ -192,7 +192,7 @@ describe('Batch renderers', function () {
}); });
describe('constructor', function () { describe('constructor', function () {
it('generates the attributes list', function () { it('generates the attributes list', function () {
expect(batchRenderer.attributes_).to.eql([ expect(batchRenderer.attributes).to.eql([
{name: 'a_segmentStart', size: 2, type: FLOAT}, {name: 'a_segmentStart', size: 2, type: FLOAT},
{name: 'a_segmentEnd', size: 2, type: FLOAT}, {name: 'a_segmentEnd', size: 2, type: FLOAT},
{name: 'a_parameters', size: 1, type: FLOAT}, {name: 'a_parameters', size: 1, type: FLOAT},
@@ -257,7 +257,7 @@ describe('Batch renderers', function () {
}); });
describe('constructor', function () { describe('constructor', function () {
it('generates the attributes list', function () { it('generates the attributes list', function () {
expect(batchRenderer.attributes_).to.eql([ expect(batchRenderer.attributes).to.eql([
{name: 'a_position', size: 2, type: FLOAT}, {name: 'a_position', size: 2, type: FLOAT},
{name: 'a_test', size: 1, type: FLOAT}, {name: 'a_test', size: 1, type: FLOAT},
]); ]);