Skip to content

Commit

Permalink
Use explicit 'symbol_text_and_icon' shader name instead of 'symbol'
Browse files Browse the repository at this point in the history
Add is_text back, in follow-up pr shader can be renamed to sdf and
raster, and can be used to draw sdf and raster icons in one pass.
  • Loading branch information
alexshalamov committed Nov 15, 2019
1 parent 61c7310 commit fdc2e55
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 15 deletions.
6 changes: 3 additions & 3 deletions src/render/draw_symbol.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {evaluateVariableOffset} from '../symbol/symbol_layout';
import {
symbolIconUniformValues,
symbolSDFUniformValues,
symbolUniformValues
symbolTextAndIconUniformValues
} from './program/symbol_program';

import type Painter from './painter';
Expand Down Expand Up @@ -213,7 +213,7 @@ function updateVariableAnchorsForBucket(bucket, rotateWithMap, pitchWithMap, var

function getSymbolProgramName(isSDF: boolean, isText: boolean, bucket: SymbolBucket) {
if (bucket.iconsInText && isText) {
return 'symbol';
return 'symbolTextAndIcon';
} else if (isSDF) {
return 'symbolSDF';
} else {
Expand Down Expand Up @@ -314,7 +314,7 @@ function drawLayerSymbols(painter, sourceCache, layer, coords, isText, translate
size, rotateInShader, pitchWithMap, painter, matrix,
uLabelPlaneMatrix, uglCoordMatrix, isText, texSize, true);
} else {
uniformValues = symbolUniformValues(sizeData.kind,
uniformValues = symbolTextAndIconUniformValues(sizeData.kind,
size, rotateInShader, pitchWithMap, painter, matrix,
uLabelPlaneMatrix, uglCoordMatrix, texSize, texSizeIcon);
}
Expand Down
4 changes: 2 additions & 2 deletions src/render/program/program_uniforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {heatmapUniforms, heatmapTextureUniforms} from './heatmap_program';
import {hillshadeUniforms, hillshadePrepareUniforms} from './hillshade_program';
import {lineUniforms, lineGradientUniforms, linePatternUniforms, lineSDFUniforms} from './line_program';
import {rasterUniforms} from './raster_program';
import {symbolIconUniforms, symbolSDFUniforms, symbolUniforms} from './symbol_program';
import {symbolIconUniforms, symbolSDFUniforms, symbolTextAndIconUniforms} from './symbol_program';
import {backgroundUniforms, backgroundPatternUniforms} from './background_program';

export const programUniforms = {
Expand All @@ -36,7 +36,7 @@ export const programUniforms = {
raster: rasterUniforms,
symbolIcon: symbolIconUniforms,
symbolSDF: symbolSDFUniforms,
symbol: symbolUniforms,
symbolTextAndIcon: symbolTextAndIconUniforms,
background: backgroundUniforms,
backgroundPattern: backgroundPatternUniforms
};
14 changes: 7 additions & 7 deletions src/render/program/symbol_program.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export type SymbolSDFUniformsType = {|
'u_is_halo': Uniform1f
|};

export type SymbolUniformsType = {|
export type symbolTextAndIconUniformsType = {|
'u_is_size_zoom_constant': Uniform1i,
'u_is_size_feature_constant': Uniform1i,
'u_size_t': Uniform1f,
Expand All @@ -67,6 +67,7 @@ export type SymbolUniformsType = {|
'u_matrix': UniformMatrix4f,
'u_label_plane_matrix': UniformMatrix4f,
'u_coord_matrix': UniformMatrix4f,
'u_is_text': Uniform1f,
'u_pitch_with_map': Uniform1i,
'u_texsize': Uniform2f,
'u_texsize_icon': Uniform2f,
Expand Down Expand Up @@ -118,7 +119,7 @@ const symbolSDFUniforms = (context: Context, locations: UniformLocations): Symbo
'u_is_halo': new Uniform1f(context, locations.u_is_halo)
});

const symbolUniforms = (context: Context, locations: UniformLocations): SymbolUniformsType => ({
const symbolTextAndIconUniforms = (context: Context, locations: UniformLocations): symbolTextAndIconUniformsType => ({
'u_is_size_zoom_constant': new Uniform1i(context, locations.u_is_size_zoom_constant),
'u_is_size_feature_constant': new Uniform1i(context, locations.u_is_size_feature_constant),
'u_size_t': new Uniform1f(context, locations.u_size_t),
Expand All @@ -131,6 +132,7 @@ const symbolUniforms = (context: Context, locations: UniformLocations): SymbolUn
'u_matrix': new UniformMatrix4f(context, locations.u_matrix),
'u_label_plane_matrix': new UniformMatrix4f(context, locations.u_label_plane_matrix),
'u_coord_matrix': new UniformMatrix4f(context, locations.u_coord_matrix),
'u_is_text': new Uniform1f(context, locations.u_is_text),
'u_pitch_with_map': new Uniform1i(context, locations.u_pitch_with_map),
'u_texsize': new Uniform2f(context, locations.u_texsize),
'u_texsize_icon': new Uniform2f(context, locations.u_texsize_icon),
Expand Down Expand Up @@ -199,7 +201,7 @@ const symbolSDFUniformValues = (
});
};

const symbolUniformValues = (
const symbolTextAndIconUniformValues = (
functionType: string,
size: ?{uSizeT: number, uSize: number},
rotateInShader: boolean,
Expand All @@ -211,14 +213,12 @@ const symbolUniformValues = (
texSizeSDF: [number, number],
texSizeIcon: [number, number]
): UniformValues<SymbolIconUniformsType> => {
const uniforms = extend(symbolSDFUniformValues(functionType, size,
return extend(symbolSDFUniformValues(functionType, size,
rotateInShader, pitchWithMap, painter, matrix, labelPlaneMatrix,
glCoordMatrix, true, texSizeSDF, true), {
'u_texsize_icon': texSizeIcon,
'u_texture_icon': 1
});
delete uniforms['u_is_text'];
return uniforms;
};

export {symbolIconUniforms, symbolSDFUniforms, symbolIconUniformValues, symbolSDFUniformValues, symbolUniformValues, symbolUniforms};
export {symbolIconUniforms, symbolSDFUniforms, symbolIconUniformValues, symbolSDFUniformValues, symbolTextAndIconUniformValues, symbolTextAndIconUniforms};
6 changes: 3 additions & 3 deletions src/shaders/shaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ import symbolIconFrag from './symbol_icon.fragment.glsl';
import symbolIconVert from './symbol_icon.vertex.glsl';
import symbolSDFFrag from './symbol_sdf.fragment.glsl';
import symbolSDFVert from './symbol_sdf.vertex.glsl';
import symbolFrag from './symbol.fragment.glsl';
import symbolVert from './symbol.vertex.glsl';
import symbolTextAndIconFrag from './symbol_text_and_icon.fragment.glsl';
import symbolTextAndIconVert from './symbol_text_and_icon.vertex.glsl';

export const prelude = compile(preludeFrag, preludeVert);
export const background = compile(backgroundFrag, backgroundVert);
Expand All @@ -80,7 +80,7 @@ export const lineSDF = compile(lineSDFFrag, lineSDFVert);
export const raster = compile(rasterFrag, rasterVert);
export const symbolIcon = compile(symbolIconFrag, symbolIconVert);
export const symbolSDF = compile(symbolSDFFrag, symbolSDFVert);
export const symbol = compile(symbolFrag, symbolVert);
export const symbolTextAndIcon = compile(symbolTextAndIconFrag, symbolTextAndIconVert);

// Expand #pragmas to #ifdefs.

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ uniform highp float u_size; // used when size is both zoom and feature constant
uniform mat4 u_matrix;
uniform mat4 u_label_plane_matrix;
uniform mat4 u_coord_matrix;
uniform bool u_is_text;
uniform bool u_pitch_with_map;
uniform highp float u_pitch;
uniform bool u_rotate_symbol;
Expand Down

0 comments on commit fdc2e55

Please sign in to comment.