Merge branch 'master' of github.com:mapbox/mapbox-gl-native into android-mason
This commit is contained in:
@@ -37,6 +37,8 @@
|
||||
},
|
||||
'variables' : {
|
||||
'ldflags': [
|
||||
'<@(uv_ldflags)',
|
||||
'<@(uv_static_libs)',
|
||||
'<@(sqlite3_ldflags)',
|
||||
'<@(glfw3_static_libs)',
|
||||
'<@(glfw3_ldflags)',
|
||||
@@ -54,7 +56,7 @@
|
||||
],
|
||||
'dependencies': [
|
||||
'../mapboxgl.gyp:bundle_styles',
|
||||
'../mapboxgl.gyp:mbgl-standalone',
|
||||
'../mapboxgl.gyp:mbgl-core',
|
||||
'../mapboxgl.gyp:mbgl-osx',
|
||||
]
|
||||
}
|
||||
|
||||
@@ -391,9 +391,10 @@ void showColorDebugImage(std::string name, const char *data, size_t logicalWidth
|
||||
float xScale = static_cast<float>(fbWidth) / static_cast<float>(width);
|
||||
float yScale = static_cast<float>(fbHeight) / static_cast<float>(height);
|
||||
|
||||
MBGL_CHECK_ERROR(glClearColor(0.8, 0.8, 0.8, 1));
|
||||
MBGL_CHECK_ERROR(glClear(GL_COLOR_BUFFER_BIT));
|
||||
MBGL_CHECK_ERROR(glEnable(GL_BLEND));
|
||||
MBGL_CHECK_ERROR(glBlendFunc(GL_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
|
||||
MBGL_CHECK_ERROR(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
|
||||
|
||||
MBGL_CHECK_ERROR(glPixelZoom(xScale, -yScale));
|
||||
MBGL_CHECK_ERROR(glRasterPos2f(-1.0f, 1.0f));
|
||||
|
||||
@@ -19,15 +19,17 @@ size_t IconVertexBuffer::add(int16_t x, int16_t y, float ox, float oy, int16_t t
|
||||
shorts[3] /* offset */ = std::round(oy * 64);
|
||||
|
||||
uint8_t *ubytes = static_cast<uint8_t *>(data);
|
||||
ubytes[8] /* labelminzoom */ = labelminzoom * 10;
|
||||
ubytes[9] /* minzoom */ = minzoom * 10; // 1/10 zoom levels: z16 == 160.
|
||||
ubytes[10] /* maxzoom */ = std::fmin(maxzoom, 25) * 10; // 1/10 zoom levels: z16 == 160.
|
||||
// a_data1
|
||||
ubytes[8] /* tex */ = tx / 4;
|
||||
ubytes[9] /* tex */ = ty / 4;
|
||||
ubytes[10] /* labelminzoom */ = labelminzoom * 10;
|
||||
ubytes[11] /* angle */ = (int16_t)std::round(angle * angleFactor) % 256;
|
||||
ubytes[12] /* rangeend */ = util::max((int16_t)std::round(range[0] * angleFactor), (int16_t)0) % 256;
|
||||
ubytes[13] /* rangestart */ = util::min((int16_t)std::round(range[1] * angleFactor), (int16_t)255) % 256;
|
||||
|
||||
shorts[8] /* tex */ = tx;
|
||||
shorts[9] /* tex */ = ty;
|
||||
// a_data2
|
||||
ubytes[12] /* minzoom */ = minzoom * 10; // 1/10 zoom levels: z16 == 160.
|
||||
ubytes[13] /* maxzoom */ = std::fmin(maxzoom, 25) * 10; // 1/10 zoom levels: z16 == 160.
|
||||
ubytes[14] /* rangeend */ = util::max((int16_t)std::round(range[0] * angleFactor), (int16_t)0) % 256;
|
||||
ubytes[15] /* rangestart */ = util::min((int16_t)std::round(range[1] * angleFactor), (int16_t)255) % 256;
|
||||
|
||||
return idx;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
namespace mbgl {
|
||||
|
||||
class IconVertexBuffer : public Buffer<
|
||||
20
|
||||
16
|
||||
> {
|
||||
public:
|
||||
static const double angleFactor;
|
||||
|
||||
@@ -16,8 +16,8 @@ size_t LineVertexBuffer::add(vertex_type x, vertex_type y, float ex, float ey, i
|
||||
int8_t *extrude = static_cast<int8_t *>(data);
|
||||
extrude[4] = std::round(extrudeScale * ex);
|
||||
extrude[5] = std::round(extrudeScale * ey);
|
||||
|
||||
coords[3] = linesofar;
|
||||
extrude[6] = static_cast<int8_t>(linesofar / 128);
|
||||
extrude[7] = static_cast<int8_t>(linesofar % 128);
|
||||
|
||||
return idx;
|
||||
}
|
||||
|
||||
@@ -77,18 +77,22 @@ void copy_bitmap(const uint32_t *src, const int src_stride, const int src_x, con
|
||||
}
|
||||
}
|
||||
|
||||
Rect<SpriteAtlas::dimension> SpriteAtlas::allocateImage(size_t pixel_width, size_t pixel_height) {
|
||||
Rect<SpriteAtlas::dimension> SpriteAtlas::allocateImage(const size_t pixel_width, const size_t pixel_height) {
|
||||
// Increase to next number divisible by 4, but at least 1.
|
||||
// This is so we can scale down the texture coordinates and pack them
|
||||
// into 2 bytes rather than 4 bytes.
|
||||
const uint16_t pack_width = pixel_width + (4 - pixel_width % 4);
|
||||
const uint16_t pack_height = pixel_height + (4 - pixel_width % 4);
|
||||
|
||||
// We have to allocate a new area in the bin, and store an empty image in it.
|
||||
// Add a 1px border around every image.
|
||||
Rect<dimension> rect = bin.allocate(pixel_width + 2 * buffer, pixel_height + 2 * buffer);
|
||||
Rect<dimension> rect = bin.allocate(pack_width, pack_height);
|
||||
if (rect.w == 0) {
|
||||
return rect;
|
||||
}
|
||||
|
||||
rect.x += buffer;
|
||||
rect.y += buffer;
|
||||
rect.w -= 2 * buffer;
|
||||
rect.h -= 2 * buffer;
|
||||
|
||||
return rect;
|
||||
}
|
||||
@@ -123,15 +127,24 @@ Rect<SpriteAtlas::dimension> SpriteAtlas::getImage(const std::string& name) {
|
||||
|
||||
SpriteAtlasPosition SpriteAtlas::getPosition(const std::string& name, bool repeating) {
|
||||
std::lock_guard<std::recursive_mutex> lock(mtx);
|
||||
// `repeating` indicates that the image will be used in a repeating pattern
|
||||
// repeating pattern images are assumed to have a 1px padding that mirrors the opposite edge
|
||||
// positions for repeating images are adjusted to exclude the edge
|
||||
|
||||
Rect<dimension> rect = getImage(name);
|
||||
const int r = repeating ? 1 : 0;
|
||||
if (repeating) {
|
||||
// When the image is repeating, get the correct position of the image, rather than the
|
||||
// one rounded up to 4 pixels.
|
||||
const SpritePosition &pos = sprite->getSpritePosition(name);
|
||||
if (!pos.width || !pos.height) {
|
||||
return SpriteAtlasPosition {};
|
||||
}
|
||||
|
||||
rect.w = pos.width / pos.pixelRatio;
|
||||
rect.h = pos.height / pos.pixelRatio;
|
||||
}
|
||||
|
||||
return SpriteAtlasPosition {
|
||||
{{ float(rect.w) / pixelRatio, float(rect.h) / pixelRatio }},
|
||||
{{ float(rect.x + r) / width, float(rect.y + r) / height }},
|
||||
{{ float(rect.x + rect.w - 2*r) / width, float(rect.y + rect.h - 2*r) / height }}
|
||||
{{ float(rect.w), float(rect.h) }},
|
||||
{{ float(rect.x) / width, float(rect.y) / height }},
|
||||
{{ float(rect.x + rect.w) / width, float(rect.y + rect.h) / height }}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -249,6 +262,8 @@ void SpriteAtlas::bind(bool linear) {
|
||||
}
|
||||
|
||||
dirty = false;
|
||||
|
||||
// platform::show_color_debug_image("Sprite Atlas", reinterpret_cast<const char *>(data), width, height, width * pixelRatio, height * pixelRatio);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -19,6 +19,10 @@ class Sprite;
|
||||
class SpritePosition;
|
||||
|
||||
struct SpriteAtlasPosition {
|
||||
inline SpriteAtlasPosition(const std::array<float, 2> size_ = {{0, 0}},
|
||||
const std::array<float, 2> tl_ = {{0, 0}},
|
||||
const std::array<float, 2> br_ = {{0, 0}})
|
||||
: size(size_), tl(tl_), br(br_) {}
|
||||
std::array<float, 2> size;
|
||||
std::array<float, 2> tl;
|
||||
std::array<float, 2> br;
|
||||
|
||||
@@ -4,30 +4,34 @@
|
||||
|
||||
#include <cmath>
|
||||
|
||||
using namespace mbgl;
|
||||
namespace mbgl {
|
||||
|
||||
const double TextVertexBuffer::angleFactor = 128.0 / M_PI;
|
||||
|
||||
size_t TextVertexBuffer::add(int16_t x, int16_t y, float ox, float oy, uint16_t tx, uint16_t ty, float angle, float minzoom, std::array<float, 2> range, float maxzoom, float labelminzoom) {
|
||||
size_t idx = index();
|
||||
const size_t idx = index();
|
||||
void *data = addElement();
|
||||
|
||||
int16_t *shorts = static_cast<int16_t *>(data);
|
||||
shorts[0] = x;
|
||||
shorts[1] = y;
|
||||
shorts[2] = std::round(ox * 64); // use 1/64 pixels for placement
|
||||
shorts[3] = std::round(oy * 64);
|
||||
shorts[0] /* pos */ = x;
|
||||
shorts[1] /* pos */ = y;
|
||||
shorts[2] /* offset */ = std::round(ox * 64); // use 1/64 pixels for placement
|
||||
shorts[3] /* offset */ = std::round(oy * 64);
|
||||
|
||||
uint8_t *ubytes = static_cast<uint8_t *>(data);
|
||||
ubytes[8] = labelminzoom * 10;
|
||||
ubytes[9] = minzoom * 10; // 1/10 zoom levels: z16 == 160.
|
||||
ubytes[10] = fmin(maxzoom, 25) * 10; // 1/10 zoom levels: z16 == 160.
|
||||
ubytes[11] = (int16_t)round(angle * angleFactor) % 256;
|
||||
ubytes[12] = util::max((int16_t)std::round(range[0] * angleFactor), (int16_t)0) % 256;
|
||||
ubytes[13] = util::min((int16_t)std::round(range[1] * angleFactor), (int16_t)255) % 256;
|
||||
// a_data1
|
||||
ubytes[8] /* tex */ = tx / 4;
|
||||
ubytes[9] /* tex */ = ty / 4;
|
||||
ubytes[10] /* labelminzoom */ = labelminzoom * 10;
|
||||
ubytes[11] /* angle */ = (int16_t)std::round(angle * angleFactor) % 256;
|
||||
|
||||
ubytes[14] = tx / 4;
|
||||
ubytes[15] = ty / 4;
|
||||
// a_data2
|
||||
ubytes[12] /* minzoom */ = minzoom * 10; // 1/10 zoom levels: z16 == 160.
|
||||
ubytes[13] /* maxzoom */ = std::fmin(maxzoom, 25) * 10; // 1/10 zoom levels: z16 == 160.
|
||||
ubytes[14] /* rangeend */ = util::max((int16_t)std::round(range[0] * angleFactor), (int16_t)0) % 256;
|
||||
ubytes[15] /* rangestart */ = util::min((int16_t)std::round(range[1] * angleFactor), (int16_t)255) % 256;
|
||||
|
||||
return idx;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -244,8 +244,6 @@ void Painter::render(const Style& style, const std::set<util::ptr<StyleSource>>&
|
||||
for (const util::ptr<StyleSource> &source : sources) {
|
||||
source->source->finishRender(*this);
|
||||
}
|
||||
|
||||
MBGL_CHECK_ERROR(glFlush());
|
||||
}
|
||||
|
||||
void Painter::renderLayers(util::ptr<StyleLayerGroup> group) {
|
||||
|
||||
@@ -15,13 +15,25 @@ void Painter::renderLine(LineBucket& bucket, util::ptr<StyleLayer> layer_desc, c
|
||||
|
||||
const LineProperties &properties = layer_desc->getProperties<LineProperties>();
|
||||
|
||||
// the distance over which the line edge fades out.
|
||||
// Retina devices need a smaller distance to avoid aliasing.
|
||||
float antialiasing = 1 / state.getPixelRatio();
|
||||
float width = properties.width;
|
||||
float offset = properties.gap_width == 0 ? 0 : (properties.gap_width + width) / 2;
|
||||
float blur = properties.blur + antialiasing;
|
||||
|
||||
float inset = std::fmin((std::fmax(-1, offset - width / 2 - antialiasing / 2) + 1), 16.0f);
|
||||
float outset = std::fmin(offset + width / 2 + antialiasing / 2, 16.0f);
|
||||
float blur = properties.blur + antialiasing;
|
||||
float edgeWidth = properties.width / 2.0;
|
||||
float inset = -1;
|
||||
float offset = 0;
|
||||
float shift = 0;
|
||||
|
||||
if (properties.gap_width != 0) {
|
||||
inset = properties.gap_width / 2.0 + antialiasing * 0.5;
|
||||
edgeWidth = properties.width;
|
||||
|
||||
// shift outer lines half a pixel towards the middle to eliminate the crack
|
||||
offset = inset - antialiasing / 2.0;
|
||||
}
|
||||
|
||||
float outset = offset + edgeWidth + antialiasing / 2.0 + shift;
|
||||
|
||||
Color color = properties.color;
|
||||
color[0] *= properties.opacity;
|
||||
@@ -61,7 +73,7 @@ void Painter::renderLine(LineBucket& bucket, util::ptr<StyleLayer> layer_desc, c
|
||||
}
|
||||
|
||||
if (properties.image.size()) {
|
||||
SpriteAtlasPosition imagePos = spriteAtlas.getPosition(properties.image);
|
||||
SpriteAtlasPosition imagePos = spriteAtlas.getPosition(properties.image, true);
|
||||
|
||||
float factor = 8.0 / std::pow(2, state.getIntegerZoom() - id.z);
|
||||
float fade = std::fmod(state.getZoom(), 1.0);
|
||||
@@ -79,6 +91,7 @@ void Painter::renderLine(LineBucket& bucket, util::ptr<StyleLayer> layer_desc, c
|
||||
linepatternShader->u_pattern_br = imagePos.br;
|
||||
linepatternShader->u_fade = fade;
|
||||
|
||||
MBGL_CHECK_ERROR(glActiveTexture(GL_TEXTURE0));
|
||||
spriteAtlas.bind(true);
|
||||
MBGL_CHECK_ERROR(glDepthRange(strata + strata_epsilon, 1.0f)); // may or may not matter
|
||||
|
||||
|
||||
@@ -134,11 +134,6 @@ void Painter::renderSymbol(SymbolBucket &bucket, util::ptr<StyleLayer> layer_des
|
||||
|
||||
spriteAtlas.bind(state.isChanging() || bucket.properties.placement == PlacementType::Line || angleOffset != 0 || fontScale != 1 || sdf);
|
||||
|
||||
std::array<float, 2> texsize = {{
|
||||
float(spriteAtlas.getWidth()),
|
||||
float(spriteAtlas.getHeight())
|
||||
}};
|
||||
|
||||
if (sdf) {
|
||||
renderSDF(bucket,
|
||||
id,
|
||||
@@ -146,7 +141,7 @@ void Painter::renderSymbol(SymbolBucket &bucket, util::ptr<StyleLayer> layer_des
|
||||
bucket.properties.icon,
|
||||
properties.icon,
|
||||
1.0f,
|
||||
texsize,
|
||||
{{ float(spriteAtlas.getWidth()) / 4.0f, float(spriteAtlas.getHeight()) / 4.0f }},
|
||||
*sdfIconShader,
|
||||
&SymbolBucket::drawIcons);
|
||||
} else {
|
||||
@@ -164,7 +159,7 @@ void Painter::renderSymbol(SymbolBucket &bucket, util::ptr<StyleLayer> layer_des
|
||||
useProgram(iconShader->program);
|
||||
iconShader->u_matrix = vtxMatrix;
|
||||
iconShader->u_exmatrix = exMatrix;
|
||||
iconShader->u_texsize = texsize;
|
||||
iconShader->u_texsize = {{ float(spriteAtlas.getWidth()) / 4.0f, float(spriteAtlas.getHeight()) / 4.0f }};
|
||||
|
||||
// Convert the -pi..pi to an int8 range.
|
||||
const float angle = std::round(state.getAngle() / M_PI * 128);
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
attribute vec2 a_pos;
|
||||
attribute vec2 a_offset;
|
||||
attribute vec2 a_tex;
|
||||
attribute float a_angle;
|
||||
attribute float a_minzoom;
|
||||
attribute float a_maxzoom;
|
||||
attribute float a_rangeend;
|
||||
attribute float a_rangestart;
|
||||
attribute float a_labelminzoom;
|
||||
attribute vec4 a_data1;
|
||||
attribute vec4 a_data2;
|
||||
|
||||
|
||||
// matrix is for the vertex position, exmatrix is for rotating and projecting
|
||||
@@ -28,6 +23,15 @@ varying vec2 v_tex;
|
||||
varying float v_alpha;
|
||||
|
||||
void main() {
|
||||
vec2 a_tex = a_data1.xy;
|
||||
float a_labelminzoom = a_data1[2];
|
||||
float a_angle = a_data1[3];
|
||||
vec2 a_zoom = a_data2.st;
|
||||
float a_minzoom = a_zoom[0];
|
||||
float a_maxzoom = a_zoom[1];
|
||||
vec2 a_range = a_data2.pq;
|
||||
float a_rangeend = a_range[0];
|
||||
float a_rangestart = a_range[1];
|
||||
|
||||
float a_fadedist = 10.0;
|
||||
float rev = 0.0;
|
||||
|
||||
@@ -19,17 +19,12 @@ IconShader::IconShader()
|
||||
|
||||
a_pos = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_pos"));
|
||||
a_offset = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_offset"));
|
||||
a_tex = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_tex"));
|
||||
a_angle = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_angle"));
|
||||
a_minzoom = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_minzoom"));
|
||||
a_maxzoom = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_maxzoom"));
|
||||
a_rangeend = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_rangeend"));
|
||||
a_rangestart = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_rangestart"));
|
||||
a_labelminzoom = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_labelminzoom"));
|
||||
a_data1 = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_data1"));
|
||||
a_data2 = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_data2"));
|
||||
}
|
||||
|
||||
void IconShader::bind(char *offset) {
|
||||
const int stride = 20;
|
||||
const int stride = 16;
|
||||
|
||||
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_pos));
|
||||
MBGL_CHECK_ERROR(glVertexAttribPointer(a_pos, 2, GL_SHORT, false, stride, offset + 0));
|
||||
@@ -37,24 +32,9 @@ void IconShader::bind(char *offset) {
|
||||
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_offset));
|
||||
MBGL_CHECK_ERROR(glVertexAttribPointer(a_offset, 2, GL_SHORT, false, stride, offset + 4));
|
||||
|
||||
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_labelminzoom));
|
||||
MBGL_CHECK_ERROR(glVertexAttribPointer(a_labelminzoom, 1, GL_UNSIGNED_BYTE, false, stride, offset + 8));
|
||||
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_data1));
|
||||
MBGL_CHECK_ERROR(glVertexAttribPointer(a_data1, 4, GL_UNSIGNED_BYTE, false, stride, offset + 8));
|
||||
|
||||
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_minzoom));
|
||||
MBGL_CHECK_ERROR(glVertexAttribPointer(a_minzoom, 1, GL_UNSIGNED_BYTE, false, stride, offset + 9));
|
||||
|
||||
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_maxzoom));
|
||||
MBGL_CHECK_ERROR(glVertexAttribPointer(a_maxzoom, 1, GL_UNSIGNED_BYTE, false, stride, offset + 10));
|
||||
|
||||
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_angle));
|
||||
MBGL_CHECK_ERROR(glVertexAttribPointer(a_angle, 1, GL_UNSIGNED_BYTE, false, stride, offset + 11));
|
||||
|
||||
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_rangeend));
|
||||
MBGL_CHECK_ERROR(glVertexAttribPointer(a_rangeend, 1, GL_UNSIGNED_BYTE, false, stride, offset + 12));
|
||||
|
||||
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_rangestart));
|
||||
MBGL_CHECK_ERROR(glVertexAttribPointer(a_rangestart, 1, GL_UNSIGNED_BYTE, false, stride, offset + 13));
|
||||
|
||||
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_tex));
|
||||
MBGL_CHECK_ERROR(glVertexAttribPointer(a_tex, 2, GL_SHORT, false, stride, offset + 16));
|
||||
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_data2));
|
||||
MBGL_CHECK_ERROR(glVertexAttribPointer(a_data2, 4, GL_UNSIGNED_BYTE, false, stride, offset + 12));
|
||||
}
|
||||
|
||||
@@ -27,13 +27,8 @@ public:
|
||||
private:
|
||||
int32_t a_pos = -1;
|
||||
int32_t a_offset = -1;
|
||||
int32_t a_tex = -1;
|
||||
int32_t a_angle = -1;
|
||||
int32_t a_minzoom = -1;
|
||||
int32_t a_maxzoom = -1;
|
||||
int32_t a_rangeend = -1;
|
||||
int32_t a_rangestart = -1;
|
||||
int32_t a_labelminzoom = -1;
|
||||
int32_t a_data1 = -1;
|
||||
int32_t a_data2 = -1;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
#define scale 0.015873016
|
||||
|
||||
attribute vec2 a_pos;
|
||||
attribute vec2 a_extrude;
|
||||
attribute float a_linesofar;
|
||||
attribute vec4 a_data;
|
||||
|
||||
// matrix is for the vertex position, exmatrix is for rotating and projecting
|
||||
// the extrusion vector.
|
||||
@@ -24,6 +23,9 @@ varying vec2 v_normal;
|
||||
varying float v_linesofar;
|
||||
|
||||
void main() {
|
||||
vec2 a_extrude = a_data.xy;
|
||||
float a_linesofar = a_data.z * 128.0 + a_data.w;
|
||||
|
||||
// We store the texture normals in the most insignificant bit
|
||||
// transform y so that 0 => -1 and 1 => 1
|
||||
// In the texture normal, x is 0 if the normal points straight up/down and 1 if it's a round cap
|
||||
|
||||
@@ -18,17 +18,13 @@ LineShader::LineShader()
|
||||
}
|
||||
|
||||
a_pos = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_pos"));
|
||||
a_extrude = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_extrude"));
|
||||
a_linesofar = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_linesofar"));
|
||||
a_data = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_data"));
|
||||
}
|
||||
|
||||
void LineShader::bind(char *offset) {
|
||||
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_pos));
|
||||
MBGL_CHECK_ERROR(glVertexAttribPointer(a_pos, 2, GL_SHORT, false, 8, offset + 0));
|
||||
|
||||
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_extrude));
|
||||
MBGL_CHECK_ERROR(glVertexAttribPointer(a_extrude, 2, GL_BYTE, false, 8, offset + 4));
|
||||
|
||||
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_linesofar));
|
||||
MBGL_CHECK_ERROR(glVertexAttribPointer(a_linesofar, 1, GL_SHORT, false, 8, offset + 6));
|
||||
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_data));
|
||||
MBGL_CHECK_ERROR(glVertexAttribPointer(a_data, 4, GL_BYTE, false, 8, offset + 4));
|
||||
}
|
||||
|
||||
@@ -22,8 +22,7 @@ public:
|
||||
|
||||
private:
|
||||
int32_t a_pos = -1;
|
||||
int32_t a_extrude = -1;
|
||||
int32_t a_linesofar = -1;
|
||||
int32_t a_data = -1;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
// stored in a byte (-128..127). we scale regular normals up to length 63, but
|
||||
// there are also "special" normals that have a bigger length (of up to 126 in
|
||||
// this case).
|
||||
#define scale 63.0
|
||||
// #define scale 63.0
|
||||
#define scale 0.015873016
|
||||
|
||||
attribute vec2 a_pos;
|
||||
attribute vec2 a_extrude;
|
||||
attribute float a_linesofar;
|
||||
attribute vec4 a_data;
|
||||
|
||||
// matrix is for the vertex position, exmatrix is for rotating and projecting
|
||||
// the extrusion vector.
|
||||
@@ -24,6 +24,9 @@ varying vec2 v_normal;
|
||||
varying float v_linesofar;
|
||||
|
||||
void main() {
|
||||
vec2 a_extrude = a_data.xy;
|
||||
float a_linesofar = a_data.z * 128.0 + a_data.w;
|
||||
|
||||
// We store the texture normals in the most insignificant bit
|
||||
// transform y so that 0 => -1 and 1 => 1
|
||||
// In the texture normal, x is 0 if the normal points straight up/down and 1 if it's a round cap
|
||||
@@ -34,7 +37,7 @@ void main() {
|
||||
|
||||
// Scale the extrusion vector down to a normal and then up by the line width
|
||||
// of this vertex.
|
||||
vec2 extrude = a_extrude / scale;
|
||||
vec2 extrude = a_extrude * scale;
|
||||
vec2 dist = u_linewidth.s * extrude * (1.0 - u_point);
|
||||
|
||||
// If the x coordinate is the maximum integer, we move the z coordinates out
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include <mbgl/shader/linepattern_shader.hpp>
|
||||
#include <mbgl/shader/shaders.hpp>
|
||||
#include <mbgl/platform/gl.hpp>
|
||||
#include <iostream>
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
@@ -19,17 +18,13 @@ LinepatternShader::LinepatternShader()
|
||||
}
|
||||
|
||||
a_pos = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_pos"));
|
||||
a_extrude = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_extrude"));
|
||||
a_linesofar = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_linesofar"));
|
||||
a_data = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_data"));
|
||||
}
|
||||
|
||||
void LinepatternShader::bind(char *offset) {
|
||||
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_pos));
|
||||
MBGL_CHECK_ERROR(glVertexAttribPointer(a_pos, 2, GL_SHORT, false, 8, offset + 0));
|
||||
|
||||
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_extrude));
|
||||
MBGL_CHECK_ERROR(glVertexAttribPointer(a_extrude, 2, GL_BYTE, false, 8, offset + 4));
|
||||
|
||||
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_linesofar));
|
||||
MBGL_CHECK_ERROR(glVertexAttribPointer(a_linesofar, 1, GL_SHORT, false, 8, offset + 6));
|
||||
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_data));
|
||||
MBGL_CHECK_ERROR(glVertexAttribPointer(a_data, 4, GL_BYTE, false, 8, offset + 4));
|
||||
}
|
||||
|
||||
@@ -25,8 +25,7 @@ public:
|
||||
|
||||
private:
|
||||
int32_t a_pos = -1;
|
||||
int32_t a_extrude = -1;
|
||||
int32_t a_linesofar = -1;
|
||||
int32_t a_data = -1;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
attribute vec2 a_pos;
|
||||
attribute vec2 a_offset;
|
||||
attribute vec2 a_tex;
|
||||
attribute float a_angle;
|
||||
attribute float a_minzoom;
|
||||
attribute float a_maxzoom;
|
||||
attribute float a_rangeend;
|
||||
attribute float a_rangestart;
|
||||
attribute float a_labelminzoom;
|
||||
attribute vec4 a_data1;
|
||||
attribute vec4 a_data2;
|
||||
|
||||
|
||||
// matrix is for the vertex position, exmatrix is for rotating and projecting
|
||||
@@ -27,6 +22,15 @@ varying vec2 v_tex;
|
||||
varying float v_alpha;
|
||||
|
||||
void main() {
|
||||
vec2 a_tex = a_data1.xy;
|
||||
float a_labelminzoom = a_data1[2];
|
||||
float a_angle = a_data1[3];
|
||||
vec2 a_zoom = a_data2.st;
|
||||
float a_minzoom = a_zoom[0];
|
||||
float a_maxzoom = a_zoom[1];
|
||||
vec2 a_range = a_data2.pq;
|
||||
float a_rangeend = a_range[0];
|
||||
float a_rangestart = a_range[1];
|
||||
|
||||
float rev = 0.0;
|
||||
|
||||
|
||||
@@ -19,13 +19,8 @@ SDFShader::SDFShader()
|
||||
|
||||
a_pos = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_pos"));
|
||||
a_offset = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_offset"));
|
||||
a_tex = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_tex"));
|
||||
a_angle = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_angle"));
|
||||
a_minzoom = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_minzoom"));
|
||||
a_maxzoom = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_maxzoom"));
|
||||
a_rangeend = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_rangeend"));
|
||||
a_rangestart = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_rangestart"));
|
||||
a_labelminzoom = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_labelminzoom"));
|
||||
a_data1 = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_data1"));
|
||||
a_data2 = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_data2"));
|
||||
}
|
||||
|
||||
void SDFGlyphShader::bind(char *offset) {
|
||||
@@ -37,30 +32,15 @@ void SDFGlyphShader::bind(char *offset) {
|
||||
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_offset));
|
||||
MBGL_CHECK_ERROR(glVertexAttribPointer(a_offset, 2, GL_SHORT, false, stride, offset + 4));
|
||||
|
||||
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_labelminzoom));
|
||||
MBGL_CHECK_ERROR(glVertexAttribPointer(a_labelminzoom, 1, GL_UNSIGNED_BYTE, false, stride, offset + 8));
|
||||
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_data1));
|
||||
MBGL_CHECK_ERROR(glVertexAttribPointer(a_data1, 4, GL_UNSIGNED_BYTE, false, stride, offset + 8));
|
||||
|
||||
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_minzoom));
|
||||
MBGL_CHECK_ERROR(glVertexAttribPointer(a_minzoom, 1, GL_UNSIGNED_BYTE, false, stride, offset + 9));
|
||||
|
||||
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_maxzoom));
|
||||
MBGL_CHECK_ERROR(glVertexAttribPointer(a_maxzoom, 1, GL_UNSIGNED_BYTE, false, stride, offset + 10));
|
||||
|
||||
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_angle));
|
||||
MBGL_CHECK_ERROR(glVertexAttribPointer(a_angle, 1, GL_UNSIGNED_BYTE, false, stride, offset + 11));
|
||||
|
||||
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_rangeend));
|
||||
MBGL_CHECK_ERROR(glVertexAttribPointer(a_rangeend, 1, GL_UNSIGNED_BYTE, false, stride, offset + 12));
|
||||
|
||||
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_rangestart));
|
||||
MBGL_CHECK_ERROR(glVertexAttribPointer(a_rangestart, 1, GL_UNSIGNED_BYTE, false, stride, offset + 13));
|
||||
|
||||
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_tex));
|
||||
MBGL_CHECK_ERROR(glVertexAttribPointer(a_tex, 2, GL_UNSIGNED_BYTE, false, stride, offset + 14));
|
||||
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_data2));
|
||||
MBGL_CHECK_ERROR(glVertexAttribPointer(a_data2, 4, GL_UNSIGNED_BYTE, false, stride, offset + 12));
|
||||
}
|
||||
|
||||
void SDFIconShader::bind(char *offset) {
|
||||
const int stride = 20;
|
||||
const int stride = 16;
|
||||
|
||||
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_pos));
|
||||
MBGL_CHECK_ERROR(glVertexAttribPointer(a_pos, 2, GL_SHORT, false, stride, offset + 0));
|
||||
@@ -68,24 +48,9 @@ void SDFIconShader::bind(char *offset) {
|
||||
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_offset));
|
||||
MBGL_CHECK_ERROR(glVertexAttribPointer(a_offset, 2, GL_SHORT, false, stride, offset + 4));
|
||||
|
||||
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_labelminzoom));
|
||||
MBGL_CHECK_ERROR(glVertexAttribPointer(a_labelminzoom, 1, GL_UNSIGNED_BYTE, false, stride, offset + 8));
|
||||
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_data1));
|
||||
MBGL_CHECK_ERROR(glVertexAttribPointer(a_data1, 4, GL_UNSIGNED_BYTE, false, stride, offset + 8));
|
||||
|
||||
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_minzoom));
|
||||
MBGL_CHECK_ERROR(glVertexAttribPointer(a_minzoom, 1, GL_UNSIGNED_BYTE, false, stride, offset + 9));
|
||||
|
||||
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_maxzoom));
|
||||
MBGL_CHECK_ERROR(glVertexAttribPointer(a_maxzoom, 1, GL_UNSIGNED_BYTE, false, stride, offset + 10));
|
||||
|
||||
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_angle));
|
||||
MBGL_CHECK_ERROR(glVertexAttribPointer(a_angle, 1, GL_UNSIGNED_BYTE, false, stride, offset + 11));
|
||||
|
||||
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_rangeend));
|
||||
MBGL_CHECK_ERROR(glVertexAttribPointer(a_rangeend, 1, GL_UNSIGNED_BYTE, false, stride, offset + 12));
|
||||
|
||||
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_rangestart));
|
||||
MBGL_CHECK_ERROR(glVertexAttribPointer(a_rangestart, 1, GL_UNSIGNED_BYTE, false, stride, offset + 13));
|
||||
|
||||
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_tex));
|
||||
MBGL_CHECK_ERROR(glVertexAttribPointer(a_tex, 2, GL_SHORT, false, stride, offset + 16));
|
||||
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_data2));
|
||||
MBGL_CHECK_ERROR(glVertexAttribPointer(a_data2, 4, GL_UNSIGNED_BYTE, false, stride, offset + 12));
|
||||
}
|
||||
|
||||
@@ -29,13 +29,8 @@ public:
|
||||
protected:
|
||||
int32_t a_pos = -1;
|
||||
int32_t a_offset = -1;
|
||||
int32_t a_tex = -1;
|
||||
int32_t a_angle = -1;
|
||||
int32_t a_minzoom = -1;
|
||||
int32_t a_maxzoom = -1;
|
||||
int32_t a_rangeend = -1;
|
||||
int32_t a_rangestart = -1;
|
||||
int32_t a_labelminzoom = -1;
|
||||
int32_t a_data1 = -1;
|
||||
int32_t a_data2 = -1;
|
||||
};
|
||||
|
||||
class SDFGlyphShader : public SDFShader {
|
||||
|
||||
@@ -222,7 +222,7 @@ INSTANTIATE_TEST_CASE_P(Headless, HeadlessTest, ::testing::ValuesIn([] {
|
||||
|
||||
for (dirent *dp = nullptr; (dp = readdir(dir)) != nullptr;) {
|
||||
const std::string name = dp->d_name;
|
||||
if (name != "." && name != ".." && name != "index.html") {
|
||||
if (name != "index.html" && !(name.size() >= 1 && name[0] == '.')) {
|
||||
names.push_back(name);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user