make implicit type conversions explicit
This commit is contained in:
@@ -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