Skip to content

Commit

Permalink
Add internal API docs for Binder
Browse files Browse the repository at this point in the history
  • Loading branch information
jfirebaugh committed Nov 17, 2017
1 parent 4a20890 commit 485ff9f
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/data/program_configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> {
property: string;
statistics: { max: number };
Expand Down

0 comments on commit 485ff9f

Please sign in to comment.