make implicit type conversions explicit
This commit is contained in:
@@ -17,7 +17,7 @@ public:
|
||||
* Returns the number of elements in this buffer. This is not the number of
|
||||
* bytes, but rather the number of coordinates with associated information.
|
||||
*/
|
||||
uint32_t index() const;
|
||||
size_t index() const;
|
||||
|
||||
/*
|
||||
* Transfers this buffer to the GPU and binds the buffer to the GL context.
|
||||
|
||||
@@ -52,9 +52,9 @@ private:
|
||||
std::shared_ptr<LineElementsBuffer> lineElementsBuffer;
|
||||
|
||||
// hold information on where the vertices are located in the FillBuffer
|
||||
const uint32_t vertex_start;
|
||||
const uint32_t triangle_elements_start;
|
||||
const uint32_t line_elements_start;
|
||||
const size_t vertex_start;
|
||||
const size_t triangle_elements_start;
|
||||
const size_t line_elements_start;
|
||||
VertexArrayObject<OutlineShader> array;
|
||||
std::vector<triangle_group_type> triangleGroups;
|
||||
std::vector<line_group_type> lineGroups;
|
||||
|
||||
@@ -47,9 +47,9 @@ private:
|
||||
std::shared_ptr<TriangleElementsBuffer> triangleElementsBuffer;
|
||||
std::shared_ptr<PointElementsBuffer> pointElementsBuffer;
|
||||
|
||||
const uint32_t vertex_start;
|
||||
const uint32_t triangle_elements_start;
|
||||
const uint32_t point_elements_start;
|
||||
const size_t vertex_start;
|
||||
const size_t triangle_elements_start;
|
||||
const size_t point_elements_start;
|
||||
|
||||
std::vector<triangle_group_type> triangleGroups;
|
||||
std::vector<point_group_type> pointGroups;
|
||||
|
||||
@@ -42,8 +42,8 @@ private:
|
||||
std::shared_ptr<PointVertexBuffer> vertexBuffer;
|
||||
VertexArrayObject<PointShader> array;
|
||||
|
||||
const uint32_t vertex_start;
|
||||
uint32_t vertex_end = 0;
|
||||
const size_t vertex_start;
|
||||
size_t vertex_end = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public:
|
||||
Style();
|
||||
|
||||
void reset();
|
||||
void load(const uint8_t *const data, uint32_t bytes);
|
||||
void load(const uint8_t *const data, size_t bytes);
|
||||
|
||||
// This is commented out because it is not fully implemented yet. For now,
|
||||
// we keep using the protobuf stylesheet format
|
||||
|
||||
@@ -20,7 +20,7 @@ struct pbf {
|
||||
struct unknown_field_type_exception : exception {};
|
||||
struct end_of_buffer_exception : exception {};
|
||||
|
||||
inline pbf(const unsigned char *data, uint32_t length);
|
||||
inline pbf(const unsigned char *data, size_t length);
|
||||
inline pbf();
|
||||
|
||||
inline operator bool() const;
|
||||
@@ -49,7 +49,7 @@ struct pbf {
|
||||
uint32_t tag = 0;
|
||||
};
|
||||
|
||||
pbf::pbf(const unsigned char *data, uint32_t length)
|
||||
pbf::pbf(const unsigned char *data, size_t length)
|
||||
: data(data),
|
||||
end(data + length),
|
||||
value(0),
|
||||
|
||||
@@ -10,8 +10,8 @@ using namespace llmr;
|
||||
void DebugFontBuffer::addText(const char *text, double left, double baseline, double scale) {
|
||||
uint16_t *coords = nullptr;
|
||||
|
||||
int32_t length = strlen(text);
|
||||
for (int32_t i = 0; i < length; ++i) {
|
||||
size_t length = strlen(text);
|
||||
for (size_t i = 0; i < length; ++i) {
|
||||
if (text[i] < 32 || text[i] > 127) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ VertexBuffer::~VertexBuffer() {
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t VertexBuffer::index() const {
|
||||
size_t VertexBuffer::index() const {
|
||||
// We store 2 coordinates per vertex + 1 linesofar + 1 extrude coord pair == 4 (== 8 bytes)
|
||||
return array.size() / 2;
|
||||
}
|
||||
|
||||
@@ -52,13 +52,13 @@ FilteredVectorTileLayer::FilteredVectorTileLayer(const VectorTileLayer& layer, c
|
||||
// Find out what key/value IDs we need.
|
||||
auto key_it = std::find(layer.keys.begin(), layer.keys.end(), bucket_desc.source_field);
|
||||
if (key_it != layer.keys.end()) {
|
||||
key = key_it - layer.keys.begin();
|
||||
key = (int32_t)(key_it - layer.keys.begin());
|
||||
}
|
||||
|
||||
for (const Value& source_value : bucket_desc.source_value) {
|
||||
auto value_it = std::find(layer.values.begin(), layer.values.end(), source_value);
|
||||
if (value_it != layer.values.end()) {
|
||||
values.insert(value_it - layer.values.begin());
|
||||
values.insert((uint32_t)(value_it - layer.values.begin()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ void FillBucket::addGeometry(pbf& geom) {
|
||||
}
|
||||
|
||||
void FillBucket::addGeometry(const std::vector<Coordinate>& line) {
|
||||
uint32_t vertex_start = vertexBuffer->index();
|
||||
size_t vertex_start = vertexBuffer->index();
|
||||
|
||||
size_t length = line.size();
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ void LineBucket::addGeometry(const std::vector<Coordinate>& vertices) {
|
||||
nextNormal = util::normal<double>(currentVertex, lastVertex);
|
||||
}
|
||||
|
||||
size_t start_vertex = vertexBuffer->index();
|
||||
int32_t start_vertex = (int32_t)vertexBuffer->index();
|
||||
|
||||
std::vector<TriangleElement> triangle_store;
|
||||
std::vector<PointElement> point_store;
|
||||
@@ -174,7 +174,7 @@ void LineBucket::addGeometry(const std::vector<Coordinate>& vertices) {
|
||||
// Add offset square begin cap.
|
||||
if (!prevVertex && beginCap == CapType::Square) {
|
||||
// Add first vertex
|
||||
e3 = vertexBuffer->add(currentVertex.x, currentVertex.y, // vertex pos
|
||||
e3 = (int32_t)vertexBuffer->add(currentVertex.x, currentVertex.y, // vertex pos
|
||||
flip * (prevNormal.x + prevNormal.y), flip * (-prevNormal.x + prevNormal.y), // extrude normal
|
||||
0, 0, distance) - start_vertex; // texture normal
|
||||
|
||||
@@ -182,7 +182,7 @@ void LineBucket::addGeometry(const std::vector<Coordinate>& vertices) {
|
||||
e1 = e2; e2 = e3;
|
||||
|
||||
// Add second vertex
|
||||
e3 = vertexBuffer->add(currentVertex.x, currentVertex.y, // vertex pos
|
||||
e3 = (int32_t)vertexBuffer->add(currentVertex.x, currentVertex.y, // vertex pos
|
||||
flip * (prevNormal.x - prevNormal.y), flip * (prevNormal.x + prevNormal.y), // extrude normal
|
||||
0, 1, distance) - start_vertex; // texture normal
|
||||
|
||||
@@ -193,7 +193,7 @@ void LineBucket::addGeometry(const std::vector<Coordinate>& vertices) {
|
||||
// Add offset square end cap.
|
||||
else if (!nextVertex && endCap == CapType::Square) {
|
||||
// Add first vertex
|
||||
e3 = vertexBuffer->add(currentVertex.x, currentVertex.y, // vertex pos
|
||||
e3 = (int32_t)vertexBuffer->add(currentVertex.x, currentVertex.y, // vertex pos
|
||||
nextNormal.x - flip * nextNormal.y, flip * nextNormal.x + nextNormal.y, // extrude normal
|
||||
0, 0, distance) - start_vertex; // texture normal
|
||||
|
||||
@@ -201,7 +201,7 @@ void LineBucket::addGeometry(const std::vector<Coordinate>& vertices) {
|
||||
e1 = e2; e2 = e3;
|
||||
|
||||
// Add second vertex
|
||||
e3 = vertexBuffer->add(currentVertex.x, currentVertex.y, // vertex pos
|
||||
e3 = (int32_t)vertexBuffer->add(currentVertex.x, currentVertex.y, // vertex pos
|
||||
nextNormal.x + flip * nextNormal.y, -flip * nextNormal.x + nextNormal.y, // extrude normal
|
||||
0, 1, distance) - start_vertex; // texture normal
|
||||
|
||||
@@ -227,7 +227,7 @@ void LineBucket::addGeometry(const std::vector<Coordinate>& vertices) {
|
||||
}
|
||||
|
||||
// Add first vertex
|
||||
e3 = vertexBuffer->add(currentVertex.x, currentVertex.y, // vertex pos
|
||||
e3 = (int32_t)vertexBuffer->add(currentVertex.x, currentVertex.y, // vertex pos
|
||||
flip * joinNormal.x, flip * joinNormal.y, // extrude normal
|
||||
0, 0, distance) - start_vertex; // texture normal
|
||||
|
||||
@@ -235,7 +235,7 @@ void LineBucket::addGeometry(const std::vector<Coordinate>& vertices) {
|
||||
e1 = e2; e2 = e3;
|
||||
|
||||
// Add second vertex
|
||||
e3 = vertexBuffer->add(currentVertex.x, currentVertex.y, // vertex pos
|
||||
e3 = (int32_t)vertexBuffer->add(currentVertex.x, currentVertex.y, // vertex pos
|
||||
-flip * joinNormal.x, -flip * joinNormal.y, // extrude normal
|
||||
0, 1, distance) - start_vertex; // texture normal
|
||||
|
||||
@@ -251,7 +251,7 @@ void LineBucket::addGeometry(const std::vector<Coordinate>& vertices) {
|
||||
else {
|
||||
// Close up the previous line
|
||||
// Add first vertex
|
||||
e3 = vertexBuffer->add(currentVertex.x, currentVertex.y, // vertex pos
|
||||
e3 = (int32_t)vertexBuffer->add(currentVertex.x, currentVertex.y, // vertex pos
|
||||
flip * prevNormal.y, -flip * prevNormal.x, // extrude normal
|
||||
0, 0, distance) - start_vertex; // texture normal
|
||||
|
||||
@@ -259,7 +259,7 @@ void LineBucket::addGeometry(const std::vector<Coordinate>& vertices) {
|
||||
e1 = e2; e2 = e3;
|
||||
|
||||
// Add second vertex.
|
||||
e3 = vertexBuffer->add(currentVertex.x, currentVertex.y, // vertex pos
|
||||
e3 = (int32_t)vertexBuffer->add(currentVertex.x, currentVertex.y, // vertex pos
|
||||
-flip * prevNormal.y, flip * prevNormal.x, // extrude normal
|
||||
0, 1, distance) - start_vertex; // texture normal
|
||||
|
||||
@@ -289,7 +289,7 @@ void LineBucket::addGeometry(const std::vector<Coordinate>& vertices) {
|
||||
|
||||
// Start the new quad.
|
||||
// Add first vertex
|
||||
e3 = vertexBuffer->add(currentVertex.x, currentVertex.y, // vertex pos
|
||||
e3 = (int32_t)vertexBuffer->add(currentVertex.x, currentVertex.y, // vertex pos
|
||||
-flip * nextNormal.y, flip * nextNormal.x, // extrude normal
|
||||
0, 0, distance) - start_vertex; // texture normal
|
||||
|
||||
@@ -297,7 +297,7 @@ void LineBucket::addGeometry(const std::vector<Coordinate>& vertices) {
|
||||
e1 = e2; e2 = e3;
|
||||
|
||||
// Add second vertex
|
||||
e3 = vertexBuffer->add(currentVertex.x, currentVertex.y, // vertex pos
|
||||
e3 = (int32_t)vertexBuffer->add(currentVertex.x, currentVertex.y, // vertex pos
|
||||
flip * nextNormal.y, -flip * nextNormal.x, // extrude normal
|
||||
0, 1, distance) - start_vertex; // texture normal
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ void Painter::drawClippingMask() {
|
||||
|
||||
// Draw the clipping mask
|
||||
plainShader->setColor(1.0f, 0.0f, 1.0f, 1.0f);
|
||||
glDrawArrays(GL_TRIANGLES, 0, tileStencilBuffer.index());
|
||||
glDrawArrays(GL_TRIANGLES, 0, (GLsizei)tileStencilBuffer.index());
|
||||
|
||||
// glEnable(GL_STENCIL_TEST);
|
||||
glStencilFunc(GL_EQUAL, 0x80, 0x80);
|
||||
@@ -287,7 +287,7 @@ void Painter::renderFill(FillBucket& bucket, const std::string& layer_name, cons
|
||||
|
||||
// Draw a rectangle that covers the entire viewport.
|
||||
coveringPatternArray.bind(*patternShader, tileStencilBuffer, BUFFER_OFFSET(0));
|
||||
glDrawArrays(GL_TRIANGLES, 0, tileStencilBuffer.index());
|
||||
glDrawArrays(GL_TRIANGLES, 0, (GLsizei)tileStencilBuffer.index());
|
||||
|
||||
} else {
|
||||
// Draw filling rectangle.
|
||||
@@ -297,7 +297,7 @@ void Painter::renderFill(FillBucket& bucket, const std::string& layer_name, cons
|
||||
|
||||
// Draw a rectangle that covers the entire viewport.
|
||||
coveringPlainArray.bind(*plainShader, tileStencilBuffer, BUFFER_OFFSET(0));
|
||||
glDrawArrays(GL_TRIANGLES, 0, tileStencilBuffer.index());
|
||||
glDrawArrays(GL_TRIANGLES, 0, (GLsizei)tileStencilBuffer.index());
|
||||
}
|
||||
|
||||
glStencilFunc(GL_EQUAL, 0x80, 0x80);
|
||||
@@ -428,16 +428,16 @@ void Painter::renderDebug(const Tile::Ptr& tile) {
|
||||
tileBorderArray.bind(*plainShader, tileBorderBuffer, BUFFER_OFFSET(0));
|
||||
plainShader->setColor(1.0f, 0.0f, 0.0f, 1.0f);
|
||||
lineWidth(4.0f * transform.pixelRatio);
|
||||
glDrawArrays(GL_LINE_STRIP, 0, tileBorderBuffer.index());
|
||||
glDrawArrays(GL_LINE_STRIP, 0, (GLsizei)tileBorderBuffer.index());
|
||||
|
||||
// draw debug info
|
||||
tile->debugFontArray.bind(*plainShader, tile->debugFontBuffer, BUFFER_OFFSET(0));
|
||||
plainShader->setColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
lineWidth(4.0f * transform.pixelRatio);
|
||||
glDrawArrays(GL_LINES, 0, tile->debugFontBuffer.index());
|
||||
glDrawArrays(GL_LINES, 0, (GLsizei)tile->debugFontBuffer.index());
|
||||
plainShader->setColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
lineWidth(2.0f * transform.pixelRatio);
|
||||
glDrawArrays(GL_LINES, 0, tile->debugFontBuffer.index());
|
||||
glDrawArrays(GL_LINES, 0, (GLsizei)tile->debugFontBuffer.index());
|
||||
|
||||
// Revert blending mode to blend to the back.
|
||||
glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_ONE);
|
||||
@@ -454,7 +454,7 @@ void Painter::renderMatte() {
|
||||
// Draw the clipping mask
|
||||
matteArray.bind(*plainShader, matteBuffer, BUFFER_OFFSET(0));
|
||||
plainShader->setColor(white);
|
||||
glDrawArrays(GL_TRIANGLES, 0, matteBuffer.index());
|
||||
glDrawArrays(GL_TRIANGLES, 0, (GLsizei)matteBuffer.index());
|
||||
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
}
|
||||
@@ -468,5 +468,5 @@ void Painter::renderBackground() {
|
||||
// Draw the clipping mask
|
||||
coveringPlainArray.bind(*plainShader, tileStencilBuffer, BUFFER_OFFSET(0));
|
||||
plainShader->setColor(white);
|
||||
glDrawArrays(GL_TRIANGLES, 0, tileStencilBuffer.index());
|
||||
glDrawArrays(GL_TRIANGLES, 0, (GLsizei)tileStencilBuffer.index());
|
||||
}
|
||||
|
||||
@@ -48,5 +48,5 @@ bool PointBucket::hasPoints() const {
|
||||
void PointBucket::drawPoints(PointShader& shader) {
|
||||
char *vertex_index = BUFFER_OFFSET(vertex_start * vertexBuffer->itemSize);
|
||||
array.bind(shader, *vertexBuffer, vertex_index);
|
||||
glDrawArrays(GL_POINTS, 0, vertex_end - vertex_start);
|
||||
glDrawArrays(GL_POINTS, 0, (GLsizei)(vertex_end - vertex_start));
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ void Sprite::loadImage(const std::string& data) {
|
||||
|
||||
png_read_update_info(png, info);
|
||||
|
||||
unsigned int rowbytes = png_get_rowbytes(png, info);
|
||||
png_size_t rowbytes = png_get_rowbytes(png, info);
|
||||
assert(width * 4 == rowbytes);
|
||||
|
||||
img = (char *)malloc(width * height * 4);
|
||||
|
||||
@@ -15,7 +15,7 @@ void Style::reset() {
|
||||
computed.points.clear();
|
||||
}
|
||||
|
||||
void Style::load(const uint8_t *const data, uint32_t bytes) {
|
||||
void Style::load(const uint8_t *const data, size_t bytes) {
|
||||
pbf style(data, bytes);
|
||||
|
||||
while (style.next()) {
|
||||
|
||||
Reference in New Issue
Block a user