From 485ff9f03712cd1d4b1506ae99b47b9b65fc0e37 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Fri, 17 Nov 2017 10:30:55 -0800 Subject: [PATCH] Add internal API docs for Binder --- src/data/program_configuration.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/data/program_configuration.js b/src/data/program_configuration.js index f372263e1df..442bba4ed6d 100644 --- a/src/data/program_configuration.js +++ b/src/data/program_configuration.js @@ -46,6 +46,30 @@ function packColor(color: Color): [number, number] { ]; } +/** + * `Binder` is the interface definition for the strategies for constructing, + * uploading, and binding paint property data as GLSL attributes. + * + * It has three implementations, one for each of the three strategies we use: + * + * * For _constant_ properties -- those whose value is a constant, or the constant + * result of evaluating a camera expression at a particular camera position -- we + * don't need a vertex buffer, and instead use a uniform. + * * For data expressions, we use a vertex buffer with a single attribute value, + * the evaluated result of the source function for the given feature. + * * For composite expressions, we use a vertex buffer with two attributes: min and + * max values covering the range of zooms at which we expect the tile to be + * displayed. These values are calculated by evaluating the composite expression for + * the given feature at strategically chosen zoom levels. In addition to this + * attribute data, we also use a uniform value which the shader uses to interpolate + * between the min and max value at the final displayed zoom level. The use of a + * uniform allows us to cheaply update the value on every frame. + * + * Note that the shader source varies depending on whether we're using a uniform or + * attribute. We dynamically compile shaders at runtime to accomodate this. + * + * @private + */ interface Binder { property: string; statistics: { max: number };