Conflicts:
	src/geometry/debug_font.cpp
This commit is contained in:
Konstantin Käfer
2014-02-06 15:14:51 +01:00
32 changed files with 126 additions and 156 deletions

View File

@@ -28,7 +28,7 @@ public:
}
int width, height;
emscripten_get_canvas_size(&width, &height, NULL);
emscripten_get_canvas_size(&width, &height, nullptr);
glfwSetMousePosCallback(mousemove);
glfwSetMouseButtonCallback(mouseclick);

View File

@@ -1,6 +1,7 @@
#ifndef LLMR_GEOMETRY_BINPACK
#define LLMR_GEOMETRY_BINPACK
#include <llmr/util/noncopyable.hpp>
#include <cstdint>
#include <list>
@@ -14,23 +15,15 @@ struct Rect {
};
template <typename T>
class BinPack {
class BinPack : private noncopyable {
public:
BinPack(T width, T height)
: free(1, { 0, 0, width, height }) {}
private:
// Make noncopyable
BinPack(const BinPack&) = delete;
BinPack(const BinPack&&) = delete;
BinPack& operator=(const BinPack&) = delete;
BinPack& operator=(const BinPack && ) = delete;
public:
Rect<T> allocate(T width, T height) {
// Find the smallest free rect angle
auto smallest = free.end();
for (auto it = free.begin(); it != free.end(); it++) {
for (auto it = free.begin(); it != free.end(); ++it) {
const Rect<T>& ref = *it;
const Rect<T>& rect = *smallest;
if (width <= ref.w && height <= ref.h) {
@@ -76,7 +69,7 @@ public:
// Simple algorithm to recursively merge the newly released cell with its
// neighbor. This doesn't merge more than two cells at a time, and fails
// for complicated merges.
for (auto it = free.begin(); it != free.end(); it++) {
for (auto it = free.begin(); it != free.end(); ++it) {
Rect<T> ref = *it;
if (ref.y == rect.y && ref.h == rect.h && ref.x + ref.w == rect.x) {
ref.w += rect.w;

View File

@@ -9,6 +9,7 @@ namespace llmr {
class FillBuffer {
public:
typedef int16_t vertex_type;
typedef uint16_t element_type;
const uint8_t components = 2;
FillBuffer();
@@ -19,13 +20,13 @@ public:
void addDegenerate();
void addCoordinate(vertex_type x, vertex_type y);
void addElements(uint16_t a, uint16_t b, uint16_t c);
void addElements(element_type a, element_type b, element_type c);
void bind();
private:
std::vector<vertex_type> vertices;
std::vector<uint16_t> elements;
std::vector<element_type> elements;
uint32_t vertex_buffer;
uint32_t element_buffer;
bool dirty;

View File

@@ -2,16 +2,18 @@
#define LLMR_GEOMETRY_GEOMETRY
#include <llmr/util/pbf.hpp>
#include <llmr/util/noncopyable.hpp>
#include <cstdlib>
namespace llmr {
class Geometry {
public:
inline Geometry(pbf& data);
class Geometry : private util::noncopyable {
enum command {
public:
inline explicit Geometry(pbf& data);
enum command : uint8_t {
end = 0,
move_to = 1,
line_to = 2,
@@ -22,7 +24,7 @@ public:
private:
pbf& data;
uint32_t cmd;
uint8_t cmd;
uint32_t length;
int32_t x, y;
int32_t ox, oy;
@@ -37,13 +39,13 @@ Geometry::Geometry(pbf& data)
Geometry::command Geometry::next(int32_t &rx, int32_t &ry) {
if (data.data < data.end) {
if (!length) {
uint32_t cmd_length = (uint32_t)data.varint();
if (length == 0) {
uint32_t cmd_length = static_cast<uint32_t>(data.varint());
cmd = cmd_length & 0x7;
length = cmd_length >> 3;
}
length--;
--length;
if (cmd == move_to || cmd == line_to) {
rx = (x += data.svarint());

View File

@@ -9,6 +9,8 @@ namespace llmr {
class LineBuffer {
public:
typedef int16_t vertex_type;
~LineBuffer();
/*
@@ -30,7 +32,7 @@ public:
* @param {number} tx texture normal
* @param {number} ty texture normal
*/
void add(int16_t x, int16_t y, float ex, float ey, int8_t tx, int8_t ty, int32_t linesofar = 0);
void add(vertex_type x, vertex_type y, float ex, float ey, int8_t tx, int8_t ty, int32_t linesofar = 0);
/*
* Add a degenerate triangle to the buffer
@@ -56,7 +58,7 @@ public:
private:
bool dirty = true;
std::vector<int16_t> array;
std::vector<vertex_type> array;
uint32_t buffer = 0;
};

View File

@@ -42,7 +42,7 @@ private:
// For debug reasons, we're storing the bind information so that we can
// detect errors and report
void *buffer_ptr = NULL;
void *buffer_ptr = nullptr;
char *offset_ptr = 0;
};

View File

@@ -9,7 +9,8 @@ namespace llmr {
class VertexBuffer {
public:
VertexBuffer(std::initializer_list<int16_t> init);
typedef int16_t vertex_type;
VertexBuffer(std::initializer_list<vertex_type> init);
~VertexBuffer();
/*
@@ -24,7 +25,7 @@ public:
void bind();
private:
const std::vector<int16_t> array;
const std::vector<vertex_type> array;
uint32_t buffer = 0;
};

View File

@@ -5,6 +5,7 @@
#include <llmr/map/transform.hpp>
#include <llmr/style/style.hpp>
#include <llmr/renderer/painter.hpp>
#include <llmr/util/noncopyable.hpp>
#include <cstdint>
#include <string>
@@ -13,18 +14,11 @@ namespace llmr {
class Settings;
class Map {
class Map : private util::noncopyable {
public:
Map(Settings& settings);
explicit Map(Settings& settings);
~Map();
// Make noncopyable
Map(const Map&) = delete;
Map(const Map&&) = delete;
Map &operator=(const Map&) = delete;
Map &operator=(const Map&&) = delete;
/* setup */
void setup();
void loadStyle(const uint8_t *const data, uint32_t bytes);

View File

@@ -1,19 +1,14 @@
#ifndef LLMR_MAP_SETTINGS
#define LLMR_MAP_SETTINGS
#include <llmr/util/noncopyable.hpp>
namespace llmr {
class Settings {
class Settings : private util::noncopyable {
public:
virtual void save() = 0;
// Make noncopyable
Settings() = default;
Settings(const Settings&) = delete;
Settings(const Settings&&) = delete;
Settings &operator=(const Settings&) = delete;
Settings &operator=(const Settings&&) = delete;
virtual ~Settings() {}
public:
// position
double longitude = 0;

View File

@@ -2,6 +2,7 @@
#define LLMR_MAP_TILE
#include <llmr/util/vec.hpp>
#include <llmr/util/noncopyable.hpp>
#include <llmr/geometry/debug_font_buffer.hpp>
#include <llmr/geometry/vao.hpp>
@@ -24,7 +25,8 @@ class FillBuffer;
class LineBuffer;
class PlainShader;
class Tile : public std::enable_shared_from_this<Tile> {
class Tile : public std::enable_shared_from_this<Tile>,
private util::noncopyable {
public:
struct exception : std::exception {};
struct geometry_too_long_exception : exception {};
@@ -45,12 +47,6 @@ public:
Tile(ID id, const Style& style);
~Tile();
// Make noncopyable
Tile(const Tile&) = delete;
Tile(const Tile&&) = delete;
Tile& operator=(const Tile&) = delete;
Tile& operator=(const Tile && ) = delete;
// Start loading the tile.
void request();

View File

@@ -4,6 +4,7 @@
#include <llmr/util/vec.hpp>
#include <llmr/util/mat4.hpp>
#include <llmr/util/animation.hpp>
#include <llmr/util/noncopyable.hpp>
#include <forward_list>
@@ -11,16 +12,10 @@ namespace llmr {
struct box;
class Transform {
class Transform : private util::noncopyable {
public:
Transform();
// Make noncopyable
Transform(const Transform&) = delete;
Transform(const Transform&&) = delete;
Transform &operator=(const Transform&) = delete;
Transform &operator=(const Transform&&) = delete;
// Animations
bool needsAnimation() const;
void updateAnimations();

View File

@@ -5,7 +5,7 @@
#include <functional>
#include <string>
#define kTileURL "http://mapbox:magic@kkaefer.net/gl/tiles/plain/%d-%d-%d.vector.pbf"
#define kTileURL "http://a.gl-api-us-east-1.tilestream.net/v3/mapbox.mapbox-streets-v4/%d/%d/%d.gl.pbf"
#define kSpriteURL "http://mapbox:magic@kkaefer.net/gl/debug/img/sprite"
namespace llmr {

View File

@@ -3,22 +3,16 @@
#include <string>
#include <llmr/map/tile.hpp>
#include <llmr/util/noncopyable.hpp>
namespace llmr {
class Painter;
class Bucket {
class Bucket : private util::noncopyable {
public:
Bucket() = default;
virtual void render(Painter& painter, const std::string& layer_name, const Tile::ID& id) = 0;
private:
// Make noncopyable
Bucket(const Bucket&) = delete;
Bucket(const Bucket&&) = delete;
Bucket& operator=(const Bucket&) = delete;
Bucket& operator=(const Bucket && ) = delete;
virtual ~Bucket() {}
};
}

View File

@@ -10,7 +10,7 @@
#include <memory>
#ifndef BUFFER_OFFSET
#define BUFFER_OFFSET(i) ((char *)NULL + (i))
#define BUFFER_OFFSET(i) ((char *)nullptr + (i))
#endif
namespace llmr {

View File

@@ -5,6 +5,7 @@
#include <llmr/geometry/vao.hpp>
#include <llmr/geometry/vertex_buffer.hpp>
#include <llmr/util/mat4.hpp>
#include <llmr/util/noncopyable.hpp>
#include <llmr/renderer/shader-plain.hpp>
#include <llmr/renderer/shader-outline.hpp>
@@ -22,18 +23,11 @@ class Tile;
class FillBucket;
class LineBucket;
class Painter {
class Painter : private util::noncopyable {
public:
Painter(Transform& transform, Settings& settings, Style& style);
// Make noncopyable
Painter(const Painter&) = delete;
Painter(const Painter&&) = delete;
Painter& operator=(const Painter&) = delete;
Painter& operator=(const Painter && ) = delete;
void setup();
void clear();
void changeMatrix(const Tile::ID& id);
void render(const std::shared_ptr<Tile>& tile);

View File

@@ -2,20 +2,14 @@
#define LLMR_RENDERER_SHADER
#include <cstdint>
#include <llmr/util/noncopyable.hpp>
namespace llmr {
class Shader {
class Shader : private util::noncopyable {
public:
Shader(const char *vertex, const char *fragment);
virtual ~Shader();
// Make noncopyable
Shader(const Shader&) = delete;
Shader(const Shader&&) = delete;
Shader &operator=(const Shader&) = delete;
Shader &operator=(const Shader&&) = delete;
~Shader();
bool valid;
uint32_t program;

View File

@@ -1,10 +1,12 @@
#ifndef LLMR_UTIL_ANIMATION
#define LLMR_UTIL_ANIMATION
#include <llmr/util/noncopyable.hpp>
namespace llmr {
namespace util {
class animation {
class animation : private noncopyable {
public:
enum state {
running,
@@ -12,13 +14,6 @@ public:
};
animation(double from, double to, double &value, double duration);
// Make noncopyable
animation(const animation&) = delete;
animation(const animation&&) = delete;
animation &operator=(const animation&) = delete;
animation &operator=(const animation&&) = delete;
state update() const;
private:

View File

@@ -0,0 +1,23 @@
#ifndef LLMR_UTIL_NONCOPYABLE
#define LLMR_UTIL_NONCOPYABLE
namespace llmr { namespace util {
namespace non_copyable_
{
class noncopyable
{
protected:
constexpr noncopyable() = default;
~noncopyable() = default;
noncopyable( noncopyable const& ) = delete;
noncopyable& operator=(noncopyable const& ) = delete;
};
}
typedef non_copyable_::noncopyable noncopyable;
}}
#endif //LLMR_UTIL_NONCOPYABLE

View File

@@ -8,12 +8,8 @@
* Author: Josh Haberman <jhaberman@gmail.com>
*/
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
namespace llmr {
struct pbf {
@@ -46,8 +42,8 @@ struct pbf {
inline void skipValue(uint32_t val);
inline void skipBytes(uint32_t bytes);
const uint8_t *data = NULL;
const uint8_t *end = NULL;
const uint8_t *data = nullptr;
const uint8_t *end = nullptr;
uint32_t value = 0;
uint32_t tag = 0;
};
@@ -60,8 +56,8 @@ pbf::pbf(const unsigned char *data, uint32_t length)
}
pbf::pbf()
: data(NULL),
end(NULL),
: data(nullptr),
end(nullptr),
value(0),
tag(0) {
}
@@ -73,7 +69,7 @@ pbf::operator bool() const {
bool pbf::next() {
if (data < end) {
value = (uint32_t)varint();
value = static_cast<uint32_t>(varint());
tag = value >> 3;
return true;
}
@@ -134,8 +130,8 @@ double pbf::float64() {
}
std::string pbf::string() {
uint32_t bytes = (uint32_t)varint();
const char *string = (const char *)data;
uint32_t bytes = static_cast<uint32_t>(varint());
const char *string = reinterpret_cast<const char*>(data);
skipBytes(bytes);
return std::string(string, bytes);
}
@@ -146,7 +142,7 @@ bool pbf::boolean() {
}
pbf pbf::message() {
uint32_t bytes = (uint32_t)varint();
uint32_t bytes = static_cast<uint32_t>(varint());
const uint8_t *pos = data;
skipBytes(bytes);
return pbf(pos, bytes);
@@ -165,7 +161,7 @@ void pbf::skipValue(uint32_t val) {
skipBytes(8);
break;
case 2: // string/message
skipBytes((uint32_t)varint());
skipBytes(static_cast<uint32_t>(varint()));
break;
case 5: // 32 bit
skipBytes(4);
@@ -185,4 +181,3 @@ void pbf::skipBytes(uint32_t bytes) {
} // end namespace llmr
#endif

View File

@@ -66,7 +66,7 @@ struct UnitBezier {
int i;
// First try a few iterations of Newton's method -- normally very fast.
for (t2 = x, i = 0; i < 8; i++) {
for (t2 = x, i = 0; i < 8; ++i) {
x2 = sampleCurveX(t2) - x;
if (fabs (x2) < epsilon)
return t2;

View File

@@ -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 } },

View File

@@ -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;
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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);
}

View File

@@ -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);
}
}

View File

@@ -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) {

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -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()) {

View File

@@ -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;

View File

@@ -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 {