Merge branch 'master' of https://github.com/mapbox/llmr-native
Conflicts: src/geometry/debug_font.cpp
This commit is contained in:
@@ -97,7 +97,7 @@ const int8_t simplex_93[] = { 5, 25, 7, 24, 8, 23, 9, 21, 9, 19, 8, 17, 7, 16, 6
|
||||
const int8_t simplex_94[] = { 3, 6, 3, 8, 4, 11, 6, 12, 8, 12, 10, 11, 14, 8, 16, 7, 18, 7, 20, 8, 21, 10, -1, -1, 3, 8, 4, 10, 6, 11, 8, 11, 10, 10, 14, 7, 16, 6, 18, 6, 20, 7, 21, 10, 21, 12 };
|
||||
|
||||
struct glyph {
|
||||
glyph() : width(0), length(0), data(NULL) { }
|
||||
glyph() : width(0), length(0), data(nullptr) { }
|
||||
glyph(uint8_t width, uint8_t length, const int8_t *data)
|
||||
: width(width),
|
||||
length(length),
|
||||
@@ -110,7 +110,7 @@ struct glyph {
|
||||
// Font data From Hershey Simplex Font
|
||||
// http://paulbourke.net/dataformats/hershey/
|
||||
const std::map<char, glyph> simplex = {
|
||||
{ ' ', { 16, 0, NULL } },
|
||||
{ ' ', { 16, 0, nullptr } },
|
||||
{ '!', { 10, sizeof(simplex_1), simplex_1 } },
|
||||
{ '"', { 16, sizeof(simplex_2), simplex_2 } },
|
||||
{ '#', { 21, sizeof(simplex_3), simplex_3 } },
|
||||
|
||||
@@ -22,7 +22,7 @@ DebugFontBuffer::~DebugFontBuffer() {
|
||||
|
||||
void DebugFontBuffer::addText(const char *text, double left, double baseline, double scale) {
|
||||
int32_t length = strlen(text);
|
||||
for (int32_t i = 0; i < length; i++) {
|
||||
for (int32_t i = 0; i < length; ++i) {
|
||||
if (text[i] < 32 || text[i] > 127) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include <llmr/geometry/fill_buffer.hpp>
|
||||
#include <llmr/platform/gl.hpp>
|
||||
|
||||
#include <climits>
|
||||
|
||||
using namespace llmr;
|
||||
|
||||
FillBuffer::FillBuffer()
|
||||
@@ -32,16 +34,16 @@ uint32_t FillBuffer::elements_length() const {
|
||||
}
|
||||
|
||||
void FillBuffer::addDegenerate() {
|
||||
vertices.push_back(32767);
|
||||
vertices.push_back(std::numeric_limits<vertex_type>::max());
|
||||
vertices.push_back(0);
|
||||
}
|
||||
|
||||
void FillBuffer::addCoordinate(int16_t x, int16_t y) {
|
||||
void FillBuffer::addCoordinate(vertex_type x, vertex_type y) {
|
||||
vertices.push_back(x);
|
||||
vertices.push_back(y);
|
||||
}
|
||||
|
||||
void FillBuffer::addElements(uint16_t a, uint16_t b, uint16_t c) {
|
||||
void FillBuffer::addElements(element_type a, element_type b, element_type c) {
|
||||
elements.push_back(a);
|
||||
elements.push_back(b);
|
||||
elements.push_back(c);
|
||||
@@ -60,8 +62,8 @@ void FillBuffer::bind() {
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, element_buffer);
|
||||
|
||||
if (dirty) {
|
||||
glBufferData(GL_ARRAY_BUFFER, vertices.size() * sizeof(uint16_t), vertices.data(), GL_STATIC_DRAW);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, elements.size() * sizeof(uint16_t), elements.data(), GL_STATIC_DRAW);
|
||||
glBufferData(GL_ARRAY_BUFFER, vertices.size() * sizeof(vertex_type), vertices.data(), GL_STATIC_DRAW);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, elements.size() * sizeof(element_type), elements.data(), GL_STATIC_DRAW);
|
||||
dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ uint32_t LineBuffer::length() const {
|
||||
return array.size() / 4;
|
||||
}
|
||||
|
||||
void LineBuffer::add(int16_t x, int16_t y, float ex, float ey, int8_t tx, int8_t ty, int32_t linesofar) {
|
||||
void LineBuffer::add(vertex_type x, vertex_type y, float ex, float ey, int8_t tx, int8_t ty, int32_t linesofar) {
|
||||
array.push_back((x * 2) | tx);
|
||||
array.push_back((y * 2) | ty);
|
||||
array.push_back(linesofar);
|
||||
@@ -40,7 +40,7 @@ void LineBuffer::bind() {
|
||||
glBindBuffer(GL_ARRAY_BUFFER, buffer);
|
||||
|
||||
if (dirty) {
|
||||
glBufferData(GL_ARRAY_BUFFER, array.size() * sizeof(int16_t), array.data(), GL_STATIC_DRAW);
|
||||
glBufferData(GL_ARRAY_BUFFER, array.size() * sizeof(vertex_type), array.data(), GL_STATIC_DRAW);
|
||||
dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ void VertexBuffer::bind() {
|
||||
if (buffer == 0) {
|
||||
glGenBuffers(1, &buffer);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, buffer);
|
||||
glBufferData(GL_ARRAY_BUFFER, array.size() * sizeof(int16_t), array.data(), GL_STATIC_DRAW);
|
||||
glBufferData(GL_ARRAY_BUFFER, array.size() * sizeof(vertex_type), array.data(), GL_STATIC_DRAW);
|
||||
} else {
|
||||
glBindBuffer(GL_ARRAY_BUFFER, buffer);
|
||||
}
|
||||
|
||||
@@ -222,7 +222,7 @@ bool Map::findLoadedChildren(const Tile::ID& id, int32_t maxCoveringZoom, std::f
|
||||
* @return boolean Whether a parent was found.
|
||||
*/
|
||||
bool Map::findLoadedParent(const Tile::ID& id, int32_t minCoveringZoom, std::forward_list<Tile::ID>& retain) {
|
||||
for (int32_t z = id.z - 1; z >= minCoveringZoom; z--) {
|
||||
for (int32_t z = id.z - 1; z >= minCoveringZoom; --z) {
|
||||
const Tile::ID parent_id = Tile::parent(id, z);
|
||||
const Tile::Ptr tile = hasTile(parent_id);
|
||||
if (tile && tile->state == Tile::ready) {
|
||||
@@ -263,8 +263,8 @@ void Map::updateTiles() {
|
||||
|
||||
// TODO: Discard tiles that are outside the viewport
|
||||
std::forward_list<Tile::ID> required;
|
||||
for (int32_t y = tl.y; y < br.y; y++) {
|
||||
for (int32_t x = tl.x; x < br.x; x++) {
|
||||
for (int32_t y = tl.y; y < br.y; ++y) {
|
||||
for (int32_t x = tl.x; x < br.x; ++x) {
|
||||
required.emplace_front(x, y, zoom);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ Tile::ID Tile::parent(const ID& id, int32_t z) {
|
||||
assert(z < id.z);
|
||||
ID pos(id);
|
||||
while (pos.z > z) {
|
||||
pos.z--;
|
||||
--pos.z;
|
||||
pos.x = floor(pos.x / 2);
|
||||
pos.y = floor(pos.y / 2);
|
||||
}
|
||||
@@ -30,8 +30,8 @@ std::forward_list<Tile::ID> Tile::children(const ID& id, int32_t z) {
|
||||
int32_t factor = pow(2, z - id.z);
|
||||
|
||||
std::forward_list<ID> children;
|
||||
for (int32_t y = id.y * factor, y_max = (id.y + 1) * factor; y < y_max; y++) {
|
||||
for (int32_t x = id.x * factor, x_max = (id.x + 1) * factor; x < x_max; x++) {
|
||||
for (int32_t y = id.y * factor, y_max = (id.y + 1) * factor; y < y_max; ++y) {
|
||||
for (int32_t x = id.x * factor, x_max = (id.x + 1) * factor; x < x_max; ++x) {
|
||||
children.emplace_front(x, y, z);
|
||||
}
|
||||
}
|
||||
@@ -77,7 +77,7 @@ void Tile::request() {
|
||||
}
|
||||
}, []() {
|
||||
// TODO: Make sure this gets passed the correct map ID/pointer.
|
||||
platform::restart(NULL);
|
||||
platform::restart(nullptr);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ std::shared_ptr<Bucket> Tile::createBucket(const VectorTile& tile, const BucketD
|
||||
// The layer specified in the bucket does not exist. Do nothing.
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<Bucket> Tile::createFillBucket(const VectorTileLayer& layer, const BucketDescription& bucket_desc) {
|
||||
|
||||
@@ -44,17 +44,13 @@ void FillBucket::addGeometry(pbf& geom) {
|
||||
}
|
||||
|
||||
void FillBucket::addGeometry(const std::vector<Coordinate>& line) {
|
||||
// Alias this.
|
||||
FillBuffer& buffer = *this->buffer;
|
||||
|
||||
uint32_t vertex_start = buffer.vertex_length();
|
||||
|
||||
buffer.addDegenerate();
|
||||
uint32_t vertex_start = buffer->vertex_length();
|
||||
buffer->addDegenerate();
|
||||
for (const Coordinate& coord : line) {
|
||||
buffer.addCoordinate(coord.x, coord.y);
|
||||
buffer->addCoordinate(coord.x, coord.y);
|
||||
}
|
||||
|
||||
uint32_t vertex_end = buffer.vertex_length();
|
||||
uint32_t vertex_end = buffer->vertex_length();
|
||||
|
||||
if (vertex_end - vertex_start > 65535) {
|
||||
throw geometry_too_long_exception();
|
||||
@@ -82,13 +78,13 @@ void FillBucket::addGeometry(const std::vector<Coordinate>& line) {
|
||||
|
||||
assert(firstIndex + vertex_count - 1 < 65536);
|
||||
|
||||
uint32_t elements_start = buffer.elements_length();
|
||||
uint32_t elements_start = buffer->elements_length();
|
||||
|
||||
for (uint32_t i = 2; i < vertex_count; i++) {
|
||||
buffer.addElements(firstIndex, firstIndex + i - 1, firstIndex + i);
|
||||
for (uint32_t i = 2; i < vertex_count; ++i) {
|
||||
buffer->addElements(firstIndex, firstIndex + i - 1, firstIndex + i);
|
||||
}
|
||||
|
||||
uint32_t elements_end = buffer.elements_length();
|
||||
uint32_t elements_end = buffer->elements_length();
|
||||
uint32_t elements_count = elements_end - elements_start;
|
||||
group.vertex_length += vertex_count;
|
||||
group.elements_length += elements_count;
|
||||
@@ -122,5 +118,3 @@ void FillBucket::drawVertices(OutlineShader& shader) {
|
||||
array.bind(shader, *buffer, vertex_index);
|
||||
glDrawArrays(GL_LINE_STRIP, 0, length);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <llmr/util/math.hpp>
|
||||
#include <llmr/platform/gl.hpp>
|
||||
|
||||
#define BUFFER_OFFSET(i) ((char *)NULL + (i))
|
||||
#define BUFFER_OFFSET(i) ((char *)nullptr + (i))
|
||||
|
||||
#include <cassert>
|
||||
|
||||
@@ -34,7 +34,7 @@ void LineBucket::addGeometry(pbf& geom) {
|
||||
int32_t x, y;
|
||||
while ((cmd = geometry.next(x, y)) != Geometry::end) {
|
||||
if (cmd == Geometry::move_to) {
|
||||
if (line.size()) {
|
||||
if (!line.empty()) {
|
||||
addGeometry(line);
|
||||
line.clear();
|
||||
}
|
||||
@@ -93,7 +93,7 @@ void LineBucket::addGeometry(const std::vector<Coordinate>& vertices) {
|
||||
// Start all lines with a degenerate vertex
|
||||
buffer->addDegenerate();
|
||||
|
||||
for (size_t i = 0; i < vertices.size(); i++) {
|
||||
for (size_t i = 0; i < vertices.size(); ++i) {
|
||||
if (nextNormal) prevNormal = { -nextNormal.x, -nextNormal.y };
|
||||
if (currentVertex) prevVertex = currentVertex;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
using namespace llmr;
|
||||
|
||||
#define BUFFER_OFFSET(i) ((char *)NULL + (i))
|
||||
#define BUFFER_OFFSET(i) ((char *)nullptr + (i))
|
||||
|
||||
Painter::Painter(Transform& transform, Settings& settings, Style& style)
|
||||
: transform(transform),
|
||||
@@ -131,7 +131,7 @@ void Painter::render(const Tile::Ptr& tile) {
|
||||
void Painter::renderLayers(const std::shared_ptr<Tile>& tile, const std::vector<LayerDescription>& layers) {
|
||||
// Render everything top-to-bottom by using reverse iterators
|
||||
typedef std::vector<LayerDescription>::const_reverse_iterator iterator;
|
||||
for (iterator it = layers.rbegin(), end = layers.rend(); it != end; it++) {
|
||||
for (iterator it = layers.rbegin(), end = layers.rend(); it != end; ++it) {
|
||||
const LayerDescription& layer_desc = *it;
|
||||
|
||||
if (layer_desc.child_layer.size()) {
|
||||
|
||||
@@ -129,7 +129,7 @@ void Sprite::loadImage(const std::string& data) {
|
||||
return;
|
||||
}
|
||||
|
||||
png_structp png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, errorHandler, warningHandler);
|
||||
png_structp png = png_create_read_struct(PNG_LIBPNG_VER_STRING, nullptr, errorHandler, warningHandler);
|
||||
assert(png);
|
||||
|
||||
png_infop info = png_create_info_struct(png);
|
||||
@@ -140,7 +140,7 @@ void Sprite::loadImage(const std::string& data) {
|
||||
try {
|
||||
png_set_read_fn(png, (png_voidp)&buffer, readCallback);
|
||||
png_read_info(png, info);
|
||||
png_get_IHDR(png, info, (png_uint_32*)&width, (png_uint_32*)&height, &depth, &color, &interlace, NULL, NULL);
|
||||
png_get_IHDR(png, info, (png_uint_32*)&width, (png_uint_32*)&height, &depth, &color, &interlace, nullptr, nullptr);
|
||||
bool alpha = (color & PNG_COLOR_MASK_ALPHA) || png_get_valid(png, info, PNG_INFO_tRNS);
|
||||
|
||||
// From http://trac.mapnik.org/browser/trunk/src/png_reader.cpp
|
||||
@@ -180,17 +180,17 @@ void Sprite::loadImage(const std::string& data) {
|
||||
assert(surface);
|
||||
|
||||
png_bytep row_pointers[height];
|
||||
for (unsigned i = 0; i < height; i++) {
|
||||
for (unsigned i = 0; i < height; ++i) {
|
||||
row_pointers[i] = (png_bytep)(surface + (i * rowbytes));
|
||||
}
|
||||
|
||||
// Read image data
|
||||
png_read_image(png, row_pointers);
|
||||
|
||||
png_read_end(png, NULL);
|
||||
png_read_end(png, nullptr);
|
||||
} catch (std::exception& e) {
|
||||
fprintf(stderr, "loading PNG failed: %s\n", e.what());
|
||||
png_destroy_read_struct(&png, &info, NULL);
|
||||
png_destroy_read_struct(&png, &info, nullptr);
|
||||
img.clear();
|
||||
width = 0;
|
||||
height = 0;
|
||||
|
||||
@@ -322,7 +322,7 @@ BucketDescription loadBucketJSON(const rapidjson::Value& value) {
|
||||
}
|
||||
} else if (name == "value") {
|
||||
if (value.IsArray()) {
|
||||
for (rapidjson::SizeType i = 0; i < value.Size(); i++) {
|
||||
for (rapidjson::SizeType i = 0; i < value.Size(); ++i) {
|
||||
bucket.source_value.push_back(loadValueJSON(value[i]));
|
||||
}
|
||||
} else {
|
||||
@@ -361,7 +361,7 @@ BucketDescription loadBucketJSON(const rapidjson::Value& value) {
|
||||
|
||||
void loadLayersJSON(const rapidjson::Value& value, std::vector<LayerDescription>& layers) {
|
||||
if (value.IsArray()) {
|
||||
for (rapidjson::SizeType i = 0; i < value.Size(); i++) {
|
||||
for (rapidjson::SizeType i = 0; i < value.Size(); ++i) {
|
||||
layers.push_back(loadLayerJSON(value[i]));
|
||||
}
|
||||
} else {
|
||||
@@ -407,7 +407,7 @@ LayerDescription loadLayerJSON(const rapidjson::Value& value) {
|
||||
|
||||
void loadClassesJSON(const rapidjson::Value& value, std::map<std::string, ClassDescription>& classes) {
|
||||
if (value.IsArray()) {
|
||||
for (rapidjson::SizeType i = 0; i < value.Size(); i++) {
|
||||
for (rapidjson::SizeType i = 0; i < value.Size(); ++i) {
|
||||
classes.insert(loadClassDescriptionJSON(value[i]));
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user